## Summary
This PR changes removes the typeshed stubs from the vendored file system
shipped with ruff
and instead ships an empty "typeshed".
Making the typeshed files optional required extracting the typshed files
into a new `ruff_vendored` crate. I do like this even if all our builds
always include typeshed because it means `red_knot_python_semantic`
contains less code that needs compiling.
This also allows us to use deflate because the compression algorithm
doesn't matter for an archive containing a single, empty file.
## Test Plan
`cargo test`
I verified with ` cargo tree -f "{p} {f}" -p <package> ` that:
* red_knot_wasm: enables `deflate` compression
* red_knot: enables `zstd` compression
* `ruff`: uses stored
I'm not quiet sure how to build the binary that maturin builds but
comparing the release artifact size with `strip = true` shows a `1.5MB`
size reduction
---------
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
46 lines
1.0 KiB
Rust
46 lines
1.0 KiB
Rust
use std::iter::FusedIterator;
|
|
|
|
pub use module::Module;
|
|
pub use resolver::resolve_module;
|
|
pub(crate) use resolver::{file_to_module, SearchPaths};
|
|
use ruff_db::system::SystemPath;
|
|
|
|
use crate::module_resolver::resolver::search_paths;
|
|
use crate::Db;
|
|
use resolver::SearchPathIterator;
|
|
|
|
mod module;
|
|
mod path;
|
|
mod resolver;
|
|
mod typeshed;
|
|
|
|
#[cfg(test)]
|
|
mod testing;
|
|
|
|
/// Returns an iterator over all search paths pointing to a system path
|
|
pub fn system_module_search_paths(db: &dyn Db) -> SystemModuleSearchPathsIter {
|
|
SystemModuleSearchPathsIter {
|
|
inner: search_paths(db),
|
|
}
|
|
}
|
|
|
|
pub struct SystemModuleSearchPathsIter<'db> {
|
|
inner: SearchPathIterator<'db>,
|
|
}
|
|
|
|
impl<'db> Iterator for SystemModuleSearchPathsIter<'db> {
|
|
type Item = &'db SystemPath;
|
|
|
|
fn next(&mut self) -> Option<Self::Item> {
|
|
loop {
|
|
let next = self.inner.next()?;
|
|
|
|
if let Some(system_path) = next.as_system_path() {
|
|
return Some(system_path);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
impl FusedIterator for SystemModuleSearchPathsIter<'_> {}
|