goodmami / wn

A modern, interlingual wordnet interface for Python
https://wn.readthedocs.io/
MIT License
207 stars 20 forks source link

pyproject.toml: Fix ruff rules in tool.ruff.ignore #190

Closed cclauss closed 10 months ago

cclauss commented 1 year ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is.

I an always frustrated when our code quality could be improved.

Describe the solution you'd like A clear and concise description of what you want to happen.

As discussed at https://github.com/goodmami/wn/pull/189#discussion_r1313641276, once #189 has been merged there should be an effort to remove some ruff rules from the tool.ruff.ignore of pyproject.toml.

For instance, ruff rule B028 (no-explicit-stacklevel) is currently on the list so a new pull request could be created to remove it from the list and fix all instances so that this project's nox tests pass.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

% pipx install ruff % ruff rule B028

no-explicit-stacklevel (B028)

Derived from the flake8-bugbear linter.

What it does

Checks for warnings.warn calls without an explicit stacklevel keyword argument.

Why is this bad?

The warnings.warn method uses a stacklevel of 1 by default, which limits the rendered stack trace to that of the line on which the warn method is called.

It's recommended to use a stacklevel of 2 or higher, give the caller more context about the warning.

Example

warnings.warn("This is a warning")

Use instead:

warnings.warn("This is a warning", stacklevel=2)