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

style: Fix unnecessary-dunder-call (PLC2801) #4170

Merged
merged 14 commits into from
Aug 19, 2024

Conversation

echoix
Copy link
Member

@echoix echoix commented Aug 13, 2024

Ruff rule: https://docs.astral.sh/ruff/rules/unnecessary-dunder-call/
Pylint rule: https://pylint.readthedocs.io/en/latest/user_guide/messages/convention/unnecessary-dunder-call.html

Solves some issues reported by Pylint 3.2.6 through unnecessary-dunder-call / C2801.

I left out the cases where it touched __del__() as the Python docs explain a difference, and even with static analysis the meaning of the code was worse with a change.
I also left out the cases where it changed the test cases, so that they can fail as before if the current changes are wrong (it wouldn't be wise to change the code + the tests at the same time).

@echoix echoix requested a review from ninsbl August 13, 2024 02:20
@github-actions github-actions bot added GUI wxGUI related Python Related code is in Python libraries tests Related to Test Suite labels Aug 13, 2024
ninsbl
ninsbl previously approved these changes Aug 14, 2024
Copy link
Member

@ninsbl ninsbl left a comment

Choose a reason for hiding this comment

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

Looks good to me. My two comments are actually more questions, so I better understand...

python/grass/pygrass/vector/__init__.py Show resolved Hide resolved
gui/wxpython/mapdisp/main.py Show resolved Hide resolved
@echoix echoix merged commit 2cf98da into OSGeo:main Aug 19, 2024
26 checks passed
@echoix echoix deleted the fix-unnecessary-dunder-call-PLC2801 branch August 19, 2024 20:31
@neteler neteler added this to the 8.5.0 milestone Aug 21, 2024
landam pushed a commit to landam/grass that referenced this pull request Aug 22, 2024
* style: Fix unnecessary-dunder-call (PLC2801)

Ruff rule: https://docs.astral.sh/ruff/rules/unnecessary-dunder-call/

12 instances fixed. Solves some reported issues by Pylint 3.2.6 through unnecessary-dunder-call / C2801

* style: Fix unnecessary-dunder-call (PLC2801) for __init__
4 instances fixed

* style: Fix unnecessary-dunder-call (PLC2801) using getattr
6 instances fixed

* Ignore PLC2801 in test suite file for preserving meaning of test during the change

* style: Fix unnecessary-dunder-call (PLC2801) for get and set item
3 instances fixed

* style: Fix unnecessary-dunder-call (PLC2801) for repr
1 instance fixed

* Ignore PLC2801 for __del__, as there seems to be some differences between both

* Update pyproject.toml to remove PLC2801 exclusion

* gui.wxpython.mapdisp.main: Remove next(self) from LayerList

* grass.pygrass.vector: Remove next(self) from vector class (old Python 2 iterator)

* Revert "grass.pygrass.vector: Remove next(self) from vector class (old Python 2 iterator)"

This reverts commit f79172c.

* Revert "gui.wxpython.mapdisp.main: Remove next(self) from LayerList"

This reverts commit 9963dd1.
Mahesh1998 pushed a commit to Mahesh1998/grass that referenced this pull request Sep 19, 2024
* style: Fix unnecessary-dunder-call (PLC2801)

Ruff rule: https://docs.astral.sh/ruff/rules/unnecessary-dunder-call/

12 instances fixed. Solves some reported issues by Pylint 3.2.6 through unnecessary-dunder-call / C2801

* style: Fix unnecessary-dunder-call (PLC2801) for __init__
4 instances fixed

* style: Fix unnecessary-dunder-call (PLC2801) using getattr
6 instances fixed

* Ignore PLC2801 in test suite file for preserving meaning of test during the change

* style: Fix unnecessary-dunder-call (PLC2801) for get and set item
3 instances fixed

* style: Fix unnecessary-dunder-call (PLC2801) for repr
1 instance fixed

* Ignore PLC2801 for __del__, as there seems to be some differences between both

* Update pyproject.toml to remove PLC2801 exclusion

* gui.wxpython.mapdisp.main: Remove next(self) from LayerList

* grass.pygrass.vector: Remove next(self) from vector class (old Python 2 iterator)

* Revert "grass.pygrass.vector: Remove next(self) from vector class (old Python 2 iterator)"

This reverts commit f79172c.

* Revert "gui.wxpython.mapdisp.main: Remove next(self) from LayerList"

This reverts commit 9963dd1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI wxGUI related libraries Python Related code is in Python tests Related to Test Suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants