python-trio / trio-typing

Type hints for Trio and related projects
Other
27 stars 13 forks source link

Use `Union[int, Literal[inf]]` instead of `float` for capacity annotations #61

Closed Zac-HD closed 2 years ago

Zac-HD commented 2 years ago

https://github.com/python-trio/trio-typing/blob/d5835f7065f58ebdd95ca27b09d1d5cbe686b8b8/trio-stubs/__init__.pyi#L194-L199 https://github.com/python-trio/trio-typing/blob/d5835f7065f58ebdd95ca27b09d1d5cbe686b8b8/trio-stubs/__init__.pyi#L284-L288

In both cases the value must be either an integer, or inf - no other float is valid. While the PEP-586 Literal type wasn't handled by mypy when these annotations were first written, it certainly is now and would be semantically quite useful for IDE help.

Zac-HD commented 2 years ago

Hmm, no, turns out the Literal spec doesn't allow float values 🤨. Apologies for the noise.