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

Check py-version for async unnecessary-dunder-call #7549

Merged
merged 2 commits into from Oct 1, 2022

Conversation

DanielNoord
Copy link
Collaborator

  • Write a good description on what the PR does.
  • Create a news fragment with towncrier create <IssueNumber>.<type> which will be
    included in the changelog. <type> can be one of: new_check, removed_check, extension,
    false_positive, false_negative, bugfix, other, internal. If necessary you can write
    details or offer examples on how the new change is supposed to work.
  • If you used multiple emails or multiple names when contributing, add your mails
    and preferred name in script/.contributors_aliases.json

Type of Changes

Type
🐛 Bug fix

Description

Closes #7529.

@DanielNoord DanielNoord added Needs backport Needs to be cherry-picked on the current patch version by a pylint's maintainer False Positive 🦟 A message is emitted but nothing is wrong with the code labels Oct 1, 2022
@DanielNoord DanielNoord added this to the 2.15.4 milestone Oct 1, 2022
@coveralls
Copy link

coveralls commented Oct 1, 2022

Pull Request Test Coverage Report for Build 3165251258

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 95.333%

Totals Coverage Status
Change from base Build 3164548731: 0.001%
Covered Lines: 17118
Relevant Lines: 17956

💛 - Coveralls

@@ -105,8 +105,6 @@
"__floor__": "Use math.floor function",
"__ceil__": "Use math.ceil function",
"__enter__": "Invoke context manager directly",
Copy link
Member

Choose a reason for hiding this comment

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

I think we should handle this generically by changing this datastructure (DUNDER_METHODS) to include the min version of the dunder method. Maybe:

DUNDER_METHODS = {
    "3.10": {
       "__aiter__": "Use iter built-in function",
       "__anext__": "Use next built-in function",
    }
    "default" : {
        "__index__": "Use index method",
        "__round__": "Use round built-in function",
        ...
    }
}

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.

Thank you for the fix !

"__deepcopy__": "Use copy.deepcopy function",
"__fspath__": "Use os.fspath function instead",
DUNDER_METHODS: dict[tuple[int, int], dict[str, str]] = {
(0, 0): {
Copy link
Member

Choose a reason for hiding this comment

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

Clever 👍

pylint/checkers/dunder_methods.py Show resolved Hide resolved
@Pierre-Sassoulas Pierre-Sassoulas merged commit 6291295 into pylint-dev:main Oct 1, 2022
@DanielNoord DanielNoord deleted the aiter branch October 1, 2022 20:09
@Pierre-Sassoulas Pierre-Sassoulas added Backported and removed Needs backport Needs to be cherry-picked on the current patch version by a pylint's maintainer labels Oct 10, 2022
Pierre-Sassoulas pushed a commit to Pierre-Sassoulas/pylint that referenced this pull request Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported 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.

fales positive: unnecessary-dunder-call (__aiter__, __anext__)
3 participants