top | item 41766912

(no title)

wdroz | 1 year ago

With the 3.13 TypeIs[0] and the 3.10 TypeGuard[1], we can achieve some of Rust's power (such as the 'if let' pattern) without runtime guarantees.

This is a win for the DX, but this is not yet widely used. For example, "TypeGuard[" appears in only 8k Python files on GitHub.[2]

[0] -- https://docs.python.org/3.13/library/typing.html#typing.Type...

[1] -- https://docs.python.org/3.13/library/typing.html#typing.Type...

[2] -- https://github.com/search?q=%22TypeGuard%5B%22+path%3A*.py&t...

discuss

order

silviogutierrez|1 year ago

Big fan of typing improvements in Python. Any chance you can elaborate on the "if let" pattern in Rust and how it would look in Python now? Not sure I follow how it translates.

Buttons840|1 year ago

What type checker do you recommend?

Ey7NFZ3P0nzAe|1 year ago

Beartype is incredible. It is soo fast I put it as decorator on all functions of all my projects.

It's day and night compared to typeguard.

Also the dev is... Completely out of this world

wdroz|1 year ago

disclaimer: I don't work on big codebases.

Pylance with pyright[0] while developing (with strict mode) and mypy[1] with pre-commit and CI.

Previously, I had to rely on pyright in pre-commit and CI for a while because mypy didn’t support PEP 695 until its 1.11 release in July.

[0] -- https://github.com/microsoft/pyright

[1] -- https://github.com/python/mypy