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

fix fixture checker #29

Merged
merged 5 commits into from
Jan 25, 2024
Merged

fix fixture checker #29

merged 5 commits into from
Jan 25, 2024

Conversation

anis-campos
Copy link

the current implementation provokes recursion errors because of the
VariablesChecker.add_message patch not working properly.
This rework fix the issue by replacing the original variable checker by a subclass, without patch.

Copy link

codecov bot commented Dec 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (bb1a8de) 93.98% compared to head (46cf450) 98.02%.
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #29      +/-   ##
==========================================
+ Coverage   93.98%   98.02%   +4.03%     
==========================================
  Files          18       20       +2     
  Lines         549      556       +7     
  Branches      106      105       -1     
==========================================
+ Hits          516      545      +29     
+ Misses         23        8      -15     
+ Partials       10        3       -7     
Flag Coverage Δ
3.10 98.02% <100.00%> (+4.03%) ⬆️
3.11 98.02% <100.00%> (+4.03%) ⬆️
3.12 98.02% <100.00%> (+4.03%) ⬆️
3.8 98.02% <100.00%> (+4.03%) ⬆️
3.9 98.02% <100.00%> (+4.03%) ⬆️
macos-latest 98.02% <100.00%> (+4.03%) ⬆️
ubuntu-latest 97.66% <100.00%> (+3.67%) ⬆️
windows-latest 98.02% <100.00%> (+4.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stdedos
Copy link
Collaborator

stdedos commented Dec 20, 2023

the current implementation provokes recursion errors because of the
VariablesChecker.add_message patch not working properly.

Would you mind creating a test, that demonstrates the issue?

@anis-campos anis-campos force-pushed the fix-checkers branch 2 times, most recently from 128e502 to da69357 Compare December 23, 2023 17:53
@anis-campos
Copy link
Author

anis-campos commented Dec 23, 2023

the current implementation provokes recursion errors because of the
VariablesChecker.add_message patch not working properly.

Would you mind creating a test, that demonstrates the issue?

I would love to, but i'm not sure how.

I dived on this a bit, turns out the issue is invisible in the tests suits because we are running mono process checks. In our project, we use pylint -j 0 that will run the checks in several threads, one per cpu cores.

This means that I'm actually fixing a thread safety issue.

Now, that being said, I would like to reproduce it here, but I'm not sure how to make a test suit that will use a the -j option of pylint, as we are not actually running pylint, just unit checking the checkers.

Should we include a new test folder, that would actually run pylint , something akin to a integration_tests ?

@anis-campos
Copy link
Author

I went with a very simple integration test. This run https://github.com/pylint-dev/pylint-pytest/actions/runs/7310392985 shows the error before the fix

Anis Da Silva Campos added 3 commits December 23, 2023 22:42
the current implementation provokes recursion errors because of the
VariablesChecker.add_message patch not working properly.
This rework fix the issue by replacing the original variable checker by a subclass, without patch.
This shall uncover some hidden error, like non thread safe checks during multiprocess execution
@anis-campos
Copy link
Author

@stdedos , happy new year 🎊. Can we go forward with this PR ?

@stdedos
Copy link
Collaborator

stdedos commented Jan 11, 2024

Hello @anis-campos! Happy new year 🎊🎊🎊

Apologies for the long radio silence. Winter vacations were not ... so much vacations for me, sadly 😅

Thank you for adding the test. While I don't understand "exactly" what is the issue - it is clearly an issue, and one your commit deals with!

The b52f6f6 (#29) commit is also definitely wanted. I'd stamp it immediately, if it were separate.

AFAIS, the essence of your first commit is:

pylint_pytest/__init__.py

  • Make register explicit, rather than implicit/recursive into explicit. 👍 / 👎
    There are both arguments here. I'd say it's nicer not to have to remember to register your checker (ofc, "how many times are you going to add new checkers?" is also a question ...)
  • ... and remove_original_variables_checker(). If we have to do it, we do it 👍

pylint_pytest/checkers/variables.py

  • You essentially moved all patch_add_message logic into the new CustomVariablesChecker. 👍

pylint_pytest/checkers/fixture.py

  • ... by doing this, you avoided all of the def open(self) fiddling?? 👍 👍 👍 (You should then be able to remove replacement_add_message? I think it's unused at this point. What about self.checker.open() calls?)
  • You renamed a bunch of FixtureChecker's "private" class variables into public.
    I assume you need to access FixtureChecker.pytest_fixtures from CustomVariablesChecker without pylint complaining?
    If we have to do it, we do it 👍. I'd like to avoid "exposing internals" if not necessary, though 👎 Spraying with # pylint: disable=protected-access is acceptable (I'm thinking to experiment with exposing less at a later time)

@anis-campos
Copy link
Author

There are both arguments here. I'd say it's nicer not to have to remember to register your checker (ofc, "how many times are you going to add new checkers?" is also a question ...)

that was indeed my reasoning, I wasn't sure it it was worth it trying to understand the auto discovery when there is only 3 classes to register.

If we have to do it, we do it 👍. I'd like to avoid "exposing internals" if not necessary, though 👎 Spraying with # pylint: disable=protected-access is acceptable (I'm thinking to experiment with exposing less at a later time)

Hum, it is still a internal use only, so yes, we can keep it private.

Copy link
Collaborator

@stdedos stdedos left a comment

Choose a reason for hiding this comment

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

Amazing MR 🤩

I am deeply sorry this has taken so much time to go through 🙏

@stdedos stdedos merged commit 1ca1d86 into pylint-dev:master Jan 25, 2024
20 checks passed
@anis-campos anis-campos deleted the fix-checkers branch January 26, 2024 20:33
stdedos added a commit that referenced this pull request Feb 2, 2024
# Added

* Migrate setup.py to pyproject.toml (#8)
* Support for Python 3.12 (#3,
  "side effect" of #8)
* Introduced @dependabot (part of #28)
* Improved reliability of the `FixtureChecker` class (#29)

# Removed

* Support for Python 3.6 & 3.7 (#23)

# Improved

* Increased reproducibility of the project, by using `pip-compile` for the development dependencies
  (#28, small bugfix in #39)
* Minor CI + License updates (in 29f0c33, e0e529a, 8f56d1c)

Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
stdedos added a commit that referenced this pull request Feb 2, 2024
# Added

* Increased reproducibility of the project, by using `pip-compile` for the development dependencies
  (#28, small bugfix in #39)
* Introduced @dependabot (part of #28)

# Removed

* Support for Python 3.6 & 3.7 (#23)

# Improved

* Migrate setup.py to pyproject.toml (#8)
* Support for Python 3.12 (#3,
  "side effect" of #8)
* Improved reliability of the `FixtureChecker` class (#29)
* Minor CI + License updates (in 29f0c33, e0e529a, 8f56d1c)

Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
stdedos added a commit that referenced this pull request Feb 2, 2024
# Added

* Increased reproducibility of the project, by using `pip-compile` for the development dependencies
  (#28, small bugfix in #39)
* Introduced @dependabot (part of #28)

# Removed

* Support for Python 3.6 & 3.7 (#23)

# Improved

* Migrate setup.py to pyproject.toml (#8)
* Support for Python 3.12 (#3,
  "side effect" of #8)
* Improved reliability of the `FixtureChecker` class (#29)
* Minor CI + License updates (in 29f0c33, e0e529a, 8f56d1c)

Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
@stdedos stdedos added this to the Release v2 milestone Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants