question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enforce usage of built-in types in typing.

See original GitHub issue

Rule 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:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sobolevncommented, Jul 31, 2022
0reactions
Waszkercommented, Jul 31, 2022

@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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found