-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Improve non ascii checker #5643
Improve non ascii checker #5643
Conversation
- non-ascii-identifier (replaces non-ascii-name) - non-ascii-file-name (a warning) - non-ascii-module-import (only considering the namespace the import is imported in)
Pull Request Test Coverage Report for Build 1678974913
💛 - Coveralls |
@DanielNoord and @Pierre-Sassoulas here the splitted version of the ascii name checker. About the Only good solution would be to spend a lot more time into figuring out why some nodes are hit multiple times. But sorry I spent to much time already sorry, I won't do that. If something should be added within Astroid, I would recommend something like at I would kindly ask you to this for me. Alternative would be that I keep a list of all checked nodes within the parser and just check "if node in self._checked". |
BTW: Some test always fail locally for me. So I have no way to check the coverage. |
You need to connect with your github account on coveralls.io, they need your token to display the file or they would get rate limited. |
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.
Is there a reason for adding the tests/functional/n/non_ascii_name_class/__init__.py
and tests/functional/n/non_ascii_name/__init__.py
files? I think they can be removed tight?
Could you add a docstring to tests/functional/n/non_ascii_import/foobar.py
to say what it is testing. I can't make a suggestion because it is empty 😢
I haven't looked at pylint/checkers/non_ascii_names.py
and the unittest this time (hopefully I'll get time this evening), but this should help this along again. I'm at 47/69 files viewed and approved right now so we're certainly getting there 😄
tests/functional/n/non_ascii_name/non_ascii_name_pos_and_kwonly_function.rc
Show resolved
Hide resolved
tests/functional/n/non_ascii_name/non_ascii_name_function_argument_py38.py
Show resolved
Hide resolved
tests/functional/n/non_ascii_name/non_ascii_name_function_argument_py39plus.py
Show resolved
Hide resolved
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.
Got to the other files as well!
@CarliJoy Tests look very good and robust. 🎉 I just wonder if we can move some of the remaining unittests to the functional tests as well. I'm asking this not only because I find them more readable, but also since I know they are actually better "tests". They way those are invoked better resembles the way pylint
is invoked by normal users than the unittests are, which has recently caught a bug that the unittests simply could not in their current setup. This is something we as maintainers/contributors should fix, but in the meantime functional tests are often the way to go.
@DanielNoord which unit test are you referring to? |
I was thinking of |
be1749c
to
415a13b
Compare
Then they are integration tests and I have to consider too many other side effects: i.e. nothing marked duplicated, modules should really exist, you name it. I again was just glad about my unit tests, because I am in the process of figuring out how to remove (And I mean like it is not, that I didn't add function tests -> I hit the limit of maximum files in a folder already.... btw...) |
Co-authored-by: Daniël van Noord <[email protected]>
9184357
to
54709b8
Compare
Using Unit Tests I was able to checkout and debug a number of things and so could simplify the Checker a good amount. Also recognized, that I used Plural for the checker name and changed that. The Checker is now almost dead simple 🎉 Hope you like it :-) @DanielNoord @Pierre-Sassoulas |
57ef516
to
58827c3
Compare
58827c3
to
1a0fed3
Compare
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.
@CarliJoy Thanks again! See my comments about unittests and functional tests about why I was so insistent on them. You're right I shouldn't have complained about too many tests 😄
I think we're really getting there with this PR. The final checker is becoming really quite elegant and concise.
One questions that couldn't really be commented anywhere:
Do we need tests/functional/n/non_ascii_name_class/__init__.py
? And the other __init__
files in the functional test directories?
tests/functional/n/non_ascii_name/non_ascii_name_pos_and_kwonly_function.py
Show resolved
Hide resolved
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.
Thank you for splitting the unicode MR, this is easier to review. The tests are also getting exhaustive and this is very nice. I think we're converging and will be able to merge this first part soon.
@DanielNoord wrote:
I oriented myself on the existing functional tests and all main folders (a-z) and some of the subfolders contain a |
Co-authored-by: Daniël van Noord <[email protected]> Co-authored-by: Pierre Sassoulas <[email protected]>
for more information, see https://pre-commit.ci
@DanielNoord and @Pierre-Sassoulas I reverted the changes to the Base Checkers and now use a simpler args checks. I also removed two unittests but kept the other. See #5643 (comment) for my view on them. |
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.
Approving with my last recommendations.
I think we could keep going back and forth about pylint
's testing framework, but it doesn't feel too productive. I just want to say that I do see and agree with some of the points you're making or made previously, but that within the context of the current code we can't easily fix those. That's the result of working with such an old codebase I guess.
With regard to conflicting suggestions, I think that is to be expected in open source projects without strict hierarchy and review procedures on large PRs such as these. Of course we try to minimise them, but I don't think it is strange that reviewers can have conflicting opinions about certain decisions. With PRs with 100+ comments it's easy to miss comments from previous reviewers (or even your own) about the same topic. I know that that is frustrating and it was something I ran into when I first started contributing to pylint
but I think that's one of the downsides of these open source projects. That doesn't really make this less annoying but I hope you can see how such things can occur.
Co-authored-by: Daniël van Noord <[email protected]>
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.
Thank you for the new checker @CarliJoy !
To add to what @DanielNoord said about conflicting reviews: the smaller and atomic the MR is, the less likely it's going to happen. Making our lives easier by making small easy reviewable MR will help tremendously. If we need to review 1000 lines repeatedly with hundred of comments then we might not have the time to read all comments from everyone. Especially if something that should be discussed in another MR in detail is lost in the hundred of comments and makes us feel that the code change a lot and that we need to reread everything every-time as a result.
Also remember there's other interactions at the same time on the repository (repositories!) we're maintaining, we don't have a single MR / issue to take care of and we have jobs and lifes on top of it.
doc/whatsnew/<current release.rst>
.Type of Changes
Description
Add
non-ascii-identifier
as replacementnon-ascii-name
to ensure really all Python names are ASCII. Checker now checks properly the names of imports (non-ascii-module-import
) as well for as of file names (non-ascii-file-name
). Non ASCII characters could be homoglyphs (look alike characters) and hard to enter on a non specialized keyboard.-> See Confusable Characters in PEP 672