Skip to content

Allow passing arguments when entry points are used as functions #5613

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

Merged
merged 2 commits into from
Dec 30, 2021

Conversation

DanielNoord
Copy link
Collaborator

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • Write a good description on what the PR does.

Type of Changes

Type
✨ New feature
📜 Docs

Description

@Pierre-Sassoulas I'm not sure if this warrants a changelog entry? I haven't added one.

I'll do a follow-up for epylint, as it requires some additional changes to its Run class.

Closes #5320

@DanielNoord DanielNoord added the Enhancement ✨ Improvement to a component label Dec 30, 2021
@DanielNoord DanielNoord added this to the 2.13.0 milestone Dec 30, 2021
@DanielNoord
Copy link
Collaborator Author

Oops, I based on the wrong branch. This should be better!

@DanielNoord DanielNoord changed the title Pyreverse entry Allow passing arguments when entry points are used as functions Dec 30, 2021
@coveralls
Copy link

coveralls commented Dec 30, 2021

Pull Request Test Coverage Report for Build 1638542036

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • 13 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.02%) to 93.693%

Files with Coverage Reduction New Missed Lines %
pylint/lint/parallel.py 2 94.03%
pylint/lint/pylinter.py 2 93.97%
pylint/checkers/refactoring/refactoring_checker.py 9 98.18%
Totals Coverage Status
Change from base Build 1637742925: -0.02%
Covered Lines: 14336
Relevant Lines: 15301

💛 - 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.

Great ! I think a changelog would be bice, if only to advertise the feature. I'll approve either way.

@DanielNoord
Copy link
Collaborator Author

How do we call this?

"When invoking pylint, symilar or pyreverse programatically you can now pass an arguments keyword"? I'm really not sure...

@Pierre-Sassoulas
Copy link
Member

"When invoking pylint, symilar or pyreverse programatically you can now pass an arguments keyword"? I'm really not sure...

Maybe : "The API of pylint, symilar and pyreverse now do not rely exclusively on sys.argv and also permits to pass args programmatically" ?

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.

👌 You're doing so much lately, you're carrying 2.13.0 on your back 😄

@Pierre-Sassoulas Pierre-Sassoulas merged commit b9fe597 into pylint-dev:main Dec 30, 2021
@DanielNoord DanielNoord deleted the pyreverse-entry branch December 30, 2021 21:41

from pylint.__pkginfo__ import __version__

# pylint: disable=import-outside-toplevel


def run_pylint():
def run_pylint(*, arguments: Optional[List[str]] = None):
Copy link
Member

Choose a reason for hiding this comment

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

I'm probably a bit late on this one.

I would suggest using args or argv instead, without the keyword requirement. This is what I usually see in these cases.

def main(argv: Optional[Sequence[str]] = None):
    argv = argv or sys.argv[1:]
    ...

Keyword only isn't really necessary here, it's just one argument. Even with more, the first will likely always be args / argv. More detail (optional) once can always be keyword only later, although even then not strictly necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please provide a better entry point to pyreverse
4 participants