Open bellini666 opened 1 year ago
Isn't this the same thing as TID? https://beta.ruff.rs/docs/rules/#flake8-tidy-imports-tid ?
Yeah this looks identical to banned-api
.
Yeah this looks identical to
banned-api
.
Not necessarily. What it it does it to ensure that some imports are done in a specific way.
For example, if you want for someone to always import os
and use os.path
instead of from is import path
.
The banned-api
, if I understood that correctly, will totally prevent it from being used
With banned-api
, you cannot specify with a glob which modules are concerned for the ban.
The configuration of flake8-obey-import-goat
look like this:
[flake8]
forbidden-imports =
*: datetime.datetime, stdlib modules should be imported as a module
*: typing.Optional, we use T | None instead of Optional[T]
users.*: foo.*, users module should not use foo module
*.implementation.*: *.domain.*, implementation layer should not use domain layer
With the banned-api
plugin, the configuration would look like this:
[tool.ruff.flake8-tidy-imports.banned-api]
"datetime.datetime".msg = "stdlib modules should be imported as a module"
"typing.Optional".msg = "we use T | None instead of Optional[T]"
"foo.*".msg = "users module should not use foo module"
"*.domain.*".msg = "implementation layer should not use domain layer"
banned-api
, could be extended by adding a path
like this, by default would be *
.
[tool.ruff.flake8-tidy-imports.banned-api]
"datetime.datetime".msg = "stdlib modules should be imported as a module"
"typing.Optional".msg = "we use T | None instead of Optional[T]"
"foo.*".msg = "users module should not use foo module"
"foo.*".path = "users.*"
"*.domain.*".msg = "implementation layer should not use domain layer"
"*.domain.*".path = "*.implementation.*"
Is a pull request welcome with this new behavior?
It would be backward compatible.
How should we handle that this is a merge of two plugins in the documentation?
Should we mention flake8-obey-import-goat
in flake8-tidy-imports.banned-api
?
Or, should we only add the license flake8-obey-import-goat
?
Ref: https://pypi.org/project/flake8-obey-import-goat