Skip to content

Use consistent style for warnings #418

@zzril

Description

@zzril

Is your feature request related to a problem?

The way warnings are raised is not consistent throughout the codebase.

Some things I noticed:

  1. _elastic_net_regression.py uses both from warnings import warn (in combination with calls to warn(...)) and import warnings (in combination with warnings.warn(...)).
  2. Sometimes, UserWarning is explicitely passed as category keyword argument, sometimes it is left out (as UserWarning is the default value).
  3. The warnings raised in the Transformer classes lack the trailing period.
  4. The warnings raised in the Transformer class generally talk about columns even when there could be just one column that is mentioned. Saying column(s) might be more accurate in those cases.

Point 3 is actually somewhat important because it would make writing regexes easier if the warnings all had the same format.
Point 4 is probably the least important, might even decide to keep it as is, as the messages are probably easier to read this way.


To quickly find the warnings raised with warnings.warn:

grep -E -r -n 'warnings.warn' src

To quickly find those raised with warn:

grep -E -r -n 'from warnings import warn' src

Desired solution

Use the same style everywhere.

Ideally, find a way to have the linter enforce a consistent style.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cleanup 🧹Refactorings and other tasks that improve the codegood first issueGood for newcomers

    Type

    Projects

    Status

    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions