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

feat: script improvements #13

Merged
merged 1 commit into from
Oct 31, 2024
Merged

Conversation

henryiii
Copy link
Contributor

@henryiii henryiii commented Oct 31, 2024

This makes several improvements to the python -m dependency-groups script:

  • Adds a dependency-groups script, so that uvx dependency-groups and pipx run dependency-groups works, along with pipx install/uv tool install.
  • Adds a cli extra so that pipx run dependency-groups[cli] works on Python < 3.11
  • Allows more than one extra to be requested
  • Adds a --list to quickly see all the dependency groups available

I don't think there are CLI tests yet, so didn't add tests.


📚 Documentation preview 📚: https://dependency-groups--13.org.readthedocs.build/en/13/

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Copy link
Owner

@sirosen sirosen left a comment

Choose a reason for hiding this comment

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

Yep, this seems like a good enhancement to me! Originally I thought making python -m dependency_groups the way to run it would be sufficient, but you make a good point about pipx/uvx.

I'd already been considering maybe adding --list, so I'm onboard for that.


This is reminding me that I need to rig up CLI tests. I've got some specific ideas on how I want that to work, so I'll get to it soon.

"Usage error: dependency-groups CLI requires tomli or Python 3.11+",
file=sys.stderr,
)
raise SystemExit(2) from None
Copy link
Owner

Choose a reason for hiding this comment

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

Just curious, does explicitly raising a SystemExit behave significantly differently from sys.exit? (Will it capture the outer error in __cause__ by default?)

If I need to adjust my habits around this, it's a good opportunity to learn.

Copy link
Contributor Author

@henryiii henryiii Oct 31, 2024

Choose a reason for hiding this comment

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

It doesn't require an import, is microscopically faster, and is a bit more explicitly obvious as a control flow statement than a NoReturn function. If someone does explicitly catch it, like in tests, you can inspect the __cause__/__context__/__suppress_context__, as well, but it doesn't show the cause with the default exception hook.

See https://www.youtube.com/watch?v=ZbeSPc5wL0g.

Edit: ignore what I put here originally, exception suppression works as you'd expect if you inspect it, I just forgot how it worked for a minute.

@sirosen sirosen merged commit 2a8d14e into sirosen:main Oct 31, 2024
6 checks passed
@henryiii henryiii deleted the henryiii/feat/main branch October 31, 2024 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants