Skip to content

Conversation

@tqa236
Copy link
Contributor

@tqa236 tqa236 commented Nov 4, 2025

Type of Changes

Type
🐛 Bug fix

Description

Add a few missing dunder in the Enum class to the allowed list. Also convert EXTRA_DUNDER_METHODS to a dictionary with Python version.

Closes #10435

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code backport maintenance/4.0.x labels Nov 5, 2025
@Pierre-Sassoulas Pierre-Sassoulas added this to the 4.0.3 milestone Nov 5, 2025
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.

Look great, let's just fix the mypy warning :)

@github-actions

This comment has been minimized.

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@4f0716a). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10722   +/-   ##
=======================================
  Coverage        ?   95.97%           
=======================================
  Files           ?      176           
  Lines           ?    19540           
  Branches        ?        0           
=======================================
  Hits            ?    18753           
  Misses          ?      787           
  Partials        ?        0           
Files with missing lines Coverage Δ
pylint/constants.py 100.00% <100.00%> (ø)
pylint/extensions/dunder.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

This comment has been minimized.

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.

What do you think about the new message raised in the primer ? Also could you add a changelog please ? :) See in doc/whatsnew/fragment

@tqa236
Copy link
Contributor Author

tqa236 commented Nov 5, 2025

@Pierre-Sassoulas I added the change log. About the message in the prime, it looks good to me as the message "Bad or misspelled dunder method name generate_next_value." is no longer emitted as the 2 classes inherits from Enum (or StrEnum).

@github-actions

This comment has been minimized.

"__reduce_ex__",
"__post_init__", # part of `dataclasses` module
]
EXTRA_DUNDER_METHODS: dict[tuple[int, int], list[str]] = {
Copy link
Member

Choose a reason for hiding this comment

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

I guess it could be tuple[str] since we have no need to mutate this anywhere in the code; but I don't feel too strongly about changing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @mbyrnepr2, I think that'll work too but it'll be tuple[str, str] and we'll need to keep extending it if we add more values to the tuple, so I'm not sure it's worth it as this constant is used very little already.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
EXTRA_DUNDER_METHODS: dict[tuple[int, int], list[str]] = {
EXTRA_DUNDER_METHODS: dict[tuple[int, int], tuple[str, ...]] = {

Would this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes I think that will work. Thank you for the suggestion.

mbyrnepr2
mbyrnepr2 previously approved these changes Nov 7, 2025
Copy link
Member

@mbyrnepr2 mbyrnepr2 left a comment

Choose a reason for hiding this comment

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

Thanks @tqa236 !

@tqa236 tqa236 dismissed stale reviews from mbyrnepr2 and Pierre-Sassoulas via 33ada01 November 7, 2025 10:07
@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2025

🤖 Effect of this PR on checked open source code: 🤖

Effect on ansible:
The following messages are no longer emitted:

  1. bad-dunder-name:
    Bad or misspelled dunder method name generate_next_value.
    https://github.com/ansible/ansible/blob/55e4ba224d57b108ce1f8caa0addf5a418f631df/lib/ansible/module_utils/_internal/_datatag/__init__.py#L295

Effect on django:
The following messages are no longer emitted:

  1. bad-dunder-name:
    Bad or misspelled dunder method name generate_next_value.
    https://github.com/django/django/blob/8af79e2c0c5608196369600268756772a6343525/django/db/models/enums.py#L78

This comment was generated for commit 33ada01

@Pierre-Sassoulas Pierre-Sassoulas enabled auto-merge (squash) November 8, 2025 07:55
@Pierre-Sassoulas Pierre-Sassoulas merged commit 0426f8b into pylint-dev:main Nov 8, 2025
44 checks passed
pylint-backport bot pushed a commit that referenced this pull request Nov 8, 2025
Co-authored-by: Pierre Sassoulas <[email protected]>
Co-authored-by: Mark Byrne <[email protected]>
(cherry picked from commit 0426f8b)
@tqa236 tqa236 deleted the issues-10435 branch November 8, 2025 08:13
Pierre-Sassoulas added a commit that referenced this pull request Nov 8, 2025
…under (#10725)

Add Enum dunder to the list of allowed dunder (#10722)



(cherry picked from commit 0426f8b)

Co-authored-by: Trinh Quoc Anh <[email protected]>
Co-authored-by: Pierre Sassoulas <[email protected]>
Co-authored-by: Mark Byrne <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport maintenance/4.0.x 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.

Enum dunder method _generate_next_value_ not allowed

3 participants