Skip to content

Don't emit incorrect-variance for type parameters (PEP 695) - #9638

Merged
cdce8p merged 1 commit into
pylint-dev:mainfrom
cdce8p:pep695-variance
May 17, 2024
Merged

cdce8p merged 1 commit into
pylint-dev:mainfrom
cdce8p:pep695-variance

Conversation

@cdce8p

@cdce8p cdce8p commented May 16, 2024

Copy link
Copy Markdown
Member

Type of Changes

Type
✓ 🐛 Bug fix

Description

Don't emit typevar-name-incorrect-variance warnings for PEP 695 style TypeVars.
The variance is inferred automatically by the type checker.
Adding _co or _contra suffix can help to reason about TypeVar.

@codecov

codecov Bot commented May 16, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.84%. Comparing base (7521eb1) to head (40b43ba).
Report is 177 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #9638      +/-   ##
==========================================
+ Coverage   95.82%   95.84%   +0.01%     
==========================================
  Files         173      174       +1     
  Lines       18835    18896      +61     
==========================================
+ Hits        18049    18110      +61     
  Misses        786      786              
Files Coverage Δ
pylint/checkers/base/name_checker/checker.py 98.64% <100.00%> (+0.01%) ⬆️

... and 7 files with indirect coverage changes

@github-actions

Copy link
Copy Markdown
Contributor

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit 40b43ba

@DanielNoord DanielNoord left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks

name_arg = args[0].value

if variance == TypeVarVariance.double_variant:
if variance == TypeVarVariance.inferred:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if variance == TypeVarVariance.inferred:
if variance is TypeVarVariance.inferred:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

All other comparisons with TypeVarVariance also use the equals sign.
Let's change it when we implement #5356, maybe?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants