Enforce usage of built-in types in typing.
See original GitHub issueRule request
Python 3.9 introduced support for PEP585 which discourages usage of the typing.List
, typing.Tuple
, etc. in favor of the built-in types.
Thesis
The usage of the built-in generics should be encouraged. The usage of the generics from the typing
module should be blocked by a rule, when using Python 3.9+ versions.
Reasoning
I think that having two different ways to denote those types does not comply with the “There should be one – and preferably only one – obvious way to do it” rule.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
typing — Support for type hints — Python 3.11.1 documentation
The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers,...
Read more >Enforcing Data Types in JavaScript | by Linda Zhao | Medium
The short answer is no, but it doesn't need to. JavaScript uses duck typing (yes, that's a real term). Since we never tell...
Read more >Possible to enforce type hints? - python - Stack Overflow
Input types are first validated (lazily on the function call) and if valid, the function is processed where the return value is then...
Read more >Type System - MuleSoft Documentation
You can use type parameters to construct new types that dispatch the correct implementation. %dw 2.0 type FileData<Content> = { data: Content, name:...
Read more >How to Use Data Types & the Python Type() Function
A type is assigned to a variable when it is assigned a value. Gradual typing (type annotations/type hints) was introduced in PEP 484....
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 FreeTop 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
Top GitHub Comments
Great! Also check out https://github.com/python/typeshed/blob/master/tests/check_new_syntax.py
@sobolevn I’ve already prepared and released the first version of the plugin that takes care of the checks from this issue and https://github.com/wemake-services/wemake-python-styleguide/issues/2421
Link: https://github.com/Waszker/flake-type-annotations-plugin
The project is in its early stages but I was too excited to release it that I’ve forgot to ask for your review. 😞
Nevertheless feel free to take a look at it and I think that we can close this issue, the https://github.com/wemake-services/wemake-python-styleguide/issues/2421 one and its related PR.
What do you think?