-
Notifications
You must be signed in to change notification settings - Fork 117
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
Add support for new load_configuration hook of pylint #214
Conversation
This PR can be closed after releasing new version of pylint with pylint-dev/pylint#2644 |
Pull Request Test Coverage Report for Build 547
💛 - Coveralls |
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.
How about db_performance.py
checker ? It also modifes blacklist config.
Generally looks good, I'm not sure why tests failed though. The job with DJANGO=master
is pulling the pylint master branch so in theory it should not fail with your changes.
@atodorov I have fixed also |
Perhaps I misunderstand but this would not be backwards compatible with older pylints as I think that calling |
@carlio You are right. This PR needs to bump dependency to pylint version which supports
I am fine with adjusting this PR with backward compatibility - when older version of pylint is detected, |
@matusvalo the compat.py file is exactly for things like this. The problem is the number of configurations for build systems of the type @atodorov and I have had this discussion many times, I think he's more on your side but I certainly prefer making a smooth movement given how often a change to pylint-django can break a build. A simple 'if pylint_version < x.y.z: load_configuration()' isn't much and could be in compat.py with a good comment so it can be removed in the future. We do need to figure out a better way to warn about things like this, perhaps a new emitted warning our regular python |
@carlio I am fine with your proposal. I will implement your comments. I think adding warning would be ideal. |
+1 for that. Re #181 - there's no way around that if people are using an older version of pylint. We'll document this when releasing the new version but really if you insist on using an older pylint there's nothing we can do about it. I personally favor using the latest and greatest versions of dev tools but not everybody does this unfortunately. |
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.
All good - thanks for the compat addition, I know it's a PITA but it will save many bug reports too :-) Thanks for the PR and fixes.
@matusvalo oh btw don't forget to add the change to the CHANGELOG if you want. No worries it will get done for next release though 👍 |
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.
All good - thanks for the compat addition, I know it's a PITA but it will save many bug reports too :-) Thanks for the PR and fixes.
pylint_django/__init__.py
Outdated
# backward compatible we call load_configuration() directly from register() | ||
# hook. Using legacy approach yields issue #181. | ||
# For more details see issue #181 and PR #214. | ||
if compat.REGISTER_LEGACY: |
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.
wait is this the right way round? compat.REGISTER_LEGACY
sounds like it should call plugin.register_legacy
. Might just be a naming issue
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.
Oh stupid mistake... I will fix it. In any case I would like to do some manual tests for this functionality + investigate whether we can print some warning when old pylint is used. Maybe some unittests can be added for this functionality what do you think?
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.
It seems like it's more of a test for building against different versions, so adding something to the build matrix would be how to deal with this. Different pylint versions in the env are needed to test each branch properly. @atodorov what do you think? will the existing build matrix be enough to catch this?
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.
@carlio, @matusvalo - looking at the latest test results I see all PASS. See job 524.8 with env DJANGO=master. This is installing pylint from their master branch and the console log shows pylint version 2.3.0.
IMO we're OK on the testing side here.
Btw. I manually tried the PR and: PR with current pylint version (2.2.2) works as expected:
BUT with with pylint from master branch I am getting the following stacktrace:
And this is not connected to this PR since it occurs also on master branch of pylint-django. I think it is connected to this commit: I am not able to verify this PR until this is handled :-( |
@matusvalo welcome to the world of trying to keep compatability between pylint upstream and users' configurations downstream :-) This is why I always push to have that |
@carlio my opinion is that this is not ideal for users in any case: When user is not using latest version pylint-django he does not know which version of pylint he can use because E.g. for instance if pylint 2.3 is released and user uses combination of pylint 2.3 and pylint-django 2.0.5 he will get exception. Don't get me wrong. I am not saying that this should be fixed on pylint-django side - this would be very difficult to fix if not impossible. (I think better is to have stable API for plugins on pylint side). |
@carlio @atodorov I am proposing the following implementation of warnings when "old" version of pylint is detected: $ git diff
diff --git a/pylint_django/compat.py b/pylint_django/compat.py
index a461548..0393082 100644
--- a/pylint_django/compat.py
+++ b/pylint_django/compat.py
@@ -2,6 +2,10 @@
# pylint: skip-file
# no sane linter can figure out the hackiness in this compatability layer...
+import warnings
+
+warnings.simplefilter('always', DeprecationWarning)
+
try:
from astroid.nodes import ClassDef, FunctionDef, ImportFrom, AssignName, Attribute
except ImportError:
@@ -26,3 +30,11 @@ import pylint
# pylint before version 2.3 does not support load_configuration() hook.
REGISTER_LEGACY = pylint.__pkginfo__.numversion < (2, 3)
+
+if REGISTER_LEGACY:
+ warnings.warn(
+ "Legacy pylint version is detected. Custom configuration is not supported. "
+ "Please upgrade pylint to version >=2.3. For more details see: "
+ "https://github.com/PyCQA/pylint-django/issues/181",
+ DeprecationWarning
+ ) For user it will be displayed as follows:
Are you fine with it? If yes I will add it to this PR. |
@matusvalo about your proposal for warnings: It is out of scope for this PR IMO. I am open to discussing this in another PR or issue but please don't add it here. I don't mind the warning but honestly for people who need to use older versions for whatever reason this warning doesn't bring them any good. @carlio - the above mentioned traceback may be a future breakage waiting to happen in pylint-plugin-utils. I'll try adding the same test config with pylint@master that we have here. |
@atodorov I have implemented your comments. |
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.
@matusvalo looks good, but you will have to squash all commits together and rebase to master.
3cc3d00
to
76e1ab2
Compare
76e1ab2
to
d3dfbbd
Compare
@atodorov all commits are squashed now. |
Merged. I suggest we release a new version when pylint 2.3.0 comes out. |
This PR adds new pylint hook
load_configuration()
. This hook serves for adjusting configuration of linter: http://pylint.pycqa.org/en/latest/how_tos/plugins.htmlCloses #181