From b081aa62d4de450a82f85756453f6c992e2a29ed Mon Sep 17 00:00:00 2001 From: David Peter Date: Thu, 16 Oct 2025 19:12:47 +0200 Subject: [PATCH 1/3] Bump version to 0.0.1-alpha.23 --- CHANGELOG.md | 50 ++++ dist-workspace.toml | 2 +- docs/reference/rules.md | 602 +++++++++++++++++++++++++--------------- pyproject.toml | 2 +- ruff | 2 +- uv.lock | 2 +- 6 files changed, 431 insertions(+), 229 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4c37acfd..9bece6db2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,55 @@ # Changelog +## 0.0.1-alpha.23 + +Released on 2025-10-16. + +### Bug fixes + +- Fix handling of dataclass `field()`s without a default value ([#20914](https://github.com/astral-sh/ruff/pull/20914)) +- Fix false-positive diagnostics on `super()` calls ([#20814](https://github.com/astral-sh/ruff/pull/20814)) +- Fix issues in `super()` inference logic ([#20843](https://github.com/astral-sh/ruff/pull/20843)) +- Fix `match` pattern value narrowing to use equality semantics ([#20882](https://github.com/astral-sh/ruff/pull/20882)) +- Fix "missing root" panic when handling completion requests ([#20917](https://github.com/astral-sh/ruff/pull/20917)) +- Fix overwriting of declared base class attributes through undeclared subclass members ([#20764](https://github.com/astral-sh/ruff/pull/20764)) +- Fix run-away execution time for mutually referential instance attributes ([#20645](https://github.com/astral-sh/ruff/pull/20645)) +- Fix lookup of Python version in which a module was introduced for diagnostic messages ([#20908](https://github.com/astral-sh/ruff/pull/20908)) + +### CLI + +- Limit shown import paths to at most five, unless in verbose mode ([#20912](https://github.com/astral-sh/ruff/pull/20912)) +- Write files that are slow to type check to log output ([#20836](https://github.com/astral-sh/ruff/pull/20836)) + +### LSP server + +- Add completion ranking improvements ([#20807](https://github.com/astral-sh/ruff/pull/20807)) + +### Type inference and diagnostics + +- Use return type annotations as context for bidirectional type inference ([#20528](https://github.com/astral-sh/ruff/pull/20528)) +- Use bidirectional type context for `TypedDict` construction ([#20806](https://github.com/astral-sh/ruff/pull/20806)) +- Add support for unpacking of heterogeneous tuples in unions ([#20377](https://github.com/astral-sh/ruff/pull/20377)) +- Add a new diagnostic for generic classes that reference typevars from an enclosing scope ([#20822](https://github.com/astral-sh/ruff/pull/20822)) +- Add hint when accessing standard library module attributes that are not available on the configured Python version ([#20909](https://github.com/astral-sh/ruff/pull/20909)) +- Treat functions, methods, and dynamic types as function-like `Callable`s ([#20842](https://github.com/astral-sh/ruff/pull/20842)) +- Treat `Callable`s as bound-method descriptors in special cases ([#20802](https://github.com/astral-sh/ruff/pull/20802)) +- Treat `Callable` dunder members as bound method descriptors ([#20860](https://github.com/astral-sh/ruff/pull/20860)) +- Sync vendored typeshed stubs ([#20876](https://github.com/astral-sh/ruff/pull/20876)). [Typeshed diff](https://github.com/python/typeshed/compare/91055c730ffcda6311654cf32d663858ece69bad...d6f4a0f7102b1400a21742cf9b7ea93614e2b6ec) + +### Contributors + +- [@mtshiba](https://github.com/mtshiba) +- [@AlexWaygood](https://github.com/AlexWaygood) +- [@github-actions](https://github.com/github-actions) +- [@ericmarkmartin](https://github.com/ericmarkmartin) +- [@carljm](https://github.com/carljm) +- [@ntBre](https://github.com/ntBre) +- [@sharkdp](https://github.com/sharkdp) +- [@BurntSushi](https://github.com/BurntSushi) +- [@Gankra](https://github.com/Gankra) +- [@MichaReiser](https://github.com/MichaReiser) +- [@dcreager](https://github.com/dcreager) + ## 0.0.1-alpha.22 Released on 2025-10-10. diff --git a/dist-workspace.toml b/dist-workspace.toml index 3f02acb50..a056f09e5 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -1,7 +1,7 @@ [workspace] members = ["cargo:./ruff"] packages = ["ty"] -version = "0.0.1-alpha.22" +version = "0.0.1-alpha.23" # Config for 'dist' [dist] diff --git a/docs/reference/rules.md b/docs/reference/rules.md index cc35151b5..7687ea2a7 100644 --- a/docs/reference/rules.md +++ b/docs/reference/rules.md @@ -5,11 +5,13 @@ ## `byte-string-type-annotation` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20byte-string-type-annotation) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fstring_annotation.rs#L36) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for byte-strings in type annotation positions. @@ -34,11 +36,13 @@ def test(): -> "int": ## `call-non-callable` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20call-non-callable) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L115) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for calls to non-callable objects. @@ -56,11 +60,13 @@ Calling a non-callable object will raise a `TypeError` at runtime. ## `conflicting-argument-forms` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20conflicting-argument-forms) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L159) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks whether an argument is used as both a value and a type form in a call. @@ -86,11 +92,13 @@ f(int) # error ## `conflicting-declarations` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20conflicting-declarations) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L185) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks whether a variable has been declared as two conflicting types. @@ -115,11 +123,13 @@ a = 1 ## `conflicting-metaclass` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20conflicting-metaclass) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L210) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for class definitions where the metaclass of the class @@ -145,11 +155,13 @@ class C(A, B): ... ## `cyclic-class-definition` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20cyclic-class-definition) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L236) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for class definitions in stub files that inherit @@ -175,11 +187,13 @@ class B(A): ... ## `duplicate-base` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20duplicate-base) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L301) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for class definitions with duplicate bases. @@ -200,11 +214,13 @@ class B(A, A): ... ## `duplicate-kw-only` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20duplicate-kw-only) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L322) +Default level: error · +Added in 0.0.1-alpha.12 · +Related issues · +View source + **What it does** Checks for dataclass definitions with more than one field @@ -236,21 +252,25 @@ class A: # Crash at runtime ## `escape-character-in-forward-annotation` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20escape-character-in-forward-annotation) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fstring_annotation.rs#L120) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + TODO #14889 ## `fstring-type-annotation` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20fstring-type-annotation) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fstring_annotation.rs#L11) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for f-strings in type annotation positions. @@ -275,11 +295,13 @@ def test(): -> "int": ## `implicit-concatenated-string-type-annotation` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20implicit-concatenated-string-type-annotation) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fstring_annotation.rs#L86) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for implicit concatenated strings in type annotation positions. @@ -304,11 +326,13 @@ def test(): -> "Literal[5]": ## `inconsistent-mro` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20inconsistent-mro) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L525) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for classes with an inconsistent [method resolution order] (MRO). @@ -332,11 +356,13 @@ class C(A, B): ... ## `index-out-of-bounds` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20index-out-of-bounds) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L549) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for attempts to use an out of bounds index to get an item from @@ -356,11 +382,13 @@ t[3] # IndexError: tuple index out of range ## `instance-layout-conflict` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20instance-layout-conflict) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L354) +Default level: error · +Added in 0.0.1-alpha.12 · +Related issues · +View source + **What it does** Checks for classes definitions which will fail at runtime due to @@ -443,11 +471,13 @@ an atypical memory layout. ## `invalid-argument-type` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-argument-type) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L594) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Detects call arguments whose type is not assignable to the corresponding typed parameter. @@ -468,11 +498,13 @@ func("foo") # error: [invalid-argument-type] ## `invalid-assignment` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-assignment) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L634) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for assignments where the type of the value @@ -494,11 +526,13 @@ a: int = '' ## `invalid-attribute-access` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-attribute-access) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1745) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for assignments to class variables from instances @@ -526,11 +560,13 @@ C.instance_var = 3 # error: Cannot assign to instance variable ## `invalid-await` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-await) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L656) +Default level: error · +Added in 0.0.1-alpha.19 · +Related issues · +View source + **What it does** Checks for `await` being used with types that are not [Awaitable]. @@ -560,11 +596,13 @@ asyncio.run(main()) ## `invalid-base` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-base) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L686) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for class definitions that have bases which are not instances of `type`. @@ -582,11 +620,13 @@ class A(42): ... # error: [invalid-base] ## `invalid-context-manager` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-context-manager) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L737) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for expressions used in `with` statements @@ -607,11 +647,13 @@ with 1: ## `invalid-declaration` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-declaration) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L758) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for declarations where the inferred type of an existing symbol @@ -634,11 +676,13 @@ a: str ## `invalid-exception-caught` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-exception-caught) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L781) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for exception handlers that catch non-exception classes. @@ -676,11 +720,13 @@ except ZeroDivisionError: ## `invalid-generic-class` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-generic-class) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L817) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for the creation of invalid generic classes @@ -707,11 +753,13 @@ class C[U](Generic[T]): ... ## `invalid-key` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-key) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L569) +Default level: error · +Added in 0.0.1-alpha.17 · +Related issues · +View source + **What it does** Checks for subscript accesses with invalid keys. @@ -736,11 +784,13 @@ alice["height"] # KeyError: 'height' ## `invalid-legacy-type-variable` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-legacy-type-variable) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L843) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for the creation of invalid legacy `TypeVar`s @@ -769,11 +819,13 @@ def f(t: TypeVar("U")): ... ## `invalid-metaclass` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-metaclass) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L892) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for arguments to `metaclass=` that are invalid. @@ -801,11 +853,13 @@ class B(metaclass=f): ... ## `invalid-named-tuple` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-named-tuple) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L499) +Default level: error · +Added in 0.0.1-alpha.19 · +Related issues · +View source + **What it does** Checks for invalidly defined `NamedTuple` classes. @@ -831,11 +885,13 @@ TypeError: can only inherit from a NamedTuple type and Generic ## `invalid-overload` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-overload) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L919) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for various invalid `@overload` usages. @@ -879,11 +935,13 @@ def foo(x: int) -> int: ... ## `invalid-parameter-default` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-parameter-default) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1018) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for default values that can't be @@ -903,11 +961,13 @@ def f(a: int = ''): ... ## `invalid-protocol` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-protocol) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L436) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for protocol classes that will raise `TypeError` at runtime. @@ -935,11 +995,13 @@ TypeError: Protocols can only inherit from other protocols, got ## `invalid-raise` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-raise) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1038) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + Checks for `raise` statements that raise non-exceptions or use invalid causes for their raised exceptions. @@ -982,11 +1044,13 @@ def g(): ## `invalid-return-type` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-return-type) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L615) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Detects returned values that can't be assigned to the function's annotated return type. @@ -1005,11 +1069,13 @@ def func() -> int: ## `invalid-super-argument` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-super-argument) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1081) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Detects `super()` calls where: @@ -1049,21 +1115,25 @@ super(B, A) # error: `A` does not satisfy `issubclass(A, B)` ## `invalid-syntax-in-forward-annotation` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-syntax-in-forward-annotation) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fstring_annotation.rs#L111) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + TODO #14889 ## `invalid-type-alias-type` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-type-alias-type) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L871) +Default level: error · +Added in 0.0.1-alpha.6 · +Related issues · +View source + **What it does** Checks for the creation of invalid `TypeAliasType`s @@ -1084,11 +1154,13 @@ NewAlias = TypeAliasType(get_name(), int) # error: TypeAliasType name mus ## `invalid-type-checking-constant` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-type-checking-constant) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1120) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for a value other than `False` assigned to the `TYPE_CHECKING` variable, or an @@ -1112,11 +1184,13 @@ TYPE_CHECKING = '' ## `invalid-type-form` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-type-form) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1144) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for expressions that are used as [type expressions] @@ -1140,11 +1214,13 @@ b: Annotated[int] # `Annotated` expects at least two arguments ## `invalid-type-guard-call` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-type-guard-call) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1196) +Default level: error · +Added in 0.0.1-alpha.11 · +Related issues · +View source + **What it does** Checks for type guard function calls without a valid target. @@ -1172,11 +1248,13 @@ f(10) # Error ## `invalid-type-guard-definition` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-type-guard-definition) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1168) +Default level: error · +Added in 0.0.1-alpha.11 · +Related issues · +View source + **What it does** Checks for type guard functions without @@ -1204,11 +1282,13 @@ class C: ## `invalid-type-variable-constraints` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-type-variable-constraints) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1224) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for constrained [type variables] with only one constraint. @@ -1237,11 +1317,13 @@ T = TypeVar('T', bound=str) # valid bound TypeVar ## `missing-argument` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20missing-argument) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1253) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for missing required arguments in a call. @@ -1260,11 +1342,13 @@ func() # TypeError: func() missing 1 required positional argument: 'x' ## `missing-typed-dict-key` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20missing-typed-dict-key) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1844) +Default level: error · +Added in 0.0.1-alpha.20 · +Related issues · +View source + **What it does** Detects missing required keys in `TypedDict` constructor calls. @@ -1291,11 +1375,13 @@ alice["age"] # KeyError ## `no-matching-overload` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20no-matching-overload) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1272) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for calls to an overloaded function that do not match any of the overloads. @@ -1318,11 +1404,13 @@ func("string") # error: [no-matching-overload] ## `non-subscriptable` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20non-subscriptable) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1295) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for subscripting objects that do not support subscripting. @@ -1340,11 +1428,13 @@ Subscripting an object that does not support it will raise a `TypeError` at runt ## `not-iterable` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20not-iterable) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1313) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for objects that are not iterable but are used in a context that requires them to be. @@ -1364,11 +1454,13 @@ for i in 34: # TypeError: 'int' object is not iterable ## `parameter-already-assigned` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20parameter-already-assigned) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1364) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for calls which provide more than one argument for a single parameter. @@ -1389,11 +1481,13 @@ f(1, x=2) # Error raised here ## `positional-only-parameter-as-kwarg` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20positional-only-parameter-as-kwarg) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1599) +Default level: error · +Added in 0.0.1-alpha.22 · +Related issues · +View source + **What it does** Checks for keyword arguments in calls that match positional-only parameters of the callable. @@ -1414,11 +1508,13 @@ f(x=1) # Error raised here ## `raw-string-type-annotation` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20raw-string-type-annotation) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fstring_annotation.rs#L61) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for raw-strings in type annotation positions. @@ -1443,11 +1539,13 @@ def test(): -> "int": ## `static-assert-error` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20static-assert-error) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1721) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Makes sure that the argument of `static_assert` is statically known to be true. @@ -1471,11 +1569,13 @@ static_assert(int(2.0 * 3.0) == 6) # error: does not have a statically known tr ## `subclass-of-final-class` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20subclass-of-final-class) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1455) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for classes that subclass final classes. @@ -1498,11 +1598,13 @@ class B(A): ... # Error raised here ## `too-many-positional-arguments` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20too-many-positional-arguments) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1500) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for calls that pass more positional arguments than the callable can accept. @@ -1523,11 +1625,13 @@ f("foo") # Error raised here ## `type-assertion-failure` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20type-assertion-failure) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1478) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for `assert_type()` and `assert_never()` calls where the actual type @@ -1549,11 +1653,13 @@ def _(x: int): ## `unavailable-implicit-super-arguments` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unavailable-implicit-super-arguments) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1521) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Detects invalid `super()` calls where implicit arguments like the enclosing class or first method argument are unavailable. @@ -1593,11 +1699,13 @@ class A: ## `unknown-argument` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unknown-argument) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1578) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for keyword arguments in calls that don't match any parameter of the callable. @@ -1618,11 +1726,13 @@ f(x=1, y=2) # Error raised here ## `unresolved-attribute` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unresolved-attribute) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1620) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for unresolved attributes. @@ -1644,11 +1754,13 @@ A().foo # AttributeError: 'A' object has no attribute 'foo' ## `unresolved-import` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unresolved-import) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1642) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for import statements for which the module cannot be resolved. @@ -1667,11 +1779,13 @@ import foo # ModuleNotFoundError: No module named 'foo' ## `unresolved-reference` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unresolved-reference) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1661) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for references to names that are not defined. @@ -1690,11 +1804,13 @@ print(x) # NameError: name 'x' is not defined ## `unsupported-bool-conversion` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unsupported-bool-conversion) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1333) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for bool conversions where the object doesn't correctly implement `__bool__`. @@ -1725,11 +1841,13 @@ b1 < b2 < b1 # exception raised here ## `unsupported-operator` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unsupported-operator) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1680) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for binary expressions, comparisons, and unary expressions where @@ -1751,11 +1869,13 @@ A() + A() # TypeError: unsupported operand type(s) for +: 'A' and 'A' ## `zero-stepsize-in-slice` -Default level: [`error`](../rules.md#rule-levels "This lint has a default level of 'error'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20zero-stepsize-in-slice) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1702) +Default level: error · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for step size 0 in slices. @@ -1774,11 +1894,13 @@ l[1:10:0] # ValueError: slice step cannot be zero ## `ambiguous-protocol-member` -Default level: [`warn`](../rules.md#rule-levels "This lint has a default level of 'warn'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20ambiguous-protocol-member) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L464) +Default level: warn · +Added in 0.0.1-alpha.20 · +Related issues · +View source + **What it does** Checks for protocol classes with members that will lead to ambiguous interfaces. @@ -1813,11 +1935,13 @@ class SubProto(BaseProto, Protocol): ## `deprecated` -Default level: [`warn`](../rules.md#rule-levels "This lint has a default level of 'warn'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20deprecated) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L280) +Default level: warn · +Added in 0.0.1-alpha.16 · +Related issues · +View source + **What it does** Checks for uses of deprecated items @@ -1838,11 +1962,13 @@ old_func() # emits [deprecated] diagnostic ## `invalid-ignore-comment` -Default level: [`warn`](../rules.md#rule-levels "This lint has a default level of 'warn'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20invalid-ignore-comment) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Fsuppression.rs#L65) +Default level: warn · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for `type: ignore` and `ty: ignore` comments that are syntactically incorrect. @@ -1866,11 +1992,13 @@ a = 20 / 0 # type: ignore ## `possibly-missing-attribute` -Default level: [`warn`](../rules.md#rule-levels "This lint has a default level of 'warn'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20possibly-missing-attribute) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1385) +Default level: warn · +Added in 0.0.1-alpha.22 · +Related issues · +View source + **What it does** Checks for possibly missing attributes. @@ -1892,11 +2020,13 @@ A.c # AttributeError: type object 'A' has no attribute 'c' ## `possibly-missing-implicit-call` -Default level: [`warn`](../rules.md#rule-levels "This lint has a default level of 'warn'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20possibly-missing-implicit-call) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L133) +Default level: warn · +Added in 0.0.1-alpha.22 · +Related issues · +View source + **What it does** Checks for implicit calls to possibly missing methods. @@ -1922,11 +2052,13 @@ A()[0] # TypeError: 'A' object is not subscriptable ## `possibly-missing-import` -Default level: [`warn`](../rules.md#rule-levels "This lint has a default level of 'warn'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20possibly-missing-import) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1407) +Default level: warn · +Added in 0.0.1-alpha.22 · +Related issues · +View source + **What it does** Checks for imports of symbols that may be missing. @@ -1952,11 +2084,13 @@ from module import a # ImportError: cannot import name 'a' from 'module' ## `redundant-cast` -Default level: [`warn`](../rules.md#rule-levels "This lint has a default level of 'warn'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20redundant-cast) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1773) +Default level: warn · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Detects redundant `cast` calls where the value already has the target type. @@ -1977,11 +2111,13 @@ cast(int, f()) # Redundant ## `undefined-reveal` -Default level: [`warn`](../rules.md#rule-levels "This lint has a default level of 'warn'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20undefined-reveal) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1560) +Default level: warn · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for calls to `reveal_type` without importing it. @@ -1999,11 +2135,13 @@ reveal_type(1) # NameError: name 'reveal_type' is not defined ## `unknown-rule` -Default level: [`warn`](../rules.md#rule-levels "This lint has a default level of 'warn'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unknown-rule) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Fsuppression.rs#L40) +Default level: warn · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for `ty: ignore[code]` where `code` isn't a known lint rule. @@ -2028,11 +2166,13 @@ a = 20 / 0 # ty: ignore[division-by-zero] ## `unresolved-global` -Default level: [`warn`](../rules.md#rule-levels "This lint has a default level of 'warn'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unresolved-global) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1794) +Default level: warn · +Added in 0.0.1-alpha.15 · +Related issues · +View source + **What it does** Detects variables declared as `global` in an inner scope that have no explicit @@ -2056,6 +2196,7 @@ def g(): ``` Use instead: + ```python x: int @@ -2068,6 +2209,7 @@ def g(): ``` Or: + ```python x: int | None = None @@ -2082,11 +2224,13 @@ def g(): ## `unsupported-base` -Default level: [`warn`](../rules.md#rule-levels "This lint has a default level of 'warn'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unsupported-base) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L704) +Default level: warn · +Added in 0.0.1-alpha.7 · +Related issues · +View source + **What it does** Checks for class definitions that have bases which are unsupported by ty. @@ -2119,11 +2263,13 @@ class D(C): ... # error: [unsupported-base] ## `useless-overload-body` -Default level: [`warn`](../rules.md#rule-levels "This lint has a default level of 'warn'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20useless-overload-body) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L962) +Default level: warn · +Added in 0.0.1-alpha.22 · +Related issues · +View source + **What it does** Checks for various `@overload`-decorated functions that have non-stub bodies. @@ -2180,11 +2326,13 @@ def foo(x: int | str) -> int | str: ## `division-by-zero` -Default level: [`ignore`](../rules.md#rule-levels "This lint has a default level of 'ignore'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20division-by-zero) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L262) +Default level: ignore · +Preview (since 0.0.1-alpha.1) · +Related issues · +View source + **What it does** It detects division by zero. @@ -2202,11 +2350,13 @@ Dividing by zero raises a `ZeroDivisionError` at runtime. ## `possibly-unresolved-reference` -Default level: [`ignore`](../rules.md#rule-levels "This lint has a default level of 'ignore'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20possibly-unresolved-reference) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1433) +Default level: ignore · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for references to names that are possibly not defined. @@ -2228,11 +2378,13 @@ print(x) # NameError: name 'x' is not defined ## `unused-ignore-comment` -Default level: [`ignore`](../rules.md#rule-levels "This lint has a default level of 'ignore'.") · -[Related issues](https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20unused-ignore-comment) · -[View source](https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Fsuppression.rs#L15) +Default level: ignore · +Added in 0.0.1-alpha.1 · +Related issues · +View source + **What it does** Checks for `type: ignore` or `ty: ignore` directives that are no longer applicable. diff --git a/pyproject.toml b/pyproject.toml index 300478607..e0679c0c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "ty" -version = "0.0.1a22" +version = "0.0.1a23" requires-python = ">=3.8" dependencies = [] description = "An extremely fast Python type checker, written in Rust." diff --git a/ruff b/ruff index 44807c4a0..e64d77278 160000 --- a/ruff +++ b/ruff @@ -1 +1 @@ -Subproject commit 44807c4a054ee77ce803fb0e594cc544f62c859e +Subproject commit e64d77278830954a323d227e8f9f714c1d0e4c57 diff --git a/uv.lock b/uv.lock index 5d1517700..201c7158d 100644 --- a/uv.lock +++ b/uv.lock @@ -762,7 +762,7 @@ wheels = [ [[package]] name = "ty" -version = "0.0.1a22" +version = "0.0.1a23" source = { editable = "." } [package.dev-dependencies] From 2ea898ea6d7b0ace0ee47c43eee4c464a05de459 Mon Sep 17 00:00:00 2001 From: David Peter Date: Thu, 16 Oct 2025 19:32:48 +0200 Subject: [PATCH 2/3] Review findings --- CHANGELOG.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bece6db2..1bfe044c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,23 +6,22 @@ Released on 2025-10-16. ### Bug fixes -- Fix handling of dataclass `field()`s without a default value ([#20914](https://github.com/astral-sh/ruff/pull/20914)) -- Fix false-positive diagnostics on `super()` calls ([#20814](https://github.com/astral-sh/ruff/pull/20814)) -- Fix issues in `super()` inference logic ([#20843](https://github.com/astral-sh/ruff/pull/20843)) +- Fix handling of dataclass `field()`s without default values ([#20914](https://github.com/astral-sh/ruff/pull/20914)) +- Fix false-positive diagnostics on `super()` calls ([#20814](https://github.com/astral-sh/ruff/pull/20814), [#20843](https://github.com/astral-sh/ruff/pull/20843)) - Fix `match` pattern value narrowing to use equality semantics ([#20882](https://github.com/astral-sh/ruff/pull/20882)) - Fix "missing root" panic when handling completion requests ([#20917](https://github.com/astral-sh/ruff/pull/20917)) - Fix overwriting of declared base class attributes through undeclared subclass members ([#20764](https://github.com/astral-sh/ruff/pull/20764)) -- Fix run-away execution time for mutually referential instance attributes ([#20645](https://github.com/astral-sh/ruff/pull/20645)) -- Fix lookup of Python version in which a module was introduced for diagnostic messages ([#20908](https://github.com/astral-sh/ruff/pull/20908)) +- Fix runaway execution time for mutually referential instance attributes ([#20645](https://github.com/astral-sh/ruff/pull/20645)) ### CLI -- Limit shown import paths to at most five, unless in verbose mode ([#20912](https://github.com/astral-sh/ruff/pull/20912)) +- For `unresolved-import` diagnostics, limit the shown import paths to at most five, unless in verbose mode ([#20912](https://github.com/astral-sh/ruff/pull/20912)) - Write files that are slow to type check to log output ([#20836](https://github.com/astral-sh/ruff/pull/20836)) +- Remove "pre-release software" warning ([#20817](https://github.com/astral-sh/ruff/pull/20817)) ### LSP server -- Add completion ranking improvements ([#20807](https://github.com/astral-sh/ruff/pull/20807)) +- Improve ranking of autocomplete suggestions ([#20807](https://github.com/astral-sh/ruff/pull/20807)) ### Type inference and diagnostics @@ -36,6 +35,10 @@ Released on 2025-10-16. - Treat `Callable` dunder members as bound method descriptors ([#20860](https://github.com/astral-sh/ruff/pull/20860)) - Sync vendored typeshed stubs ([#20876](https://github.com/astral-sh/ruff/pull/20876)). [Typeshed diff](https://github.com/python/typeshed/compare/91055c730ffcda6311654cf32d663858ece69bad...d6f4a0f7102b1400a21742cf9b7ea93614e2b6ec) +### Performance improvements + +- Improve performance by caching union simplification type relations ([#20477](https://github.com/astral-sh/ruff/pull/20477)) + ### Contributors - [@mtshiba](https://github.com/mtshiba) From d942ede3fef7e67b54f263363021780489818ddb Mon Sep 17 00:00:00 2001 From: David Peter Date: Thu, 16 Oct 2025 19:51:42 +0200 Subject: [PATCH 3/3] Remove bot from contributors --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bfe044c1..82f2e53d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,6 @@ Released on 2025-10-16. - [@mtshiba](https://github.com/mtshiba) - [@AlexWaygood](https://github.com/AlexWaygood) -- [@github-actions](https://github.com/github-actions) - [@ericmarkmartin](https://github.com/ericmarkmartin) - [@carljm](https://github.com/carljm) - [@ntBre](https://github.com/ntBre)