Skip to content

Conversation

@cdce8p
Copy link
Member

@cdce8p cdce8p commented May 7, 2022

Description

We previously checked if a class is explicitly mentioned in PEP 585 as being subscriptable. That frequently results in errors as some classes are only generic in type stubs. We could continue to update the set of subscriptable names, but that still wouldn't cover custom packages and is impractical.

With this PR, pylint will ignore all string annotations (explicit or via from __future__ import annotations). We might miss a few issues, however those aren't runtime errors and a type checker is likely used anyway witch would catch these.

Not emitting false-positives is more important than catching all errors here IMO.

Closes #4369
Closes #6523

@cdce8p cdce8p added the False Positive 🦟 A message is emitted but nothing is wrong with the code label May 7, 2022
@cdce8p cdce8p added this to the 2.14.0 milestone May 7, 2022
@cdce8p cdce8p force-pushed the fix-unsubscriptable_object branch from dc9a832 to 7f72b9d Compare May 7, 2022 10:40
@coveralls
Copy link

Pull Request Test Coverage Report for Build 2286115814

  • 3 of 4 (75.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.01%) to 95.314%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pylint/checkers/utils.py 3 4 75.0%
Files with Coverage Reduction New Missed Lines %
pylint/checkers/utils.py 1 95.54%
Totals Coverage Status
Change from base Build 2283754721: -0.01%
Covered Lines: 15986
Relevant Lines: 16772

💛 - Coveralls

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.

Agree with the sentiment about reducing false positives vs false negative.

@cdce8p cdce8p merged commit cd5556f into pylint-dev:main May 7, 2022
@cdce8p cdce8p deleted the fix-unsubscriptable_object branch May 7, 2022 16:48
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.

from __future__ import annotations ignored False unsubscriptable-object positive with generic subprocess.Popen and __future__ annotations

3 participants