-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Search PYTHONPATH to find modules #20441
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
Conversation
carljm
left a comment
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 reasonable to me. Not sure if it's feasible to test this, or if we should have a CLI flag to disable reading PYTHONPATH (just unsetting PYTHONPATH does seem like a reasonable alternative.). Would prefer for @MichaReiser or @AlexWaygood to review.
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
|
Thanks for picking this up, I just have been underwater dealing with things lately, I really appreciate it. |
MichaReiser
left a comment
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. I left a few comments. We should also add a CLI test for this in
| fn config_override_python_version() -> anyhow::Result<()> { |
| .map(|path| path.absolute(project_root, system)), | ||
| ); | ||
|
|
||
| let settings = SearchPathSettings { |
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.
@AlexWaygood any thoughts on whether we should move this logic into SearchPaths::from_settings?
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.
No strong opinion really!
62138e0 to
89f57d1
Compare
I'll take a look at this and give it a go. |
89f57d1 to
1870de5
Compare
1870de5 to
46bc82e
Compare
|
Thank you. This looks good now and we can merge it once there's a CLI test. |
This brings ty in line with other type checkers and python interpreters, including on by default and no options to disable. Can be disabled by clearing the PYTHONPATH environment variable. Co-authored-by: Manuel Mendez <[email protected]> Co-authored-by: Micha Reiser <[email protected]>
46bc82e to
b9f05f7
Compare
Done! |
MichaReiser
left a comment
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.
Perfect, thank you
This brings ty in line with other type checkers and python interpreters, including on by default and no options to disable. Can be disabled by clearing the PYTHONPATH environment variable.
Summary
Prepend PYTHONPATH to extra_paths so ty behaves similar to other type checkers and the interpreters. Fixes astral-sh/ty#547
Test Plan
I built ty locally and ran it in nix-shell environment that sets PYTHONPATH, without this PR ty errors with
unresolved-attribute.