Skip to content

Commit

Permalink
chore: Replace general Ruff F401 exclusion with per-file-ignore
Browse files Browse the repository at this point in the history
A general problem with F401 is __init__.py because naturally symbols
imported there merely define the package interface and aren't actually
used/referenced apart from the import.

Basically there are two ways to go about this:

1. Define __all__ in __init__.py
(see [Importing * From a Package](https://docs.python.org/3/tutorial/modules.html#importing-from-a-package))

or

2. Add __init__.py to Ruff's per-file-ignores
(see [Ruff per-file-ignores](https://docs.astral.sh/ruff/settings/#per-file-ignores)).

Adding __init__.py to per-file-ignores imo is a better option here
because __all__ encourages the 'from <package> import *' antipattern.

Closes: #34
  • Loading branch information
lu-pl committed Aug 3, 2024
1 parent a3cdfbf commit 24d11a6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ hypothesis = "^6.108.4"
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"


[tool.ruff]
lint.ignore = ["F401"]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]

[tool.deptry.package_module_name_map]
sparqlwrapper = "SPARQLWrapper"
Expand Down

0 comments on commit 24d11a6

Please sign in to comment.