Skip to content

[blacklisted-name] Allow emission on non-constants #4061

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

Closed
wants to merge 1 commit into from

Conversation

relrod
Copy link

@relrod relrod commented Feb 2, 2021

NOTE: CI is currently failing (independently of this change) due to this PR in astroid. I didn't try to debug it beyond bisecting it to that PR.

Steps

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature or an important bug fix, add a What's New entry in doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Description

  • Fix a regression introduced in
    3422e4a where blacklisted-name
    (emitted by _check_name()) would only be emitted for constants.
  • The blacklisted-name check has been pulled out into its own helper
    function, and is now called instead of _check_name() when we are NOT
    at a constant.
  • Fix a similar bug (not regression) for non-ascii-name in the same
    scenario.
  • Changelog updated.

Type of Changes

Type
🐛 Bug fix

Related Issue

Change:
- Fix a regression introduced in
  3422e4a where blacklisted-name
  (emitted by _check_name()) would only be emitted for constants.
- The blacklisted-name check has been pulled out into its own helper
  function, and is now called instead of _check_name() when we are NOT
  at a constant.
- Fix a similar bug (not regression) for non-ascii-name in the same
  scenario.
- Changelog updated.

Test Plan:
- New functional tests added

Tickets:
- Fixes pylint-dev#3701

Signed-off-by: Rick Elrod <rick@elrod.me>
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.

Thank you, for the change. The code became very convoluted, yet what it does is supposed to be very simple (check if a string is in a list). I know it was mixed before too, but this is starting to get unreasonable. As someone who just worked on it, how would you refactor the code in order to implement this change easily after the refactor ? Would creating a NameChecker class to iterate on all name and make the name checks inherit it would be feasible ?

@relrod
Copy link
Author

relrod commented Feb 3, 2021

@Pierre-Sassoulas I think that might be a reasonable approach. However, I've talked with my team a bit and unfortunately we don't have time right now to work on a full refactor of the code. I'd be happy to address any small issues with the changes in this PR if you want to take it. If not, I understand.

@Pierre-Sassoulas
Copy link
Member

Ok, thank you for the heads up. I added a comment in the original issue, to understand the problem better.

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.

disallowed-name check no longer checks non-constants
2 participants