typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

Consistency with `Final` usage in Standard Library Stubs

Open max-muoto opened this issue 1 year ago • 3 comments

Currently usage of typing.Final to indicate constants is mixed throughout the standard library (e.g. some newer stubs will utilize it potentially, but it's left out in other places) Has there been any discussion in the past of experimenting with applying Final to all UPPER_UNDER module stdlib constants?

I think class var constants would require a bit more context on usage, as it might be expected for subclasses to override them, but it could be worth starting with modules and gauging the impact from MyPy primer.

max-muoto avatar Jul 10 '24 06:07 max-muoto

Not that I recall! I think worth experimenting. IIRC pyright implicitly marks these as final

hauntsaninja avatar Jul 10 '24 06:07 hauntsaninja

Not that I recall! I think worth experimenting. IIRC pyright implicitly marks these as final

Yes, if you have the strictest settings enabled that is the case, but this doesn't apply to the default settings.

max-muoto avatar Jul 10 '24 16:07 max-muoto

Put up a PR here: https://github.com/python/typeshed/pull/12318

max-muoto avatar Jul 11 '24 05:07 max-muoto