mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Add support for more forms of computed `__all__`

Open AustinScola opened this issue 2 years ago • 1 comments

Feature Add typing support for the following forms of computing __all__:

__all__ += ['a', b']
__all__ += submodule.__all__
__all__.extend(submodule.__all__)

Pitch Combining __all__ from multiple submodules is a common and useful pattern.

Related: https://github.com/python/mypy/issues/12582

AustinScola avatar May 24 '23 18:05 AustinScola

What is the progress of this?

rayzchen avatar Jul 01 '23 21:07 rayzchen

When we can expect it to be fixed? Is someone working on it? The initial setup is working, but only for 1 layer! If you add more layers, then it is breaking.

sshishov avatar Aug 11 '23 10:08 sshishov

I'll also point out that @public is another common-ish way of computing __all__ and it also causes a raft of bogus attr-defined warnings. E.g.


from public import public

@public
def a_public_method():
    pass

@public
class APublicClass:
    pass

from foo.bar import PublicFoo, PublicBaz

# Often seen in a re-exporting __init__.py
public(
    PublicFoo=PublicFoo,
    PublicBar=PublicBar,
)

All of these cases are common ways to declare publicly exported names for __all__ and which are not supported by mypy.

warsaw avatar Aug 22 '23 23:08 warsaw