Skip to content

Commit ecdd401

Browse files
authored
[ty] Separate script and uv modules from project metadata (#27720)
Move standalone script handling and uv workspace metadata into dedicated top-level project modules. This establishes the module structure used by the stacked PEP 723 work without changing behavior. Testing: Ran the project test suite, all affected CLI/LSP tests, Clippy, and repository hooks.
1 parent 1263524 commit ecdd401

7 files changed

Lines changed: 20 additions & 13 deletions

File tree

‎crates/ty_project/src/lib.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ mod files;
3737
pub mod glob;
3838
pub mod metadata;
3939
pub mod parallel;
40+
mod script;
41+
mod uv;
4042
mod walk;
4143
pub mod watch;
4244

‎crates/ty_project/src/metadata.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ use crate::metadata::options::{
1717
use crate::metadata::pyproject::{Project, PyProject, PyProjectError, ResolveRequiresPythonError};
1818
use crate::metadata::settings::Settings;
1919
use crate::metadata::value::RelativePathBuf;
20+
use crate::uv;
2021
pub use options::Options;
2122
use options::TyTomlError;
2223

2324
mod configuration_file;
2425
pub mod options;
2526
pub mod pyproject;
2627
pub mod python_version;
27-
pub(crate) mod script;
2828
pub mod settings;
29-
mod uv;
3029
pub mod value;
3130

3231
#[derive(Debug, Clone, PartialEq, Eq, get_size2::GetSize)]
@@ -640,7 +639,8 @@ mod tests {
640639
use ruff_ranged_value::ValueSource;
641640
use ty_static::EnvVars;
642641

643-
use crate::metadata::{Options, uv::UvWorkspace, value::RelativePathBuf};
642+
use crate::metadata::{Options, value::RelativePathBuf};
643+
use crate::uv::UvWorkspace;
644644
use crate::{ProjectMetadata, ProjectMetadataError};
645645

646646
#[test]

‎crates/ty_project/src/metadata/settings.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use ty_python_semantic::AnalysisSettings;
66
use ty_python_semantic::lint::RuleSelection;
77

88
use crate::metadata::options::{InnerOverrideOptions, Options, OutputFormat};
9-
use crate::metadata::script::script_metadata;
9+
use crate::script::script_metadata;
1010
use crate::{Db, glob::IncludeExcludeFilter};
1111

1212
/// The resolved [`super::Options`] for the project.

‎crates/ty_project/src/uv.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//! Integrates uv with project discovery.
2+
3+
pub(crate) use metadata::UvWorkspace;
4+
5+
mod metadata;
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ use serde::Deserialize;
77
use thiserror::Error;
88
use ty_static::EnvVars;
99

10-
use super::python_version::SupportedPythonVersion;
10+
use crate::metadata::python_version::SupportedPythonVersion;
1111

1212
#[derive(Debug, Clone, PartialEq, Eq, get_size2::GetSize)]
13-
pub(super) struct UvWorkspace {
13+
pub(crate) struct UvWorkspace {
1414
root: SystemPathBuf,
1515
environment: Option<SystemPathBuf>,
1616
python_version: Option<RangedValue<SupportedPythonVersion>>,
1717
}
1818

1919
impl UvWorkspace {
20-
pub(super) fn discover(
20+
pub(crate) fn discover(
2121
path: &SystemPath,
2222
system: &dyn System,
2323
) -> Result<Self, UvWorkspaceError> {
@@ -50,7 +50,7 @@ impl UvWorkspace {
5050
Self::from_metadata(&output.stdout, system)
5151
}
5252

53-
pub(super) fn from_metadata(
53+
pub(crate) fn from_metadata(
5454
metadata: &[u8],
5555
system: &dyn System,
5656
) -> Result<Self, UvWorkspaceError> {
@@ -78,15 +78,15 @@ impl UvWorkspace {
7878
})
7979
}
8080

81-
pub(super) fn root(&self) -> &SystemPath {
81+
pub(crate) fn root(&self) -> &SystemPath {
8282
&self.root
8383
}
8484

85-
pub(super) fn environment(&self) -> Option<&SystemPath> {
85+
pub(crate) fn environment(&self) -> Option<&SystemPath> {
8686
self.environment.as_deref()
8787
}
8888

89-
pub(super) fn python_version(&self) -> Option<&RangedValue<SupportedPythonVersion>> {
89+
pub(crate) fn python_version(&self) -> Option<&RangedValue<SupportedPythonVersion>> {
9090
self.python_version.as_ref()
9191
}
9292
}
@@ -129,7 +129,7 @@ fn existing_directory(
129129
}
130130

131131
#[derive(Debug, Error)]
132-
pub(super) enum UvWorkspaceError {
132+
pub(crate) enum UvWorkspaceError {
133133
#[error("Failed to invoke `uv workspace metadata`: {0}")]
134134
Invocation(#[source] std::io::Error),
135135

‎crates/ty_project/src/walk.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::glob::IncludeExcludeFilter;
2-
use crate::metadata::script::script_metadata;
2+
use crate::script::script_metadata;
33
use crate::{Db, GlobFilterCheckMode, IncludeResult, Project};
44
use ruff_db::diagnostic::{Diagnostic, DiagnosticId, Severity};
55
use ruff_db::files::{File, system_path_to_file};

0 commit comments

Comments
 (0)