-
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
[red-knot] Watch search paths #12407
Conversation
|
7cb5f50
to
f969d0d
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 admit, adding countme
fields to the different tracked structs isn't directly related to this PR but it seemed useful to have and it's a local enough change. But I can extract it if it is preferred.
|
||
/// Paths that should be watched but setting up the watcher failed for some reason. | ||
/// This should be rare. | ||
errored_paths: Vec<SystemPathBuf>, |
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 use a Vec
here because this should almost always be empty and searching small vecs tends to be faster than hash maps, not that it matters much 😆
CodSpeed Performance ReportMerging #12407 will not alter performanceComparing Summary
|
f969d0d
to
d5ba5ce
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.
The module-resolver crate bits look good (haven't looked at the other bits yet, but I will!)
use crate::resolver::{module_resolution_settings, SearchPathIterator}; | ||
pub use db::{Db, Jar}; | ||
pub use module::{Module, ModuleKind}; | ||
pub use module_name::ModuleName; | ||
pub use resolver::resolve_module; | ||
use ruff_db::system::SystemPath; | ||
use std::iter::FusedIterator; | ||
pub use typeshed::{ | ||
vendored_typeshed_stubs, TypeshedVersionsParseError, TypeshedVersionsParseErrorKind, | ||
}; |
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: this is inconsistent with the import style I've used for the rest of this crate
use crate::resolver::{module_resolution_settings, SearchPathIterator}; | |
pub use db::{Db, Jar}; | |
pub use module::{Module, ModuleKind}; | |
pub use module_name::ModuleName; | |
pub use resolver::resolve_module; | |
use ruff_db::system::SystemPath; | |
use std::iter::FusedIterator; | |
pub use typeshed::{ | |
vendored_typeshed_stubs, TypeshedVersionsParseError, TypeshedVersionsParseErrorKind, | |
}; | |
use std::iter::FusedIterator; | |
use ruff_db::system::SystemPath; | |
pub use db::{Db, Jar}; | |
pub use module::{Module, ModuleKind}; | |
pub use module_name::ModuleName; | |
use resolver::{module_resolution_settings, SearchPathIterator}; | |
pub use resolver::resolve_module; | |
pub use typeshed::{ | |
vendored_typeshed_stubs, TypeshedVersionsParseError, TypeshedVersionsParseErrorKind, | |
}; |
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 think we should either deploy tooling to standardize use sorting or not be opinionated about it. It otherwise is guaranteed to get out of sync.
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.
Fair enough, I'll try to be less picky about it in the future :(
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.
FWIW I'd be happy to have tooling that standardizes it, but I haven't looked into what the options are.
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.
Rustfmt has an option for it but it isn't stabilized. https://rust-lang.github.io/rustfmt/?version=master&search=import#group_imports and it can't be enabled on non-nigthly rustfmt
Warning: can't set `group_imports = StdExternalCrate`, unstable features are only available in nightly channel.
Warning: can't set `unstable_features = true`, unstable features are only available in nightly channel.
d5ba5ce
to
98a3959
Compare
98a3959
to
b396613
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.
Nice!
Summary
This PR extends the CLI to watch not only the workspace root but also all search paths. The watcher automatically registers new search paths or stops watching search paths when the program's
SearchPathSettings
change.Test Plan
Added integration tests.