diff --git a/crates/ty/docs/configuration.md b/crates/ty/docs/configuration.md index edbea9c803..98567da740 100644 --- a/crates/ty/docs/configuration.md +++ b/crates/ty/docs/configuration.md @@ -200,24 +200,22 @@ Configuration override that applies to specific files based on glob patterns. An override allows you to apply different rule configurations to specific files or directories. Multiple overrides can match the same file, with -later overrides take precedence. +later overrides take precedence. Override rules take precedence over global +rules for matching files. -### Precedence - -- Later overrides in the array take precedence over earlier ones -- Override rules take precedence over global rules for matching files - -### Examples +For example, to relax enforcement of rules in test files: ```toml -# Relax rules for test files [[tool.ty.overrides]] include = ["tests/**", "**/test_*.py"] [tool.ty.overrides.rules] possibly-unresolved-reference = "warn" +``` -# Ignore generated files but still check important ones +Or, to ignore a rule in generated files but retain enforcement in an important file: + +```toml [[tool.ty.overrides]] include = ["generated/**"] exclude = ["generated/important.py"] diff --git a/crates/ty_project/src/metadata/options.rs b/crates/ty_project/src/metadata/options.rs index 5bd73f28f4..4aeec8bb60 100644 --- a/crates/ty_project/src/metadata/options.rs +++ b/crates/ty_project/src/metadata/options.rs @@ -1230,7 +1230,7 @@ pub struct TerminalOptions { /// /// For example, to relax enforcement of rules in test files: /// -/// ```toml title="pyproject.toml" +/// ```toml /// [[tool.ty.overrides]] /// include = ["tests/**", "**/test_*.py"] /// @@ -1240,7 +1240,7 @@ pub struct TerminalOptions { /// /// Or, to ignore a rule in generated files but retain enforcement in an important file: /// -/// ```toml title="pyproject.toml" +/// ```toml /// [[tool.ty.overrides]] /// include = ["generated/**"] /// exclude = ["generated/important.py"] diff --git a/ty.schema.json b/ty.schema.json index 74c142ec4c..183a60dadf 100644 --- a/ty.schema.json +++ b/ty.schema.json @@ -222,7 +222,7 @@ "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```", + "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. Override rules take precedence over global\nrules for matching files.\n\nFor example, to relax enforcement of rules in test files:\n\n```toml\n[[tool.ty.overrides]]\ninclude = [\"tests/**\", \"**/test_*.py\"]\n\n[tool.ty.overrides.rules]\npossibly-unresolved-reference = \"warn\"\n```\n\nOr, to ignore a rule in generated files but retain enforcement in an important file:\n\n```toml\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"