Skip to content
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

Remove the concept of checker priority #6034

Merged
merged 3 commits into from
Apr 1, 2022

Conversation

DanielNoord
Copy link
Collaborator

  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature, or an important bug fix, add a What's New entry in
    doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.
  • If you used multiple emails or multiple names when contributing, add your mails
    and preferred name in script/.contributors_aliases.json

Type of Changes

Type
✨ New feature
🔨 Refactoring
📜 Docs

Description

I don't really see what this does? There is this issue #229.
But it seems more like a "let's make a function that uses something that is already there" than something that actually adds something. When is it ever useful to have some checker be executed 50ms earlier than another?

I'd vote for removal. I don't consider this a breaking change because you can still define priority without it breaking anything.
And we can easily revert this commit if something does depend on it.

@DanielNoord DanielNoord added the Maintenance Discussion or action around maintaining pylint or the dev workflow label Mar 29, 2022
@DanielNoord DanielNoord added this to the 2.14.0 milestone Mar 29, 2022
@coveralls
Copy link

coveralls commented Mar 29, 2022

Pull Request Test Coverage Report for Build 2063319443

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 44 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 94.194%

Files with Coverage Reduction New Missed Lines %
pylint/config/option_manager_mixin.py 19 89.22%
pylint/lint/run.py 25 73.76%
Totals Coverage Status
Change from base Build 2058545153: 0.02%
Covered Lines: 15381
Relevant Lines: 16329

💛 - Coveralls

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, I don't see what the use case could be. Did you search for the rational in the history ? Nice cleanup imo.

@DanielNoord
Copy link
Collaborator Author

Yeap, I don't see what the use case could be. Did you search for the rational in the history ? Nice cleanup imo.

No I can't access the bitbucket issue, so I can't see a discussion in the original PR. After working on this some more, I feel like a lot of the optparse code was directly copied from logilab "patterns". There seems to be some functionality that was just copied from other projects. That might be what happened here as well, and then later somebody actually made this functionality work.
I wonder if there is any real functionality though.

@jacobtylerwalls Thoughts?

Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't quickly assure myself this isn't being used somehow. But I can definitely see it helping the argparse migration to reduce complexity. I just am not familiar with in what sense a checker provides options, unfortunately.

doc/whatsnew/2.14.rst Outdated Show resolved Hide resolved
Comment on lines -977 to -980
# Sort checkers by priority
needed_checkers = sorted(
needed_checkers, key=operator.attrgetter("priority"), reverse=True
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is anyone aware of pylint ever having a failfast mode? That's all I can think of for the usefulness of sorting checkers. If you want the more important checkers to run first when failing fast.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have a failfast mode but you're right it's probably a use case. We could want to order by warnings significance instead of checkers later (i.e. to raise most significant messages first) see #5604. Cutting other checkers analysis if we don't have messages to show in them would be nice performance wise, but I don't think we need priority to do that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a failfast mode, but this wasn't really documented or implemented, so we can always put one back if we want it and document it.

assert provider.priority <= 0, "provider's priority can't be >= 0"
for i, options_provider in enumerate(self.options_providers):
if provider.priority > options_provider.priority:
self.options_providers.insert(i, provider)
break
else:
self.options_providers.append(provider)
self.options_providers.append(provider)
Copy link
Member

@jacobtylerwalls jacobtylerwalls Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Option provider priority is different than checker priority, right? We should document that as going away also.

I'm a little nervous that a behavior change could be hiding here, but maybe you can reassure me :D. I tried to trace downstream from this where this could be used and noticed ConfigurationMixin (subclass of OptionsManagerMixIn) is used in pyreverse, which is way outside my involvement.

Also, apparently checkers are option providers? So could removing the checker priority alter the status quo for what order checker-provided-options get overwritten? But if this is part of removing complexity during the argparse migration that's fine...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, since each check is a option provider they share the same priority. Thus, we're basically doing the same checks here as we're doing at that other place.

I think the only two "functions" that come from these priorities is that:

  1. Checkers will be run sooner, but when is that ever needed?
  2. Options could be overwritten by providers with higher priority. But then again, why would we allow that? That creates a lot of mess and duplicate options have actually caused me multiple headaches before.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That creates a lot of mess and duplicate options have actually caused me multiple headaches before.

+1 for reducing the API footprint by removing features we don't understand / aren't documented while migrating to argparse anyway!

Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed there could be subtle option-overwriting behavior changes with this change, but the changes are probably for the better and not anything we're going to support after migrating to argparse. Thanks for clearing out old cruft!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Discussion or action around maintaining pylint or the dev workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants