pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.32k stars 1.14k forks source link

Cleanup variables checker #9978

Closed nickdrozd closed 1 month ago

nickdrozd commented 1 month ago

Type of Changes

Type
:hammer: Refactoring

Description

The variables checker contains some really complicated code (complicated in a bad way). It is difficult to understand and therefore difficult to modify. I became keenly aware of this over the course of several failed attempts to implement https://github.com/pylint-dev/pylint/pull/9964. The complicatedness of this code may also account for why https://github.com/pylint-dev/pylint/issues/8893 remains open.

This MR makes a few minor changes in the direction of cleaning up the variables checker. It should make no functional difference.

There are more changes that need to be made, but it preferable that MRs be small. So this is the first of several.

Each commit makes one specific change, so the commits should be reviewed one at a time.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.80%. Comparing base (8630cfd) to head (208b434). Report is 4 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/pylint-dev/pylint/pull/9978/graphs/tree.svg?width=650&height=150&src=pr&token=ZETEzayrfk&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev)](https://app.codecov.io/gh/pylint-dev/pylint/pull/9978?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev) ```diff @@ Coverage Diff @@ ## main #9978 +/- ## ========================================== - Coverage 95.80% 95.80% -0.01% ========================================== Files 174 174 Lines 18940 18934 -6 ========================================== - Hits 18146 18140 -6 Misses 794 794 ``` | [Files with missing lines](https://app.codecov.io/gh/pylint-dev/pylint/pull/9978?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev) | Coverage Δ | | |---|---|---| | [pylint/checkers/variables.py](https://app.codecov.io/gh/pylint-dev/pylint/pull/9978?src=pr&el=tree&filepath=pylint%2Fcheckers%2Fvariables.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev#diff-cHlsaW50L2NoZWNrZXJzL3ZhcmlhYmxlcy5weQ==) | `97.22% <100.00%> (-0.02%)` | :arrow_down: |
github-actions[bot] commented 1 month ago

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

This comment was generated for commit 208b43483c6b1719131579ea87beae3d80b5c0cc