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

Fix issue with PEP 585 and 604 syntax #4094

Merged
merged 2 commits into from
Feb 16, 2021
Merged

Fix issue with PEP 585 and 604 syntax #4094

merged 2 commits into from
Feb 16, 2021

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Feb 16, 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

Followup to #4059 and #4075. Fixes multiple smaller issues that occurred while testing.

Nested PEP 585 syntax
This MR fixes a false-positive issue where the new syntax was used inside another type (eg. Union, Dict, ...).

# Python 3.7 / 3.8
from __future__ import annotations
from typing import Dict
var4: Dict[str, list[int]]  # `list` was falsely marked with -> unsubscriptable-object
var7: list[list[int]]       # inner `list` -> unsubscriptable-object

Nested PEP 604 syntax
Fix false-positive issue with unsupported-binary-operation

# Python 3.7 - 3.9
from __future__ import annotations
import typing
var1: typing.Dict[str, int | None]

Improve recognition of invalid PEP 604 syntax
The following will now be correctly marked with unsupported-binary-operation (the future import is missing).

# Python 3.7 - 3.9
var2: int | str | None

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 90.594% when pulling f183f07 on cdce8p:fix-typing into e48946f on PyCQA:master.

@cdce8p cdce8p marked this pull request as ready for review February 16, 2021 04:23
@cdce8p
Copy link
Member Author

cdce8p commented Feb 16, 2021

cc: @Pierre-Sassoulas

@Pierre-Sassoulas Pierre-Sassoulas added the False Positive 🦟 A message is emitted but nothing is wrong with the code label Feb 16, 2021
@Pierre-Sassoulas Pierre-Sassoulas merged commit 1093e5d into pylint-dev:master Feb 16, 2021
@cdce8p cdce8p deleted the fix-typing branch February 16, 2021 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants