Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

krikera
Copy link
Contributor

@krikera krikera commented Jun 14, 2025

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

Fixes #483

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
Copy link
Contributor

@connernilsen connernilsen left a 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!

@krikera krikera requested a review from connernilsen June 23, 2025 08:06
Copy link
Contributor

@connernilsen connernilsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's still a part from the last review that is unaddressed. Let me know when it's fixed and I'll review/pull it in @krikera!

@@ -223,6 +223,10 @@ pub struct ConfigFile {
)]
pub fallback_search_path: Vec<PathBuf>,

/// Override the bundled typeshed with a custom path.
#[serde(skip)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this like the other serde macros above? Probably instead of regular skip, do

#[serde(
  default,
  skip_serializing_if = "Vec::is_empty",
)]

Comment on lines 367 to 382
} 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,
))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @krikera, it looks like this part is still duplicated here. Can you delete this before I pull it in?

It's doing the same thing as lines 388-403 as far as I can tell.

@yangdanny97 yangdanny97 requested a review from connernilsen July 8, 2025 15:12
@facebook-github-bot
Copy link
Contributor

@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this in D77937605.

Copy link
Contributor

@stroxler stroxler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@facebook-github-bot
Copy link
Contributor

@yangdanny97 merged this pull request in 5e36fb7.

@yangdanny97
Copy link
Contributor

Thanks for your contribution @krikera !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CLI flag to override typeshed
5 participants