-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
allow non-ASCII characters in identifiers in the invalid-name rule and add non-ascii-name #3409
allow non-ASCII characters in identifiers in the invalid-name rule and add non-ascii-name #3409
Conversation
Hey @bfgray3 Thank you for working on this, looks great from the start! Let me know if you want to continue this PR for adding the new check or if you want to add it in a separate PR. Both alternatives work for me! |
I'll continue on this PR--I'll push some more commits in the next few days 👍 |
@PCManticore I pushed some more commits for a first stab at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @bfgray3 Overall this looks great, thank you! Left just a comment to be addressed before merging this. Is this ready to be merged or do you plan to add some other tests? Also the error code looks fine to me.
pylint/checkers/base.py
Outdated
@@ -1955,6 +1972,14 @@ def _name_invalid_due_to_blacklist(self, name: str) -> bool: | |||
def _check_name(self, node_type, name, node, confidence=interfaces.HIGH): | |||
"""check for a name using the type's regexp""" | |||
|
|||
non_ascii_regexp = re.compile("[^\u0000-\u007F]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the compilation at __init__
level? This way we don't have to compile a regex for every name we analyze.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
I think this should be ready to merge, the only thing I was wondering was whether or not the regexps here need to be updated. |
@bfgray3 Good catch, we should also fix those. Also it seems that the tests are failing on AppVeyor, can you take a look on why that happens? |
@PCManticore I took a look at the AppVeyor logs and saw the following. I wonder if Windows doesn't always handle unicode correctly. Not sure.
|
@bfgray3 It's entirely possible that's the case. Other users seem to complain about this as well in https://help.appveyor.com/discussions/problems/6245-unicode-characters-show-as-in-build-output. Let's try something, can you add the following Let me know how that sounds. |
@PCManticore I tried the |
Thank you @bfgray3 for the PR! 🎉 |
Steps
doc/whatsnew/<current release.rst>
.Description
This PR attempts to allow non-ASCII characters in identifiers in the
invalid-name
rule.Type of Changes
Related Issue
This PR is in reference to issue #2725 but I have not closed it in the commit message yet because I have not yet implemented the second part and there are likely more changes required to this PR as well.