Update type hinting to follow PEP 585
See original GitHub issueIs your feature request related to a problem? Please describe.
I am getting the following warning
/Users/bpedigo/JHU_code/bilateral/.venv/lib/python3.9/site-packages/beartype/_util/hint/pep/utilpeptest.py:396:
BeartypeDecorHintPepDeprecatedWarning: Type hint typing.List[scipy.sparse.csr.csr_matrix] deprecated by PEP 585. To
resolve this, globally replace this hint by the equivalent PEP 585 type hint (e.g., "typing.List[int]" by "list[int]").
See also:
https://www.python.org/dev/peps/pep-0585
warn(warning_message, BeartypeDecorHintPepDeprecatedWarning)
Describe the solution you’d like
Should update anywhere in the code we use typing.List to be just list[], I think? That’s just what it sounds like from a cursory glance at https://www.python.org/dev/peps/pep-0585/ but I could be wrong.
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (4 by maintainers)
Top Results From Across the Web
PEP 585 – Type Hinting Generics In Standard Collections
This PEP proposes to enable support for the generics syntax in all standard collections currently available in the typing module. Rationale and ...
Read more >typing.Any in Python 3.9 and PEP 585 - Stack Overflow
Starting with Python 3.9 , the following collections become generic and importing those from typing is deprecated: tuple # typing.
Read more >snok/pep585-upgrade: Pre-commit hook for ... - GitHub
This is a pre-commit hook configured to automatically upgrade your type hints to the new native types implemented in PEP 585. This will...
Read more >Another kind of clean up comes in PEP 585 ("Type Hinting ...
It will allow the removal of a parallel set of type aliases maintained in the typing module in order to support generic types....
Read more >Support for type hints — Python 3.9.2 documentation
The Python runtime does not enforce function and variable type annotations. ... See details in PEP 585—Type Hinting Generics In Standard ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

While perambulating in an exhausted late-night stupor through this exciting project, I couldn’t help but notice this issue. As Mr. Beartype, I am the culprit responsible for everyone’s pain here. 😞
The core issue is that PEP 585 deprecates most of PEP 484. Specifically, most of the
typingmodule (includingtyping.List) will be going away by 2024. You have two options here:BeartypeDecorHintPepDeprecatedWarning. Since this is currently the only type of deprecated type hint, this is a decent temporary solution. Of course, this solution will still fail sometime in 2024 with fiery explosions. Thanks alot, Guido! If that wasn’t easy enough, here are two even easier ways to do this with differing tradeoffs depending on who you want to suffer the most – you or your awesome userbase:graspologic._typingsubmodule resembling:Then instead of importing
ListandTuplefromtypingwhen annotating callables, you importListandTuplefrom your privategraspologic._typingsubmodule instead: e.g.,What could be simpler? gagging sounds faintly heard
And… I should just write this up as a FAQ entry already. May your pain be felt by no one else.
The Bear has landed.