-
-
Notifications
You must be signed in to change notification settings - Fork 628
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
Make pylint run on transitive deps #13918
Conversation
Unfortunately this change has some negative side-effects as we'll be making lints with pylint pull in far more dependencies 😭 Unless you're linting with mypy which already requires transitive deps. In that case I'd expect the same PEX of deps to be re-used between both tools. But also, this means people might see lint errors where there was none previously. 😬 |
@thejcannon : Is it the case that only some lints require the transitive deps? And if so, is it worth putting use of transitive dependencies behind a flag? But additionally, the "re-export of an |
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.
Is it the case that only some lints require the transitive deps?
I've been lagging on reviewing for this reason - I'm confused how both Toolchain and StackStorm have been using Pylint without ever hitting this issue (cc @cognifloyd). They're large repos.
Your test makes clear that you do sometimes need transitive deps, but it seems like not always.
is it worth putting use of transitive dependencies behind a flag?
This could make sense...this PR has a performance downside and also means you need to use --changed-since-dependees=transitive
rather than --changed-since-depndees=direct
, which results in much more invalidation.
Unfortunately, it seems like doing the same thing here would require some pretty serious type analysis.
Yeah, probably not feasible for Python imo. Good context though.
I would assume the need for transitive deps is woven throughout most of the various error checks. Technically speaking, The fact that the test in question is a re-export is a red herring per-se. I believe it would also fail if say: Now how did no one catch this? Pylint (via |
On the side, I think |
Pylint and astroid caused me serious grief in the StackStorm repo. After many hours (days) of debugging, I traced the issue to a custom pylint extension that used I then refactored the pylint plugin to extract the dict from the astroid AST. That turned out to be involved because I had to resolve several cases where So, now I don't need transitive deps with pylint because I fixed that plugin. Are you using any pylint plugins? |
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 :)
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.
This looks correct to me, but I will defer to Eric for the final word.
Apologies for my delay again! To recap our DM message, it sounds like Pylint does not error if you only have direct dependencies. Which is why Toolchain and others have been able to use Pylint just fine for so long. @cognifloyd points out that certain plugins also error if you don't have transitive deps, but I don't think that's what this PR was motivated by. But, Pylint does underreport issues if transitive deps are missing. Not good. Merging this PR as-is is going to be disruptive for folks because it may result in multiple lint failures. (@asherf is testing this out on the Toolchain repository to get a sense of how disruptive it is there - I had issues with my M1.) I believe this violates our deprecation policy https://www.pantsbuild.org/docs/deprecation-policy, and either way it may hold back people from upgrading to Pants 2.10 which isn't ideal. So, Joshua and I discussed adding an option to
You can do that by checking |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
If I understand the issue correctly, we currently have a bug that causes lint errors to be underreported? I'm not sure fixing that falls under the deprecation policy, even if disruptive... |
This might be somewhat off-topic, but (naming faux pas aside) should
Even more off-topic (but still relevant). At some point I was hoping to correlate Of course, I wish |
This is an interesting proposal. The semantic line between linting and checking is blurry. But we necessarily have to sharpen it when we decide what goes in each goal. So, yeah, definitely possible that "check" is for things that find bugs and "lint" is for style? |
According to Wikipedia "Lint" is for "programming errors, bugs, stylistic errors and suspicious constructs" so there's no winning this war 😂 I guess taking a step back, what the difference between
And So maybe stick to the current art (which has a nice clean delineation) and we tackle the |
Yes, at least partially. Some of this is about cost: if you're operating on transitive dependencies, you're going to be a much more expensive check in general. It also makes it easier (...or, possible, at least) to decide what to do locally: i.e. And we can certainly tweak the definition/help of |
So what do we think for the deprecation? Should we go add an option to toggle behavior, or call this a "bug fix" and merge as-is? cc @stuhood @thejcannon, what do you think as the author of this change? |
I could see it either way. I'm more "move-fast-and-break-things". Also if there were hidden bugs I'd want to know sooner rather than later. But then again I'm not the one "representing" and supporting Pants per-se. If I'm being honest, I suspect the likelihood of this breaking anyone low, as I expect most people's CI to run on all files, which would then likely catch the hidden bugs. Not impossible, but low. But an option is also perfectly fine and possibly expected. |
Oh!!! You know what, you're totally right there. I was forgetting that we batch all of the run together, meaning transitive deps are present most the time. Great! Okay, let's land this :) |
(FYI I updated the PR description to better explain PYlint's expectations) |
👍 move |
cc @asherf re thoughts on moving Pylint to |
Same as #13918, but for third-party deps. As with first-party code, Pylint doesn't complain if transitive deps are missing, but it is less exhaustive than normal. [ci skip-build-wheels] [ci skip-rust]
Pylint was our only user of this functionality, and @thejcannon found in #13918 that it wasn't even correct to use. It indeed seems very unusual for Python to want just direct deps and not transitive. If we need this back again, we have Git. [ci skip-rust] [ci skip-build-wheels]
Pylint works when you just have direct dependencies, but it will underreport issues. That's not ideal.
That behavior is also confusing because it means
./pants lint ::
will behave differently than./pants lint f.py
as::
will have all transitive deps in the same batchd run.The fix is to always use transitive deps. Unfortunately, this does mean that Pylint will be a bit slower.