|
15 | 15 | } |
16 | 16 | ] |
17 | 17 | }, |
| 18 | + "overrides": { |
| 19 | + "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.", |
| 20 | + "type": ["array", "null"], |
| 21 | + "items": { |
| 22 | + "$ref": "#/definitions/OverrideOptions" |
| 23 | + } |
| 24 | + }, |
18 | 25 | "rules": { |
19 | 26 | "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.", |
20 | 27 | "anyOf": [ |
|
129 | 136 | } |
130 | 137 | ] |
131 | 138 | }, |
| 139 | + "OverrideOptions": { |
| 140 | + "type": "object", |
| 141 | + "properties": { |
| 142 | + "exclude": { |
| 143 | + "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).", |
| 144 | + "type": ["array", "null"], |
| 145 | + "items": { |
| 146 | + "type": "string" |
| 147 | + } |
| 148 | + }, |
| 149 | + "include": { |
| 150 | + "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).", |
| 151 | + "type": ["array", "null"], |
| 152 | + "items": { |
| 153 | + "type": "string" |
| 154 | + } |
| 155 | + }, |
| 156 | + "rules": { |
| 157 | + "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.", |
| 158 | + "anyOf": [ |
| 159 | + { |
| 160 | + "$ref": "#/definitions/Rules" |
| 161 | + }, |
| 162 | + { |
| 163 | + "type": "null" |
| 164 | + } |
| 165 | + ] |
| 166 | + } |
| 167 | + }, |
| 168 | + "additionalProperties": false |
| 169 | + }, |
132 | 170 | "PythonPlatform": { |
| 171 | + "description": "The target platform to assume when resolving types.\n", |
133 | 172 | "anyOf": [ |
134 | 173 | { |
135 | 174 | "type": "string" |
|
545 | 584 | } |
546 | 585 | ] |
547 | 586 | }, |
| 587 | + "invalid-type-guard-call": { |
| 588 | + "title": "detects type guard function calls that has no narrowing effect", |
| 589 | + "description": "## What it does\nChecks for type guard function calls without a valid target.\n\n## Why is this bad?\nThe first non-keyword non-variadic argument to a type guard function\nis its target and must map to a symbol.\n\nStarred (`is_str(*a)`), literal (`is_str(42)`) and other non-symbol-like\nexpressions are invalid as narrowing targets.\n\n## Examples\n```python\nfrom typing import TypeIs\n\ndef f(v: object) -> TypeIs[int]: ...\n\nf() # Error\nf(*a) # Error\nf(10) # Error\n```", |
| 590 | + "default": "error", |
| 591 | + "oneOf": [ |
| 592 | + { |
| 593 | + "$ref": "#/definitions/Level" |
| 594 | + } |
| 595 | + ] |
| 596 | + }, |
| 597 | + "invalid-type-guard-definition": { |
| 598 | + "title": "detects malformed type guard functions", |
| 599 | + "description": "## What it does\nChecks for type guard functions without\na first non-self-like non-keyword-only non-variadic parameter.\n\n## Why is this bad?\nType narrowing functions must accept at least one positional argument\n(non-static methods must accept another in addition to `self`/`cls`).\n\nExtra parameters/arguments are allowed but do not affect narrowing.\n\n## Examples\n```python\nfrom typing import TypeIs\n\ndef f() -> TypeIs[int]: ... # Error, no parameter\ndef f(*, v: object) -> TypeIs[int]: ... # Error, no positional arguments allowed\ndef f(*args: object) -> TypeIs[int]: ... # Error, expect variadic arguments\nclass C:\n def f(self) -> TypeIs[int]: ... # Error, only positional argument expected is `self`\n```", |
| 600 | + "default": "error", |
| 601 | + "oneOf": [ |
| 602 | + { |
| 603 | + "$ref": "#/definitions/Level" |
| 604 | + } |
| 605 | + ] |
| 606 | + }, |
548 | 607 | "invalid-type-variable-constraints": { |
549 | 608 | "title": "detects invalid type variable constraints", |
550 | 609 | "description": "## What it does\nChecks for constrained [type variables] with only one constraint.\n\n## Why is this bad?\nA constrained type variable must have at least two constraints.\n\n## Examples\n```python\nfrom typing import TypeVar\n\nT = TypeVar('T', str) # invalid constrained TypeVar\n```\n\nUse instead:\n```python\nT = TypeVar('T', str, int) # valid constrained TypeVar\n# or\nT = TypeVar('T', bound=str) # valid bound TypeVar\n```\n\n[type variables]: https://docs.python.org/3/library/typing.html#typing.TypeVar", |
|
841 | 900 | } |
842 | 901 | }, |
843 | 902 | "include": { |
844 | | - "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 files or directories named `src` anywhere in the tree (e.g. `./src` or `./tests/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\nUnlike `exclude`, all paths are anchored relative to the project root (`src` only matches `<project_root>/src` and not `<project_root>/test/src`).\n\n`exclude` take precedence over `include`.", |
| 903 | + "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\nUnlike `exclude`, all 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`.", |
845 | 904 | "type": ["array", "null"], |
846 | 905 | "items": { |
847 | 906 | "type": "string" |
|
0 commit comments