-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Eagerly validate typeshed versions #12786
Conversation
b6f2f3d
to
fedd0b8
Compare
60568d5
to
099162a
Compare
fedd0b8
to
533ec59
Compare
@@ -133,6 +133,8 @@ pub(crate) struct SearchPaths { | |||
/// in terms of module-resolution priority until we've discovered the editable installs | |||
/// for the first `site-packages` path | |||
site_packages: Vec<SearchPath>, | |||
|
|||
typeshed_versions: Cow<'static, TypeshedVersions>, |
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.
An alternative to storing typeshed_versions
on SearchPaths
would be to store the TypeshedVersions
alongside the SearchPath
(for the Custom or vendored stdlib variants). I don't really have an opinion on what's better. Let me know if you have ;)
533ec59
to
c4f163f
Compare
|
If I understand correctly, this PR appears to treat the |
Hmm I missed this point. I have to add some manual file-watching to trigger a reload in this case. It also forces us to explicitly think about what should happen if parsing the VERSION files fails when we were able to parse it successfully before (in watch mode) |
099162a
to
7b9da87
Compare
c4f163f
to
6dab77a
Compare
6dab77a
to
4e2b2d7
Compare
CodSpeed Performance ReportMerging #12786 will degrade performances by 6.56%Comparing Summary
Benchmarks breakdown
|
/// The unresolved search path configuration. | ||
#[return_ref] | ||
pub search_path_configuration: SearchPathConfiguration, |
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.
We may want to store the entire WorkspaceSettings
on Workspace
long term but it isn't clear to me if we actually want to do this. That's why I went with storing the absolute minimum
d70ce0c
to
f2385fa
Compare
32ac8e8
to
a4c9afe
Compare
a4c9afe
to
ecd8af3
Compare
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.
I skimmed this and it looks reasonable to me, but I'd rather have @AlexWaygood take a look.
I plan to merge this tomorrow afternoon. |
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.
Looks fantastic. Thanks for working on this, and sorry for the slow review!
crates/red_knot_python_semantic/src/module_resolver/resolver.rs
Outdated
Show resolved
Hide resolved
crates/red_knot_python_semantic/src/module_resolver/resolver.rs
Outdated
Show resolved
Hide resolved
crates/red_knot_python_semantic/src/module_resolver/resolver.rs
Outdated
Show resolved
Hide resolved
crates/red_knot_python_semantic/src/module_resolver/typeshed/versions.rs
Outdated
Show resolved
Hide resolved
Uff, rebasing this PR after so long is painful |
ecd8af3
to
d11c49c
Compare
d11c49c
to
ba1a840
Compare
Summary
This should be the last PR in the module resolver validation stack.
It makes the typeshed version file parsing eagerly by moving it into
SearchPaths::from_settings
. This allows us to exit Red Knot early if theVERSIONS
file is missing or incorrect. I added custom logic to the file watching to handle changes to the VERSIONS file (and added a test for it).Handling changes to the
VERSIONS
file introduces some complexity becauseProgram::update_search_paths
takes aSearchPathSettings
struct but we no longer know theSearchPathSettings
inapply_changes
.A possible solution to this problem is to expose a method
Program::reload_versions_file instead
, which would do the trick just fine. However, I disliked that it is very low-level. We may have other cases where we need to reload the search-path settings, and I want to avoid introducing special case methods for each of those.That's why I started looking into how we want to support configurations. What we need in
apply_changes
is access to what the user configured. The approach follows the same as Ruff's:*Configuration
: The configuration that usesOption
in most places to know whether the user provided a value or not. Configurations from different sources can be merged (e.g. CLI overrides thepyproject.toml
configuration)*Settings
: A resolved configuration in the sense that Red Knot fills in default values and e.g. merges values from different configurations (resolves thetarget-python
version).This PR does not add support for loading or deserializing configurations. It just builds out some of the infrastructure.
Test Plan
cargo test