Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for alternative union syntax - PEP 604 #4075

Merged
merged 1 commit into from
Feb 15, 2021
Merged

Add check for alternative union syntax - PEP 604 #4075

merged 1 commit into from
Feb 15, 2021

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Feb 6, 2021

Steps

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature or an important bug fix, add a What's New entry in doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Description

Add check for correct usage of alternative union syntax (PEP 604).

Example Python 3.7 - 3.9

from __future__ import annotations  # required

var: int | None
def func() -> str | int:
    ...

Alias = int | None  # [unsupported-binary-operation]

Example Python 3.10+

var: int | None
def func() -> str | int:
    ...

Alias = int | None

Links
https://www.python.org/dev/peps/pep-0604/
https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-x-y-syntax-for-unions
https://mypy.readthedocs.io/en/stable/runtime_troubles.html#future-annotations

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

Related Issue

Closes #4065

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Look like you're going to upgrade from "first time contributor" to "person who implemented all the checks for new typing syntax" as soon as the astroid master is fixed ;)

@cdce8p
Copy link
Member Author

cdce8p commented Feb 7, 2021

image

Look like you're going to upgrade from "first time contributor" to "person who implemented all the checks for new typing syntax" as soon as the astroid master is fixed ;)

I just would really like to use the new syntax in a project I frequently contribute to that just upgraded to min Python 3.8. Since we have a lot of beginners, it's just best to have checks in place to catch mistakes early. Especially if it's not exactly clear what works and what doesn't (#4059 😄).

@cdce8p
Copy link
Member Author

cdce8p commented Feb 7, 2021

@Pierre-Sassoulas Can you also tag it with 2.6.1? I would really like to see it be included in the next release.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 90.569% when pulling 49ecbee on cdce8p:pep604-alternative_union_syntax into b6edb60 on PyCQA:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 90.569% when pulling 49ecbee on cdce8p:pep604-alternative_union_syntax into b6edb60 on PyCQA:master.

@coveralls
Copy link

coveralls commented Feb 15, 2021

Coverage Status

Coverage increased (+0.01%) to 90.576% when pulling 49ecbee on cdce8p:pep604-alternative_union_syntax into b6edb60 on PyCQA:master.

@Pierre-Sassoulas Pierre-Sassoulas merged commit 1175b6e into pylint-dev:master Feb 15, 2021
@cdce8p cdce8p deleted the pep604-alternative_union_syntax branch February 15, 2021 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve checks for PEP 604 - alternative Union syntax
3 participants