mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-28 10:50:26 +00:00
[ruff] Update schemars to v1 (#20942)
This commit is contained in:
parent
991e8ed178
commit
48b50128eb
22 changed files with 686 additions and 704 deletions
33
Cargo.lock
generated
33
Cargo.lock
generated
|
|
@ -2767,6 +2767,26 @@ dependencies = [
|
||||||
"thiserror 2.0.16",
|
"thiserror 2.0.16",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ref-cast"
|
||||||
|
version = "1.0.25"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d"
|
||||||
|
dependencies = [
|
||||||
|
"ref-cast-impl",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ref-cast-impl"
|
||||||
|
version = "1.0.25"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.11.3"
|
version = "1.11.3"
|
||||||
|
|
@ -3197,6 +3217,7 @@ dependencies = [
|
||||||
"salsa",
|
"salsa",
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"thiserror 2.0.16",
|
"thiserror 2.0.16",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -3484,6 +3505,7 @@ dependencies = [
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"shellexpand",
|
"shellexpand",
|
||||||
"strum",
|
"strum",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
|
@ -3589,11 +3611,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "schemars"
|
name = "schemars"
|
||||||
version = "0.8.22"
|
version = "1.0.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615"
|
checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dyn-clone",
|
"dyn-clone",
|
||||||
|
"ref-cast",
|
||||||
"schemars_derive",
|
"schemars_derive",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|
@ -3601,9 +3624,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "schemars_derive"
|
name = "schemars_derive"
|
||||||
version = "0.8.22"
|
version = "1.0.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d"
|
checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
@ -4384,6 +4407,7 @@ dependencies = [
|
||||||
"salsa",
|
"salsa",
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"thiserror 2.0.16",
|
"thiserror 2.0.16",
|
||||||
"toml",
|
"toml",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
|
@ -4431,6 +4455,7 @@ dependencies = [
|
||||||
"salsa",
|
"salsa",
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
"strsim",
|
"strsim",
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "ef9f9329be6923ac
|
||||||
"salsa_unstable",
|
"salsa_unstable",
|
||||||
"inventory",
|
"inventory",
|
||||||
] }
|
] }
|
||||||
schemars = { version = "0.8.16" }
|
schemars = { version = "1.0.4" }
|
||||||
seahash = { version = "4.1.0" }
|
seahash = { version = "4.1.0" }
|
||||||
serde = { version = "1.0.197", features = ["derive"] }
|
serde = { version = "1.0.197", features = ["derive"] }
|
||||||
serde-wasm-bindgen = { version = "0.6.4" }
|
serde-wasm-bindgen = { version = "0.6.4" }
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
use anyhow::{Result, bail};
|
use anyhow::{Result, bail};
|
||||||
use pretty_assertions::StrComparison;
|
use pretty_assertions::StrComparison;
|
||||||
use schemars::schema_for;
|
use schemars::generate::SchemaSettings;
|
||||||
|
|
||||||
use crate::ROOT_DIR;
|
use crate::ROOT_DIR;
|
||||||
use crate::generate_all::{Mode, REGENERATE_ALL_COMMAND};
|
use crate::generate_all::{Mode, REGENERATE_ALL_COMMAND};
|
||||||
|
|
@ -17,7 +17,9 @@ pub(crate) struct Args {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn main(args: &Args) -> Result<()> {
|
pub(crate) fn main(args: &Args) -> Result<()> {
|
||||||
let schema = schema_for!(Options);
|
let settings = SchemaSettings::draft07();
|
||||||
|
let generator = settings.into_generator();
|
||||||
|
let schema = generator.into_root_schema_for::<Options>();
|
||||||
let schema_string = serde_json::to_string_pretty(&schema).unwrap();
|
let schema_string = serde_json::to_string_pretty(&schema).unwrap();
|
||||||
let filename = "ruff.schema.json";
|
let filename = "ruff.schema.json";
|
||||||
let schema_path = PathBuf::from(ROOT_DIR).join(filename);
|
let schema_path = PathBuf::from(ROOT_DIR).join(filename);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
use anyhow::{Result, bail};
|
use anyhow::{Result, bail};
|
||||||
use pretty_assertions::StrComparison;
|
use pretty_assertions::StrComparison;
|
||||||
use schemars::schema_for;
|
use schemars::generate::SchemaSettings;
|
||||||
|
|
||||||
use crate::ROOT_DIR;
|
use crate::ROOT_DIR;
|
||||||
use crate::generate_all::{Mode, REGENERATE_ALL_COMMAND};
|
use crate::generate_all::{Mode, REGENERATE_ALL_COMMAND};
|
||||||
|
|
@ -17,7 +17,9 @@ pub(crate) struct Args {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn main(args: &Args) -> Result<()> {
|
pub(crate) fn main(args: &Args) -> Result<()> {
|
||||||
let schema = schema_for!(Options);
|
let settings = SchemaSettings::draft07();
|
||||||
|
let generator = settings.into_generator();
|
||||||
|
let schema = generator.into_root_schema_for::<Options>();
|
||||||
let schema_string = serde_json::to_string_pretty(&schema).unwrap();
|
let schema_string = serde_json::to_string_pretty(&schema).unwrap();
|
||||||
let filename = "ty.schema.json";
|
let filename = "ty.schema.json";
|
||||||
let schema_path = PathBuf::from(ROOT_DIR).join(filename);
|
let schema_path = PathBuf::from(ROOT_DIR).join(filename);
|
||||||
|
|
|
||||||
|
|
@ -257,9 +257,8 @@ pub struct PreviewOptions {
|
||||||
#[cfg(feature = "schemars")]
|
#[cfg(feature = "schemars")]
|
||||||
mod schema {
|
mod schema {
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use schemars::_serde_json::Value;
|
use schemars::{JsonSchema, Schema, SchemaGenerator};
|
||||||
use schemars::JsonSchema;
|
use serde_json::Value;
|
||||||
use schemars::schema::{InstanceType, Schema, SchemaObject};
|
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::RuleSelector;
|
use crate::RuleSelector;
|
||||||
|
|
@ -267,64 +266,65 @@ mod schema {
|
||||||
use crate::rule_selector::{Linter, RuleCodePrefix};
|
use crate::rule_selector::{Linter, RuleCodePrefix};
|
||||||
|
|
||||||
impl JsonSchema for RuleSelector {
|
impl JsonSchema for RuleSelector {
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> std::borrow::Cow<'static, str> {
|
||||||
"RuleSelector".to_string()
|
std::borrow::Cow::Borrowed("RuleSelector")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> Schema {
|
fn json_schema(_gen: &mut SchemaGenerator) -> Schema {
|
||||||
Schema::Object(SchemaObject {
|
let enum_values: Vec<String> = [
|
||||||
instance_type: Some(InstanceType::String.into()),
|
// Include the non-standard "ALL" selectors.
|
||||||
enum_values: Some(
|
"ALL".to_string(),
|
||||||
[
|
// Include the legacy "C" and "T" selectors.
|
||||||
// Include the non-standard "ALL" selectors.
|
"C".to_string(),
|
||||||
"ALL".to_string(),
|
"T".to_string(),
|
||||||
// Include the legacy "C" and "T" selectors.
|
// Include some common redirect targets for those legacy selectors.
|
||||||
"C".to_string(),
|
"C9".to_string(),
|
||||||
"T".to_string(),
|
"T1".to_string(),
|
||||||
// Include some common redirect targets for those legacy selectors.
|
"T2".to_string(),
|
||||||
"C9".to_string(),
|
]
|
||||||
"T1".to_string(),
|
.into_iter()
|
||||||
"T2".to_string(),
|
.chain(
|
||||||
]
|
RuleCodePrefix::iter()
|
||||||
.into_iter()
|
.map(|p| {
|
||||||
.chain(
|
let prefix = p.linter().common_prefix();
|
||||||
RuleCodePrefix::iter()
|
let code = p.short_code();
|
||||||
.map(|p| {
|
format!("{prefix}{code}")
|
||||||
let prefix = p.linter().common_prefix();
|
|
||||||
let code = p.short_code();
|
|
||||||
format!("{prefix}{code}")
|
|
||||||
})
|
|
||||||
.chain(Linter::iter().filter_map(|l| {
|
|
||||||
let prefix = l.common_prefix();
|
|
||||||
(!prefix.is_empty()).then(|| prefix.to_string())
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
.filter(|p| {
|
|
||||||
// Exclude any prefixes where all of the rules are removed
|
|
||||||
if let Ok(Self::Rule { prefix, .. } | Self::Prefix { prefix, .. }) =
|
|
||||||
RuleSelector::parse_no_redirect(p)
|
|
||||||
{
|
|
||||||
!prefix.rules().all(|rule| rule.is_removed())
|
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.filter(|_rule| {
|
.chain(Linter::iter().filter_map(|l| {
|
||||||
// Filter out all test-only rules
|
let prefix = l.common_prefix();
|
||||||
#[cfg(any(feature = "test-rules", test))]
|
(!prefix.is_empty()).then(|| prefix.to_string())
|
||||||
#[expect(clippy::used_underscore_binding)]
|
})),
|
||||||
if _rule.starts_with("RUF9") || _rule == "PLW0101" {
|
)
|
||||||
return false;
|
.filter(|p| {
|
||||||
}
|
// Exclude any prefixes where all of the rules are removed
|
||||||
|
if let Ok(Self::Rule { prefix, .. } | Self::Prefix { prefix, .. }) =
|
||||||
true
|
RuleSelector::parse_no_redirect(p)
|
||||||
})
|
{
|
||||||
.sorted()
|
!prefix.rules().all(|rule| rule.is_removed())
|
||||||
.map(Value::String)
|
} else {
|
||||||
.collect(),
|
true
|
||||||
),
|
}
|
||||||
..SchemaObject::default()
|
|
||||||
})
|
})
|
||||||
|
.filter(|_rule| {
|
||||||
|
// Filter out all test-only rules
|
||||||
|
#[cfg(any(feature = "test-rules", test))]
|
||||||
|
#[expect(clippy::used_underscore_binding)]
|
||||||
|
if _rule.starts_with("RUF9") || _rule == "PLW0101" {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
true
|
||||||
|
})
|
||||||
|
.sorted()
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let mut schema = schemars::json_schema!({ "type": "string" });
|
||||||
|
schema.ensure_object().insert(
|
||||||
|
"enum".to_string(),
|
||||||
|
Value::Array(enum_values.into_iter().map(Value::String).collect()),
|
||||||
|
);
|
||||||
|
|
||||||
|
schema
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -617,12 +617,12 @@ impl TryFrom<String> for RequiredVersion {
|
||||||
|
|
||||||
#[cfg(feature = "schemars")]
|
#[cfg(feature = "schemars")]
|
||||||
impl schemars::JsonSchema for RequiredVersion {
|
impl schemars::JsonSchema for RequiredVersion {
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> std::borrow::Cow<'static, str> {
|
||||||
"RequiredVersion".to_string()
|
std::borrow::Cow::Borrowed("RequiredVersion")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
|
fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schema {
|
||||||
generator.subschema_for::<String>()
|
<String as schemars::JsonSchema>::json_schema(generator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,11 @@ rustc-hash = { workspace = true }
|
||||||
salsa = { workspace = true, optional = true }
|
salsa = { workspace = true, optional = true }
|
||||||
schemars = { workspace = true, optional = true }
|
schemars = { workspace = true, optional = true }
|
||||||
serde = { workspace = true, optional = true }
|
serde = { workspace = true, optional = true }
|
||||||
|
serde_json = { workspace = true, optional = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
schemars = ["dep:schemars"]
|
schemars = ["dep:schemars", "dep:serde_json"]
|
||||||
cache = ["dep:ruff_cache", "dep:ruff_macros"]
|
cache = ["dep:ruff_cache", "dep:ruff_macros"]
|
||||||
serde = [
|
serde = [
|
||||||
"dep:serde",
|
"dep:serde",
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,11 @@ use crate::generated::ExprName;
|
||||||
#[cfg_attr(feature = "cache", derive(ruff_macros::CacheKey))]
|
#[cfg_attr(feature = "cache", derive(ruff_macros::CacheKey))]
|
||||||
#[cfg_attr(feature = "salsa", derive(salsa::Update))]
|
#[cfg_attr(feature = "salsa", derive(salsa::Update))]
|
||||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
||||||
|
#[cfg_attr(
|
||||||
|
feature = "schemars",
|
||||||
|
derive(schemars::JsonSchema),
|
||||||
|
schemars(with = "String")
|
||||||
|
)]
|
||||||
pub struct Name(compact_str::CompactString);
|
pub struct Name(compact_str::CompactString);
|
||||||
|
|
||||||
impl Name {
|
impl Name {
|
||||||
|
|
@ -201,35 +206,6 @@ impl PartialEq<Name> for &String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "schemars")]
|
|
||||||
impl schemars::JsonSchema for Name {
|
|
||||||
fn is_referenceable() -> bool {
|
|
||||||
String::is_referenceable()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn schema_name() -> String {
|
|
||||||
String::schema_name()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn schema_id() -> std::borrow::Cow<'static, str> {
|
|
||||||
String::schema_id()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
|
|
||||||
String::json_schema(generator)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn _schemars_private_non_optional_json_schema(
|
|
||||||
generator: &mut schemars::r#gen::SchemaGenerator,
|
|
||||||
) -> schemars::schema::Schema {
|
|
||||||
String::_schemars_private_non_optional_json_schema(generator)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn _schemars_private_is_option() -> bool {
|
|
||||||
String::_schemars_private_is_option()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A representation of a qualified name, like `typing.List`.
|
/// A representation of a qualified name, like `typing.List`.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct QualifiedName<'a>(SegmentsVec<'a>);
|
pub struct QualifiedName<'a>(SegmentsVec<'a>);
|
||||||
|
|
|
||||||
|
|
@ -188,42 +188,39 @@ mod serde {
|
||||||
#[cfg(feature = "schemars")]
|
#[cfg(feature = "schemars")]
|
||||||
mod schemars {
|
mod schemars {
|
||||||
use super::PythonVersion;
|
use super::PythonVersion;
|
||||||
use schemars::_serde_json::Value;
|
use schemars::{JsonSchema, Schema, SchemaGenerator};
|
||||||
use schemars::JsonSchema;
|
use serde_json::Value;
|
||||||
use schemars::schema::{Metadata, Schema, SchemaObject, SubschemaValidation};
|
|
||||||
|
|
||||||
impl JsonSchema for PythonVersion {
|
impl JsonSchema for PythonVersion {
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> std::borrow::Cow<'static, str> {
|
||||||
"PythonVersion".to_string()
|
std::borrow::Cow::Borrowed("PythonVersion")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> Schema {
|
fn json_schema(_gen: &mut SchemaGenerator) -> Schema {
|
||||||
let sub_schemas = std::iter::once(Schema::Object(SchemaObject {
|
let mut any_of: Vec<Value> = vec![
|
||||||
instance_type: Some(schemars::schema::InstanceType::String.into()),
|
schemars::json_schema!({
|
||||||
string: Some(Box::new(schemars::schema::StringValidation {
|
"type": "string",
|
||||||
pattern: Some(r"^\d+\.\d+$".to_string()),
|
"pattern": r"^\d+\.\d+$",
|
||||||
..Default::default()
|
|
||||||
})),
|
|
||||||
..Default::default()
|
|
||||||
}))
|
|
||||||
.chain(Self::iter().map(|v| {
|
|
||||||
Schema::Object(SchemaObject {
|
|
||||||
const_value: Some(Value::String(v.to_string())),
|
|
||||||
metadata: Some(Box::new(Metadata {
|
|
||||||
description: Some(format!("Python {v}")),
|
|
||||||
..Metadata::default()
|
|
||||||
})),
|
|
||||||
..SchemaObject::default()
|
|
||||||
})
|
})
|
||||||
}));
|
.into(),
|
||||||
|
];
|
||||||
|
|
||||||
Schema::Object(SchemaObject {
|
for version in Self::iter() {
|
||||||
subschemas: Some(Box::new(SubschemaValidation {
|
let mut schema = schemars::json_schema!({
|
||||||
any_of: Some(sub_schemas.collect()),
|
"const": version.to_string(),
|
||||||
..Default::default()
|
});
|
||||||
})),
|
schema.ensure_object().insert(
|
||||||
..SchemaObject::default()
|
"description".to_string(),
|
||||||
})
|
Value::String(format!("Python {version}")),
|
||||||
|
);
|
||||||
|
any_of.push(schema.into());
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut schema = Schema::default();
|
||||||
|
schema
|
||||||
|
.ensure_object()
|
||||||
|
.insert("anyOf".to_string(), Value::Array(any_of));
|
||||||
|
schema
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ rustc-hash = { workspace = true }
|
||||||
salsa = { workspace = true }
|
salsa = { workspace = true }
|
||||||
serde = { workspace = true, optional = true }
|
serde = { workspace = true, optional = true }
|
||||||
schemars = { workspace = true, optional = true }
|
schemars = { workspace = true, optional = true }
|
||||||
|
serde_json = { workspace = true, optional = true }
|
||||||
smallvec = { workspace = true }
|
smallvec = { workspace = true }
|
||||||
static_assertions = { workspace = true }
|
static_assertions = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
|
|
@ -66,7 +67,7 @@ serde = [
|
||||||
"ruff_source_file/serde",
|
"ruff_source_file/serde",
|
||||||
"ruff_python_ast/serde",
|
"ruff_python_ast/serde",
|
||||||
]
|
]
|
||||||
schemars = ["dep:schemars", "ruff_formatter/schemars"]
|
schemars = ["dep:schemars", "dep:serde_json", "ruff_formatter/schemars"]
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
|
||||||
|
|
@ -403,15 +403,12 @@ pub enum DocstringCodeLineWidth {
|
||||||
#[cfg(feature = "schemars")]
|
#[cfg(feature = "schemars")]
|
||||||
mod schema {
|
mod schema {
|
||||||
use ruff_formatter::LineWidth;
|
use ruff_formatter::LineWidth;
|
||||||
use schemars::r#gen::SchemaGenerator;
|
use schemars::{Schema, SchemaGenerator};
|
||||||
use schemars::schema::{Metadata, Schema, SubschemaValidation};
|
use serde_json::Value;
|
||||||
|
|
||||||
/// A dummy type that is used to generate a schema for `DocstringCodeLineWidth::Dynamic`.
|
/// A dummy type that is used to generate a schema for `DocstringCodeLineWidth::Dynamic`.
|
||||||
pub(super) fn dynamic(_: &mut SchemaGenerator) -> Schema {
|
pub(super) fn dynamic(_: &mut SchemaGenerator) -> Schema {
|
||||||
Schema::Object(schemars::schema::SchemaObject {
|
schemars::json_schema!({ "const": "dynamic" })
|
||||||
const_value: Some("dynamic".to_string().into()),
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use a manual schema for `fixed` even thought it isn't strictly necessary according to the
|
// We use a manual schema for `fixed` even thought it isn't strictly necessary according to the
|
||||||
|
|
@ -422,19 +419,14 @@ mod schema {
|
||||||
// `allOf`. There's no semantic difference between `allOf` and `oneOf` for single element lists.
|
// `allOf`. There's no semantic difference between `allOf` and `oneOf` for single element lists.
|
||||||
pub(super) fn fixed(generator: &mut SchemaGenerator) -> Schema {
|
pub(super) fn fixed(generator: &mut SchemaGenerator) -> Schema {
|
||||||
let schema = generator.subschema_for::<LineWidth>();
|
let schema = generator.subschema_for::<LineWidth>();
|
||||||
Schema::Object(schemars::schema::SchemaObject {
|
let mut schema_object = Schema::default();
|
||||||
metadata: Some(Box::new(Metadata {
|
let map = schema_object.ensure_object();
|
||||||
description: Some(
|
map.insert(
|
||||||
"Wrap docstring code examples at a fixed line width.".to_string(),
|
"description".to_string(),
|
||||||
),
|
Value::String("Wrap docstring code examples at a fixed line width.".to_string()),
|
||||||
..Metadata::default()
|
);
|
||||||
})),
|
map.insert("oneOf".to_string(), Value::Array(vec![schema.into()]));
|
||||||
subschemas: Some(Box::new(SubschemaValidation {
|
schema_object
|
||||||
one_of: Some(vec![schema]),
|
|
||||||
..SubschemaValidation::default()
|
|
||||||
})),
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -274,15 +274,11 @@ impl<'de> serde::de::Deserialize<'de> for NameImports {
|
||||||
|
|
||||||
#[cfg(feature = "schemars")]
|
#[cfg(feature = "schemars")]
|
||||||
impl schemars::JsonSchema for NameImports {
|
impl schemars::JsonSchema for NameImports {
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> std::borrow::Cow<'static, str> {
|
||||||
"NameImports".to_string()
|
std::borrow::Cow::Borrowed("NameImports")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
|
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
|
||||||
schemars::schema::SchemaObject {
|
schemars::json_schema!({ "type": "string" })
|
||||||
instance_type: Some(schemars::schema::InstanceType::String.into()),
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,12 @@
|
||||||
//! bindings to the Workspace API
|
//! bindings to the Workspace API
|
||||||
|
|
||||||
use crate::{TextRange, TextSize};
|
use crate::{TextRange, TextSize};
|
||||||
use schemars::{JsonSchema, r#gen::SchemaGenerator, schema::Schema};
|
use schemars::{JsonSchema, Schema, SchemaGenerator};
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
impl JsonSchema for TextSize {
|
impl JsonSchema for TextSize {
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> Cow<'static, str> {
|
||||||
String::from("TextSize")
|
Cow::Borrowed("TextSize")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(r#gen: &mut SchemaGenerator) -> Schema {
|
fn json_schema(r#gen: &mut SchemaGenerator) -> Schema {
|
||||||
|
|
@ -21,8 +22,8 @@ impl JsonSchema for TextSize {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JsonSchema for TextRange {
|
impl JsonSchema for TextRange {
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> Cow<'static, str> {
|
||||||
String::from("TextRange")
|
Cow::Borrowed("TextRange")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(r#gen: &mut SchemaGenerator) -> Schema {
|
fn json_schema(r#gen: &mut SchemaGenerator) -> Schema {
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ regex = { workspace = true }
|
||||||
rustc-hash = { workspace = true }
|
rustc-hash = { workspace = true }
|
||||||
schemars = { workspace = true, optional = true }
|
schemars = { workspace = true, optional = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
serde_json = { workspace = true, optional = true }
|
||||||
shellexpand = { workspace = true }
|
shellexpand = { workspace = true }
|
||||||
strum = { workspace = true }
|
strum = { workspace = true }
|
||||||
toml = { workspace = true }
|
toml = { workspace = true }
|
||||||
|
|
@ -63,6 +64,7 @@ ignored = ["colored"]
|
||||||
default = []
|
default = []
|
||||||
schemars = [
|
schemars = [
|
||||||
"dep:schemars",
|
"dep:schemars",
|
||||||
|
"dep:serde_json",
|
||||||
"ruff_formatter/schemars",
|
"ruff_formatter/schemars",
|
||||||
"ruff_linter/schemars",
|
"ruff_linter/schemars",
|
||||||
"ruff_python_formatter/schemars",
|
"ruff_python_formatter/schemars",
|
||||||
|
|
|
||||||
|
|
@ -469,6 +469,7 @@ pub struct Options {
|
||||||
deny_unknown_fields,
|
deny_unknown_fields,
|
||||||
rename_all = "kebab-case"
|
rename_all = "kebab-case"
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "schemars", schemars(!from))]
|
||||||
pub struct LintOptions {
|
pub struct LintOptions {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub common: LintCommonOptions,
|
pub common: LintCommonOptions,
|
||||||
|
|
@ -563,8 +564,8 @@ impl OptionsMetadata for DeprecatedTopLevelLintOptions {
|
||||||
|
|
||||||
#[cfg(feature = "schemars")]
|
#[cfg(feature = "schemars")]
|
||||||
impl schemars::JsonSchema for DeprecatedTopLevelLintOptions {
|
impl schemars::JsonSchema for DeprecatedTopLevelLintOptions {
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> std::borrow::Cow<'static, str> {
|
||||||
"DeprecatedTopLevelLintOptions".to_owned()
|
std::borrow::Cow::Borrowed("DeprecatedTopLevelLintOptions")
|
||||||
}
|
}
|
||||||
fn schema_id() -> std::borrow::Cow<'static, str> {
|
fn schema_id() -> std::borrow::Cow<'static, str> {
|
||||||
std::borrow::Cow::Borrowed(concat!(
|
std::borrow::Cow::Borrowed(concat!(
|
||||||
|
|
@ -573,28 +574,25 @@ impl schemars::JsonSchema for DeprecatedTopLevelLintOptions {
|
||||||
"DeprecatedTopLevelLintOptions"
|
"DeprecatedTopLevelLintOptions"
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
|
fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schema {
|
||||||
use schemars::schema::Schema;
|
use serde_json::Value;
|
||||||
|
|
||||||
let common_schema = LintCommonOptions::json_schema(generator);
|
let mut schema = LintCommonOptions::json_schema(generator);
|
||||||
let mut schema_obj = common_schema.into_object();
|
if let Some(properties) = schema
|
||||||
|
.ensure_object()
|
||||||
if let Some(object) = schema_obj.object.as_mut() {
|
.get_mut("properties")
|
||||||
for property in object.properties.values_mut() {
|
.and_then(|value| value.as_object_mut())
|
||||||
if let Schema::Object(property_object) = property {
|
{
|
||||||
if let Some(metadata) = &mut property_object.metadata {
|
for property in properties.values_mut() {
|
||||||
metadata.deprecated = true;
|
if let Ok(property_schema) = <&mut schemars::Schema>::try_from(property) {
|
||||||
} else {
|
property_schema
|
||||||
property_object.metadata = Some(Box::new(schemars::schema::Metadata {
|
.ensure_object()
|
||||||
deprecated: true,
|
.insert("deprecated".to_string(), Value::Bool(true));
|
||||||
..schemars::schema::Metadata::default()
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Schema::Object(schema_obj)
|
schema
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ rustc-hash = { workspace = true }
|
||||||
salsa = { workspace = true }
|
salsa = { workspace = true }
|
||||||
schemars = { workspace = true, optional = true }
|
schemars = { workspace = true, optional = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
serde_json = { workspace = true, optional = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
toml = { workspace = true }
|
toml = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
|
|
@ -54,6 +55,7 @@ default = ["zstd"]
|
||||||
deflate = ["ty_vendored/deflate"]
|
deflate = ["ty_vendored/deflate"]
|
||||||
schemars = [
|
schemars = [
|
||||||
"dep:schemars",
|
"dep:schemars",
|
||||||
|
"dep:serde_json",
|
||||||
"ruff_db/schemars",
|
"ruff_db/schemars",
|
||||||
"ruff_python_ast/schemars",
|
"ruff_python_ast/schemars",
|
||||||
"ty_python_semantic/schemars",
|
"ty_python_semantic/schemars",
|
||||||
|
|
|
||||||
|
|
@ -784,9 +784,7 @@ impl SrcOptions {
|
||||||
Debug, Default, Clone, Eq, PartialEq, Combine, Serialize, Deserialize, Hash, get_size2::GetSize,
|
Debug, Default, Clone, Eq, PartialEq, Combine, Serialize, Deserialize, Hash, get_size2::GetSize,
|
||||||
)]
|
)]
|
||||||
#[serde(rename_all = "kebab-case", transparent)]
|
#[serde(rename_all = "kebab-case", transparent)]
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
|
||||||
pub struct Rules {
|
pub struct Rules {
|
||||||
#[cfg_attr(feature = "schemars", schemars(with = "schema::Rules"))]
|
|
||||||
#[get_size(ignore)] // TODO: Add `GetSize` support for `OrderMap`.
|
#[get_size(ignore)] // TODO: Add `GetSize` support for `OrderMap`.
|
||||||
inner: OrderMap<RangedValue<String>, RangedValue<Level>, BuildHasherDefault<FxHasher>>,
|
inner: OrderMap<RangedValue<String>, RangedValue<Level>, BuildHasherDefault<FxHasher>>,
|
||||||
}
|
}
|
||||||
|
|
@ -1535,62 +1533,55 @@ impl std::error::Error for ToSettingsError {}
|
||||||
|
|
||||||
#[cfg(feature = "schemars")]
|
#[cfg(feature = "schemars")]
|
||||||
mod schema {
|
mod schema {
|
||||||
use schemars::JsonSchema;
|
impl schemars::JsonSchema for super::Rules {
|
||||||
use schemars::r#gen::SchemaGenerator;
|
fn schema_name() -> std::borrow::Cow<'static, str> {
|
||||||
use schemars::schema::{
|
std::borrow::Cow::Borrowed("Rules")
|
||||||
InstanceType, Metadata, ObjectValidation, Schema, SchemaObject, SubschemaValidation,
|
|
||||||
};
|
|
||||||
use ty_python_semantic::lint::Level;
|
|
||||||
|
|
||||||
pub(super) struct Rules;
|
|
||||||
|
|
||||||
impl JsonSchema for Rules {
|
|
||||||
fn schema_name() -> String {
|
|
||||||
"Rules".to_string()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(generator: &mut SchemaGenerator) -> Schema {
|
fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schema {
|
||||||
|
use serde_json::{Map, Value};
|
||||||
|
|
||||||
let registry = ty_python_semantic::default_lint_registry();
|
let registry = ty_python_semantic::default_lint_registry();
|
||||||
|
let level_schema = generator.subschema_for::<super::Level>();
|
||||||
|
|
||||||
let level_schema = generator.subschema_for::<Level>();
|
let properties: Map<String, Value> = registry
|
||||||
|
|
||||||
let properties: schemars::Map<String, Schema> = registry
|
|
||||||
.lints()
|
.lints()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|lint| {
|
.map(|lint| {
|
||||||
(
|
let mut schema = schemars::Schema::default();
|
||||||
lint.name().to_string(),
|
let object = schema.ensure_object();
|
||||||
Schema::Object(SchemaObject {
|
object.insert(
|
||||||
metadata: Some(Box::new(Metadata {
|
"title".to_string(),
|
||||||
title: Some(lint.summary().to_string()),
|
Value::String(lint.summary().to_string()),
|
||||||
description: Some(lint.documentation()),
|
);
|
||||||
deprecated: lint.status.is_deprecated(),
|
object.insert(
|
||||||
default: Some(lint.default_level.to_string().into()),
|
"description".to_string(),
|
||||||
..Metadata::default()
|
Value::String(lint.documentation()),
|
||||||
})),
|
);
|
||||||
subschemas: Some(Box::new(SubschemaValidation {
|
if lint.status.is_deprecated() {
|
||||||
one_of: Some(vec![level_schema.clone()]),
|
object.insert("deprecated".to_string(), Value::Bool(true));
|
||||||
..Default::default()
|
}
|
||||||
})),
|
object.insert(
|
||||||
..Default::default()
|
"default".to_string(),
|
||||||
}),
|
Value::String(lint.default_level.to_string()),
|
||||||
)
|
);
|
||||||
|
object.insert(
|
||||||
|
"oneOf".to_string(),
|
||||||
|
Value::Array(vec![level_schema.clone().into()]),
|
||||||
|
);
|
||||||
|
|
||||||
|
(lint.name().to_string(), schema.into())
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Schema::Object(SchemaObject {
|
let mut schema = schemars::json_schema!({ "type": "object" });
|
||||||
instance_type: Some(InstanceType::Object.into()),
|
let object = schema.ensure_object();
|
||||||
object: Some(Box::new(ObjectValidation {
|
object.insert("properties".to_string(), Value::Object(properties));
|
||||||
properties,
|
// Allow unknown rules: ty will warn about them. It gives a better experience when using an older
|
||||||
// Allow unknown rules: ty will warn about them.
|
// ty version because the schema will not deny rules that have been removed in newer versions.
|
||||||
// It gives a better experience when using an older ty version because
|
object.insert("additionalProperties".to_string(), level_schema.into());
|
||||||
// the schema will not deny rules that have been removed in newer versions.
|
|
||||||
additional_properties: Some(Box::new(level_schema)),
|
|
||||||
..ObjectValidation::default()
|
|
||||||
})),
|
|
||||||
|
|
||||||
..Default::default()
|
schema
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,6 @@ impl Drop for ValueSourceGuard {
|
||||||
/// or if the values were loaded from different sources.
|
/// or if the values were loaded from different sources.
|
||||||
#[derive(Clone, serde::Serialize, get_size2::GetSize)]
|
#[derive(Clone, serde::Serialize, get_size2::GetSize)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
|
||||||
pub struct RangedValue<T> {
|
pub struct RangedValue<T> {
|
||||||
value: T,
|
value: T,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
|
|
@ -100,6 +99,34 @@ pub struct RangedValue<T> {
|
||||||
range: Option<TextRange>,
|
range: Option<TextRange>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "schemars")]
|
||||||
|
impl<T> schemars::JsonSchema for RangedValue<T>
|
||||||
|
where
|
||||||
|
T: schemars::JsonSchema,
|
||||||
|
{
|
||||||
|
fn schema_name() -> std::borrow::Cow<'static, str> {
|
||||||
|
T::schema_name()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn schema_id() -> std::borrow::Cow<'static, str> {
|
||||||
|
T::schema_id()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schema {
|
||||||
|
T::json_schema(generator)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn _schemars_private_non_optional_json_schema(
|
||||||
|
generator: &mut schemars::SchemaGenerator,
|
||||||
|
) -> schemars::Schema {
|
||||||
|
T::_schemars_private_non_optional_json_schema(generator)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn _schemars_private_is_option() -> bool {
|
||||||
|
T::_schemars_private_is_option()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> RangedValue<T> {
|
impl<T> RangedValue<T> {
|
||||||
pub fn new(value: T, source: ValueSource) -> Self {
|
pub fn new(value: T, source: ValueSource) -> Self {
|
||||||
Self::with_range(value, source, TextRange::default())
|
Self::with_range(value, source, TextRange::default())
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ rustc-hash = { workspace = true }
|
||||||
hashbrown = { workspace = true }
|
hashbrown = { workspace = true }
|
||||||
schemars = { workspace = true, optional = true }
|
schemars = { workspace = true, optional = true }
|
||||||
serde = { workspace = true, optional = true }
|
serde = { workspace = true, optional = true }
|
||||||
|
serde_json = { workspace = true, optional = true }
|
||||||
smallvec = { workspace = true }
|
smallvec = { workspace = true }
|
||||||
static_assertions = { workspace = true }
|
static_assertions = { workspace = true }
|
||||||
test-case = { workspace = true }
|
test-case = { workspace = true }
|
||||||
|
|
@ -68,6 +69,7 @@ quickcheck = { version = "1.0.3", default-features = false }
|
||||||
quickcheck_macros = { version = "1.0.0" }
|
quickcheck_macros = { version = "1.0.0" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
schemars = ["dep:schemars", "dep:serde_json"]
|
||||||
serde = ["ruff_db/serde", "dep:serde", "ruff_python_ast/serde"]
|
serde = ["ruff_db/serde", "dep:serde", "ruff_python_ast/serde"]
|
||||||
testing = []
|
testing = []
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,77 +58,45 @@ impl Default for PythonPlatform {
|
||||||
mod schema {
|
mod schema {
|
||||||
use crate::PythonPlatform;
|
use crate::PythonPlatform;
|
||||||
use ruff_db::RustDoc;
|
use ruff_db::RustDoc;
|
||||||
use schemars::_serde_json::Value;
|
use schemars::{JsonSchema, Schema, SchemaGenerator};
|
||||||
use schemars::JsonSchema;
|
use serde_json::Value;
|
||||||
use schemars::r#gen::SchemaGenerator;
|
|
||||||
use schemars::schema::{Metadata, Schema, SchemaObject, SubschemaValidation};
|
|
||||||
|
|
||||||
impl JsonSchema for PythonPlatform {
|
impl JsonSchema for PythonPlatform {
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> std::borrow::Cow<'static, str> {
|
||||||
"PythonPlatform".to_string()
|
std::borrow::Cow::Borrowed("PythonPlatform")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(_gen: &mut SchemaGenerator) -> Schema {
|
fn json_schema(_gen: &mut SchemaGenerator) -> Schema {
|
||||||
Schema::Object(SchemaObject {
|
fn constant(value: &str, description: &str) -> Value {
|
||||||
// Hard code some well known values, but allow any other string as well.
|
let mut schema = schemars::json_schema!({ "const": value });
|
||||||
subschemas: Some(Box::new(SubschemaValidation {
|
schema.ensure_object().insert(
|
||||||
any_of: Some(vec.
|
|
||||||
Schema::Object(SchemaObject {
|
|
||||||
const_value: Some(Value::String("all".to_string())),
|
|
||||||
metadata: Some(Box::new(Metadata {
|
|
||||||
description: Some(
|
|
||||||
"Do not make any assumptions about the target platform."
|
|
||||||
.to_string(),
|
|
||||||
),
|
|
||||||
..Metadata::default()
|
|
||||||
})),
|
|
||||||
|
|
||||||
..SchemaObject::default()
|
// Hard code some well known values, but allow any other string as well.
|
||||||
}),
|
let mut any_of = vec![schemars::json_schema!({ "type": "string" }).into()];
|
||||||
Schema::Object(SchemaObject {
|
// Promote well-known values for better auto-completion.
|
||||||
const_value: Some(Value::String("darwin".to_string())),
|
// Using `const` over `enumValues` as recommended [here](https://github.com/SchemaStore/schemastore/blob/master/CONTRIBUTING.md#documenting-enums).
|
||||||
metadata: Some(Box::new(Metadata {
|
any_of.push(constant(
|
||||||
description: Some("Darwin".to_string()),
|
"all",
|
||||||
..Metadata::default()
|
"Do not make any assumptions about the target platform.",
|
||||||
})),
|
));
|
||||||
|
any_of.push(constant("darwin", "Darwin"));
|
||||||
|
any_of.push(constant("linux", "Linux"));
|
||||||
|
any_of.push(constant("win32", "Windows"));
|
||||||
|
|
||||||
..SchemaObject::default()
|
let mut schema = Schema::default();
|
||||||
}),
|
let object = schema.ensure_object();
|
||||||
Schema::Object(SchemaObject {
|
object.insert("anyOf".to_string(), Value::Array(any_of));
|
||||||
const_value: Some(Value::String("linux".to_string())),
|
object.insert(
|
||||||
metadata: Some(Box::new(Metadata {
|
"description".to_string(),
|
||||||
description: Some("Linux".to_string()),
|
Value::String(<PythonPlatform as RustDoc>::rust_doc().to_string()),
|
||||||
..Metadata::default()
|
);
|
||||||
})),
|
|
||||||
|
|
||||||
..SchemaObject::default()
|
schema
|
||||||
}),
|
|
||||||
Schema::Object(SchemaObject {
|
|
||||||
const_value: Some(Value::String("win32".to_string())),
|
|
||||||
metadata: Some(Box::new(Metadata {
|
|
||||||
description: Some("Windows".to_string()),
|
|
||||||
..Metadata::default()
|
|
||||||
})),
|
|
||||||
|
|
||||||
..SchemaObject::default()
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
|
|
||||||
..SubschemaValidation::default()
|
|
||||||
})),
|
|
||||||
metadata: Some(Box::new(Metadata {
|
|
||||||
description: Some(<PythonPlatform as RustDoc>::rust_doc().to_string()),
|
|
||||||
..Metadata::default()
|
|
||||||
})),
|
|
||||||
|
|
||||||
..SchemaObject::default()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
618
ruff.schema.json
generated
618
ruff.schema.json
generated
File diff suppressed because it is too large
Load diff
203
ty.schema.json
generated
203
ty.schema.json
generated
|
|
@ -15,17 +15,18 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"description": "Override configurations for specific file patterns.\n\nEach override specifies include/exclude patterns and rule configurations that apply to matching files. Multiple overrides can match the same file, with later overrides taking precedence.",
|
"description": "Override configurations for specific file patterns.\n\nEach override specifies include/exclude patterns and rule configurations\nthat apply to matching files. Multiple overrides can match the same file,\nwith later overrides taking precedence.",
|
||||||
"type": [
|
"anyOf": [
|
||||||
"array",
|
{
|
||||||
"null"
|
"$ref": "#/definitions/OverridesOptions"
|
||||||
],
|
},
|
||||||
"items": {
|
{
|
||||||
"$ref": "#/definitions/OverrideOptions"
|
"type": "null"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"description": "Configures the enabled rules and their severity.\n\nSee [the rules documentation](https://ty.dev/rules) for a list of all available rules.\n\nValid severities are:\n\n* `ignore`: Disable the rule. * `warn`: Enable the rule and create a warning diagnostic. * `error`: Enable the rule and create an error diagnostic. ty will exit with a non-zero code if any error diagnostics are emitted.",
|
"description": "Configures the enabled rules and their severity.\n\nSee [the rules documentation](https://ty.dev/rules) for a list of all available rules.\n\nValid severities are:\n\n* `ignore`: Disable the rule.\n* `warn`: Enable the rule and create a warning diagnostic.\n* `error`: Enable the rule and create an error diagnostic.\n ty will exit with a non-zero code if any error diagnostics are emitted.",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/Rules"
|
"$ref": "#/definitions/Rules"
|
||||||
|
|
@ -58,28 +59,38 @@
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"definitions": {
|
"definitions": {
|
||||||
|
"Array_of_string": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"EnvironmentOptions": {
|
"EnvironmentOptions": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"extra-paths": {
|
"extra-paths": {
|
||||||
"description": "User-provided paths that should take first priority in module resolution.\n\nThis is an advanced option that should usually only be used for first-party or third-party modules that are not installed into your Python environment in a conventional way. Use the `python` option to specify the location of your Python environment.\n\nThis option is similar to mypy's `MYPYPATH` environment variable and pyright's `stubPath` configuration setting.",
|
"description": "User-provided paths that should take first priority in module resolution.\n\nThis is an advanced option that should usually only be used for first-party or third-party\nmodules that are not installed into your Python environment in a conventional way.\nUse the `python` option to specify the location of your Python environment.\n\nThis option is similar to mypy's `MYPYPATH` environment variable and pyright's `stubPath`\nconfiguration setting.",
|
||||||
"type": [
|
"type": [
|
||||||
"array",
|
"array",
|
||||||
"null"
|
"null"
|
||||||
],
|
],
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"$ref": "#/definitions/RelativePathBuf"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"python": {
|
"python": {
|
||||||
"description": "Path to your project's Python environment or interpreter.\n\nty uses the `site-packages` directory of your project's Python environment to resolve third-party (and, in some cases, first-party) imports in your code.\n\nIf you're using a project management tool such as uv, you should not generally need to specify this option, as commands such as `uv run` will set the `VIRTUAL_ENV` environment variable to point to your project's virtual environment. ty can also infer the location of your environment from an activated Conda environment, and will look for a `.venv` directory in the project root if none of the above apply.\n\nPassing a path to a Python executable is supported, but passing a path to a dynamic executable (such as a shim) is not currently supported.\n\nThis option can be used to point to virtual or system Python environments.",
|
"description": "Path to your project's Python environment or interpreter.\n\nty uses the `site-packages` directory of your project's Python environment\nto resolve third-party (and, in some cases, first-party) imports in your code.\n\nIf you're using a project management tool such as uv, you should not generally need\nto specify this option, as commands such as `uv run` will set the `VIRTUAL_ENV`\nenvironment variable to point to your project's virtual environment. ty can also infer\nthe location of your environment from an activated Conda environment, and will look for\na `.venv` directory in the project root if none of the above apply.\n\nPassing a path to a Python executable is supported, but passing a path to a dynamic executable\n(such as a shim) is not currently supported.\n\nThis option can be used to point to virtual or system Python environments.",
|
||||||
"type": [
|
"anyOf": [
|
||||||
"string",
|
{
|
||||||
"null"
|
"$ref": "#/definitions/RelativePathBuf"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"python-platform": {
|
"python-platform": {
|
||||||
"description": "Specifies the target platform that will be used to analyze the source code. If specified, ty will understand conditions based on comparisons with `sys.platform`, such as are commonly found in typeshed to reflect the differing contents of the standard library across platforms. If `all` is specified, ty will assume that the source code can run on any platform.\n\nIf no platform is specified, ty will use the current platform: - `win32` for Windows - `darwin` for macOS - `android` for Android - `ios` for iOS - `linux` for everything else",
|
"description": "Specifies the target platform that will be used to analyze the source code.\nIf specified, ty will understand conditions based on comparisons with `sys.platform`, such\nas are commonly found in typeshed to reflect the differing contents of the standard library across platforms.\nIf `all` is specified, ty will assume that the source code can run on any platform.\n\nIf no platform is specified, ty will use the current platform:\n- `win32` for Windows\n- `darwin` for macOS\n- `android` for Android\n- `ios` for iOS\n- `linux` for everything else",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/PythonPlatform"
|
"$ref": "#/definitions/PythonPlatform"
|
||||||
|
|
@ -90,7 +101,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"python-version": {
|
"python-version": {
|
||||||
"description": "Specifies the version of Python that will be used to analyze the source code. The version should be specified as a string in the format `M.m` where `M` is the major version and `m` is the minor (e.g. `\"3.0\"` or `\"3.6\"`). If a version is provided, ty will generate errors if the source code makes use of language features that are not supported in that version.\n\nIf a version is not specified, ty will try the following techniques in order of preference to determine a value: 1. Check for the `project.requires-python` setting in a `pyproject.toml` file and use the minimum version from the specified range 2. Check for an activated or configured Python environment and attempt to infer the Python version of that environment 3. Fall back to the default value (see below)\n\nFor some language features, ty can also understand conditionals based on comparisons with `sys.version_info`. These are commonly found in typeshed, for example, to reflect the differing contents of the standard library across Python versions.",
|
"description": "Specifies the version of Python that will be used to analyze the source code.\nThe version should be specified as a string in the format `M.m` where `M` is the major version\nand `m` is the minor (e.g. `\"3.0\"` or `\"3.6\"`).\nIf a version is provided, ty will generate errors if the source code makes use of language features\nthat are not supported in that version.\n\nIf a version is not specified, ty will try the following techniques in order of preference\nto determine a value:\n1. Check for the `project.requires-python` setting in a `pyproject.toml` file\n and use the minimum version from the specified range\n2. Check for an activated or configured Python environment\n and attempt to infer the Python version of that environment\n3. Fall back to the default value (see below)\n\nFor some language features, ty can also understand conditionals based on comparisons\nwith `sys.version_info`. These are commonly found in typeshed, for example,\nto reflect the differing contents of the standard library across Python versions.",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/PythonVersion"
|
"$ref": "#/definitions/PythonVersion"
|
||||||
|
|
@ -101,20 +112,24 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"description": "The root paths of the project, used for finding first-party modules.\n\nAccepts a list of directory paths searched in priority order (first has highest priority).\n\nIf left unspecified, ty will try to detect common project layouts and initialize `root` accordingly:\n\n* if a `./src` directory exists, include `.` and `./src` in the first party search path (src layout or flat) * if a `./<project-name>/<project-name>` directory exists, include `.` and `./<project-name>` in the first party search path * otherwise, default to `.` (flat layout)\n\nBesides, if a `./python` or `./tests` directory exists and is not a package (i.e. it does not contain an `__init__.py` or `__init__.pyi` file), it will also be included in the first party search path.",
|
"description": "The root paths of the project, used for finding first-party modules.\n\nAccepts a list of directory paths searched in priority order (first has highest priority).\n\nIf left unspecified, ty will try to detect common project layouts and initialize `root` accordingly:\n\n* if a `./src` directory exists, include `.` and `./src` in the first party search path (src layout or flat)\n* if a `./<project-name>/<project-name>` directory exists, include `.` and `./<project-name>` in the first party search path\n* otherwise, default to `.` (flat layout)\n\nBesides, if a `./python` or `./tests` directory exists and is not a package (i.e. it does not contain an `__init__.py` or `__init__.pyi` file),\nit will also be included in the first party search path.",
|
||||||
"type": [
|
"type": [
|
||||||
"array",
|
"array",
|
||||||
"null"
|
"null"
|
||||||
],
|
],
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"$ref": "#/definitions/RelativePathBuf"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"typeshed": {
|
"typeshed": {
|
||||||
"description": "Optional path to a \"typeshed\" directory on disk for us to use for standard-library types. If this is not provided, we will fallback to our vendored typeshed stubs for the stdlib, bundled as a zip file in the binary",
|
"description": "Optional path to a \"typeshed\" directory on disk for us to use for standard-library types.\nIf this is not provided, we will fallback to our vendored typeshed stubs for the stdlib,\nbundled as a zip file in the binary",
|
||||||
"type": [
|
"anyOf": [
|
||||||
"string",
|
{
|
||||||
"null"
|
"$ref": "#/definitions/RelativePathBuf"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -126,25 +141,19 @@
|
||||||
"title": "Ignore",
|
"title": "Ignore",
|
||||||
"description": "The lint is disabled and should not run.",
|
"description": "The lint is disabled and should not run.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"const": "ignore"
|
||||||
"ignore"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Warn",
|
"title": "Warn",
|
||||||
"description": "The lint is enabled and diagnostic should have a warning severity.",
|
"description": "The lint is enabled and diagnostic should have a warning severity.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"const": "warn"
|
||||||
"warn"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Error",
|
"title": "Error",
|
||||||
"description": "The lint is enabled and diagnostics have an error severity.",
|
"description": "The lint is enabled and diagnostics have an error severity.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"const": "error"
|
||||||
"error"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -152,32 +161,24 @@
|
||||||
"description": "The diagnostic output format.",
|
"description": "The diagnostic output format.",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"description": "The default full mode will print \"pretty\" diagnostics.\n\nThat is, color will be used when printing to a `tty`. Moreover, diagnostic messages may include additional context and annotations on the input to help understand the message.",
|
"description": "The default full mode will print \"pretty\" diagnostics.\n\nThat is, color will be used when printing to a `tty`.\nMoreover, diagnostic messages may include additional\ncontext and annotations on the input to help understand\nthe message.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"const": "full"
|
||||||
"full"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Print diagnostics in a concise mode.\n\nThis will guarantee that each diagnostic is printed on a single line. Only the most important or primary aspects of the diagnostic are included. Contextual information is dropped.\n\nThis may use color when printing to a `tty`.",
|
"description": "Print diagnostics in a concise mode.\n\nThis will guarantee that each diagnostic is printed on\na single line. Only the most important or primary aspects\nof the diagnostic are included. Contextual information is\ndropped.\n\nThis may use color when printing to a `tty`.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"const": "concise"
|
||||||
"concise"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Print diagnostics in the JSON format expected by GitLab [Code Quality] reports.\n\n[Code Quality]: https://docs.gitlab.com/ci/testing/code_quality/#code-quality-report-format",
|
"description": "Print diagnostics in the JSON format expected by GitLab [Code Quality] reports.\n\n[Code Quality]: https://docs.gitlab.com/ci/testing/code_quality/#code-quality-report-format",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"const": "gitlab"
|
||||||
"gitlab"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Print diagnostics in the format used by [GitHub Actions] workflow error annotations.\n\n[GitHub Actions]: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-an-error-message",
|
"description": "Print diagnostics in the format used by [GitHub Actions] workflow error annotations.\n\n[GitHub Actions]: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-an-error-message",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"const": "github"
|
||||||
"github"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -185,27 +186,29 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"exclude": {
|
"exclude": {
|
||||||
"description": "A list of file and directory patterns to exclude from this override.\n\nPatterns follow a syntax similar to `.gitignore`. Exclude patterns take precedence over include patterns within the same override.\n\nIf not specified, defaults to `[]` (excludes no files).",
|
"description": "A list of file and directory patterns to exclude from this override.\n\nPatterns follow a syntax similar to `.gitignore`.\nExclude patterns take precedence over include patterns within the same override.\n\nIf not specified, defaults to `[]` (excludes no files).",
|
||||||
"type": [
|
"anyOf": [
|
||||||
"array",
|
{
|
||||||
"null"
|
"$ref": "#/definitions/Array_of_string"
|
||||||
],
|
},
|
||||||
"items": {
|
{
|
||||||
"type": "string"
|
"type": "null"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"include": {
|
"include": {
|
||||||
"description": "A list of file and directory patterns to include for this override.\n\nThe `include` option follows a similar syntax to `.gitignore` but reversed: Including a file or directory will make it so that it (and its contents) are affected by this override.\n\nIf not specified, defaults to `[\"**\"]` (matches all files).",
|
"description": "A list of file and directory patterns to include for this override.\n\nThe `include` option follows a similar syntax to `.gitignore` but reversed:\nIncluding a file or directory will make it so that it (and its contents)\nare affected by this override.\n\nIf not specified, defaults to `[\"**\"]` (matches all files).",
|
||||||
"type": [
|
"anyOf": [
|
||||||
"array",
|
{
|
||||||
"null"
|
"$ref": "#/definitions/Array_of_string"
|
||||||
],
|
},
|
||||||
"items": {
|
{
|
||||||
"type": "string"
|
"type": "null"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"description": "Rule overrides for files matching the include/exclude patterns.\n\nThese rules will be merged with the global rules, with override rules taking precedence for matching files. You can set rules to different severity levels or disable them entirely.",
|
"description": "Rule overrides for files matching the include/exclude patterns.\n\nThese rules will be merged with the global rules, with override rules\ntaking precedence for matching files. You can set rules to different\nseverity levels or disable them entirely.",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/Rules"
|
"$ref": "#/definitions/Rules"
|
||||||
|
|
@ -218,6 +221,13 @@
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
|
"OverridesOptions": {
|
||||||
|
"description": "Configuration override that applies to specific files based on glob patterns.\n\nAn override allows you to apply different rule configurations to specific\nfiles or directories. Multiple overrides can match the same file, with\nlater overrides take precedence.\n\n### Precedence\n\n- Later overrides in the array take precedence over earlier ones\n- Override rules take precedence over global rules for matching files\n\n### Examples\n\n```toml\n# Relax rules for test files\n[[tool.ty.overrides]]\ninclude = [\"tests/**\", \"**/test_*.py\"]\n\n[tool.ty.overrides.rules]\npossibly-unresolved-reference = \"warn\"\n\n# Ignore generated files but still check important ones\n[[tool.ty.overrides]]\ninclude = [\"generated/**\"]\nexclude = [\"generated/important.py\"]\n\n[tool.ty.overrides.rules]\npossibly-unresolved-reference = \"ignore\"\n```",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/OverrideOptions"
|
||||||
|
}
|
||||||
|
},
|
||||||
"PythonPlatform": {
|
"PythonPlatform": {
|
||||||
"description": "The target platform to assume when resolving types.\n",
|
"description": "The target platform to assume when resolving types.\n",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
|
|
@ -282,6 +292,14 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"RelativePathBuf": {
|
||||||
|
"description": "A possibly relative path in a configuration file.\n\nRelative paths in configuration files or from CLI options\nrequire different anchoring:\n\n* CLI: The path is relative to the current working directory\n* Configuration file: The path is relative to the project's root.",
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/SystemPathBuf"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"Rules": {
|
"Rules": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -1044,43 +1062,53 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"exclude": {
|
"exclude": {
|
||||||
"description": "A list of file and directory patterns to exclude from type checking.\n\nPatterns follow a syntax similar to `.gitignore`:\n\n- `./src/` matches only a directory - `./src` matches both files and directories - `src` matches files or directories named `src` - `*` matches any (possibly empty) sequence of characters (except `/`). - `**` matches zero or more path components. This sequence **must** form a single path component, so both `**a` and `b**` are invalid and will result in an error. A sequence of more than two consecutive `*` characters is also invalid. - `?` matches any single character except `/` - `[abc]` matches any character inside the brackets. Character sequences can also specify ranges of characters, as ordered by Unicode, so e.g. `[0-9]` specifies any character between `0` and `9` inclusive. An unclosed bracket is invalid. - `!pattern` negates a pattern (undoes the exclusion of files that would otherwise be excluded)\n\nAll paths are anchored relative to the project root (`src` only matches `<project_root>/src` and not `<project_root>/test/src`). To exclude any directory or file named `src`, use `**/src` instead.\n\nBy default, ty excludes commonly ignored directories:\n\n- `**/.bzr/` - `**/.direnv/` - `**/.eggs/` - `**/.git/` - `**/.git-rewrite/` - `**/.hg/` - `**/.mypy_cache/` - `**/.nox/` - `**/.pants.d/` - `**/.pytype/` - `**/.ruff_cache/` - `**/.svn/` - `**/.tox/` - `**/.venv/` - `**/__pypackages__/` - `**/_build/` - `**/buck-out/` - `**/dist/` - `**/node_modules/` - `**/venv/`\n\nYou can override any default exclude by using a negated pattern. For example, to re-include `dist` use `exclude = [\"!dist\"]`",
|
"description": "A list of file and directory patterns to exclude from type checking.\n\nPatterns follow a syntax similar to `.gitignore`:\n\n- `./src/` matches only a directory\n- `./src` matches both files and directories\n- `src` matches files or directories named `src`\n- `*` matches any (possibly empty) sequence of characters (except `/`).\n- `**` matches zero or more path components.\n This sequence **must** form a single path component, so both `**a` and `b**` are invalid and will result in an error.\n A sequence of more than two consecutive `*` characters is also invalid.\n- `?` matches any single character except `/`\n- `[abc]` matches any character inside the brackets. Character sequences can also specify ranges of characters, as ordered by Unicode,\n so e.g. `[0-9]` specifies any character between `0` and `9` inclusive. An unclosed bracket is invalid.\n- `!pattern` negates a pattern (undoes the exclusion of files that would otherwise be excluded)\n\nAll paths are anchored relative to the project root (`src` only\nmatches `<project_root>/src` and not `<project_root>/test/src`).\nTo exclude any directory or file named `src`, use `**/src` instead.\n\nBy default, ty excludes commonly ignored directories:\n\n- `**/.bzr/`\n- `**/.direnv/`\n- `**/.eggs/`\n- `**/.git/`\n- `**/.git-rewrite/`\n- `**/.hg/`\n- `**/.mypy_cache/`\n- `**/.nox/`\n- `**/.pants.d/`\n- `**/.pytype/`\n- `**/.ruff_cache/`\n- `**/.svn/`\n- `**/.tox/`\n- `**/.venv/`\n- `**/__pypackages__/`\n- `**/_build/`\n- `**/buck-out/`\n- `**/dist/`\n- `**/node_modules/`\n- `**/venv/`\n\nYou can override any default exclude by using a negated pattern. For example,\nto re-include `dist` use `exclude = [\"!dist\"]`",
|
||||||
"type": [
|
"anyOf": [
|
||||||
"array",
|
{
|
||||||
"null"
|
"$ref": "#/definitions/Array_of_string"
|
||||||
],
|
},
|
||||||
"items": {
|
{
|
||||||
"type": "string"
|
"type": "null"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"include": {
|
"include": {
|
||||||
"description": "A list of files and directories to check. The `include` option follows a similar syntax to `.gitignore` but reversed: Including a file or directory will make it so that it (and its contents) are type checked.\n\n- `./src/` matches only a directory - `./src` matches both files and directories - `src` matches a file or directory named `src` - `*` matches any (possibly empty) sequence of characters (except `/`). - `**` matches zero or more path components. This sequence **must** form a single path component, so both `**a` and `b**` are invalid and will result in an error. A sequence of more than two consecutive `*` characters is also invalid. - `?` matches any single character except `/` - `[abc]` matches any character inside the brackets. Character sequences can also specify ranges of characters, as ordered by Unicode, so e.g. `[0-9]` specifies any character between `0` and `9` inclusive. An unclosed bracket is invalid.\n\nAll paths are anchored relative to the project root (`src` only matches `<project_root>/src` and not `<project_root>/test/src`).\n\n`exclude` takes precedence over `include`.",
|
"description": "A list of files and directories to check. The `include` option\nfollows a similar syntax to `.gitignore` but reversed:\nIncluding a file or directory will make it so that it (and its contents)\nare type checked.\n\n- `./src/` matches only a directory\n- `./src` matches both files and directories\n- `src` matches a file or directory named `src`\n- `*` matches any (possibly empty) sequence of characters (except `/`).\n- `**` matches zero or more path components.\n This sequence **must** form a single path component, so both `**a` and `b**` are invalid and will result in an error.\n A sequence of more than two consecutive `*` characters is also invalid.\n- `?` matches any single character except `/`\n- `[abc]` matches any character inside the brackets. Character sequences can also specify ranges of characters, as ordered by Unicode,\n so e.g. `[0-9]` specifies any character between `0` and `9` inclusive. An unclosed bracket is invalid.\n\nAll paths are anchored relative to the project root (`src` only\nmatches `<project_root>/src` and not `<project_root>/test/src`).\n\n`exclude` takes precedence over `include`.",
|
||||||
"type": [
|
"anyOf": [
|
||||||
"array",
|
{
|
||||||
"null"
|
"$ref": "#/definitions/Array_of_string"
|
||||||
],
|
},
|
||||||
"items": {
|
{
|
||||||
"type": "string"
|
"type": "null"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"respect-ignore-files": {
|
"respect-ignore-files": {
|
||||||
"description": "Whether to automatically exclude files that are ignored by `.ignore`, `.gitignore`, `.git/info/exclude`, and global `gitignore` files. Enabled by default.",
|
"description": "Whether to automatically exclude files that are ignored by `.ignore`,\n`.gitignore`, `.git/info/exclude`, and global `gitignore` files.\nEnabled by default.",
|
||||||
"type": [
|
"type": [
|
||||||
"boolean",
|
"boolean",
|
||||||
"null"
|
"null"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"description": "The root of the project, used for finding first-party modules.\n\nIf left unspecified, ty will try to detect common project layouts and initialize `src.root` accordingly:\n\n* if a `./src` directory exists, include `.` and `./src` in the first party search path (src layout or flat) * if a `./<project-name>/<project-name>` directory exists, include `.` and `./<project-name>` in the first party search path * otherwise, default to `.` (flat layout)\n\nBesides, if a `./tests` directory exists and is not a package (i.e. it does not contain an `__init__.py` file), it will also be included in the first party search path.",
|
"description": "The root of the project, used for finding first-party modules.\n\nIf left unspecified, ty will try to detect common project layouts and initialize `src.root` accordingly:\n\n* if a `./src` directory exists, include `.` and `./src` in the first party search path (src layout or flat)\n* if a `./<project-name>/<project-name>` directory exists, include `.` and `./<project-name>` in the first party search path\n* otherwise, default to `.` (flat layout)\n\nBesides, if a `./tests` directory exists and is not a package (i.e. it does not contain an `__init__.py` file),\nit will also be included in the first party search path.",
|
||||||
"deprecated": true,
|
"anyOf": [
|
||||||
"type": [
|
{
|
||||||
"string",
|
"$ref": "#/definitions/RelativePathBuf"
|
||||||
"null"
|
},
|
||||||
]
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"deprecated": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
|
"SystemPathBuf": {
|
||||||
|
"description": "An owned, mutable path on [`System`](`super::System`) (akin to [`String`]).\n\nThe path is guaranteed to be valid UTF-8.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"TerminalOptions": {
|
"TerminalOptions": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -1104,6 +1132,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"string": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue