-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A005 stdlib-module-shadowing warns that utils.logging shadows python logging module #15399
Comments
Hi. Thanks for opening the question. This seems to be matching the upstream behavior (more as a note to myself rather than this being a justification why): I'm not 100% sure if this is the right behavior or if the rule is too eager to warn. IMO, the rule should warn if your module is named |
I think this rule should only trigger for modules if there isn't an This is the only way I can see module shadowing being possible, as doing so prepends the parent directory to |
I discussed this with @AlexWaygood in our 1:1 and we think that we should change the default to only flag modules that have the exact same full qualified name as a standard library module and instead, add an option to enable the more strict linting that flags modules that only have the same name. The motivation for an option is that some projects might want stricter behavior to guarantee that modules don't shadow builtins when running a module from a subdirectory (e.g. |
Somehow I can't replicate the problem.
This is perhaps because One thing to note is that
Meanwhile, Is this a bigger bug? |
It triggers if
$ uvx ruff check --isolated --select A005 src
src/test/utils/logging.py:1:1: A005 Module `logging` shadows a Python standard-library module |
Thanks. In that case, this has something to do with the "never- |
interesting that flake8 didnt trigger A005 in this setup BUT ruff did |
OpinionI think that the current rule is too strict, but "only fully qualified names" sounds like it could be too loose, depending on how it's interpreted. In my opinion, any root-level packages that are named the same as any stdlib root-level package should be blocked, along with all their child packages. Example
ReasoningI haven't been around then, but from what I've heard, in the olden days, it wasn't well-defined what However, in modern Python, this issue has been resolved. Additionally, Hope that makes sense :) |
Yeah definitely. This rule has a lot of false positives. |
This rule warns for me that
utils.logging
shadows stdliblogging
.Is this intentional? The whole point why our logging module is in
utils
is so the names do not collide. Am I missing something?The text was updated successfully, but these errors were encountered: