-
-
Notifications
You must be signed in to change notification settings - Fork 776
Refactor the handling of shellingham lazy-loading #1347
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
base: master
Are you sure you want to change the base?
Refactor the handling of shellingham lazy-loading #1347
Conversation
…b.com/nathanjmcdougall/typer into config/lazy-load-shellingham-via-ruff
…b.com/nathanjmcdougall/typer into config/lazy-load-shellingham-via-ruff
This comment was marked as outdated.
This comment was marked as outdated.
…b.com/nathanjmcdougall/typer into config/lazy-load-shellingham-via-ruff
📝 Docs preview for commit 81a8134 at: https://6eec02b4.typertiangolo.pages.dev |
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.
The motivation to lazy-load rich_utils
was because of performance reasons, as laid out in #1128. Do you see similar performance hits for loading shellingham
?
Fair question, I think probably I'm being loose with my terminology and write-ups. Since The next thing the PR does is introduce a unified method A side effect of having a What about the lazy loading? To answer your question regarding performance, I don't think performance is a concern here. However, I think it's the least confusing approach in light of the above, and it now only occurs in a single file (except the test suite, perhaps we should disable the lazy-loading Ruff rules in the test suite since it adds little value there). |
See #1297 for motivation.
There's a few places where a conditional check can be simplified but the logic is somewhat subtle. Basically the key thing to bear in mind is that the new
_get_shell_name
method handles the case whereHAS_SHELLINGHAM
is false by returning None.There were a couple calls to
shellingham.detect_shell
that potentially could have raisedShellDetectionFailure
, so I've put this under API ban in favour of the_get_shell_name
method.