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 false negative for protected-access on functions #5990

Merged

Conversation

jacobtylerwalls
Copy link
Member

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

Fixes a false negative regression in #5662.

Closes #5989

@jacobtylerwalls jacobtylerwalls added this to the 2.13.2 milestone Mar 26, 2022
@Pierre-Sassoulas Pierre-Sassoulas added Needs backport Needs to be cherry-picked on the current patch version by a pylint's maintainer False Negative πŸ¦‹ No message is emitted but something is wrong with the code labels Mar 26, 2022
Comment on lines +2120 to +2121
if not closest_func.is_bound():
return False
Copy link
Member Author

Choose a reason for hiding this comment

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

Resolves the false negative.

Comment on lines +37 to +39
@staticmethod
def func(light) -> None:
print(light._light_internal) # [protected-access]
Copy link
Member Author

Choose a reason for hiding this comment

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

I added another test.

if self._is_type_self_call(attribute.expr):
if isinstance(attribute.expr, nodes.Call):
Copy link
Member Author

Choose a reason for hiding this comment

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

Resolving the false negative then caused a failure here in another test -- we really just need to test if it's a Call and short-circuit, because Call doesn't have a name attribute and will crash below.

Copy link
Member

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

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

I tested the change against Home Assistant. It does restore the state before the regression. Thanks @jacobtylerwalls for the quick fix!

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

Good to see the speed at which these hot fixes get PRed. Great work from all involved πŸ˜„

@cdce8p
Copy link
Member

cdce8p commented Mar 26, 2022

Good to see the speed at which these hot fixes get PRed. Great work from all involved πŸ˜„

I completely agree πŸš€ From what I've seen, it also looks that the initial release was much more stable than some of the past ones. The primer tests seem to help a lot!

@Pierre-Sassoulas
Copy link
Member

the initial release was much more stable than some of the past ones.

Yes, we had average of 5 crashes opened for 100 issues (before primer from pylint 2.6 to 2.11), we just released 2.13 with 400 issues and we had 3 crashes total (one being in pylint_django a downstream library). This is night and day. It will get even better with the github actions to show the change on primer repositories that @DanielNoord has experimented with. We'll have fewer false positives too then.

@jacobtylerwalls
Copy link
Member Author

The primer tests seem to help a lot!

Time permitting this summer I was hoping to look at the baseline functionality. Adding baselines for the primer repos (and triggering PR comments etc) would have probably helped us catch the false negative regressions like this one.

@jacobtylerwalls
Copy link
Member Author

the github actions to show the change on primer repositories that @DanielNoord has experimented with.

wooooo!!! πŸ•ΊπŸ»

@DanielNoord
Copy link
Collaborator

The primer tests seem to help a lot!

Time permitting this summer I was hoping to look at the baseline functionality. Adding baselines for the primer repos (and triggering PR comments etc) would have probably helped us catch the false negative regressions like this one.

This discussion should probably take place somewhere else, but both for baseline and primer we just need to fix the json output. There has been some discussion about that already.
With a good and easily parseable json output it is trivial to create a primer for false negatives. The biggest problem (after parsable output) for the primer is getting it to run somewhat decently fast. home-assistant is awesome as a primer project but we would need to run the primer over it twice to catch false negatives and that would really inflate CI runs.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 2045944367

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.02%) to 94.161%

Files with Coverage Reduction New Missed Lines %
pylint/checkers/classes/class_checker.py 4 94.34%
Totals Coverage Status
Change from base Build 2045919298: -0.02%
Covered Lines: 15335
Relevant Lines: 16286

πŸ’› - Coveralls

@Pierre-Sassoulas Pierre-Sassoulas merged commit 5c8384e into pylint-dev:main Mar 27, 2022
@jacobtylerwalls jacobtylerwalls deleted the protected-access-function branch March 27, 2022 12:34
@Pierre-Sassoulas Pierre-Sassoulas removed the Needs backport Needs to be cherry-picked on the current patch version by a pylint's maintainer label Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Negative πŸ¦‹ No message is emitted but something is wrong with the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression protected-access not recognized
5 participants