You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: PEP 810 __lazy_modules__ should not be detected as a public module attribute #506
Adding or removing imports can lead to changes to the contents of __lazy_modules__, which are currently detected by griffe check as a public API change:
package.module:5: __lazy_modules__: Attribute value was changed: {'itertools', 'warnings'} -> {'importlib', 'itertools', 'warnings'}
Thanks for the report @edgarrmondragon. This one bothers me 😄 We generally consider special/dunder attributes public, for example __init__ is public because even though you (generally) don't call it directly, it's used when you instantiate a class, or __eq__ is public because it's used when you compare objects, etc.
I see two options for us here:
start special casing special/dunder attributes, for example to consider __lazy_modules__ non-public
remove the Attribute value was changed check. I don't think it ever triggered a true-positive in my own projects. If we think about it, it doesn't make much sense: if a user of your code is expecting a variable of yours to be stable, they can use the value directly. If not, then the value is expected to be able to change.
Activity
pawamoy commentedon Oct 21, 2026
Thanks for the report @edgarrmondragon. This one bothers me 😄 We generally consider special/dunder attributes public, for example
__init__is public because even though you (generally) don't call it directly, it's used when you instantiate a class, or__eq__is public because it's used when you compare objects, etc.I see two options for us here:
__lazy_modules__non-publicAttribute value was changedcheck. I don't think it ever triggered a true-positive in my own projects. If we think about it, it doesn't make much sense: if a user of your code is expecting a variable of yours to be stable, they can use the value directly. If not, then the value is expected to be able to change.WDYT?
pawamoy commentedon Oct 21, 2026
I've also asked people on the fediverse: https://fosstodon.org/@pawamoy/117478319734686843 🙂
edgarrmondragon commentedon Oct 21, 2026
That's been my exact experience. I've even seen false positives where the actual value didn't change, just how it's computed 🙃
I'll check the fosstodon conversation.
pawamoy commentedon Oct 21, 2026
Right, it actually doesn't compare the value but the expression that builds it. One more reason to drop it.
refactor: Stop checking attribute values