-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Move pytest search-path handling to desperate resolution #21817
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: main
Are you sure you want to change the base?
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
|
Hmm this is tricky with the tests we have written, I need to look into what pytest actually does/supports. |
|
Can't believe Carl convinced me randomly including tests with or without |
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
unresolved-import |
2 | 1 | 0 |
unsupported-base |
2 | 1 | 0 |
unused-ignore-comment |
0 | 2 | 0 |
| Total | 4 | 4 | 0 |
|
Notably having multiple desperate search-paths is problematic for resolving relative imports, with our two-phases |
|
One kind of hacky solution would be to refuse to consider the dir the file is in a desperate search-path in |
|
Tears of joy at how good these docs are omg https://docs.pytest.org/en/stable/explanation/pythonpath.html |
The same can be accomplished by reversing the priority of the desperate search-paths: try the farthest ancestor dir first, allowing us to resolve |
And try every possible desperate search-path instead of just the closest one.
The benefit here is that in 99.9% of cases we will have one less search-path, and we won't think things in the tests dir are available to the package itself.
testsfrom theenvironment.rootdefault ty#1782