microsoft / pyright

Static Type Checker for Python
Other
13.48k stars 1.48k forks source link

allow use of `+=` manipulation on `__all__` when `__all__` is a tuple #9479

Closed tungol closed 1 week ago

tungol commented 1 week ago

If you have a question about a behavior that you’re seeing in pyright, consider posting to the Pyright discussion forum.

Is your feature request related to a problem? Please describe. I was attempting to add asyncio.__all__ to typeshed. There's a lot of differences depending on python version, but pyright complains for each instance of __all__ += ("foo",). See: https://github.com/python/typeshed/pull/13038

Describe the solution you’d like Pyright supports this if __all__ is a list instead of a tuple. Is it possible to support this for tuple as well?

erictraut commented 1 week ago

Pyright conforms to the typing specification with regard to the __all__ idioms that it accepts. If you think that the spec should be extended to support more idioms, you can make your argument in the typing forum, but I think it's unlikely that additional extensions will be made. Each additional idiom requires support from a wide breadth of tools in the Python ecosystem, so the bar is high for adding new ones. I recommend that you use one of the existing supported idioms.