[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.
This commit is contained in:
Micha Reiser authored and GitHub committed 2026-08-13 14:04:12 +02:00
1 parent 1263524672
commit ecdd401fdb
7 files changed
+20 -13

No files matched your search

+2
View File
@@ -37,6 +37,8 @@ mod files;
pub mod glob;
pub mod metadata;
pub mod parallel;
mod script;
mod uv;
mod walk;
pub mod watch;
+3 -3
View File
@@ -17,6 +17,7 @@ use crate::metadata::options::{
use crate::metadata::pyproject::{Project, PyProject, PyProjectError, ResolveRequiresPythonError};
use crate::metadata::settings::Settings;
use crate::metadata::value::RelativePathBuf;
use crate::uv;
pub use options::Options;
use options::TyTomlError;
@@ -24,9 +25,7 @@ mod configuration_file;
pub mod options;
pub mod pyproject;
pub mod python_version;
pub(crate) mod script;
pub mod settings;
mod uv;
pub mod value;
#[derive(Debug, Clone, PartialEq, Eq, get_size2::GetSize)]
@@ -640,7 +639,8 @@ mod tests {
use ruff_ranged_value::ValueSource;
use ty_static::EnvVars;
use crate::metadata::{Options, uv::UvWorkspace, value::RelativePathBuf};
use crate::metadata::{Options, value::RelativePathBuf};
use crate::uv::UvWorkspace;
use crate::{ProjectMetadata, ProjectMetadataError};
#[test]
+1 -1
View File
@@ -6,7 +6,7 @@ use ty_python_semantic::AnalysisSettings;
use ty_python_semantic::lint::RuleSelection;
use crate::metadata::options::{InnerOverrideOptions, Options, OutputFormat};
use crate::metadata::script::script_metadata;
use crate::script::script_metadata;
use crate::{Db, glob::IncludeExcludeFilter};
/// The resolved [`super::Options`] for the project.
File renamed without changes.
+5
View File
@@ -0,0 +1,5 @@
//! Integrates uv with project discovery.
pub(crate) use metadata::UvWorkspace;
mod metadata;
@@ -7,17 +7,17 @@ use serde::Deserialize;
use thiserror::Error;
use ty_static::EnvVars;
use super::python_version::SupportedPythonVersion;
use crate::metadata::python_version::SupportedPythonVersion;
#[derive(Debug, Clone, PartialEq, Eq, get_size2::GetSize)]
pub(super) struct UvWorkspace {
pub(crate) struct UvWorkspace {
root: SystemPathBuf,
environment: Option<SystemPathBuf>,
python_version: Option<RangedValue<SupportedPythonVersion>>,
}
impl UvWorkspace {
pub(super) fn discover(
pub(crate) fn discover(
path: &SystemPath,
system: &dyn System,
) -> Result<Self, UvWorkspaceError> {
@@ -50,7 +50,7 @@ impl UvWorkspace {
Self::from_metadata(&output.stdout, system)
}
pub(super) fn from_metadata(
pub(crate) fn from_metadata(
metadata: &[u8],
system: &dyn System,
) -> Result<Self, UvWorkspaceError> {
@@ -78,15 +78,15 @@ impl UvWorkspace {
})
}
pub(super) fn root(&self) -> &SystemPath {
pub(crate) fn root(&self) -> &SystemPath {
&self.root
}
pub(super) fn environment(&self) -> Option<&SystemPath> {
pub(crate) fn environment(&self) -> Option<&SystemPath> {
self.environment.as_deref()
}
pub(super) fn python_version(&self) -> Option<&RangedValue<SupportedPythonVersion>> {
pub(crate) fn python_version(&self) -> Option<&RangedValue<SupportedPythonVersion>> {
self.python_version.as_ref()
}
}
@@ -129,7 +129,7 @@ fn existing_directory(
}
#[derive(Debug, Error)]
pub(super) enum UvWorkspaceError {
pub(crate) enum UvWorkspaceError {
#[error("Failed to invoke `uv workspace metadata`: {0}")]
Invocation(#[source] std::io::Error),
+1 -1
View File
@@ -1,5 +1,5 @@
use crate::glob::IncludeExcludeFilter;
use crate::metadata::script::script_metadata;
use crate::script::script_metadata;
use crate::{Db, GlobFilterCheckMode, IncludeResult, Project};
use ruff_db::diagnostic::{Diagnostic, DiagnosticId, Severity};
use ruff_db::files::{File, system_path_to_file};