-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
filebeat: fix pylint in test_registrar #3763
Conversation
So far we are using autopep8 to do some "linting" in our python file. See https://github.com/elastic/beats/blob/master/Makefile#L64 for the command. In case we introduce pylint we should run it as part of the CI. What is the difference between pylint and autopep8? |
I haven't used autopep8 before but looks geared more towards style, pylint finds common coding mistakes much like a compiler would. This commit is incomplete I fixed 41 additional errors and 14 additional warnings, let me see what went wrong. Once I publish those the usefulness of pylint should be clearer. I'm all for adding it to CI but we need to fix the other files first :) |
I had a quick look at pylint and it seems both can check for pep8 but pylint can do some more stuff. In the above change you added some flags on what should be ignore. I'm curious if we could have some global flags / config options on what should be ignored and what not to have a "definition" on what our current checks are and we don't have to add it to each file / method. How much of the above changes were done automatically by pylint and how much had you to do manaully? Few general notes:
|
All the changes were done manually, unlike autopep/goimports pylint doesn't auto-edit AFAIK. I could add a |
Autopep can automatically rewrite files to correct issue. See https://github.com/elastic/beats/blob/master/Makefile#L81 I assume pylint could do something similar? I would suggest we add a About python3: A few weeks ago I played around with some tools to figure out if there is a tool that can automatically check something is working in python 2.7 and python 3. But I wasn't successful so far. Figuring it out manually is quite hard. We have a habit of breaking python 3 from time to time ... |
I figured if I test vs python3 CI will take care of python2.7 and we should be good right? Adding the .pylintrc sounds good I'll do it now. |
Disable all the warnings found globally, except for import-error which is just too broad.
Not sure about the CI and python 2.7. CI does not execute all the scripts, for example the cherry pick one is not executed by CI. |
I guess you're right, I forgot we don't run pylint in CI yet. I'll just test for both |
.pylintrc
Outdated
@@ -0,0 +1,407 @@ | |||
[MASTER] |
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.
quite a file. Would it be possible to only have the variables inside which are not default? This makes it easier to spot where we don't follow the default behaviour.
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.
I generated it with --generate-rcfile
, one of the things I had to modify for instance was:
-method-rgx=[a-z_][a-z0-9_]{2,30}$
+method-rgx=[a-z_][a-z0-9_]{2,50}$
Would be hard to do that without a fully generated config, my guess is they generate it like that because there are many options like this. I agree it's not ideal though, let me try to simplify it a bit.
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.
LGTM
No description provided.