-
Notifications
You must be signed in to change notification settings - Fork 97
Add CLI flag to override typeshed #488
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
Add --typeshed-path flag to pyrefly check command for testing typeshed upgrades and custom typeshed modifications. - Add typeshed_path CLI argument to ConfigOverrideArgs - Add typeshed_path field to ConfigFile struct - Wire custom typeshed lookup into find_import() logic - Custom typeshed takes precedence over bundled typeshed - Falls back gracefully to bundled typeshed if module not found Fixes facebook#483
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.
Hey @krikera, thanks for doing this! Just a few things that need to be changed before we can get this in.
Once you're able to fix them, please re-request my review and I'll come check it out!
} else if let Some(path) = typeshed() | ||
.map_err(|err| FindError::not_found(err, module))? | ||
.find(module) | ||
{ | ||
Ok(path) | ||
} else if let Some(path) = find_module_in_search_path(module, self.fallback_search_path.iter()) { | ||
Ok(path) | ||
} else if let Some(path) = find_module_in_site_package_path( | ||
module, | ||
self.site_package_path(), | ||
self.use_untyped_imports, | ||
self.ignore_missing_source, | ||
)? { | ||
Ok(path) | ||
} else { | ||
Err(FindError::import_lookup_path( | ||
self.structured_import_lookup_path(), | ||
module, | ||
&self.source, | ||
)) | ||
} |
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.
Oops, it looks like this part might have been duplicated from below. Can you remove this?
module, | ||
&self.source, | ||
)) | ||
} | ||
} else if let Some(path) = typeshed() |
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 should only use the builtin typeshed if one isn't provided. Can we add an extra condition for that here?
} else if self.typeshed_path.is_none() && let Some(path) = ...
@@ -174,6 +174,9 @@ struct ConfigOverrideArgs { | |||
/// after first checking `search_path` and `typeshed`. | |||
#[arg(long, env = clap_env("SITE_PACKAGE_PATH"))] | |||
site_package_path: Option<Vec<PathBuf>>, | |||
/// Override the bundled typeshed with a custom path. | |||
#[arg(long = "typeshed-path", env = clap_env("TYPESHED_PATH"))] |
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.
nit: arg(long, ...)
does the same thing as arg(long = "typeshed-path", ...)
, but specifying "typeshed-path"
is more prone to typos/less resilient to refactors. Can we just leave this as arg(long, ...)
?
Add --typeshed-path flag to pyrefly check command for testing typeshed upgrades and custom typeshed modifications.
Fixes #483