From e0f3a064b99ffefdffc89fcf512203387da9539f Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Wed, 26 Nov 2025 16:39:49 -0800 Subject: [PATCH 01/67] [ty] don't iterate over a hashset (#21649) ## Summary This caused "deterministic but chaotic" ordering of some intersection types in diagnostics. When calling a union, we infer the argument type once per matching parameter type, intersecting the inferred types for the argument expression, and we did that in an unpredictable order. We do need a hashset here for de-duplication. Sometimes we call large unions where the type for a given parameter is the same across the union, we should infer the argument once per parameter type, not once per union element. So use an `FxIndexSet` instead of an `FxHashSet`. ## Test Plan With this change, switching between `main` and https://github.com/astral-sh/ruff/pull/21646 no longer changes the ordering of the intersection type in the test in https://github.com/astral-sh/ruff/pull/21646/commits/cca3a8045df3a1038601e848b87b2163c81aebed --- crates/ty_python_semantic/src/types/infer/builder.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index b2f8cc5687..f5d4f36a30 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -6894,10 +6894,14 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { // Infer the type of each argument once with each distinct parameter type as type context. let parameter_types = overloads_with_binding .iter() - .filter_map(|(overload, binding)| parameter_type(overload, binding)) - .collect::>(); + .filter_map(|(overload, binding)| parameter_type(overload, binding)); + + let mut seen = FxHashSet::default(); for parameter_type in parameter_types { + if !seen.insert(parameter_type) { + continue; + } let inferred_ty = self.infer_expression(ast_argument, TypeContext::new(Some(parameter_type))); From c7107a5a90740e919af0b9a9813dae70f14e9049 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Thu, 27 Nov 2025 09:22:22 +0530 Subject: [PATCH 02/67] [ty] Use `zip` to perform explicit specialization (#21635) ## Summary This PR updates the explicit specialization logic to avoid using the call machinery. Previously, the logic would use the call machinery by converting the list of type variables into a `Binding` with a single `Signature` where all the type variables are positional-only parameters with bounds and constraints as the annotated type and the default type as the default parameter value. This has the advantage that it doesn't need to implement any specific logic but the disadvantages are subpar diagnostic messages as it would use the ones specific to a function call. But, an important disadvantage is that the kind of type variable is lost in this translation which becomes important in #21445 where a `ParamSpec` can specialize into a list of types which is provided using list literal. For example, ```py class Foo[T, **P]: ... Foo[int, [int, str]] ``` This PR converts the logic to use a simple loop using `zip_longest` as all type variables and their corresponding type argument maps on a 1-1 basis. They cannot be specified using keyword argument either e.g., `dict[_VT=str, _KT=int]` is invalid. This PR also makes an initial attempt to improve the diagnostic message to specifically target the specialization part by using words like "type argument" instead of just "argument" and including information like the type variable, bounds, and constraints. Further improvements can be made by highlighting the type variable definition or the bounds / constraints as a sub-diagnostic but I'm going to leave that as a follow-up. ## Test Plan Update messages in existing test cases. --- crates/ty/docs/rules.md | 189 ++++++++++------ .../mdtest/generics/legacy/classes.md | 11 +- .../mdtest/generics/pep695/aliases.md | 11 +- .../mdtest/generics/pep695/classes.md | 11 +- .../ty_python_semantic/src/types/call/bind.rs | 9 +- .../src/types/diagnostic.rs | 42 ++++ .../ty_python_semantic/src/types/generics.rs | 35 +-- .../src/types/infer/builder.rs | 213 ++++++++++++++---- .../e2e__commands__debug_command.snap | 1 + ty.schema.json | 10 + 10 files changed, 361 insertions(+), 171 deletions(-) diff --git a/crates/ty/docs/rules.md b/crates/ty/docs/rules.md index b039ba94f7..730692f9ef 100644 --- a/crates/ty/docs/rules.md +++ b/crates/ty/docs/rules.md @@ -39,7 +39,7 @@ def test(): -> "int": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -63,7 +63,7 @@ Calling a non-callable object will raise a `TypeError` at runtime. Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -95,7 +95,7 @@ f(int) # error Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -126,7 +126,7 @@ a = 1 Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -158,7 +158,7 @@ class C(A, B): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -190,7 +190,7 @@ class B(A): ... Default level: error · Preview (since 1.0.0) · Related issues · -View source +View source @@ -218,7 +218,7 @@ type B = A Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -245,7 +245,7 @@ class B(A, A): ... Default level: error · Added in 0.0.1-alpha.12 · Related issues · -View source +View source @@ -357,7 +357,7 @@ def test(): -> "Literal[5]": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -387,7 +387,7 @@ class C(A, B): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -413,7 +413,7 @@ t[3] # IndexError: tuple index out of range Default level: error · Added in 0.0.1-alpha.12 · Related issues · -View source +View source @@ -502,7 +502,7 @@ an atypical memory layout. Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -529,7 +529,7 @@ func("foo") # error: [invalid-argument-type] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -557,7 +557,7 @@ a: int = '' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -591,7 +591,7 @@ C.instance_var = 3 # error: Cannot assign to instance variable Default level: error · Added in 0.0.1-alpha.19 · Related issues · -View source +View source @@ -627,7 +627,7 @@ asyncio.run(main()) Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -651,7 +651,7 @@ class A(42): ... # error: [invalid-base] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -678,7 +678,7 @@ with 1: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -707,7 +707,7 @@ a: str Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -751,7 +751,7 @@ except ZeroDivisionError: Default level: error · Added in 0.0.1-alpha.28 · Related issues · -View source +View source @@ -793,7 +793,7 @@ class D(A): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -826,7 +826,7 @@ class C[U](Generic[T]): ... Default level: error · Added in 0.0.1-alpha.17 · Related issues · -View source +View source @@ -865,7 +865,7 @@ carol = Person(name="Carol", age=25) # typo! Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -900,7 +900,7 @@ def f(t: TypeVar("U")): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -934,7 +934,7 @@ class B(metaclass=f): ... Default level: error · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -1020,7 +1020,7 @@ and `__ne__` methods accept `object` as their second argument. Default level: error · Added in 0.0.1-alpha.19 · Related issues · -View source +View source @@ -1052,7 +1052,7 @@ TypeError: can only inherit from a NamedTuple type and Generic Default level: error · Preview (since 1.0.0) · Related issues · -View source +View source @@ -1082,7 +1082,7 @@ Baz = NewType("Baz", int | str) # error: invalid base for `typing.NewType` Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1132,7 +1132,7 @@ def foo(x: int) -> int: ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1158,7 +1158,7 @@ def f(a: int = ''): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1189,7 +1189,7 @@ P2 = ParamSpec("S2") # error: ParamSpec name must match the variable it's assig Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1223,7 +1223,7 @@ TypeError: Protocols can only inherit from other protocols, got Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1272,7 +1272,7 @@ def g(): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1297,7 +1297,7 @@ def func() -> int: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1355,7 +1355,7 @@ TODO #14889 Default level: error · Added in 0.0.1-alpha.6 · Related issues · -View source +View source @@ -1376,13 +1376,60 @@ IntOrStr = TypeAliasType("IntOrStr", int | str) # okay NewAlias = TypeAliasType(get_name(), int) # error: TypeAliasType name must be a string literal ``` +## `invalid-type-arguments` + + +Default level: error · +Added in 0.0.1-alpha.29 · +Related issues · +View source + + + +**What it does** + +Checks for invalid type arguments in explicit type specialization. + +**Why is this bad?** + +Providing the wrong number of type arguments or type arguments that don't +satisfy the type variable's bounds or constraints will lead to incorrect +type inference and may indicate a misunderstanding of the generic type's +interface. + +**Examples** + + +Using legacy type variables: +```python +from typing import Generic, TypeVar + +T1 = TypeVar('T1', int, str) +T2 = TypeVar('T2', bound=int) + +class Foo1(Generic[T1]): ... +class Foo2(Generic[T2]): ... + +Foo1[bytes] # error: bytes does not satisfy T1's constraints +Foo2[str] # error: str does not satisfy T2's bound +``` + +Using PEP 695 type variables: +```python +class Foo[T]: ... +class Bar[T, U]: ... + +Foo[int, str] # error: too many arguments +Bar[int] # error: too few arguments +``` + ## `invalid-type-checking-constant` Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1412,7 +1459,7 @@ TYPE_CHECKING = '' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1442,7 +1489,7 @@ b: Annotated[int] # `Annotated` expects at least two arguments Default level: error · Added in 0.0.1-alpha.11 · Related issues · -View source +View source @@ -1476,7 +1523,7 @@ f(10) # Error Default level: error · Added in 0.0.1-alpha.11 · Related issues · -View source +View source @@ -1510,7 +1557,7 @@ class C: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1545,7 +1592,7 @@ T = TypeVar('T', bound=str) # valid bound TypeVar Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1570,7 +1617,7 @@ func() # TypeError: func() missing 1 required positional argument: 'x' Default level: error · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -1603,7 +1650,7 @@ alice["age"] # KeyError Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1632,7 +1679,7 @@ func("string") # error: [no-matching-overload] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1656,7 +1703,7 @@ Subscripting an object that does not support it will raise a `TypeError` at runt Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1682,7 +1729,7 @@ for i in 34: # TypeError: 'int' object is not iterable Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1709,7 +1756,7 @@ f(1, x=2) # Error raised here Default level: error · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -1767,7 +1814,7 @@ def test(): -> "int": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1797,7 +1844,7 @@ static_assert(int(2.0 * 3.0) == 6) # error: does not have a statically known tr Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1826,7 +1873,7 @@ class B(A): ... # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1853,7 +1900,7 @@ f("foo") # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1881,7 +1928,7 @@ def _(x: int): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1927,7 +1974,7 @@ class A: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1954,7 +2001,7 @@ f(x=1, y=2) # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1982,7 +2029,7 @@ A().foo # AttributeError: 'A' object has no attribute 'foo' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2007,7 +2054,7 @@ import foo # ModuleNotFoundError: No module named 'foo' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2032,7 +2079,7 @@ print(x) # NameError: name 'x' is not defined Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2069,7 +2116,7 @@ b1 < b2 < b1 # exception raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2097,7 +2144,7 @@ A() + A() # TypeError: unsupported operand type(s) for +: 'A' and 'A' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2122,7 +2169,7 @@ l[1:10:0] # ValueError: slice step cannot be zero Default level: warn · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -2163,7 +2210,7 @@ class SubProto(BaseProto, Protocol): Default level: warn · Added in 0.0.1-alpha.16 · Related issues · -View source +View source @@ -2251,7 +2298,7 @@ a = 20 / 0 # type: ignore Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2279,7 +2326,7 @@ A.c # AttributeError: type object 'A' has no attribute 'c' Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2311,7 +2358,7 @@ A()[0] # TypeError: 'A' object is not subscriptable Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2343,7 +2390,7 @@ from module import a # ImportError: cannot import name 'a' from 'module' Default level: warn · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2370,7 +2417,7 @@ cast(int, f()) # Redundant Default level: warn · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2394,7 +2441,7 @@ reveal_type(1) # NameError: name 'reveal_type' is not defined Default level: warn · Added in 0.0.1-alpha.15 · Related issues · -View source +View source @@ -2452,7 +2499,7 @@ def g(): Default level: warn · Added in 0.0.1-alpha.7 · Related issues · -View source +View source @@ -2491,7 +2538,7 @@ class D(C): ... # error: [unsupported-base] Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2554,7 +2601,7 @@ def foo(x: int | str) -> int | str: Default level: ignore · Preview (since 0.0.1-alpha.1) · Related issues · -View source +View source @@ -2578,7 +2625,7 @@ Dividing by zero raises a `ZeroDivisionError` at runtime. Default level: ignore · Added in 0.0.1-alpha.1 · Related issues · -View source +View source diff --git a/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md b/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md index 9d6cd6ded7..66f39a3aa4 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md @@ -145,7 +145,7 @@ reveal_type(C[Literal[5]]()) # revealed: C[Literal[5]] The specialization must match the generic types: ```py -# error: [too-many-positional-arguments] "Too many positional arguments to class `C`: expected 1, got 2" +# error: [invalid-type-arguments] "Too many type arguments to class `C`: expected 1, got 2" reveal_type(C[int, int]()) # revealed: Unknown ``` @@ -164,12 +164,10 @@ class IntSubclass(int): ... reveal_type(Bounded[int]()) # revealed: Bounded[int] reveal_type(Bounded[IntSubclass]()) # revealed: Bounded[IntSubclass] -# TODO: update this diagnostic to talk about type parameters and specializations -# error: [invalid-argument-type] "Argument to class `Bounded` is incorrect: Expected `int`, found `str`" +# error: [invalid-type-arguments] "Type `str` is not assignable to upper bound `int` of type variable `BoundedT@Bounded`" reveal_type(Bounded[str]()) # revealed: Unknown -# TODO: update this diagnostic to talk about type parameters and specializations -# error: [invalid-argument-type] "Argument to class `Bounded` is incorrect: Expected `int`, found `int | str`" +# error: [invalid-type-arguments] "Type `int | str` is not assignable to upper bound `int` of type variable `BoundedT@Bounded`" reveal_type(Bounded[int | str]()) # revealed: Unknown reveal_type(BoundedByUnion[int]()) # revealed: BoundedByUnion[int] @@ -197,8 +195,7 @@ reveal_type(Constrained[str]()) # revealed: Constrained[str] # TODO: revealed: Unknown reveal_type(Constrained[int | str]()) # revealed: Constrained[int | str] -# TODO: update this diagnostic to talk about type parameters and specializations -# error: [invalid-argument-type] "Argument to class `Constrained` is incorrect: Expected `int | str`, found `object`" +# error: [invalid-type-arguments] "Type `object` does not satisfy constraints `int`, `str` of type variable `ConstrainedT@Constrained`" reveal_type(Constrained[object]()) # revealed: Unknown ``` diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md index d32029311a..50df561dbc 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md @@ -61,7 +61,7 @@ def _(a: C[int], b: C[Literal[5]]): The specialization must match the generic types: ```py -# error: [too-many-positional-arguments] "Too many positional arguments: expected 1, got 2" +# error: [invalid-type-arguments] "Too many type arguments: expected 1, got 2" reveal_type(C[int, int]) # revealed: Unknown ``` @@ -88,12 +88,10 @@ class IntSubclass(int): ... reveal_type(Bounded[int]) # revealed: Bounded[int] reveal_type(Bounded[IntSubclass]) # revealed: Bounded[IntSubclass] -# TODO: update this diagnostic to talk about type parameters and specializations -# error: [invalid-argument-type] "Argument is incorrect: Expected `int`, found `str`" +# error: [invalid-type-arguments] "Type `str` is not assignable to upper bound `int` of type variable `T@Bounded`" reveal_type(Bounded[str]) # revealed: Unknown -# TODO: update this diagnostic to talk about type parameters and specializations -# error: [invalid-argument-type] "Argument is incorrect: Expected `int`, found `int | str`" +# error: [invalid-type-arguments] "Type `int | str` is not assignable to upper bound `int` of type variable `T@Bounded`" reveal_type(Bounded[int | str]) # revealed: Unknown reveal_type(BoundedByUnion[int]) # revealed: BoundedByUnion[int] @@ -119,8 +117,7 @@ reveal_type(Constrained[str]) # revealed: Constrained[str] # TODO: revealed: Unknown reveal_type(Constrained[int | str]) # revealed: Constrained[int | str] -# TODO: update this diagnostic to talk about type parameters and specializations -# error: [invalid-argument-type] "Argument is incorrect: Expected `int | str`, found `object`" +# error: [invalid-type-arguments] "Type `object` does not satisfy constraints `int`, `str` of type variable `T@Constrained`" reveal_type(Constrained[object]) # revealed: Unknown ``` diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md index 1f3d69e01b..418596b083 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md @@ -135,7 +135,7 @@ reveal_type(C[Literal[5]]()) # revealed: C[Literal[5]] The specialization must match the generic types: ```py -# error: [too-many-positional-arguments] "Too many positional arguments to class `C`: expected 1, got 2" +# error: [invalid-type-arguments] "Too many type arguments to class `C`: expected 1, got 2" reveal_type(C[int, int]()) # revealed: Unknown ``` @@ -149,12 +149,10 @@ class IntSubclass(int): ... reveal_type(Bounded[int]()) # revealed: Bounded[int] reveal_type(Bounded[IntSubclass]()) # revealed: Bounded[IntSubclass] -# TODO: update this diagnostic to talk about type parameters and specializations -# error: [invalid-argument-type] "Argument to class `Bounded` is incorrect: Expected `int`, found `str`" +# error: [invalid-type-arguments] "Type `str` is not assignable to upper bound `int` of type variable `T@Bounded`" reveal_type(Bounded[str]()) # revealed: Unknown -# TODO: update this diagnostic to talk about type parameters and specializations -# error: [invalid-argument-type] "Argument to class `Bounded` is incorrect: Expected `int`, found `int | str`" +# error: [invalid-type-arguments] "Type `int | str` is not assignable to upper bound `int` of type variable `T@Bounded`" reveal_type(Bounded[int | str]()) # revealed: Unknown reveal_type(BoundedByUnion[int]()) # revealed: BoundedByUnion[int] @@ -180,8 +178,7 @@ reveal_type(Constrained[str]()) # revealed: Constrained[str] # TODO: revealed: Unknown reveal_type(Constrained[int | str]()) # revealed: Constrained[int | str] -# TODO: update this diagnostic to talk about type parameters and specializations -# error: [invalid-argument-type] "Argument to class `Constrained` is incorrect: Expected `int | str`, found `object`" +# error: [invalid-type-arguments] "Type `object` does not satisfy constraints `int`, `str` of type variable `T@Constrained`" reveal_type(Constrained[object]()) # revealed: Unknown ``` diff --git a/crates/ty_python_semantic/src/types/call/bind.rs b/crates/ty_python_semantic/src/types/call/bind.rs index 280aa7984d..2d4b284be1 100644 --- a/crates/ty_python_semantic/src/types/call/bind.rs +++ b/crates/ty_python_semantic/src/types/call/bind.rs @@ -3586,12 +3586,15 @@ impl CallableBindingSnapshotter { /// Describes a callable for the purposes of diagnostics. #[derive(Debug)] pub(crate) struct CallableDescription<'a> { - name: &'a str, - kind: &'a str, + pub(crate) name: &'a str, + pub(crate) kind: &'a str, } impl<'db> CallableDescription<'db> { - fn new(db: &'db dyn Db, callable_type: Type<'db>) -> Option> { + pub(crate) fn new( + db: &'db dyn Db, + callable_type: Type<'db>, + ) -> Option> { match callable_type { Type::FunctionLiteral(function) => Some(CallableDescription { kind: "function", diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index 0738c41330..a3490337b0 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -84,6 +84,7 @@ pub(crate) fn register_lints(registry: &mut LintRegistryBuilder) { registry.register_lint(&INVALID_NAMED_TUPLE); registry.register_lint(&INVALID_RAISE); registry.register_lint(&INVALID_SUPER_ARGUMENT); + registry.register_lint(&INVALID_TYPE_ARGUMENTS); registry.register_lint(&INVALID_TYPE_CHECKING_CONSTANT); registry.register_lint(&INVALID_TYPE_FORM); registry.register_lint(&INVALID_TYPE_GUARD_DEFINITION); @@ -1406,6 +1407,47 @@ declare_lint! { } } +declare_lint! { + /// ## What it does + /// Checks for invalid type arguments in explicit type specialization. + /// + /// ## Why is this bad? + /// Providing the wrong number of type arguments or type arguments that don't + /// satisfy the type variable's bounds or constraints will lead to incorrect + /// type inference and may indicate a misunderstanding of the generic type's + /// interface. + /// + /// ## Examples + /// + /// Using legacy type variables: + /// ```python + /// from typing import Generic, TypeVar + /// + /// T1 = TypeVar('T1', int, str) + /// T2 = TypeVar('T2', bound=int) + /// + /// class Foo1(Generic[T1]): ... + /// class Foo2(Generic[T2]): ... + /// + /// Foo1[bytes] # error: bytes does not satisfy T1's constraints + /// Foo2[str] # error: str does not satisfy T2's bound + /// ``` + /// + /// Using PEP 695 type variables: + /// ```python + /// class Foo[T]: ... + /// class Bar[T, U]: ... + /// + /// Foo[int, str] # error: too many arguments + /// Bar[int] # error: too few arguments + /// ``` + pub(crate) static INVALID_TYPE_ARGUMENTS = { + summary: "detects invalid type arguments in generic specialization", + status: LintStatus::stable("0.0.1-alpha.29"), + default_level: Level::Error, + } +} + declare_lint! { /// ## What it does /// Checks for objects that are not iterable but are used in a context that requires them to be. diff --git a/crates/ty_python_semantic/src/types/generics.rs b/crates/ty_python_semantic/src/types/generics.rs index df15fdafc0..47b9b51cd7 100644 --- a/crates/ty_python_semantic/src/types/generics.rs +++ b/crates/ty_python_semantic/src/types/generics.rs @@ -13,7 +13,7 @@ use crate::types::class::ClassType; use crate::types::class_base::ClassBase; use crate::types::constraints::ConstraintSet; use crate::types::instance::{Protocol, ProtocolInstanceType}; -use crate::types::signatures::{Parameter, Parameters, Signature}; +use crate::types::signatures::Parameters; use crate::types::tuple::{TupleSpec, TupleType, walk_tuple_type}; use crate::types::visitor::{TypeCollector, TypeVisitor, walk_type_with_recursion_guard}; use crate::types::{ @@ -411,39 +411,6 @@ impl<'db> GenericContext<'db> { self.variables_inner(db).len() } - pub(crate) fn signature(self, db: &'db dyn Db) -> Signature<'db> { - let parameters = Parameters::new( - self.variables(db) - .map(|typevar| Self::parameter_from_typevar(db, typevar)), - ); - Signature::new(parameters, None) - } - - fn parameter_from_typevar( - db: &'db dyn Db, - bound_typevar: BoundTypeVarInstance<'db>, - ) -> Parameter<'db> { - let typevar = bound_typevar.typevar(db); - let mut parameter = Parameter::positional_only(Some(typevar.name(db).clone())); - match typevar.bound_or_constraints(db) { - Some(TypeVarBoundOrConstraints::UpperBound(bound)) => { - // TODO: This should be a type form. - parameter = parameter.with_annotated_type(bound); - } - Some(TypeVarBoundOrConstraints::Constraints(constraints)) => { - // TODO: This should be a new type variant where only these exact types are - // assignable, and not subclasses of them, nor a union of them. - parameter = parameter - .with_annotated_type(UnionType::from_elements(db, constraints.elements(db))); - } - None => {} - } - if let Some(default_ty) = bound_typevar.default_type(db) { - parameter = parameter.with_default_type(default_ty); - } - parameter - } - pub(crate) fn default_specialization( self, db: &'db dyn Db, diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index f5d4f36a30..229a872bc2 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -1,6 +1,6 @@ use std::iter; -use itertools::{Either, Itertools}; +use itertools::{Either, EitherOrBoth, Itertools}; use ruff_db::diagnostic::{Annotation, DiagnosticId, Severity}; use ruff_db::files::File; use ruff_db::parsed::ParsedModuleRef; @@ -49,7 +49,7 @@ use crate::semantic_index::{ ApplicableConstraints, EnclosingSnapshotResult, SemanticIndex, place_table, }; use crate::subscript::{PyIndex, PySlice}; -use crate::types::call::bind::MatchingOverloadIndex; +use crate::types::call::bind::{CallableDescription, MatchingOverloadIndex}; use crate::types::call::{Binding, Bindings, CallArguments, CallError, CallErrorKind}; use crate::types::class::{CodeGeneratorKind, FieldKind, MetaclassErrorKind, MethodDecorator}; use crate::types::context::{InNoTypeCheck, InferContext}; @@ -60,12 +60,13 @@ use crate::types::diagnostic::{ INVALID_ARGUMENT_TYPE, INVALID_ASSIGNMENT, INVALID_ATTRIBUTE_ACCESS, INVALID_BASE, INVALID_DECLARATION, INVALID_GENERIC_CLASS, INVALID_KEY, INVALID_LEGACY_TYPE_VARIABLE, INVALID_METACLASS, INVALID_NAMED_TUPLE, INVALID_NEWTYPE, INVALID_OVERLOAD, - INVALID_PARAMETER_DEFAULT, INVALID_PARAMSPEC, INVALID_PROTOCOL, INVALID_TYPE_FORM, - INVALID_TYPE_GUARD_CALL, INVALID_TYPE_VARIABLE_CONSTRAINTS, IncompatibleBases, - NON_SUBSCRIPTABLE, POSSIBLY_MISSING_ATTRIBUTE, POSSIBLY_MISSING_IMPLICIT_CALL, - POSSIBLY_MISSING_IMPORT, SUBCLASS_OF_FINAL_CLASS, UNDEFINED_REVEAL, UNRESOLVED_ATTRIBUTE, - UNRESOLVED_GLOBAL, UNRESOLVED_IMPORT, UNRESOLVED_REFERENCE, UNSUPPORTED_OPERATOR, - USELESS_OVERLOAD_BODY, hint_if_stdlib_attribute_exists_on_other_versions, + INVALID_PARAMETER_DEFAULT, INVALID_PARAMSPEC, INVALID_PROTOCOL, INVALID_TYPE_ARGUMENTS, + INVALID_TYPE_FORM, INVALID_TYPE_GUARD_CALL, INVALID_TYPE_VARIABLE_CONSTRAINTS, + IncompatibleBases, NON_SUBSCRIPTABLE, POSSIBLY_MISSING_ATTRIBUTE, + POSSIBLY_MISSING_IMPLICIT_CALL, POSSIBLY_MISSING_IMPORT, SUBCLASS_OF_FINAL_CLASS, + UNDEFINED_REVEAL, UNRESOLVED_ATTRIBUTE, UNRESOLVED_GLOBAL, UNRESOLVED_IMPORT, + UNRESOLVED_REFERENCE, UNSUPPORTED_OPERATOR, USELESS_OVERLOAD_BODY, + hint_if_stdlib_attribute_exists_on_other_versions, hint_if_stdlib_submodule_exists_on_other_versions, report_attempted_protocol_instantiation, report_bad_dunder_set_call, report_cannot_pop_required_field_on_typed_dict, report_duplicate_bases, report_implicit_return_type, report_index_out_of_bounds, @@ -106,9 +107,9 @@ use crate::types::{ KnownInstanceType, LintDiagnosticGuard, MemberLookupPolicy, MetaclassCandidate, PEP695TypeAliasType, ParameterForm, SpecialFormType, SubclassOfType, TrackedConstraintSet, Truthiness, Type, TypeAliasType, TypeAndQualifiers, TypeContext, TypeQualifiers, - TypeVarBoundOrConstraintsEvaluation, TypeVarDefaultEvaluation, TypeVarIdentity, - TypeVarInstance, TypeVarKind, TypeVarVariance, TypedDictType, UnionBuilder, UnionType, - UnionTypeInstance, binding_type, infer_scope_types, liskov, todo_type, + TypeVarBoundOrConstraints, TypeVarBoundOrConstraintsEvaluation, TypeVarDefaultEvaluation, + TypeVarIdentity, TypeVarInstance, TypeVarKind, TypeVarVariance, TypedDictType, UnionBuilder, + UnionType, UnionTypeInstance, binding_type, infer_scope_types, liskov, todo_type, }; use crate::types::{ClassBase, add_inferred_python_version_hint_to_diagnostic}; use crate::unpack::{EvaluationMode, UnpackPosition}; @@ -11220,45 +11221,173 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { generic_context: GenericContext<'db>, specialize: impl FnOnce(&[Option>]) -> Type<'db>, ) -> Type<'db> { + let db = self.db(); let slice_node = subscript.slice.as_ref(); - let call_argument_types = match slice_node { + + // Extract type arguments from the subscript + let type_arguments: Vec> = match slice_node { ast::Expr::Tuple(tuple) => { - let arguments = CallArguments::positional( - tuple.elts.iter().map(|elt| self.infer_type_expression(elt)), - ); + let types: Vec<_> = tuple + .elts + .iter() + .map(|elt| self.infer_type_expression(elt)) + .collect(); self.store_expression_type( slice_node, - Type::heterogeneous_tuple(self.db(), arguments.iter_types()), + Type::heterogeneous_tuple(db, types.iter().copied()), ); - arguments + types } - _ => CallArguments::positional([self.infer_type_expression(slice_node)]), + _ => vec![self.infer_type_expression(slice_node)], }; - let binding = Binding::single(value_ty, generic_context.signature(self.db())); - let bindings = match Bindings::from(binding) - .match_parameters(self.db(), &call_argument_types) - .check_types( - self.db(), - &call_argument_types, - TypeContext::default(), - &self.dataclass_field_specifiers, - ) { - Ok(bindings) => bindings, - Err(CallError(_, bindings)) => { - bindings.report_diagnostics(&self.context, subscript.into()); - return Type::unknown(); - } - }; - let callable = bindings - .into_iter() - .next() - .expect("valid bindings should have one callable"); - let (_, overload) = callable - .matching_overloads() - .next() - .expect("valid bindings should have matching overload"); - specialize(overload.parameter_types()) + let typevars = generic_context.variables(db); + let typevars_len = typevars.len(); + + let mut specialization_types = Vec::with_capacity(typevars_len); + let mut typevar_with_defaults = 0; + let mut missing_typevars = vec![]; + let mut first_excess_type_argument_index = None; + + // Helper to get the AST node corresponding to the type argument at `index`. + let get_node = |index: usize| -> ast::AnyNodeRef<'_> { + match slice_node { + ast::Expr::Tuple(ast::ExprTuple { elts, .. }) => elts + .get(index) + .expect("type argument index should not be out of range") + .into(), + _ => slice_node.into(), + } + }; + + let mut has_error = false; + + for (index, item) in typevars.zip_longest(type_arguments.iter()).enumerate() { + match item { + EitherOrBoth::Both(typevar, &provided_type) => { + if typevar.default_type(db).is_some() { + typevar_with_defaults += 1; + } + match typevar.typevar(db).bound_or_constraints(db) { + Some(TypeVarBoundOrConstraints::UpperBound(bound)) => { + if provided_type + .when_assignable_to(db, bound, InferableTypeVars::None) + .is_never_satisfied(db) + { + let node = get_node(index); + if let Some(builder) = + self.context.report_lint(&INVALID_TYPE_ARGUMENTS, node) + { + builder.into_diagnostic(format_args!( + "Type `{}` is not assignable to upper bound `{}` \ + of type variable `{}`", + provided_type.display(db), + bound.display(db), + typevar.identity(db).display(db), + )); + } + has_error = true; + continue; + } + } + Some(TypeVarBoundOrConstraints::Constraints(constraints)) => { + if provided_type + .when_assignable_to( + db, + Type::Union(constraints), + InferableTypeVars::None, + ) + .is_never_satisfied(db) + { + let node = get_node(index); + if let Some(builder) = + self.context.report_lint(&INVALID_TYPE_ARGUMENTS, node) + { + builder.into_diagnostic(format_args!( + "Type `{}` does not satisfy constraints `{}` \ + of type variable `{}`", + provided_type.display(db), + constraints + .elements(db) + .iter() + .map(|c| c.display(db)) + .format("`, `"), + typevar.identity(db).display(db), + )); + } + has_error = true; + continue; + } + } + None => {} + } + specialization_types.push(Some(provided_type)); + } + EitherOrBoth::Left(typevar) => { + if typevar.default_type(db).is_none() { + missing_typevars.push(typevar); + } else { + typevar_with_defaults += 1; + } + specialization_types.push(None); + } + EitherOrBoth::Right(_) => { + first_excess_type_argument_index.get_or_insert(index); + } + } + } + + if !missing_typevars.is_empty() { + if let Some(builder) = self.context.report_lint(&INVALID_TYPE_ARGUMENTS, subscript) { + let description = CallableDescription::new(db, value_ty); + let s = if missing_typevars.len() > 1 { "s" } else { "" }; + builder.into_diagnostic(format_args!( + "No type argument{s} provided for required type variable{s} `{}`{}", + missing_typevars + .iter() + .map(|tv| tv.typevar(db).name(db)) + .format("`, `"), + if let Some(CallableDescription { kind, name }) = description { + format!(" of {kind} `{name}`") + } else { + String::new() + } + )); + } + has_error = true; + } + + if let Some(first_excess_type_argument_index) = first_excess_type_argument_index { + let node = get_node(first_excess_type_argument_index); + if let Some(builder) = self.context.report_lint(&INVALID_TYPE_ARGUMENTS, node) { + let description = CallableDescription::new(db, value_ty); + builder.into_diagnostic(format_args!( + "Too many type arguments{}: expected {}, got {}", + if let Some(CallableDescription { kind, name }) = description { + format!(" to {kind} `{name}`") + } else { + String::new() + }, + if typevar_with_defaults == 0 { + format!("{typevars_len}") + } else { + format!( + "between {} and {}", + typevars_len - typevar_with_defaults, + typevars_len + ) + }, + type_arguments.len(), + )); + } + has_error = true; + } + + if has_error { + return Type::unknown(); + } + + specialize(&specialization_types) } fn infer_subscript_expression_types( diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__commands__debug_command.snap b/crates/ty_server/tests/e2e/snapshots/e2e__commands__debug_command.snap index b6c245a91f..0676f15fd7 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__commands__debug_command.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__commands__debug_command.snap @@ -72,6 +72,7 @@ Settings: Settings { "invalid-super-argument": Error (Default), "invalid-syntax-in-forward-annotation": Error (Default), "invalid-type-alias-type": Error (Default), + "invalid-type-arguments": Error (Default), "invalid-type-checking-constant": Error (Default), "invalid-type-form": Error (Default), "invalid-type-guard-call": Error (Default), diff --git a/ty.schema.json b/ty.schema.json index edc493f2e3..aef426eb23 100644 --- a/ty.schema.json +++ b/ty.schema.json @@ -753,6 +753,16 @@ } ] }, + "invalid-type-arguments": { + "title": "detects invalid type arguments in generic specialization", + "description": "## What it does\nChecks for invalid type arguments in explicit type specialization.\n\n## Why is this bad?\nProviding the wrong number of type arguments or type arguments that don't\nsatisfy the type variable's bounds or constraints will lead to incorrect\ntype inference and may indicate a misunderstanding of the generic type's\ninterface.\n\n## Examples\n\nUsing legacy type variables:\n```python\nfrom typing import Generic, TypeVar\n\nT1 = TypeVar('T1', int, str)\nT2 = TypeVar('T2', bound=int)\n\nclass Foo1(Generic[T1]): ...\nclass Foo2(Generic[T2]): ...\n\nFoo1[bytes] # error: bytes does not satisfy T1's constraints\nFoo2[str] # error: str does not satisfy T2's bound\n```\n\nUsing PEP 695 type variables:\n```python\nclass Foo[T]: ...\nclass Bar[T, U]: ...\n\nFoo[int, str] # error: too many arguments\nBar[int] # error: too few arguments\n```", + "default": "error", + "oneOf": [ + { + "$ref": "#/definitions/Level" + } + ] + }, "invalid-type-checking-constant": { "title": "detects invalid `TYPE_CHECKING` constant assignments", "description": "## What it does\nChecks for a value other than `False` assigned to the `TYPE_CHECKING` variable, or an\nannotation not assignable from `bool`.\n\n## Why is this bad?\nThe name `TYPE_CHECKING` is reserved for a flag that can be used to provide conditional\ncode seen only by the type checker, and not at runtime. Normally this flag is imported from\n`typing` or `typing_extensions`, but it can also be defined locally. If defined locally, it\nmust be assigned the value `False` at runtime; the type checker will consider its value to\nbe `True`. If annotated, it must be annotated as a type that can accept `bool` values.\n\n## Examples\n```python\nTYPE_CHECKING: str\nTYPE_CHECKING = ''\n```", From 792ec3e96ed83e182d53f3e5311f62db2dddf48b Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 27 Nov 2025 08:18:21 +0000 Subject: [PATCH 03/67] Improve docs on how to stop Ruff and ty disagreeing with each other (#21644) ## Summary Lots of Ruff rules encourage you to make changes that might then cause ty to start complaining about Liskov violations. Most of these Ruff rules already refrain from complaining about a method if they see that the method is decorated with `@override`, but this usually isn't documented. This PR updates the docs of many Ruff rules to note that they refrain from complaining about `@override`-decorated methods, and also adds a similar note to the ty `invalid-method-override` documentation. Helps with https://github.com/astral-sh/ty/issues/1644#issuecomment-3581663859 ## Test Plan - `uvx prek run -a` locally - CI on this PR --- ...olean_default_value_positional_argument.rs | 7 ++++ .../boolean_type_hint_positional_argument.rs | 4 ++- .../rules/builtin_argument_shadowing.rs | 5 +++ .../rules/unused_arguments.rs | 36 +++++++++++++++++++ .../rules/invalid_argument_name.rs | 4 ++- .../rules/invalid_function_name.rs | 6 ++++ .../src/rules/pydocstyle/rules/not_missing.rs | 9 +++++ .../pylint/rules/bad_dunder_method_name.rs | 4 ++- .../src/rules/pylint/rules/no_self_use.rs | 12 +++++++ .../rules/pylint/rules/too_many_arguments.rs | 12 +++++++ .../rules/too_many_positional_arguments.rs | 12 +++++++ crates/ty/docs/rules.md | 21 +++++++++++ .../src/types/diagnostic.rs | 20 +++++++++++ ty.schema.json | 2 +- 14 files changed, 150 insertions(+), 4 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs index 361f1df069..cfe817a259 100644 --- a/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs +++ b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs @@ -25,6 +25,11 @@ use crate::rules::flake8_boolean_trap::helpers::is_allowed_func_def; /// keyword-only argument, to force callers to be explicit when providing /// the argument. /// +/// This rule exempts methods decorated with [`@typing.override`][override], +/// since changing the signature of a subclass method that overrides a +/// superclass method may cause type checkers to complain about a violation of +/// the Liskov Substitution Principle. +/// /// ## Example /// ```python /// from math import ceil, floor @@ -89,6 +94,8 @@ use crate::rules::flake8_boolean_trap::helpers::is_allowed_func_def; /// ## References /// - [Python documentation: Calls](https://docs.python.org/3/reference/expressions.html#calls) /// - [_How to Avoid “The Boolean Trap”_ by Adam Johnson](https://adamj.eu/tech/2021/07/10/python-type-hints-how-to-avoid-the-boolean-trap/) +/// +/// [override]: https://docs.python.org/3/library/typing.html#typing.override #[derive(ViolationMetadata)] #[violation_metadata(stable_since = "v0.0.127")] pub(crate) struct BooleanDefaultValuePositionalArgument; diff --git a/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs index 4bc72d0f26..05a87a28c4 100644 --- a/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs +++ b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs @@ -28,7 +28,7 @@ use crate::rules::flake8_boolean_trap::helpers::is_allowed_func_def; /// the argument. /// /// Dunder methods that define operators are exempt from this rule, as are -/// setters and `@override` definitions. +/// setters and [`@override`][override] definitions. /// /// ## Example /// @@ -93,6 +93,8 @@ use crate::rules::flake8_boolean_trap::helpers::is_allowed_func_def; /// ## References /// - [Python documentation: Calls](https://docs.python.org/3/reference/expressions.html#calls) /// - [_How to Avoid “The Boolean Trap”_ by Adam Johnson](https://adamj.eu/tech/2021/07/10/python-type-hints-how-to-avoid-the-boolean-trap/) +/// +/// [override]: https://docs.python.org/3/library/typing.html#typing.override #[derive(ViolationMetadata)] #[violation_metadata(stable_since = "v0.0.127")] pub(crate) struct BooleanTypeHintPositionalArgument; diff --git a/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs b/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs index 766e4b4561..2545d9e8fd 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs +++ b/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs @@ -17,6 +17,8 @@ use crate::rules::flake8_builtins::helpers::shadows_builtin; /// non-obvious errors, as readers may mistake the argument for the /// builtin and vice versa. /// +/// Function definitions decorated with [`@override`][override] or +/// [`@overload`][overload] are exempt from this rule by default. /// Builtins can be marked as exceptions to this rule via the /// [`lint.flake8-builtins.ignorelist`] configuration option. /// @@ -48,6 +50,9 @@ use crate::rules::flake8_builtins::helpers::shadows_builtin; /// ## References /// - [_Is it bad practice to use a built-in function name as an attribute or method identifier?_](https://stackoverflow.com/questions/9109333/is-it-bad-practice-to-use-a-built-in-function-name-as-an-attribute-or-method-ide) /// - [_Why is it a bad idea to name a variable `id` in Python?_](https://stackoverflow.com/questions/77552/id-is-a-bad-variable-name-in-python) +/// +/// [override]: https://docs.python.org/3/library/typing.html#typing.override +/// [overload]: https://docs.python.org/3/library/typing.html#typing.overload #[derive(ViolationMetadata)] #[violation_metadata(stable_since = "v0.0.48")] pub(crate) struct BuiltinArgumentShadowing { diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs b/crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs index 18d0a96377..884bb00a3e 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs @@ -60,6 +60,16 @@ impl Violation for UnusedFunctionArgument { /// prefixed with an underscore, or some other value that adheres to the /// [`lint.dummy-variable-rgx`] pattern. /// +/// This rule exempts methods decorated with [`@typing.override`][override]. +/// Removing a parameter from a subclass method (or changing a parameter's +/// name) may cause type checkers to complain about a violation of the Liskov +/// Substitution Principle if it means that the method now incompatibly +/// overrides a method defined on a superclass. Explicitly decorating an +/// overriding method with `@override` signals to Ruff that the method is +/// intended to override a superclass method and that a type checker will +/// enforce that it does so; Ruff therefore knows that it should not enforce +/// rules about unused arguments on such methods. +/// /// ## Example /// ```python /// class Class: @@ -76,6 +86,8 @@ impl Violation for UnusedFunctionArgument { /// /// ## Options /// - `lint.dummy-variable-rgx` +/// +/// [override]: https://docs.python.org/3/library/typing.html#typing.override #[derive(ViolationMetadata)] #[violation_metadata(stable_since = "v0.0.168")] pub(crate) struct UnusedMethodArgument { @@ -101,6 +113,16 @@ impl Violation for UnusedMethodArgument { /// prefixed with an underscore, or some other value that adheres to the /// [`lint.dummy-variable-rgx`] pattern. /// +/// This rule exempts methods decorated with [`@typing.override`][override]. +/// Removing a parameter from a subclass method (or changing a parameter's +/// name) may cause type checkers to complain about a violation of the Liskov +/// Substitution Principle if it means that the method now incompatibly +/// overrides a method defined on a superclass. Explicitly decorating an +/// overriding method with `@override` signals to Ruff that the method is +/// intended to override a superclass method and that a type checker will +/// enforce that it does so; Ruff therefore knows that it should not enforce +/// rules about unused arguments on such methods. +/// /// ## Example /// ```python /// class Class: @@ -119,6 +141,8 @@ impl Violation for UnusedMethodArgument { /// /// ## Options /// - `lint.dummy-variable-rgx` +/// +/// [override]: https://docs.python.org/3/library/typing.html#typing.override #[derive(ViolationMetadata)] #[violation_metadata(stable_since = "v0.0.168")] pub(crate) struct UnusedClassMethodArgument { @@ -144,6 +168,16 @@ impl Violation for UnusedClassMethodArgument { /// prefixed with an underscore, or some other value that adheres to the /// [`lint.dummy-variable-rgx`] pattern. /// +/// This rule exempts methods decorated with [`@typing.override`][override]. +/// Removing a parameter from a subclass method (or changing a parameter's +/// name) may cause type checkers to complain about a violation of the Liskov +/// Substitution Principle if it means that the method now incompatibly +/// overrides a method defined on a superclass. Explicitly decorating an +/// overriding method with `@override` signals to Ruff that the method is +/// intended to override a superclass method, and that a type checker will +/// enforce that it does so; Ruff therefore knows that it should not enforce +/// rules about unused arguments on such methods. +/// /// ## Example /// ```python /// class Class: @@ -162,6 +196,8 @@ impl Violation for UnusedClassMethodArgument { /// /// ## Options /// - `lint.dummy-variable-rgx` +/// +/// [override]: https://docs.python.org/3/library/typing.html#typing.override #[derive(ViolationMetadata)] #[violation_metadata(stable_since = "v0.0.168")] pub(crate) struct UnusedStaticMethodArgument { diff --git a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_argument_name.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_argument_name.rs index a490f34702..b3ee458b31 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_argument_name.rs +++ b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_argument_name.rs @@ -23,7 +23,7 @@ use crate::checkers::ast::Checker; /// > mixedCase is allowed only in contexts where that’s already the /// > prevailing style (e.g. threading.py), to retain backwards compatibility. /// -/// Methods decorated with `@typing.override` are ignored. +/// Methods decorated with [`@typing.override`][override] are ignored. /// /// ## Example /// ```python @@ -43,6 +43,8 @@ use crate::checkers::ast::Checker; /// /// [PEP 8]: https://peps.python.org/pep-0008/#function-and-method-arguments /// [preview]: https://docs.astral.sh/ruff/preview/ +/// +/// [override]: https://docs.python.org/3/library/typing.html#typing.override #[derive(ViolationMetadata)] #[violation_metadata(stable_since = "v0.0.77")] pub(crate) struct InvalidArgumentName { diff --git a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs index 546b41c014..d7fbd985dd 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs +++ b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs @@ -24,6 +24,11 @@ use crate::rules::pep8_naming::settings::IgnoreNames; /// to ignore all functions starting with `test_` from this rule, set the /// [`lint.pep8-naming.extend-ignore-names`] option to `["test_*"]`. /// +/// This rule exempts methods decorated with [`@typing.override`][override]. +/// Explicitly decorating a method with `@override` signals to Ruff that the method is intended +/// to override a superclass method, and that a type checker will enforce that it does so. Ruff +/// therefore knows that it should not enforce naming conventions on such methods. +/// /// ## Example /// ```python /// def myFunction(): @@ -41,6 +46,7 @@ use crate::rules::pep8_naming::settings::IgnoreNames; /// - `lint.pep8-naming.extend-ignore-names` /// /// [PEP 8]: https://peps.python.org/pep-0008/#function-and-variable-names +/// [override]: https://docs.python.org/3/library/typing.html#typing.override #[derive(ViolationMetadata)] #[violation_metadata(stable_since = "v0.0.77")] pub(crate) struct InvalidFunctionName { diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs index b82098169f..24ed1e4856 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs @@ -169,7 +169,12 @@ impl Violation for UndocumentedPublicClass { /// If the codebase adheres to a standard format for method docstrings, follow /// that format for consistency. /// +/// This rule exempts methods decorated with [`@typing.override`][override], +/// since it is a common practice to document a method on a superclass but not +/// on an overriding method in a subclass. +/// /// ## Example +/// /// ```python /// class Cat(Animal): /// def greet(self, happy: bool = True): @@ -180,6 +185,7 @@ impl Violation for UndocumentedPublicClass { /// ``` /// /// Use instead (in the NumPy docstring format): +/// /// ```python /// class Cat(Animal): /// def greet(self, happy: bool = True): @@ -202,6 +208,7 @@ impl Violation for UndocumentedPublicClass { /// ``` /// /// Or (in the Google docstring format): +/// /// ```python /// class Cat(Animal): /// def greet(self, happy: bool = True): @@ -227,6 +234,8 @@ impl Violation for UndocumentedPublicClass { /// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/) /// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html) /// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) +/// +/// [override]: https://docs.python.org/3/library/typing.html#typing.override #[derive(ViolationMetadata)] #[violation_metadata(stable_since = "v0.0.70")] pub(crate) struct UndocumentedPublicMethod; diff --git a/crates/ruff_linter/src/rules/pylint/rules/bad_dunder_method_name.rs b/crates/ruff_linter/src/rules/pylint/rules/bad_dunder_method_name.rs index 200ec4dbe2..a375147665 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/bad_dunder_method_name.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/bad_dunder_method_name.rs @@ -21,7 +21,7 @@ use crate::rules::pylint::helpers::is_known_dunder_method; /// /// This rule will detect all methods starting and ending with at least /// one underscore (e.g., `_str_`), but ignores known dunder methods (like -/// `__init__`), as well as methods that are marked with `@override`. +/// `__init__`), as well as methods that are marked with [`@override`][override]. /// /// Additional dunder methods names can be allowed via the /// [`lint.pylint.allow-dunder-method-names`] setting. @@ -42,6 +42,8 @@ use crate::rules::pylint::helpers::is_known_dunder_method; /// /// ## Options /// - `lint.pylint.allow-dunder-method-names` +/// +/// [override]: https://docs.python.org/3/library/typing.html#typing.override #[derive(ViolationMetadata)] #[violation_metadata(preview_since = "v0.0.285")] pub(crate) struct BadDunderMethodName { diff --git a/crates/ruff_linter/src/rules/pylint/rules/no_self_use.rs b/crates/ruff_linter/src/rules/pylint/rules/no_self_use.rs index fd6e24528c..c6a2fe9d0d 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/no_self_use.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/no_self_use.rs @@ -17,6 +17,16 @@ use crate::rules::flake8_unused_arguments::rules::is_not_implemented_stub_with_v /// Unused `self` parameters are usually a sign of a method that could be /// replaced by a function, class method, or static method. /// +/// This rule exempts methods decorated with [`@typing.override`][override]. +/// Converting an instance method into a static method or class method may +/// cause type checkers to complain about a violation of the Liskov +/// Substitution Principle if it means that the method now incompatibly +/// overrides a method defined on a superclass. Explicitly decorating an +/// overriding method with `@override` signals to Ruff that the method is +/// intended to override a superclass method and that a type checker will +/// enforce that it does so; Ruff therefore knows that it should not enforce +/// rules about unused `self` parameters on such methods. +/// /// ## Example /// ```python /// class Person: @@ -38,6 +48,8 @@ use crate::rules::flake8_unused_arguments::rules::is_not_implemented_stub_with_v /// def greeting(): /// print("Greetings friend!") /// ``` +/// +/// [override]: https://docs.python.org/3/library/typing.html#typing.override #[derive(ViolationMetadata)] #[violation_metadata(preview_since = "v0.0.286")] pub(crate) struct NoSelfUse { diff --git a/crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs index 9242ad8342..0fb6b4f04e 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs @@ -12,6 +12,16 @@ use crate::checkers::ast::Checker; /// By default, this rule allows up to five arguments, as configured by the /// [`lint.pylint.max-args`] option. /// +/// This rule exempts methods decorated with [`@typing.override`][override]. +/// Changing the signature of a subclass method may cause type checkers to +/// complain about a violation of the Liskov Substitution Principle if it +/// means that the method now incompatibly overrides a method defined on a +/// superclass. Explicitly decorating an overriding method with `@override` +/// signals to Ruff that the method is intended to override a superclass +/// method and that a type checker will enforce that it does so; Ruff +/// therefore knows that it should not enforce rules about methods having +/// too many arguments. +/// /// ## Why is this bad? /// Functions with many arguments are harder to understand, maintain, and call. /// Consider refactoring functions with many arguments into smaller functions @@ -43,6 +53,8 @@ use crate::checkers::ast::Checker; /// /// ## Options /// - `lint.pylint.max-args` +/// +/// [override]: https://docs.python.org/3/library/typing.html#typing.override #[derive(ViolationMetadata)] #[violation_metadata(stable_since = "v0.0.238")] pub(crate) struct TooManyArguments { diff --git a/crates/ruff_linter/src/rules/pylint/rules/too_many_positional_arguments.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_positional_arguments.rs index f9f979658c..db661c68b7 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/too_many_positional_arguments.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/too_many_positional_arguments.rs @@ -21,6 +21,16 @@ use crate::checkers::ast::Checker; /// with fewer arguments, using objects to group related arguments, or migrating to /// [keyword-only arguments](https://docs.python.org/3/tutorial/controlflow.html#special-parameters). /// +/// This rule exempts methods decorated with [`@typing.override`][override]. +/// Changing the signature of a subclass method may cause type checkers to +/// complain about a violation of the Liskov Substitution Principle if it +/// means that the method now incompatibly overrides a method defined on a +/// superclass. Explicitly decorating an overriding method with `@override` +/// signals to Ruff that the method is intended to override a superclass +/// method and that a type checker will enforce that it does so; Ruff +/// therefore knows that it should not enforce rules about methods having +/// too many arguments. +/// /// ## Example /// /// ```python @@ -41,6 +51,8 @@ use crate::checkers::ast::Checker; /// /// ## Options /// - `lint.pylint.max-positional-args` +/// +/// [override]: https://docs.python.org/3/library/typing.html#typing.override #[derive(ViolationMetadata)] #[violation_metadata(preview_since = "v0.1.7")] pub(crate) struct TooManyPositionalArguments { diff --git a/crates/ty/docs/rules.md b/crates/ty/docs/rules.md index 730692f9ef..3a77ed7946 100644 --- a/crates/ty/docs/rules.md +++ b/crates/ty/docs/rules.md @@ -1012,7 +1012,28 @@ classes in Python do indeed behave this way, the strongly held convention is tha be avoided wherever possible. As part of this check, therefore, ty enforces that `__eq__` and `__ne__` methods accept `object` as their second argument. +**Why does ty disagree with Ruff about how to write my method?** + + +Ruff has several rules that will encourage you to rename a parameter, or change its type +signature, if it thinks you're falling into a certain anti-pattern. For example, Ruff's +[ARG002](https://docs.astral.sh/ruff/rules/unused-method-argument/) rule recommends that an +unused parameter should either be removed or renamed to start with `_`. Applying either of +these suggestions can cause ty to start reporting an `invalid-method-override` error if +the function in question is a method on a subclass that overrides a method on a superclass, +and the change would cause the subclass method to no longer accept all argument combinations +that the superclass method accepts. + +This can usually be resolved by adding [`@typing.override`][override] to your method +definition. Ruff knows that a method decorated with `@typing.override` is intended to +override a method by the same name on a superclass, and avoids reporting rules like ARG002 +for such methods; it knows that the changes recommended by ARG002 would violate the Liskov +Substitution Principle. + +Correct use of `@override` is enforced by ty's `invalid-explicit-override` rule. + [Liskov Substitution Principle]: https://en.wikipedia.org/wiki/Liskov_substitution_principle +[override]: https://docs.python.org/3/library/typing.html#typing.override ## `invalid-named-tuple` diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index a3490337b0..44b54d0c41 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -2114,7 +2114,27 @@ declare_lint! { /// be avoided wherever possible. As part of this check, therefore, ty enforces that `__eq__` /// and `__ne__` methods accept `object` as their second argument. /// + /// ### Why does ty disagree with Ruff about how to write my method? + /// + /// Ruff has several rules that will encourage you to rename a parameter, or change its type + /// signature, if it thinks you're falling into a certain anti-pattern. For example, Ruff's + /// [ARG002](https://docs.astral.sh/ruff/rules/unused-method-argument/) rule recommends that an + /// unused parameter should either be removed or renamed to start with `_`. Applying either of + /// these suggestions can cause ty to start reporting an `invalid-method-override` error if + /// the function in question is a method on a subclass that overrides a method on a superclass, + /// and the change would cause the subclass method to no longer accept all argument combinations + /// that the superclass method accepts. + /// + /// This can usually be resolved by adding [`@typing.override`][override] to your method + /// definition. Ruff knows that a method decorated with `@typing.override` is intended to + /// override a method by the same name on a superclass, and avoids reporting rules like ARG002 + /// for such methods; it knows that the changes recommended by ARG002 would violate the Liskov + /// Substitution Principle. + /// + /// Correct use of `@override` is enforced by ty's `invalid-explicit-override` rule. + /// /// [Liskov Substitution Principle]: https://en.wikipedia.org/wiki/Liskov_substitution_principle + /// [override]: https://docs.python.org/3/library/typing.html#typing.override pub(crate) static INVALID_METHOD_OVERRIDE = { summary: "detects method definitions that violate the Liskov Substitution Principle", status: LintStatus::stable("0.0.1-alpha.20"), diff --git a/ty.schema.json b/ty.schema.json index aef426eb23..919b0e8dfc 100644 --- a/ty.schema.json +++ b/ty.schema.json @@ -635,7 +635,7 @@ }, "invalid-method-override": { "title": "detects method definitions that violate the Liskov Substitution Principle", - "description": "## What it does\nDetects method overrides that violate the [Liskov Substitution Principle] (\"LSP\").\n\nThe LSP states that an instance of a subtype should be substitutable for an instance of its supertype.\nApplied to Python, this means:\n1. All argument combinations a superclass method accepts\n must also be accepted by an overriding subclass method.\n2. The return type of an overriding subclass method must be a subtype\n of the return type of the superclass method.\n\n## Why is this bad?\nViolating the Liskov Substitution Principle will lead to many of ty's assumptions and\ninferences being incorrect, which will mean that it will fail to catch many possible\ntype errors in your code.\n\n## Example\n```python\nclass Super:\n def method(self, x) -> int:\n return 42\n\nclass Sub(Super):\n # Liskov violation: `str` is not a subtype of `int`,\n # but the supertype method promises to return an `int`.\n def method(self, x) -> str: # error: [invalid-override]\n return \"foo\"\n\ndef accepts_super(s: Super) -> int:\n return s.method(x=42)\n\naccepts_super(Sub()) # The result of this call is a string, but ty will infer\n # it to be an `int` due to the violation of the Liskov Substitution Principle.\n\nclass Sub2(Super):\n # Liskov violation: the superclass method can be called with a `x=`\n # keyword argument, but the subclass method does not accept it.\n def method(self, y) -> int: # error: [invalid-override]\n return 42\n\naccepts_super(Sub2()) # TypeError at runtime: method() got an unexpected keyword argument 'x'\n # ty cannot catch this error due to the violation of the Liskov Substitution Principle.\n```\n\n## Common issues\n\n### Why does ty complain about my `__eq__` method?\n\n`__eq__` and `__ne__` methods in Python are generally expected to accept arbitrary\nobjects as their second argument, for example:\n\n```python\nclass A:\n x: int\n\n def __eq__(self, other: object) -> bool:\n # gracefully handle an object of an unexpected type\n # without raising an exception\n if not isinstance(other, A):\n return False\n return self.x == other.x\n```\n\nIf `A.__eq__` here were annotated as only accepting `A` instances for its second argument,\nit would imply that you wouldn't be able to use `==` between instances of `A` and\ninstances of unrelated classes without an exception possibly being raised. While some\nclasses in Python do indeed behave this way, the strongly held convention is that it should\nbe avoided wherever possible. As part of this check, therefore, ty enforces that `__eq__`\nand `__ne__` methods accept `object` as their second argument.\n\n[Liskov Substitution Principle]: https://en.wikipedia.org/wiki/Liskov_substitution_principle", + "description": "## What it does\nDetects method overrides that violate the [Liskov Substitution Principle] (\"LSP\").\n\nThe LSP states that an instance of a subtype should be substitutable for an instance of its supertype.\nApplied to Python, this means:\n1. All argument combinations a superclass method accepts\n must also be accepted by an overriding subclass method.\n2. The return type of an overriding subclass method must be a subtype\n of the return type of the superclass method.\n\n## Why is this bad?\nViolating the Liskov Substitution Principle will lead to many of ty's assumptions and\ninferences being incorrect, which will mean that it will fail to catch many possible\ntype errors in your code.\n\n## Example\n```python\nclass Super:\n def method(self, x) -> int:\n return 42\n\nclass Sub(Super):\n # Liskov violation: `str` is not a subtype of `int`,\n # but the supertype method promises to return an `int`.\n def method(self, x) -> str: # error: [invalid-override]\n return \"foo\"\n\ndef accepts_super(s: Super) -> int:\n return s.method(x=42)\n\naccepts_super(Sub()) # The result of this call is a string, but ty will infer\n # it to be an `int` due to the violation of the Liskov Substitution Principle.\n\nclass Sub2(Super):\n # Liskov violation: the superclass method can be called with a `x=`\n # keyword argument, but the subclass method does not accept it.\n def method(self, y) -> int: # error: [invalid-override]\n return 42\n\naccepts_super(Sub2()) # TypeError at runtime: method() got an unexpected keyword argument 'x'\n # ty cannot catch this error due to the violation of the Liskov Substitution Principle.\n```\n\n## Common issues\n\n### Why does ty complain about my `__eq__` method?\n\n`__eq__` and `__ne__` methods in Python are generally expected to accept arbitrary\nobjects as their second argument, for example:\n\n```python\nclass A:\n x: int\n\n def __eq__(self, other: object) -> bool:\n # gracefully handle an object of an unexpected type\n # without raising an exception\n if not isinstance(other, A):\n return False\n return self.x == other.x\n```\n\nIf `A.__eq__` here were annotated as only accepting `A` instances for its second argument,\nit would imply that you wouldn't be able to use `==` between instances of `A` and\ninstances of unrelated classes without an exception possibly being raised. While some\nclasses in Python do indeed behave this way, the strongly held convention is that it should\nbe avoided wherever possible. As part of this check, therefore, ty enforces that `__eq__`\nand `__ne__` methods accept `object` as their second argument.\n\n### Why does ty disagree with Ruff about how to write my method?\n\nRuff has several rules that will encourage you to rename a parameter, or change its type\nsignature, if it thinks you're falling into a certain anti-pattern. For example, Ruff's\n[ARG002](https://docs.astral.sh/ruff/rules/unused-method-argument/) rule recommends that an\nunused parameter should either be removed or renamed to start with `_`. Applying either of\nthese suggestions can cause ty to start reporting an `invalid-method-override` error if\nthe function in question is a method on a subclass that overrides a method on a superclass,\nand the change would cause the subclass method to no longer accept all argument combinations\nthat the superclass method accepts.\n\nThis can usually be resolved by adding [`@typing.override`][override] to your method\ndefinition. Ruff knows that a method decorated with `@typing.override` is intended to\noverride a method by the same name on a superclass, and avoids reporting rules like ARG002\nfor such methods; it knows that the changes recommended by ARG002 would violate the Liskov\nSubstitution Principle.\n\nCorrect use of `@override` is enforced by ty's `invalid-explicit-override` rule.\n\n[Liskov Substitution Principle]: https://en.wikipedia.org/wiki/Liskov_substitution_principle\n[override]: https://docs.python.org/3/library/typing.html#typing.override", "default": "error", "oneOf": [ { From 761031f729ee43fe39cdb9b04e0133740a77be17 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Thu, 27 Nov 2025 10:59:57 +0100 Subject: [PATCH 04/67] [ty] Add code action support to playground (#21655) --- Cargo.lock | 1 + crates/ty_wasm/Cargo.toml | 1 + crates/ty_wasm/src/lib.rs | 48 +++++++++++++++++ playground/ty/src/Editor/Chrome.tsx | 1 + playground/ty/src/Editor/Diagnostics.tsx | 8 ++- playground/ty/src/Editor/Editor.tsx | 66 +++++++++++++++++++++++- 6 files changed, 123 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a1cfd39ce..fb4289b220 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4602,6 +4602,7 @@ dependencies = [ "js-sys", "log", "ruff_db", + "ruff_diagnostics", "ruff_notebook", "ruff_python_formatter", "ruff_source_file", diff --git a/crates/ty_wasm/Cargo.toml b/crates/ty_wasm/Cargo.toml index 4ce9913eda..770042e501 100644 --- a/crates/ty_wasm/Cargo.toml +++ b/crates/ty_wasm/Cargo.toml @@ -27,6 +27,7 @@ ty_project = { workspace = true, default-features = false, features = [ ty_python_semantic = { workspace = true } ruff_db = { workspace = true, default-features = false, features = [] } +ruff_diagnostics = { workspace = true } ruff_notebook = { workspace = true } ruff_python_formatter = { workspace = true } ruff_source_file = { workspace = true } diff --git a/crates/ty_wasm/src/lib.rs b/crates/ty_wasm/src/lib.rs index 3faf75a4d5..8e05b5e15f 100644 --- a/crates/ty_wasm/src/lib.rs +++ b/crates/ty_wasm/src/lib.rs @@ -11,6 +11,7 @@ use ruff_db::system::{ SystemPath, SystemPathBuf, SystemVirtualPath, WritableSystem, }; use ruff_db::vendored::VendoredPath; +use ruff_diagnostics::Applicability; use ruff_notebook::Notebook; use ruff_python_formatter::formatted_file; use ruff_source_file::{LineIndex, OneIndexed, SourceLocation}; @@ -732,6 +733,53 @@ impl Diagnostic { .to_string() .into() } + + /// Returns the code action for this diagnostic, if it has a fix. + #[wasm_bindgen(js_name = "codeAction")] + pub fn code_action(&self, workspace: &Workspace) -> Option { + let fix = self + .inner + .fix() + .filter(|fix| fix.applies(Applicability::Unsafe))?; + + let primary_span = self.inner.primary_span()?; + let file = primary_span.expect_ty_file(); + + let source = source_text(&workspace.db, file); + let index = line_index(&workspace.db, file); + + let edits: Vec = fix + .edits() + .iter() + .map(|edit| TextEdit { + range: Range::from_text_range( + edit.range(), + &index, + &source, + workspace.position_encoding, + ), + new_text: edit.content().unwrap_or_default().to_string(), + }) + .collect(); + + let title = self + .inner + .first_help_text() + .map(ToString::to_string) + .unwrap_or_else(|| format!("Fix {}", self.inner.id())); + + Some(CodeAction { title, edits }) + } +} + +/// A code action that can be applied to fix a diagnostic. +#[wasm_bindgen] +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct CodeAction { + #[wasm_bindgen(getter_with_clone)] + pub title: String, + #[wasm_bindgen(getter_with_clone)] + pub edits: Vec, } #[wasm_bindgen] diff --git a/playground/ty/src/Editor/Chrome.tsx b/playground/ty/src/Editor/Chrome.tsx index 437b11d18a..737228d5da 100644 --- a/playground/ty/src/Editor/Chrome.tsx +++ b/playground/ty/src/Editor/Chrome.tsx @@ -355,6 +355,7 @@ function useCheckResult( severity: diagnostic.severity(), range: diagnostic.toRange(workspace) ?? null, textRange: diagnostic.textRange() ?? null, + raw: diagnostic, })); return { diff --git a/playground/ty/src/Editor/Diagnostics.tsx b/playground/ty/src/Editor/Diagnostics.tsx index c1a395d2a1..654b53c88d 100644 --- a/playground/ty/src/Editor/Diagnostics.tsx +++ b/playground/ty/src/Editor/Diagnostics.tsx @@ -1,4 +1,9 @@ -import type { Severity, Range, TextRange } from "ty_wasm"; +import type { + Severity, + Range, + TextRange, + Diagnostic as TyDiagnostic, +} from "ty_wasm"; import classNames from "classnames"; import { Theme } from "shared"; import { useMemo } from "react"; @@ -103,4 +108,5 @@ export interface Diagnostic { severity: Severity; range: Range | null; textRange: TextRange | null; + raw: TyDiagnostic; } diff --git a/playground/ty/src/Editor/Editor.tsx b/playground/ty/src/Editor/Editor.tsx index ed1efd9042..5fd899b19b 100644 --- a/playground/ty/src/Editor/Editor.tsx +++ b/playground/ty/src/Editor/Editor.tsx @@ -189,8 +189,11 @@ class PlaygroundServer languages.DocumentSemanticTokensProvider, languages.DocumentRangeSemanticTokensProvider, languages.SignatureHelpProvider, - languages.DocumentHighlightProvider + languages.DocumentHighlightProvider, + languages.CodeActionProvider { + private diagnostics: Diagnostic[] = []; + private typeDefinitionProviderDisposable: IDisposable; private declarationProviderDisposable: IDisposable; private definitionProviderDisposable: IDisposable; @@ -204,6 +207,7 @@ class PlaygroundServer private rangeSemanticTokensDisposable: IDisposable; private signatureHelpDisposable: IDisposable; private documentHighlightDisposable: IDisposable; + private codeActionDisposable: IDisposable; private inVendoredFileCondition: editor.IContextKey; // Cache for vendored file handles private vendoredFileHandles = new Map(); @@ -253,6 +257,10 @@ class PlaygroundServer monaco.languages.registerSignatureHelpProvider("python", this); this.documentHighlightDisposable = monaco.languages.registerDocumentHighlightProvider("python", this); + this.codeActionDisposable = monaco.languages.registerCodeActionProvider( + "python", + this, + ); this.inVendoredFileCondition = editor.createContextKey( "inVendoredFile", @@ -534,6 +542,8 @@ class PlaygroundServer } updateDiagnostics(diagnostics: Array) { + this.diagnostics = diagnostics; + if (this.props.files.selected == null) { return; } @@ -584,6 +594,59 @@ class PlaygroundServer ); } + provideCodeActions( + model: editor.ITextModel, + range: Range, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _context: languages.CodeActionContext, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _token: CancellationToken, + ): languages.ProviderResult { + const actions: languages.CodeAction[] = []; + + for (const diagnostic of this.diagnostics) { + const diagnosticRange = diagnostic.range; + if (diagnosticRange == null) { + continue; + } + + const monacoRange = tyRangeToMonacoRange(diagnosticRange); + if (!Range.areIntersecting(range, monacoRange)) { + continue; + } + + const codeAction = diagnostic.raw.codeAction(this.props.workspace); + if (codeAction == null) { + continue; + } + + actions.push({ + title: codeAction.title, + kind: "quickfix", + isPreferred: true, + edit: { + edits: codeAction.edits.map((edit) => ({ + resource: model.uri, + textEdit: { + range: tyRangeToMonacoRange(edit.range), + text: edit.new_text, + }, + versionId: model.getVersionId(), + })), + }, + }); + } + + if (actions.length === 0) { + return undefined; + } + + return { + actions, + dispose: () => {}, + }; + } + provideHover( model: editor.ITextModel, position: Position, @@ -836,6 +899,7 @@ class PlaygroundServer this.completionDisposable.dispose(); this.signatureHelpDisposable.dispose(); this.documentHighlightDisposable.dispose(); + this.codeActionDisposable.dispose(); } } From 7c7f8d1a174dc895c0feb5f9c46ca4c4992cc2bc Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Thu, 27 Nov 2025 13:29:11 +0100 Subject: [PATCH 05/67] [ty] Make inlay hint clickable in playground (#21656) --- crates/ty_wasm/src/lib.rs | 16 ++++++++++++++++ playground/ty/src/Editor/Editor.tsx | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/crates/ty_wasm/src/lib.rs b/crates/ty_wasm/src/lib.rs index 8e05b5e15f..a1ecb73062 100644 --- a/crates/ty_wasm/src/lib.rs +++ b/crates/ty_wasm/src/lib.rs @@ -493,6 +493,19 @@ impl Workspace { self.position_encoding, ), kind: hint.kind.into(), + text_edits: hint + .text_edits + .into_iter() + .map(|edit| TextEdit { + range: Range::from_text_range( + edit.range, + &index, + &source, + self.position_encoding, + ), + new_text: edit.new_text, + }) + .collect(), }) .collect()) } @@ -1110,6 +1123,9 @@ pub struct InlayHint { pub position: Position, pub kind: InlayHintKind, + + #[wasm_bindgen(getter_with_clone)] + pub text_edits: Vec, } #[wasm_bindgen] diff --git a/playground/ty/src/Editor/Editor.tsx b/playground/ty/src/Editor/Editor.tsx index 5fd899b19b..9b694bb829 100644 --- a/playground/ty/src/Editor/Editor.tsx +++ b/playground/ty/src/Editor/Editor.tsx @@ -463,6 +463,10 @@ class PlaygroundServer column: hint.position.column, }, kind: mapInlayHintKind(hint.kind), + textEdits: hint.text_edits.map((edit: TextEdit) => ({ + range: tyRangeToMonacoRange(edit.range), + text: edit.new_text, + })), })), }; } From 77f8fa6906058b935eca7ae78c29322431abb377 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Thu, 27 Nov 2025 04:44:28 -0800 Subject: [PATCH 06/67] [ty] more precise inference for a failed specialization (#21651) ## Summary Previously if an explicit specialization failed (e.g. wrong number of type arguments or violates an upper bound) we just inferred `Unknown` for the entire type. This actually caused us to panic on an a case of a recursive upper bound with invalid specialization; the upper bound would oscillate indefinitely in fixpoint iteration between `Unknown` and the given specialization. This could be fixed with a cycle recovery function, but in this case there's a simpler fix: if we infer `C[Unknown]` instead of `Unknown` for an invalid attempt to specialize `C`, that allows fixpoint iteration to quickly converge, as well as giving a more precise type inference. Other type checkers actually just go with the attempted specialization even if it's invalid. So if `C` has a type parameter with upper bound `int`, and you say `C[str]`, they'll emit a diagnostic but just go with `C[str]`. Even weirder, if `C` has a single type parameter and you say `C[str, bytes]`, they'll just go with `C[str]` as the type. I'm not convinced by this approach; it seems odd to have specializations floating around that explicitly violate the declared upper bound, or in the latter case aren't even the specialization the annotation requested. I prefer `C[Unknown]` for this case. Fixing this revealed an issue with `collections.namedtuple`, which returns `type[tuple[Any, ...]]`. Due to https://github.com/astral-sh/ty/issues/1649 we consider that to be an invalid specialization. So previously we returned `Unknown`; after this PR it would be `type[tuple[Unknown]]`, leading to more false positives from our lack of functional namedtuple support. To avoid that I added an explicit Todo type for functional namedtuples for now. ## Test Plan Added and updated mdtests. The conformance suite changes have to do with `ParamSpec`, so no meaningful signal there. The ecosystem changes appear to be the expected effects of having more precise type information (including occurrences of known issues such as https://github.com/astral-sh/ty/issues/1495 ). Most effects are just changes to types in diagnostics. --- crates/ruff_benchmark/benches/ty_walltime.rs | 2 +- .../ty_python_semantic/resources/mdtest/cycle.md | 16 ---------------- .../resources/mdtest/generics/legacy/classes.md | 8 ++++---- .../mdtest/generics/legacy/variables.md | 16 ++++++++++++++++ .../resources/mdtest/generics/pep695/aliases.md | 8 ++++---- .../resources/mdtest/generics/pep695/classes.md | 8 ++++---- .../mdtest/generics/pep695/variables.md | 12 ++++++++++++ .../resources/mdtest/typed_dict.md | 2 +- crates/ty_python_semantic/src/types/call/bind.rs | 7 ++++++- crates/ty_python_semantic/src/types/function.rs | 5 +++++ .../src/types/infer/builder.rs | 6 +++++- 11 files changed, 58 insertions(+), 32 deletions(-) diff --git a/crates/ruff_benchmark/benches/ty_walltime.rs b/crates/ruff_benchmark/benches/ty_walltime.rs index 9abd6c7c83..6c8e89de0c 100644 --- a/crates/ruff_benchmark/benches/ty_walltime.rs +++ b/crates/ruff_benchmark/benches/ty_walltime.rs @@ -223,7 +223,7 @@ static STATIC_FRAME: Benchmark = Benchmark::new( max_dep_date: "2025-08-09", python_version: PythonVersion::PY311, }, - 900, + 950, ); #[track_caller] diff --git a/crates/ty_python_semantic/resources/mdtest/cycle.md b/crates/ty_python_semantic/resources/mdtest/cycle.md index 30d8e9554a..145b7ee249 100644 --- a/crates/ty_python_semantic/resources/mdtest/cycle.md +++ b/crates/ty_python_semantic/resources/mdtest/cycle.md @@ -63,22 +63,6 @@ B = TypeVar("B", bound="Base") class Base(Generic[B]): pass - -T = TypeVar("T", bound="Foo[int]") - -class Foo(Generic[T]): ... -``` - -## Self-referential PEP-695 type variables - -```toml -[environment] -python-version = "3.12" -``` - -```py -class Node[T: "Node[int]"]: - pass ``` ## Parameter default values diff --git a/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md b/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md index 66f39a3aa4..755fa3237c 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md @@ -146,7 +146,7 @@ The specialization must match the generic types: ```py # error: [invalid-type-arguments] "Too many type arguments to class `C`: expected 1, got 2" -reveal_type(C[int, int]()) # revealed: Unknown +reveal_type(C[int, int]()) # revealed: C[Unknown] ``` If the type variable has an upper bound, the specialized type must satisfy that bound: @@ -165,10 +165,10 @@ reveal_type(Bounded[int]()) # revealed: Bounded[int] reveal_type(Bounded[IntSubclass]()) # revealed: Bounded[IntSubclass] # error: [invalid-type-arguments] "Type `str` is not assignable to upper bound `int` of type variable `BoundedT@Bounded`" -reveal_type(Bounded[str]()) # revealed: Unknown +reveal_type(Bounded[str]()) # revealed: Bounded[Unknown] # error: [invalid-type-arguments] "Type `int | str` is not assignable to upper bound `int` of type variable `BoundedT@Bounded`" -reveal_type(Bounded[int | str]()) # revealed: Unknown +reveal_type(Bounded[int | str]()) # revealed: Bounded[Unknown] reveal_type(BoundedByUnion[int]()) # revealed: BoundedByUnion[int] reveal_type(BoundedByUnion[IntSubclass]()) # revealed: BoundedByUnion[IntSubclass] @@ -196,7 +196,7 @@ reveal_type(Constrained[str]()) # revealed: Constrained[str] reveal_type(Constrained[int | str]()) # revealed: Constrained[int | str] # error: [invalid-type-arguments] "Type `object` does not satisfy constraints `int`, `str` of type variable `ConstrainedT@Constrained`" -reveal_type(Constrained[object]()) # revealed: Unknown +reveal_type(Constrained[object]()) # revealed: Constrained[Unknown] ``` If the type variable has a default, it can be omitted: diff --git a/crates/ty_python_semantic/resources/mdtest/generics/legacy/variables.md b/crates/ty_python_semantic/resources/mdtest/generics/legacy/variables.md index f2789bac94..5485fe4477 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/legacy/variables.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/legacy/variables.md @@ -444,6 +444,22 @@ class G(Generic[T]): reveal_type(G[list[G]]().x) # revealed: list[G[Unknown]] ``` +An invalid specialization in a recursive bound doesn't cause a panic: + +```py +from typing import TypeVar, Generic + +# error: [invalid-type-arguments] +T = TypeVar("T", bound="Node[int]") + +class Node(Generic[T]): + pass + +# error: [invalid-type-arguments] +def _(n: Node[str]): + reveal_type(n) # revealed: Node[Unknown] +``` + ### Defaults ```toml diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md index 50df561dbc..57fc838498 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md @@ -62,7 +62,7 @@ The specialization must match the generic types: ```py # error: [invalid-type-arguments] "Too many type arguments: expected 1, got 2" -reveal_type(C[int, int]) # revealed: Unknown +reveal_type(C[int, int]) # revealed: C[Unknown] ``` And non-generic types cannot be specialized: @@ -89,10 +89,10 @@ reveal_type(Bounded[int]) # revealed: Bounded[int] reveal_type(Bounded[IntSubclass]) # revealed: Bounded[IntSubclass] # error: [invalid-type-arguments] "Type `str` is not assignable to upper bound `int` of type variable `T@Bounded`" -reveal_type(Bounded[str]) # revealed: Unknown +reveal_type(Bounded[str]) # revealed: Bounded[Unknown] # error: [invalid-type-arguments] "Type `int | str` is not assignable to upper bound `int` of type variable `T@Bounded`" -reveal_type(Bounded[int | str]) # revealed: Unknown +reveal_type(Bounded[int | str]) # revealed: Bounded[Unknown] reveal_type(BoundedByUnion[int]) # revealed: BoundedByUnion[int] reveal_type(BoundedByUnion[IntSubclass]) # revealed: BoundedByUnion[IntSubclass] @@ -118,7 +118,7 @@ reveal_type(Constrained[str]) # revealed: Constrained[str] reveal_type(Constrained[int | str]) # revealed: Constrained[int | str] # error: [invalid-type-arguments] "Type `object` does not satisfy constraints `int`, `str` of type variable `T@Constrained`" -reveal_type(Constrained[object]) # revealed: Unknown +reveal_type(Constrained[object]) # revealed: Constrained[Unknown] ``` If the type variable has a default, it can be omitted: diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md index 418596b083..7a997dd3e4 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md @@ -136,7 +136,7 @@ The specialization must match the generic types: ```py # error: [invalid-type-arguments] "Too many type arguments to class `C`: expected 1, got 2" -reveal_type(C[int, int]()) # revealed: Unknown +reveal_type(C[int, int]()) # revealed: C[Unknown] ``` If the type variable has an upper bound, the specialized type must satisfy that bound: @@ -150,10 +150,10 @@ reveal_type(Bounded[int]()) # revealed: Bounded[int] reveal_type(Bounded[IntSubclass]()) # revealed: Bounded[IntSubclass] # error: [invalid-type-arguments] "Type `str` is not assignable to upper bound `int` of type variable `T@Bounded`" -reveal_type(Bounded[str]()) # revealed: Unknown +reveal_type(Bounded[str]()) # revealed: Bounded[Unknown] # error: [invalid-type-arguments] "Type `int | str` is not assignable to upper bound `int` of type variable `T@Bounded`" -reveal_type(Bounded[int | str]()) # revealed: Unknown +reveal_type(Bounded[int | str]()) # revealed: Bounded[Unknown] reveal_type(BoundedByUnion[int]()) # revealed: BoundedByUnion[int] reveal_type(BoundedByUnion[IntSubclass]()) # revealed: BoundedByUnion[IntSubclass] @@ -179,7 +179,7 @@ reveal_type(Constrained[str]()) # revealed: Constrained[str] reveal_type(Constrained[int | str]()) # revealed: Constrained[int | str] # error: [invalid-type-arguments] "Type `object` does not satisfy constraints `int`, `str` of type variable `T@Constrained`" -reveal_type(Constrained[object]()) # revealed: Unknown +reveal_type(Constrained[object]()) # revealed: Constrained[Unknown] ``` If the type variable has a default, it can be omitted: diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/variables.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/variables.md index 887b198312..6c13dc559b 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/pep695/variables.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/variables.md @@ -834,6 +834,18 @@ class G[T: list[G]]: reveal_type(G[list[G]]().x) # revealed: list[G[Unknown]] ``` +An invalid specialization in a recursive bound doesn't cause a panic: + +```py +# error: [invalid-type-arguments] +class Node[T: "Node[int]"]: + pass + +# error: [invalid-type-arguments] +def _(n: Node[str]): + reveal_type(n) # revealed: Node[Unknown] +``` + ### Defaults Defaults can be generic, but can only refer to earlier typevars: diff --git a/crates/ty_python_semantic/resources/mdtest/typed_dict.md b/crates/ty_python_semantic/resources/mdtest/typed_dict.md index 06d70dcd02..c843150d41 100644 --- a/crates/ty_python_semantic/resources/mdtest/typed_dict.md +++ b/crates/ty_python_semantic/resources/mdtest/typed_dict.md @@ -1397,7 +1397,7 @@ msg = Message(id=1, content="Hello") # No errors for yet-unsupported features (`closed`): OtherMessage = TypedDict("OtherMessage", {"id": int, "content": str}, closed=True) -reveal_type(Message.__required_keys__) # revealed: @Todo(Support for `TypedDict`) +reveal_type(Message.__required_keys__) # revealed: @Todo(Support for functional `TypedDict`) # TODO: this should be an error msg.content diff --git a/crates/ty_python_semantic/src/types/call/bind.rs b/crates/ty_python_semantic/src/types/call/bind.rs index 2d4b284be1..dce0c5b7eb 100644 --- a/crates/ty_python_semantic/src/types/call/bind.rs +++ b/crates/ty_python_semantic/src/types/call/bind.rs @@ -1118,6 +1118,11 @@ impl<'db> Bindings<'db> { } } + Some(KnownFunction::NamedTuple) => { + overload + .set_return_type(todo_type!("Support for functional `namedtuple`")); + } + _ => { // Ideally, either the implementation, or exactly one of the overloads // of the function can have the dataclass_transform decorator applied. @@ -1350,7 +1355,7 @@ impl<'db> Bindings<'db> { }, Type::SpecialForm(SpecialFormType::TypedDict) => { - overload.set_return_type(todo_type!("Support for `TypedDict`")); + overload.set_return_type(todo_type!("Support for functional `TypedDict`")); } // Not a special case diff --git a/crates/ty_python_semantic/src/types/function.rs b/crates/ty_python_semantic/src/types/function.rs index 3c440ba2a2..262868b7b5 100644 --- a/crates/ty_python_semantic/src/types/function.rs +++ b/crates/ty_python_semantic/src/types/function.rs @@ -1230,6 +1230,9 @@ pub enum KnownFunction { /// `builtins.__import__`, which returns the top-level module. #[strum(serialize = "__import__")] DunderImport, + /// `collections.namedtuple` + #[strum(serialize = "namedtuple")] + NamedTuple, /// `importlib.import_module`, which returns the submodule. ImportModule, /// `typing(_extensions).final` @@ -1370,6 +1373,7 @@ impl KnownFunction { Self::ImportModule => module.is_importlib(), Self::TypeCheckOnly => matches!(module, KnownModule::Typing), + Self::NamedTuple => matches!(module, KnownModule::Collections), } } @@ -1902,6 +1906,7 @@ pub(crate) mod tests { | KnownFunction::AllMembers => KnownModule::TyExtensions, KnownFunction::ImportModule => KnownModule::ImportLib, + KnownFunction::NamedTuple => KnownModule::Collections, }; let function_definition = known_module_symbol(&db, module, function_name) diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index 229a872bc2..b8005da421 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -11384,7 +11384,11 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { } if has_error { - return Type::unknown(); + let unknowns = generic_context + .variables(self.db()) + .map(|_| Some(Type::unknown())) + .collect::>(); + return specialize(&unknowns); } specialize(&specialization_types) From a7d48ffd40e0443c17e704435a283eb173284acb Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 27 Nov 2025 12:48:18 +0000 Subject: [PATCH 07/67] [ty] Add subdiagnostic hint if a variable with type `Never` is used in a type expression (#21660) --- ...ver`-inferred_var…_(6ce5aa6d2a0ce029).snap | 45 +++++++++++++++++++ .../resources/mdtest/unreachable.md | 32 +++++++++++++ crates/ty_python_semantic/src/types.rs | 14 +++--- 3 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 crates/ty_python_semantic/resources/mdtest/snapshots/unreachable.md_-_Unreachable_code_-_`Never`-inferred_var…_(6ce5aa6d2a0ce029).snap diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/unreachable.md_-_Unreachable_code_-_`Never`-inferred_var…_(6ce5aa6d2a0ce029).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/unreachable.md_-_Unreachable_code_-_`Never`-inferred_var…_(6ce5aa6d2a0ce029).snap new file mode 100644 index 0000000000..aa86b9cbef --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/unreachable.md_-_Unreachable_code_-_`Never`-inferred_var…_(6ce5aa6d2a0ce029).snap @@ -0,0 +1,45 @@ +--- +source: crates/ty_test/src/lib.rs +expression: snapshot +--- +--- +mdtest name: unreachable.md - Unreachable code - `Never`-inferred variables in type expressions +mdtest path: crates/ty_python_semantic/resources/mdtest/unreachable.md +--- + +# Python source files + +## module.py + +``` +1 | import sys +2 | +3 | if sys.version_info >= (3, 14): +4 | raise RuntimeError("this library doesn't support 3.14 yet!!!") +5 | +6 | class AwesomeAPI: ... +``` + +## main.py + +``` +1 | import module +2 | +3 | def f(x: module.AwesomeAPI): ... # error: [invalid-type-form] +``` + +# Diagnostics + +``` +error[invalid-type-form]: Variable of type `Never` is not allowed in a type expression + --> src/main.py:3:10 + | +1 | import module +2 | +3 | def f(x: module.AwesomeAPI): ... # error: [invalid-type-form] + | ^^^^^^^^^^^^^^^^^ + | +help: The variable may have been inferred as `Never` because its definition was inferred as being unreachable +info: rule `invalid-type-form` is enabled by default + +``` diff --git a/crates/ty_python_semantic/resources/mdtest/unreachable.md b/crates/ty_python_semantic/resources/mdtest/unreachable.md index 73e174f6a1..9ff84162ac 100644 --- a/crates/ty_python_semantic/resources/mdtest/unreachable.md +++ b/crates/ty_python_semantic/resources/mdtest/unreachable.md @@ -581,3 +581,35 @@ if False: 1 / number ``` + +## `Never`-inferred variables in type expressions + +We offer a helpful subdiagnostic if a variable in a type expression is inferred as having type +`Never`, since this almost certainly resulted in the definition of the type being inferred by ty as +being unreachable: + + + +```toml +[environment] +python-version = "3.14" +``` + +`module.py`: + +```py +import sys + +if sys.version_info >= (3, 14): + raise RuntimeError("this library doesn't support 3.14 yet!!!") + +class AwesomeAPI: ... +``` + +`main.py`: + +```py +import module + +def f(x: module.AwesomeAPI): ... # error: [invalid-type-form] +``` diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index c6b6c540f5..d31e8ce21a 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -8879,11 +8879,15 @@ impl<'db> InvalidTypeExpression<'db> { } fn add_subdiagnostics(self, db: &'db dyn Db, mut diagnostic: LintDiagnosticGuard) { - if let InvalidTypeExpression::InvalidType(ty, scope) = self { - let Type::ModuleLiteral(module_type) = ty else { - return; - }; - let module = module_type.module(db); + if let InvalidTypeExpression::InvalidType(Type::Never, _) = self { + diagnostic.help( + "The variable may have been inferred as `Never` because \ + its definition was inferred as being unreachable", + ); + } else if let InvalidTypeExpression::InvalidType(ty @ Type::ModuleLiteral(module), scope) = + self + { + let module = module.module(db); let Some(module_name_final_part) = module.name(db).components().next_back() else { return; }; From e5818d89fd435d63a526d0988876b6160f44f854 Mon Sep 17 00:00:00 2001 From: Aria Desires Date: Thu, 27 Nov 2025 10:06:38 -0500 Subject: [PATCH 08/67] [ty] Add "import ..." code-action for unresolved references (#21629) ## Summary Originally I planned to feed this in as a `fix` but I realized that we probably don't want to be trying to resolve import suggestions while we're doing type inference. Thus I implemented this as a fallback when there's no fixes on a diagnostic, which can use the full lsp machinery. Fixes https://github.com/astral-sh/ty/issues/1552 ## Test Plan Works in the IDE, added some e2e tests. --- crates/ty_ide/src/all_symbols.rs | 2 +- crates/ty_ide/src/code_action.rs | 43 ++++ crates/ty_ide/src/completion.rs | 51 +++- crates/ty_ide/src/lib.rs | 2 + crates/ty_ide/src/symbols.rs | 22 +- crates/ty_ide/src/workspace_symbols.rs | 2 +- crates/ty_python_semantic/src/types.rs | 2 +- .../src/types/diagnostic.rs | 2 +- .../src/server/api/requests/code_action.rs | 126 +++++++--- crates/ty_server/tests/e2e/code_actions.rs | 233 +++++++++++++++--- ...action_attribute_access_on_unimported.snap | 5 + ..._possible_missing_submodule_attribute.snap | 5 + ...ions__code_action_undefined_decorator.snap | 98 ++++++++ ...code_action_undefined_reference_multi.snap | 98 ++++++++ crates/ty_wasm/src/lib.rs | 77 ++++-- playground/ty/src/Editor/Editor.tsx | 43 ++-- 16 files changed, 698 insertions(+), 113 deletions(-) create mode 100644 crates/ty_ide/src/code_action.rs create mode 100644 crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_attribute_access_on_unimported.snap create mode 100644 crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_possible_missing_submodule_attribute.snap create mode 100644 crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_decorator.snap create mode 100644 crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_reference_multi.snap diff --git a/crates/ty_ide/src/all_symbols.rs b/crates/ty_ide/src/all_symbols.rs index fb8d49191b..46fff1593b 100644 --- a/crates/ty_ide/src/all_symbols.rs +++ b/crates/ty_ide/src/all_symbols.rs @@ -143,7 +143,7 @@ ABCDEFGHIJKLMNOP = 'https://api.example.com' impl CursorTest { fn all_symbols(&self, query: &str) -> String { - let symbols = all_symbols(&self.db, &QueryPattern::new(query)); + let symbols = all_symbols(&self.db, &QueryPattern::fuzzy(query)); if symbols.is_empty() { return "No symbols found".to_string(); diff --git a/crates/ty_ide/src/code_action.rs b/crates/ty_ide/src/code_action.rs new file mode 100644 index 0000000000..947c7481ef --- /dev/null +++ b/crates/ty_ide/src/code_action.rs @@ -0,0 +1,43 @@ +use crate::{completion, find_node::covering_node}; +use ruff_db::{files::File, parsed::parsed_module}; +use ruff_diagnostics::Edit; +use ruff_text_size::TextRange; +use ty_project::Db; +use ty_python_semantic::types::UNRESOLVED_REFERENCE; + +/// A `QuickFix` Code Action +#[derive(Debug, Clone)] +pub struct QuickFix { + pub title: String, + pub edits: Vec, + pub preferred: bool, +} + +pub fn code_actions( + db: &dyn Db, + file: File, + diagnostic_range: TextRange, + diagnostic_id: &str, +) -> Option> { + let registry = db.lint_registry(); + let Ok(lint_id) = registry.get(diagnostic_id) else { + return None; + }; + if lint_id.name() == UNRESOLVED_REFERENCE.name() { + let parsed = parsed_module(db, file).load(db); + let node = covering_node(parsed.syntax().into(), diagnostic_range).node(); + let symbol = &node.expr_name()?.id; + + let fixes = completion::missing_imports(db, file, &parsed, symbol, node) + .into_iter() + .map(|import| QuickFix { + title: import.label, + edits: vec![import.edit], + preferred: true, + }) + .collect(); + Some(fixes) + } else { + None + } +} diff --git a/crates/ty_ide/src/completion.rs b/crates/ty_ide/src/completion.rs index 03ef65f14a..9e1233cce1 100644 --- a/crates/ty_ide/src/completion.rs +++ b/crates/ty_ide/src/completion.rs @@ -4,8 +4,8 @@ use ruff_db::files::File; use ruff_db::parsed::{ParsedModuleRef, parsed_module}; use ruff_db::source::source_text; use ruff_diagnostics::Edit; -use ruff_python_ast as ast; use ruff_python_ast::name::Name; +use ruff_python_ast::{self as ast, AnyNodeRef}; use ruff_python_codegen::Stylist; use ruff_python_parser::{Token, TokenAt, TokenKind, Tokens}; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; @@ -37,9 +37,9 @@ impl<'db> Completions<'db> { /// the user has typed as part of the next symbol they are writing. /// This collection will treat it as a query when present, and only /// add completions that match it. - fn new(db: &'db dyn Db, typed: Option<&str>) -> Completions<'db> { + fn fuzzy(db: &'db dyn Db, typed: Option<&str>) -> Completions<'db> { let query = typed - .map(QueryPattern::new) + .map(QueryPattern::fuzzy) .unwrap_or_else(QueryPattern::matches_all_symbols); Completions { db, @@ -48,6 +48,15 @@ impl<'db> Completions<'db> { } } + fn exactly(db: &'db dyn Db, symbol: &str) -> Completions<'db> { + let query = QueryPattern::exactly(symbol); + Completions { + db, + items: vec![], + query, + } + } + /// Convert this collection into a simple /// sequence of completions. fn into_completions(mut self) -> Vec> { @@ -57,6 +66,21 @@ impl<'db> Completions<'db> { self.items } + fn into_imports(mut self) -> Vec { + self.items.sort_by(compare_suggestions); + self.items + .dedup_by(|c1, c2| (&c1.name, c1.module_name) == (&c2.name, c2.module_name)); + self.items + .into_iter() + .filter_map(|item| { + Some(ImportEdit { + label: format!("import {}.{}", item.module_name?, item.name), + edit: item.import?, + }) + }) + .collect() + } + /// Attempts to adds the given completion to this collection. /// /// When added, `true` is returned. @@ -369,7 +393,7 @@ pub fn completion<'db>( return vec![]; } - let mut completions = Completions::new(db, typed.as_deref()); + let mut completions = Completions::fuzzy(db, typed.as_deref()); if let Some(import) = ImportStatement::detect(db, file, &parsed, tokens, typed.as_deref()) { import.add_completions(db, file, &mut completions); @@ -417,6 +441,25 @@ pub fn completion<'db>( completions.into_completions() } +pub(crate) struct ImportEdit { + pub label: String, + pub edit: Edit, +} + +pub(crate) fn missing_imports( + db: &dyn Db, + file: File, + parsed: &ParsedModuleRef, + symbol: &str, + node: AnyNodeRef, +) -> Vec { + let mut completions = Completions::exactly(db, symbol); + let scoped = ScopedTarget { node }; + add_unimported_completions(db, file, parsed, scoped, &mut completions); + + completions.into_imports() +} + /// Adds completions derived from keywords. /// /// This should generally only be used when offering "scoped" completions. diff --git a/crates/ty_ide/src/lib.rs b/crates/ty_ide/src/lib.rs index 664412f881..28e2eddc03 100644 --- a/crates/ty_ide/src/lib.rs +++ b/crates/ty_ide/src/lib.rs @@ -3,6 +3,7 @@ reason = "Prefer System trait methods over std methods in ty crates" )] mod all_symbols; +mod code_action; mod completion; mod doc_highlights; mod docstring; @@ -27,6 +28,7 @@ mod symbols; mod workspace_symbols; pub use all_symbols::{AllSymbolInfo, all_symbols}; +pub use code_action::{QuickFix, code_actions}; pub use completion::{Completion, CompletionKind, CompletionSettings, completion}; pub use doc_highlights::document_highlights; pub use document_symbols::document_symbols; diff --git a/crates/ty_ide/src/symbols.rs b/crates/ty_ide/src/symbols.rs index c9e9856789..01b177619e 100644 --- a/crates/ty_ide/src/symbols.rs +++ b/crates/ty_ide/src/symbols.rs @@ -23,11 +23,12 @@ use crate::completion::CompletionKind; pub struct QueryPattern { re: Option, original: String, + original_is_exact: bool, } impl QueryPattern { /// Create a new query pattern from a literal search string given. - pub fn new(literal_query_string: &str) -> QueryPattern { + pub fn fuzzy(literal_query_string: &str) -> QueryPattern { let mut pattern = "(?i)".to_string(); for ch in literal_query_string.chars() { pattern.push_str(®ex::escape(ch.encode_utf8(&mut [0; 4]))); @@ -41,6 +42,16 @@ impl QueryPattern { QueryPattern { re: Regex::new(&pattern).ok(), original: literal_query_string.to_string(), + original_is_exact: false, + } + } + + /// Create a new query + pub fn exactly(symbol: &str) -> QueryPattern { + QueryPattern { + re: None, + original: symbol.to_string(), + original_is_exact: true, } } @@ -49,6 +60,7 @@ impl QueryPattern { QueryPattern { re: None, original: String::new(), + original_is_exact: false, } } @@ -59,6 +71,8 @@ impl QueryPattern { pub fn is_match_symbol_name(&self, symbol_name: &str) -> bool { if let Some(ref re) = self.re { re.is_match(symbol_name) + } else if self.original_is_exact { + symbol_name == self.original } else { // This is a degenerate case. The only way // we should get here is if the query string @@ -75,13 +89,13 @@ impl QueryPattern { /// incorrectly. That is, it's possible that this query will match all /// inputs but this still returns `false`. pub fn will_match_everything(&self) -> bool { - self.re.is_none() + self.re.is_none() && self.original.is_empty() } } impl From<&str> for QueryPattern { fn from(literal_query_string: &str) -> QueryPattern { - QueryPattern::new(literal_query_string) + QueryPattern::fuzzy(literal_query_string) } } @@ -565,7 +579,7 @@ impl SourceOrderVisitor<'_> for SymbolVisitor { #[cfg(test)] mod tests { fn matches(query: &str, symbol: &str) -> bool { - super::QueryPattern::new(query).is_match_symbol_name(symbol) + super::QueryPattern::fuzzy(query).is_match_symbol_name(symbol) } #[test] diff --git a/crates/ty_ide/src/workspace_symbols.rs b/crates/ty_ide/src/workspace_symbols.rs index 9d490bd700..a9e5e78820 100644 --- a/crates/ty_ide/src/workspace_symbols.rs +++ b/crates/ty_ide/src/workspace_symbols.rs @@ -12,7 +12,7 @@ pub fn workspace_symbols(db: &dyn Db, query: &str) -> Vec { let project = db.project(); - let query = QueryPattern::new(query); + let query = QueryPattern::fuzzy(query); let files = project.files(db); let results = std::sync::Mutex::new(Vec::new()); { diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index d31e8ce21a..998a8dd134 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -24,7 +24,7 @@ pub(crate) use self::builder::{IntersectionBuilder, UnionBuilder}; pub use self::cyclic::CycleDetector; pub(crate) use self::cyclic::{PairVisitor, TypeTransformer}; pub(crate) use self::diagnostic::register_lints; -pub use self::diagnostic::{TypeCheckDiagnostics, UNDEFINED_REVEAL}; +pub use self::diagnostic::{TypeCheckDiagnostics, UNDEFINED_REVEAL, UNRESOLVED_REFERENCE}; pub(crate) use self::infer::{ TypeContext, infer_deferred_types, infer_definition_types, infer_expression_type, infer_expression_types, infer_scope_types, static_expression_truthiness, diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index 44b54d0c41..4e9c5b96df 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -1844,7 +1844,7 @@ declare_lint! { /// ```python /// print(x) # NameError: name 'x' is not defined /// ``` - pub(crate) static UNRESOLVED_REFERENCE = { + pub static UNRESOLVED_REFERENCE = { summary: "detects references to names that are not defined", status: LintStatus::stable("0.0.1-alpha.1"), default_level: Level::Error, diff --git a/crates/ty_server/src/server/api/requests/code_action.rs b/crates/ty_server/src/server/api/requests/code_action.rs index fd7826d82a..6fac0d46f4 100644 --- a/crates/ty_server/src/server/api/requests/code_action.rs +++ b/crates/ty_server/src/server/api/requests/code_action.rs @@ -1,16 +1,23 @@ use std::borrow::Cow; +use std::collections::HashMap; -use lsp_types::{self as types, Url, request as req}; +use lsp_types::{self as types, NumberOrString, TextEdit, Url, request as req}; +use ruff_db::files::File; +use ruff_diagnostics::Edit; +use ruff_text_size::Ranged; +use ty_ide::code_actions; use ty_project::ProjectDatabase; use types::{CodeActionKind, CodeActionOrCommand}; -use crate::DIAGNOSTIC_NAME; +use crate::db::Db; +use crate::document::{RangeExt, ToRangeExt}; use crate::server::Result; use crate::server::api::RequestHandler; use crate::server::api::diagnostics::DiagnosticData; use crate::server::api::traits::{BackgroundDocumentRequestHandler, RetriableRequestHandler}; use crate::session::DocumentSnapshot; use crate::session::client::Client; +use crate::{DIAGNOSTIC_NAME, PositionEncoding}; pub(crate) struct CodeActionRequestHandler; @@ -24,55 +31,112 @@ impl BackgroundDocumentRequestHandler for CodeActionRequestHandler { } fn run_with_snapshot( - _db: &ProjectDatabase, - _snapshot: &DocumentSnapshot, + db: &ProjectDatabase, + snapshot: &DocumentSnapshot, _client: &Client, params: types::CodeActionParams, ) -> Result> { let diagnostics = params.context.diagnostics; + let Some(file) = snapshot.to_notebook_or_file(db) else { + return Ok(None); + }; let mut actions = Vec::new(); for mut diagnostic in diagnostics.into_iter().filter(|diagnostic| { diagnostic.source.as_deref() == Some(DIAGNOSTIC_NAME) && range_intersect(&diagnostic.range, ¶ms.range) }) { - let Some(data) = diagnostic.data.take() else { - continue; - }; + // If the diagnostic includes fixes, offer those up as options. + if let Some(data) = diagnostic.data.take() { + let data: DiagnosticData = match serde_json::from_value(data) { + Ok(data) => data, + Err(err) => { + tracing::warn!("Failed to deserialize diagnostic data: {err}"); + continue; + } + }; - let data: DiagnosticData = match serde_json::from_value(data) { - Ok(data) => data, - Err(err) => { - tracing::warn!("Failed to deserialize diagnostic data: {err}"); - continue; + actions.push(CodeActionOrCommand::CodeAction(lsp_types::CodeAction { + title: data.fix_title, + kind: Some(CodeActionKind::QUICKFIX), + diagnostics: Some(vec![diagnostic.clone()]), + edit: Some(lsp_types::WorkspaceEdit { + changes: Some(data.edits), + document_changes: None, + change_annotations: None, + }), + is_preferred: Some(true), + command: None, + disabled: None, + data: None, + })); + } + + // Try to find other applicable actions. + // + // This is only for actions that are messy to compute at the time of the diagnostic. + // For instance, suggesting imports requires finding symbols for the entire project, + // which is dubious when you're in the middle of resolving symbols. + let url = snapshot.url(); + let encoding = snapshot.encoding(); + if let Some(NumberOrString::String(diagnostic_id)) = &diagnostic.code + && let Some(range) = diagnostic.range.to_text_range(db, file, url, encoding) + && let Some(fixes) = code_actions(db, file, range, diagnostic_id) + { + for action in fixes { + actions.push(CodeActionOrCommand::CodeAction(lsp_types::CodeAction { + title: action.title, + kind: Some(CodeActionKind::QUICKFIX), + diagnostics: Some(vec![diagnostic.clone()]), + edit: Some(lsp_types::WorkspaceEdit { + changes: to_lsp_edits(db, file, encoding, action.edits), + document_changes: None, + change_annotations: None, + }), + is_preferred: Some(action.preferred), + command: None, + disabled: None, + data: None, + })); } - }; - - actions.push(CodeActionOrCommand::CodeAction(lsp_types::CodeAction { - title: data.fix_title, - kind: Some(CodeActionKind::QUICKFIX), - diagnostics: Some(vec![diagnostic]), - edit: Some(lsp_types::WorkspaceEdit { - changes: Some(data.edits), - document_changes: None, - change_annotations: None, - }), - is_preferred: Some(true), - command: None, - disabled: None, - data: None, - })); + } } if actions.is_empty() { - return Ok(None); + Ok(None) + } else { + Ok(Some(actions)) } - - Ok(Some(actions)) } } +fn to_lsp_edits( + db: &dyn Db, + file: File, + encoding: PositionEncoding, + edits: Vec, +) -> Option>> { + let mut lsp_edits: HashMap> = HashMap::new(); + + for edit in edits { + let location = edit + .range() + .to_lsp_range(db, file, encoding)? + .to_location()?; + + lsp_edits + .entry(location.uri) + .or_default() + .push(lsp_types::TextEdit { + range: location.range, + new_text: edit.content().unwrap_or_default().to_string(), + }); + } + + Some(lsp_edits) +} + fn range_intersect(range: &lsp_types::Range, other: &lsp_types::Range) -> bool { let start = range.start.max(other.start); let end = range.end.min(other.end); diff --git a/crates/ty_server/tests/e2e/code_actions.rs b/crates/ty_server/tests/e2e/code_actions.rs index b33a5eb935..baee6c0b42 100644 --- a/crates/ty_server/tests/e2e/code_actions.rs +++ b/crates/ty_server/tests/e2e/code_actions.rs @@ -1,8 +1,47 @@ +use crate::{TestServer, TestServerBuilder}; use anyhow::Result; -use lsp_types::{Position, Range, request::CodeActionRequest}; +use lsp_types::{DocumentDiagnosticReportResult, Position, Range, request::CodeActionRequest}; use ruff_db::system::SystemPath; -use crate::TestServerBuilder; +fn code_actions_at( + server: &TestServer, + diagnostics: DocumentDiagnosticReportResult, + file: &SystemPath, + range: Range, +) -> lsp_types::CodeActionParams { + lsp_types::CodeActionParams { + text_document: lsp_types::TextDocumentIdentifier { + uri: server.file_uri(file), + }, + range, + context: lsp_types::CodeActionContext { + diagnostics: match diagnostics { + lsp_types::DocumentDiagnosticReportResult::Report( + lsp_types::DocumentDiagnosticReport::Full(report), + ) => report.full_document_diagnostic_report.items, + _ => panic!("Expected full diagnostic report"), + }, + only: None, + trigger_kind: None, + }, + work_done_progress_params: lsp_types::WorkDoneProgressParams::default(), + partial_result_params: lsp_types::PartialResultParams::default(), + } +} + +#[allow(clippy::cast_possible_truncation)] +fn full_range(input: &str) -> Range { + let (num_lines, last_line) = input + .lines() + .enumerate() + .last() + .expect("non-empty document"); + let last_char = last_line.len() as u32; + Range::new( + Position::new(0, 0), + Position::new(num_lines as u32, last_char), + ) +} #[test] fn code_action() -> Result<()> { @@ -30,27 +69,10 @@ unused-ignore-comment = \"warn\" // Wait for diagnostics to be computed. let diagnostics = server.document_diagnostic_request(foo, None); + let range = full_range(foo_content); + let code_action_params = code_actions_at(&server, diagnostics, foo, range); // Get code actions for the line with the unused ignore comment. - let code_action_params = lsp_types::CodeActionParams { - text_document: lsp_types::TextDocumentIdentifier { - uri: server.file_uri(foo), - }, - range: Range::new(Position::new(0, 0), Position::new(0, 43)), - context: lsp_types::CodeActionContext { - diagnostics: match diagnostics { - lsp_types::DocumentDiagnosticReportResult::Report( - lsp_types::DocumentDiagnosticReport::Full(report), - ) => report.full_document_diagnostic_report.items, - _ => panic!("Expected full diagnostic report"), - }, - only: None, - trigger_kind: None, - }, - work_done_progress_params: lsp_types::WorkDoneProgressParams::default(), - partial_result_params: lsp_types::PartialResultParams::default(), - }; - let code_action_id = server.send_request::(code_action_params); let code_actions = server.await_response::(&code_action_id); @@ -88,24 +110,8 @@ unused-ignore-comment = \"warn\" // Get code actions for a range that doesn't overlap with the diagnostic. // The diagnostic is at characters 12-42, so we request actions for characters 0-10. - let code_action_params = lsp_types::CodeActionParams { - text_document: lsp_types::TextDocumentIdentifier { - uri: server.file_uri(foo), - }, - range: Range::new(Position::new(0, 0), Position::new(0, 10)), - context: lsp_types::CodeActionContext { - diagnostics: match diagnostics { - lsp_types::DocumentDiagnosticReportResult::Report( - lsp_types::DocumentDiagnosticReport::Full(report), - ) => report.full_document_diagnostic_report.items, - _ => panic!("Expected full diagnostic report"), - }, - only: None, - trigger_kind: None, - }, - work_done_progress_params: lsp_types::WorkDoneProgressParams::default(), - partial_result_params: lsp_types::PartialResultParams::default(), - }; + let range = Range::new(Position::new(0, 0), Position::new(0, 10)); + let code_action_params = code_actions_at(&server, diagnostics, foo, range); let code_action_id = server.send_request::(code_action_params); let code_actions = server.await_response::(&code_action_id); @@ -115,3 +121,152 @@ unused-ignore-comment = \"warn\" Ok(()) } + +// `Literal` is available from two places so we should suggest two possible imports +#[test] +fn code_action_undefined_reference_multi() -> Result<()> { + let workspace_root = SystemPath::new("src"); + let foo = SystemPath::new("src/foo.py"); + let foo_content = "\ +x: Literal[1] = 1 +"; + + let ty_toml = SystemPath::new("ty.toml"); + let ty_toml_content = "\ +[rules] +unused-ignore-comment = \"warn\" +"; + + let mut server = TestServerBuilder::new()? + .with_workspace(workspace_root, None)? + .with_file(ty_toml, ty_toml_content)? + .with_file(foo, foo_content)? + .enable_pull_diagnostics(true) + .build() + .wait_until_workspaces_are_initialized(); + + server.open_text_document(foo, &foo_content, 1); + + // Wait for diagnostics to be computed. + let diagnostics = server.document_diagnostic_request(foo, None); + let range = full_range(foo_content); + let code_action_params = code_actions_at(&server, diagnostics, foo, range); + + // Get code actions + let code_action_id = server.send_request::(code_action_params); + let code_actions = server.await_response::(&code_action_id); + + insta::assert_json_snapshot!(code_actions); + + Ok(()) +} + +// Using an unimported decorator `@deprecated` +#[test] +fn code_action_undefined_decorator() -> Result<()> { + let workspace_root = SystemPath::new("src"); + let foo = SystemPath::new("src/foo.py"); + let foo_content = r#"\ +@deprecated("do not use!!!") +def my_func(): ... +"#; + + let ty_toml = SystemPath::new("ty.toml"); + let ty_toml_content = ""; + + let mut server = TestServerBuilder::new()? + .with_workspace(workspace_root, None)? + .with_file(ty_toml, ty_toml_content)? + .with_file(foo, foo_content)? + .enable_pull_diagnostics(true) + .build() + .wait_until_workspaces_are_initialized(); + + server.open_text_document(foo, &foo_content, 1); + + // Wait for diagnostics to be computed. + let diagnostics = server.document_diagnostic_request(foo, None); + let range = full_range(foo_content); + let code_action_params = code_actions_at(&server, diagnostics, foo, range); + + // Get code actions + let code_action_id = server.send_request::(code_action_params); + let code_actions = server.await_response::(&code_action_id); + + insta::assert_json_snapshot!(code_actions); + + Ok(()) +} + +// Accessing `typing.Literal` without `typing` imported (ideally we suggest importing `typing`) +#[test] +fn code_action_attribute_access_on_unimported() -> Result<()> { + let workspace_root = SystemPath::new("src"); + let foo = SystemPath::new("src/foo.py"); + let foo_content = "\ +x: typing.Literal[1] = 1 +"; + + let ty_toml = SystemPath::new("ty.toml"); + let ty_toml_content = ""; + + let mut server = TestServerBuilder::new()? + .with_workspace(workspace_root, None)? + .with_file(ty_toml, ty_toml_content)? + .with_file(foo, foo_content)? + .enable_pull_diagnostics(true) + .build() + .wait_until_workspaces_are_initialized(); + + server.open_text_document(foo, &foo_content, 1); + + // Wait for diagnostics to be computed. + let diagnostics = server.document_diagnostic_request(foo, None); + let range = full_range(foo_content); + let code_action_params = code_actions_at(&server, diagnostics, foo, range); + + // Get code actions + let code_action_id = server.send_request::(code_action_params); + let code_actions = server.await_response::(&code_action_id); + + insta::assert_json_snapshot!(code_actions); + + Ok(()) +} + +// Accessing `html.parser` when we've imported `html` but not `html.parser` +#[test] +fn code_action_possible_missing_submodule_attribute() -> Result<()> { + let workspace_root = SystemPath::new("src"); + let foo = SystemPath::new("src/foo.py"); + let foo_content = "\ +import html +html.parser +"; + + let ty_toml = SystemPath::new("ty.toml"); + let ty_toml_content = ""; + + let mut server = TestServerBuilder::new()? + .with_workspace(workspace_root, None)? + .with_file(ty_toml, ty_toml_content)? + .with_file(foo, foo_content)? + .enable_pull_diagnostics(true) + .build() + .wait_until_workspaces_are_initialized(); + + server.open_text_document(foo, &foo_content, 1); + + // Wait for diagnostics to be computed. + let diagnostics = server.document_diagnostic_request(foo, None); + let range = full_range(foo_content); + let code_action_params = code_actions_at(&server, diagnostics, foo, range); + + // Get code actions + let code_action_id = server.send_request::(code_action_params); + let code_actions = server.await_response::(&code_action_id); + + insta::assert_json_snapshot!(code_actions); + + Ok(()) +} diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_attribute_access_on_unimported.snap b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_attribute_access_on_unimported.snap new file mode 100644 index 0000000000..44f60e3707 --- /dev/null +++ b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_attribute_access_on_unimported.snap @@ -0,0 +1,5 @@ +--- +source: crates/ty_server/tests/e2e/code_actions.rs +expression: code_actions +--- +null diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_possible_missing_submodule_attribute.snap b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_possible_missing_submodule_attribute.snap new file mode 100644 index 0000000000..44f60e3707 --- /dev/null +++ b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_possible_missing_submodule_attribute.snap @@ -0,0 +1,5 @@ +--- +source: crates/ty_server/tests/e2e/code_actions.rs +expression: code_actions +--- +null diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_decorator.snap b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_decorator.snap new file mode 100644 index 0000000000..c60378f1d2 --- /dev/null +++ b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_decorator.snap @@ -0,0 +1,98 @@ +--- +source: crates/ty_server/tests/e2e/code_actions.rs +expression: code_actions +--- +[ + { + "title": "import typing_extensions.deprecated", + "kind": "quickfix", + "diagnostics": [ + { + "range": { + "start": { + "line": 1, + "character": 1 + }, + "end": { + "line": 1, + "character": 11 + } + }, + "severity": 1, + "code": "unresolved-reference", + "codeDescription": { + "href": "https://ty.dev/rules#unresolved-reference" + }, + "source": "ty", + "message": "Name `deprecated` used when not defined", + "relatedInformation": [] + } + ], + "edit": { + "changes": { + "file:///src/foo.py": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "from typing_extensions import deprecated\n" + } + ] + } + }, + "isPreferred": true + }, + { + "title": "import warnings.deprecated", + "kind": "quickfix", + "diagnostics": [ + { + "range": { + "start": { + "line": 1, + "character": 1 + }, + "end": { + "line": 1, + "character": 11 + } + }, + "severity": 1, + "code": "unresolved-reference", + "codeDescription": { + "href": "https://ty.dev/rules#unresolved-reference" + }, + "source": "ty", + "message": "Name `deprecated` used when not defined", + "relatedInformation": [] + } + ], + "edit": { + "changes": { + "file:///src/foo.py": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "from warnings import deprecated\n" + } + ] + } + }, + "isPreferred": true + } +] diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_reference_multi.snap b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_reference_multi.snap new file mode 100644 index 0000000000..940dd3794f --- /dev/null +++ b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_reference_multi.snap @@ -0,0 +1,98 @@ +--- +source: crates/ty_server/tests/e2e/code_actions.rs +expression: code_actions +--- +[ + { + "title": "import typing.Literal", + "kind": "quickfix", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 3 + }, + "end": { + "line": 0, + "character": 10 + } + }, + "severity": 1, + "code": "unresolved-reference", + "codeDescription": { + "href": "https://ty.dev/rules#unresolved-reference" + }, + "source": "ty", + "message": "Name `Literal` used when not defined", + "relatedInformation": [] + } + ], + "edit": { + "changes": { + "file:///src/foo.py": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "from typing import Literal\n" + } + ] + } + }, + "isPreferred": true + }, + { + "title": "import typing_extensions.Literal", + "kind": "quickfix", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 3 + }, + "end": { + "line": 0, + "character": 10 + } + }, + "severity": 1, + "code": "unresolved-reference", + "codeDescription": { + "href": "https://ty.dev/rules#unresolved-reference" + }, + "source": "ty", + "message": "Name `Literal` used when not defined", + "relatedInformation": [] + } + ], + "edit": { + "changes": { + "file:///src/foo.py": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "from typing_extensions import Literal\n" + } + ] + } + }, + "isPreferred": true + } +] diff --git a/crates/ty_wasm/src/lib.rs b/crates/ty_wasm/src/lib.rs index a1ecb73062..1930ba9399 100644 --- a/crates/ty_wasm/src/lib.rs +++ b/crates/ty_wasm/src/lib.rs @@ -11,7 +11,7 @@ use ruff_db::system::{ SystemPath, SystemPathBuf, SystemVirtualPath, WritableSystem, }; use ruff_db::vendored::VendoredPath; -use ruff_diagnostics::Applicability; +use ruff_diagnostics::{Applicability, Edit}; use ruff_notebook::Notebook; use ruff_python_formatter::formatted_file; use ruff_source_file::{LineIndex, OneIndexed, SourceLocation}; @@ -556,6 +556,51 @@ impl Workspace { Ok(result) } + #[wasm_bindgen(js_name = "codeActions")] + pub fn code_actions( + &self, + file_id: &FileHandle, + diagnostic: &Diagnostic, + ) -> Option> { + // If the diagnostic includes fixes, offer those up as options. + let mut actions = Vec::new(); + if let Some(action) = diagnostic.code_action(self) { + actions.push(action); + } + + // Try to find other applicable actions. + // + // This is only for actions that are messy to compute at the time of the diagnostic. + // For instance, suggesting imports requires finding symbols for the entire project, + // which is dubious when you're in the middle of resolving symbols. + if let Some(range) = diagnostic.inner.range() + && let Some(fixes) = ty_ide::code_actions( + &self.db, + file_id.file, + range, + diagnostic.inner.id().as_str(), + ) + { + for action in fixes { + actions.push(CodeAction { + title: action.title, + preferred: action.preferred, + edits: action + .edits + .into_iter() + .map(|edit| edit_to_text_edit(self, file_id.file, &edit)) + .collect(), + }); + } + } + + if actions.is_empty() { + None + } else { + Some(actions) + } + } + #[wasm_bindgen(js_name = "signatureHelp")] pub fn signature_help( &self, @@ -758,21 +803,10 @@ impl Diagnostic { let primary_span = self.inner.primary_span()?; let file = primary_span.expect_ty_file(); - let source = source_text(&workspace.db, file); - let index = line_index(&workspace.db, file); - let edits: Vec = fix .edits() .iter() - .map(|edit| TextEdit { - range: Range::from_text_range( - edit.range(), - &index, - &source, - workspace.position_encoding, - ), - new_text: edit.content().unwrap_or_default().to_string(), - }) + .map(|edit| edit_to_text_edit(workspace, file, edit)) .collect(); let title = self @@ -781,7 +815,21 @@ impl Diagnostic { .map(ToString::to_string) .unwrap_or_else(|| format!("Fix {}", self.inner.id())); - Some(CodeAction { title, edits }) + Some(CodeAction { + title, + edits, + preferred: true, + }) + } +} + +fn edit_to_text_edit(workspace: &Workspace, file: File, edit: &Edit) -> TextEdit { + let source = source_text(&workspace.db, file); + let index = line_index(&workspace.db, file); + + TextEdit { + range: Range::from_text_range(edit.range(), &index, &source, workspace.position_encoding), + new_text: edit.content().unwrap_or_default().to_string(), } } @@ -793,6 +841,7 @@ pub struct CodeAction { pub title: String, #[wasm_bindgen(getter_with_clone)] pub edits: Vec, + pub preferred: bool, } #[wasm_bindgen] diff --git a/playground/ty/src/Editor/Editor.tsx b/playground/ty/src/Editor/Editor.tsx index 9b694bb829..c104a93c63 100644 --- a/playground/ty/src/Editor/Editor.tsx +++ b/playground/ty/src/Editor/Editor.tsx @@ -607,6 +607,10 @@ class PlaygroundServer _token: CancellationToken, ): languages.ProviderResult { const actions: languages.CodeAction[] = []; + const fileHandle = this.getFileHandleForModel(model); + if (fileHandle == null) { + return undefined; + } for (const diagnostic of this.diagnostics) { const diagnosticRange = diagnostic.range; @@ -619,26 +623,31 @@ class PlaygroundServer continue; } - const codeAction = diagnostic.raw.codeAction(this.props.workspace); - if (codeAction == null) { + const codeActions = this.props.workspace.codeActions( + fileHandle, + diagnostic.raw, + ); + if (codeActions == null) { continue; } - actions.push({ - title: codeAction.title, - kind: "quickfix", - isPreferred: true, - edit: { - edits: codeAction.edits.map((edit) => ({ - resource: model.uri, - textEdit: { - range: tyRangeToMonacoRange(edit.range), - text: edit.new_text, - }, - versionId: model.getVersionId(), - })), - }, - }); + for (const codeAction of codeActions) { + actions.push({ + title: codeAction.title, + kind: "quickfix", + isPreferred: codeAction.preferred, + edit: { + edits: codeAction.edits.map((edit) => ({ + resource: model.uri, + textEdit: { + range: tyRangeToMonacoRange(edit.range), + text: edit.new_text, + }, + versionId: model.getVersionId(), + })), + }, + }); + } } if (actions.length === 0) { From efb23b01afb0e414d6ffa15cf143a83ed0bdb6b2 Mon Sep 17 00:00:00 2001 From: David Peter Date: Thu, 27 Nov 2025 16:47:01 +0100 Subject: [PATCH 09/67] [ty] Ecosystem analyzer: diff report updates (#21662) ## Summary Pulls in an ecosystem-analyzer change with a few updates to the diff report: * Breakdown of added/removed/changed diagnostics by project * Option to filter diagnostics by project * Small button to copy a file path to the clipboard * `(-R +A ~C)` indicators in the filter dropdowns (removed, added, changed) * More concise layout, less scrolling ## Test Plan Tested on https://github.com/astral-sh/ruff/pull/21553 => https://david-generic-implicit-alias.ecosystem-663.pages.dev/diff --- .github/workflows/ty-ecosystem-analyzer.yaml | 2 +- .github/workflows/ty-ecosystem-report.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ty-ecosystem-analyzer.yaml b/.github/workflows/ty-ecosystem-analyzer.yaml index e42685d4ee..417ab77bad 100644 --- a/.github/workflows/ty-ecosystem-analyzer.yaml +++ b/.github/workflows/ty-ecosystem-analyzer.yaml @@ -67,7 +67,7 @@ jobs: cd .. - uv tool install "git+https://github.com/astral-sh/ecosystem-analyzer@e26ebfb78d372b8b091e1cb1d6fc522e135474c1" + uv tool install "git+https://github.com/astral-sh/ecosystem-analyzer@55df3c868f3fa9ab34cff0498dd6106722aac205" ecosystem-analyzer \ --repository ruff \ diff --git a/.github/workflows/ty-ecosystem-report.yaml b/.github/workflows/ty-ecosystem-report.yaml index 0b897bb700..aa07cccd04 100644 --- a/.github/workflows/ty-ecosystem-report.yaml +++ b/.github/workflows/ty-ecosystem-report.yaml @@ -52,7 +52,7 @@ jobs: cd .. - uv tool install "git+https://github.com/astral-sh/ecosystem-analyzer@e26ebfb78d372b8b091e1cb1d6fc522e135474c1" + uv tool install "git+https://github.com/astral-sh/ecosystem-analyzer@55df3c868f3fa9ab34cff0498dd6106722aac205" ecosystem-analyzer \ --verbose \ From df66946b8959589307e4278b0fd5c1d0b187e854 Mon Sep 17 00:00:00 2001 From: Tsvika Shapira Date: Thu, 27 Nov 2025 19:03:36 +0200 Subject: [PATCH 10/67] Show partial fixability indicator in statistics output (#21513) Co-authored-by: Claude Co-authored-by: Micha Reiser --- crates/ruff/src/printer.rs | 79 ++++++++++++------- crates/ruff/tests/integration_test.rs | 60 ++++++++++++-- .../resources/test/project/README.md | 12 +-- docs/faq.md | 2 +- 4 files changed, 112 insertions(+), 41 deletions(-) diff --git a/crates/ruff/src/printer.rs b/crates/ruff/src/printer.rs index 1de440ac6e..70431dda9d 100644 --- a/crates/ruff/src/printer.rs +++ b/crates/ruff/src/printer.rs @@ -34,9 +34,21 @@ struct ExpandedStatistics<'a> { code: Option<&'a SecondaryCode>, name: &'static str, count: usize, - fixable: bool, + #[serde(rename = "fixable")] + all_fixable: bool, + fixable_count: usize, } +impl ExpandedStatistics<'_> { + fn any_fixable(&self) -> bool { + self.fixable_count > 0 + } +} + +/// Accumulator type for grouping diagnostics by code. +/// Format: (`code`, `representative_diagnostic`, `total_count`, `fixable_count`) +type DiagnosticGroup<'a> = (Option<&'a SecondaryCode>, &'a Diagnostic, usize, usize); + pub(crate) struct Printer { format: OutputFormat, log_level: LogLevel, @@ -133,7 +145,7 @@ impl Printer { if fixables.applicable > 0 { writeln!( writer, - "{fix_prefix} {} fixable with the --fix option.", + "{fix_prefix} {} fixable with the `--fix` option.", fixables.applicable )?; } @@ -256,35 +268,41 @@ impl Printer { diagnostics: &Diagnostics, writer: &mut dyn Write, ) -> Result<()> { + let required_applicability = self.unsafe_fixes.required_applicability(); let statistics: Vec = diagnostics .inner .iter() - .map(|message| (message.secondary_code(), message)) - .sorted_by_key(|(code, message)| (*code, message.fixable())) - .fold( - vec![], - |mut acc: Vec<((Option<&SecondaryCode>, &Diagnostic), usize)>, (code, message)| { - if let Some(((prev_code, _prev_message), count)) = acc.last_mut() { - if *prev_code == code { - *count += 1; - return acc; + .sorted_by_key(|diagnostic| diagnostic.secondary_code()) + .fold(vec![], |mut acc: Vec, diagnostic| { + let is_fixable = diagnostic + .fix() + .is_some_and(|fix| fix.applies(required_applicability)); + let code = diagnostic.secondary_code(); + + if let Some((prev_code, _prev_message, count, fixable_count)) = acc.last_mut() { + if *prev_code == code { + *count += 1; + if is_fixable { + *fixable_count += 1; } + return acc; } - acc.push(((code, message), 1)); - acc + } + acc.push((code, diagnostic, 1, usize::from(is_fixable))); + acc + }) + .iter() + .map( + |&(code, message, count, fixable_count)| ExpandedStatistics { + code, + name: message.name(), + count, + // Backward compatibility: `fixable` is true only when all violations are fixable. + // See: https://github.com/astral-sh/ruff/pull/21513 + all_fixable: fixable_count == count, + fixable_count, }, ) - .iter() - .map(|&((code, message), count)| ExpandedStatistics { - code, - name: message.name(), - count, - fixable: if let Some(fix) = message.fix() { - fix.applies(self.unsafe_fixes.required_applicability()) - } else { - false - }, - }) .sorted_by_key(|statistic| Reverse(statistic.count)) .collect(); @@ -308,13 +326,14 @@ impl Printer { .map(|statistic| statistic.code.map_or(0, |s| s.len())) .max() .unwrap(); - let any_fixable = statistics.iter().any(|statistic| statistic.fixable); + let any_fixable = statistics.iter().any(ExpandedStatistics::any_fixable); - let fixable = format!("[{}] ", "*".cyan()); + let all_fixable = format!("[{}] ", "*".cyan()); + let partially_fixable = format!("[{}] ", "-".cyan()); let unfixable = "[ ] "; // By default, we mimic Flake8's `--statistics` format. - for statistic in statistics { + for statistic in &statistics { writeln!( writer, "{:>count_width$}\t{: -:1:1 Found 2 errors. - [*] 1 fixable with the --fix option. + [*] 1 fixable with the `--fix` option. ----- stderr ----- "); @@ -1853,7 +1903,7 @@ fn check_shows_unsafe_fixes_with_opt_in() { --> -:1:1 Found 2 errors. - [*] 2 fixable with the --fix option. + [*] 2 fixable with the `--fix` option. ----- stderr ----- "); diff --git a/crates/ruff_linter/resources/test/project/README.md b/crates/ruff_linter/resources/test/project/README.md index dbd91047e7..fe44d49565 100644 --- a/crates/ruff_linter/resources/test/project/README.md +++ b/crates/ruff_linter/resources/test/project/README.md @@ -17,7 +17,7 @@ crates/ruff_linter/resources/test/project/examples/docs/docs/file.py:8:5: F841 [ crates/ruff_linter/resources/test/project/project/file.py:1:8: F401 [*] `os` imported but unused crates/ruff_linter/resources/test/project/project/import_file.py:1:1: I001 [*] Import block is un-sorted or un-formatted Found 7 errors. -[*] 7 potentially fixable with the --fix option. +[*] 7 potentially fixable with the `--fix` option. ``` Running from the project directory itself should exhibit the same behavior: @@ -32,7 +32,7 @@ examples/docs/docs/file.py:8:5: F841 [*] Local variable `x` is assigned to but n project/file.py:1:8: F401 [*] `os` imported but unused project/import_file.py:1:1: I001 [*] Import block is un-sorted or un-formatted Found 7 errors. -[*] 7 potentially fixable with the --fix option. +[*] 7 potentially fixable with the `--fix` option. ``` Running from the sub-package directory should exhibit the same behavior, but omit the top-level @@ -43,7 +43,7 @@ files: docs/file.py:1:1: I001 [*] Import block is un-sorted or un-formatted docs/file.py:8:5: F841 [*] Local variable `x` is assigned to but never used Found 2 errors. -[*] 2 potentially fixable with the --fix option. +[*] 2 potentially fixable with the `--fix` option. ``` `--config` should force Ruff to use the specified `pyproject.toml` for all files, and resolve @@ -61,7 +61,7 @@ crates/ruff_linter/resources/test/project/examples/docs/docs/file.py:4:27: F401 crates/ruff_linter/resources/test/project/examples/excluded/script.py:1:8: F401 [*] `os` imported but unused crates/ruff_linter/resources/test/project/project/file.py:1:8: F401 [*] `os` imported but unused Found 9 errors. -[*] 9 potentially fixable with the --fix option. +[*] 9 potentially fixable with the `--fix` option. ``` Running from a parent directory should "ignore" the `exclude` (hence, `concepts/file.py` gets @@ -74,7 +74,7 @@ docs/docs/file.py:1:1: I001 [*] Import block is un-sorted or un-formatted docs/docs/file.py:8:5: F841 [*] Local variable `x` is assigned to but never used excluded/script.py:5:5: F841 [*] Local variable `x` is assigned to but never used Found 4 errors. -[*] 4 potentially fixable with the --fix option. +[*] 4 potentially fixable with the `--fix` option. ``` Passing an excluded directory directly should report errors in the contained files: @@ -83,7 +83,7 @@ Passing an excluded directory directly should report errors in the contained fil ∴ cargo run -p ruff -- check crates/ruff_linter/resources/test/project/examples/excluded/ crates/ruff_linter/resources/test/project/examples/excluded/script.py:1:8: F401 [*] `os` imported but unused Found 1 error. -[*] 1 potentially fixable with the --fix option. +[*] 1 potentially fixable with the `--fix` option. ``` Unless we `--force-exclude`: diff --git a/docs/faq.md b/docs/faq.md index 68e69ee9bd..b94f0b64e4 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -454,7 +454,7 @@ Untitled.ipynb:cell_1:2:5: F841 Local variable `x` is assigned to but never used Untitled.ipynb:cell_2:1:1: E402 Module level import not at top of file Untitled.ipynb:cell_2:1:8: F401 `os` imported but unused Found 3 errors. -1 potentially fixable with the --fix option. +1 potentially fixable with the `--fix` option. ``` ## Does Ruff support NumPy- or Google-style docstrings? From aef2fad0c5d572ac3344839ba0aac6def50d80a1 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 27 Nov 2025 18:20:02 +0000 Subject: [PATCH 11/67] [ty] Add IDE autofixes for two "Did you mean...?" suggestions (#21667) --- Cargo.lock | 1 + crates/ty/docs/rules.md | 144 +++++++++--------- ..._Misspelled_key_for_`…_(7cf0fa634e2a2d59).snap | 6 + ..._Unknown_key_for_all_…_(8a0f0e8ceccc51b2).snap | 12 ++ ..._Module-literal_used_…_(652fec4fd4a6c63a).snap | 10 ++ ...ict`_-_Diagnostics_(e5289abf5c570c29).snap | 18 +++ crates/ty_python_semantic/src/types.rs | 16 +- .../src/types/diagnostic.rs | 5 + crates/ty_test/Cargo.toml | 1 + crates/ty_test/src/lib.rs | 4 +- 10 files changed, 140 insertions(+), 77 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb4289b220..c95acc34a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4561,6 +4561,7 @@ dependencies = [ "path-slash", "regex", "ruff_db", + "ruff_diagnostics", "ruff_index", "ruff_notebook", "ruff_python_ast", diff --git a/crates/ty/docs/rules.md b/crates/ty/docs/rules.md index 3a77ed7946..16c4c225dc 100644 --- a/crates/ty/docs/rules.md +++ b/crates/ty/docs/rules.md @@ -39,7 +39,7 @@ def test(): -> "int": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -63,7 +63,7 @@ Calling a non-callable object will raise a `TypeError` at runtime. Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -95,7 +95,7 @@ f(int) # error Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -126,7 +126,7 @@ a = 1 Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -158,7 +158,7 @@ class C(A, B): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -190,7 +190,7 @@ class B(A): ... Default level: error · Preview (since 1.0.0) · Related issues · -View source +View source @@ -218,7 +218,7 @@ type B = A Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -245,7 +245,7 @@ class B(A, A): ... Default level: error · Added in 0.0.1-alpha.12 · Related issues · -View source +View source @@ -357,7 +357,7 @@ def test(): -> "Literal[5]": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -387,7 +387,7 @@ class C(A, B): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -413,7 +413,7 @@ t[3] # IndexError: tuple index out of range Default level: error · Added in 0.0.1-alpha.12 · Related issues · -View source +View source @@ -502,7 +502,7 @@ an atypical memory layout. Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -529,7 +529,7 @@ func("foo") # error: [invalid-argument-type] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -557,7 +557,7 @@ a: int = '' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -591,7 +591,7 @@ C.instance_var = 3 # error: Cannot assign to instance variable Default level: error · Added in 0.0.1-alpha.19 · Related issues · -View source +View source @@ -627,7 +627,7 @@ asyncio.run(main()) Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -651,7 +651,7 @@ class A(42): ... # error: [invalid-base] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -678,7 +678,7 @@ with 1: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -707,7 +707,7 @@ a: str Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -751,7 +751,7 @@ except ZeroDivisionError: Default level: error · Added in 0.0.1-alpha.28 · Related issues · -View source +View source @@ -793,7 +793,7 @@ class D(A): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -826,7 +826,7 @@ class C[U](Generic[T]): ... Default level: error · Added in 0.0.1-alpha.17 · Related issues · -View source +View source @@ -865,7 +865,7 @@ carol = Person(name="Carol", age=25) # typo! Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -900,7 +900,7 @@ def f(t: TypeVar("U")): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -934,7 +934,7 @@ class B(metaclass=f): ... Default level: error · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -1041,7 +1041,7 @@ Correct use of `@override` is enforced by ty's `invalid-explicit-override` rule. Default level: error · Added in 0.0.1-alpha.19 · Related issues · -View source +View source @@ -1073,7 +1073,7 @@ TypeError: can only inherit from a NamedTuple type and Generic Default level: error · Preview (since 1.0.0) · Related issues · -View source +View source @@ -1103,7 +1103,7 @@ Baz = NewType("Baz", int | str) # error: invalid base for `typing.NewType` Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1153,7 +1153,7 @@ def foo(x: int) -> int: ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1179,7 +1179,7 @@ def f(a: int = ''): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1210,7 +1210,7 @@ P2 = ParamSpec("S2") # error: ParamSpec name must match the variable it's assig Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1244,7 +1244,7 @@ TypeError: Protocols can only inherit from other protocols, got Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1293,7 +1293,7 @@ def g(): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1318,7 +1318,7 @@ def func() -> int: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1376,7 +1376,7 @@ TODO #14889 Default level: error · Added in 0.0.1-alpha.6 · Related issues · -View source +View source @@ -1403,7 +1403,7 @@ NewAlias = TypeAliasType(get_name(), int) # error: TypeAliasType name mus Default level: error · Added in 0.0.1-alpha.29 · Related issues · -View source +View source @@ -1450,7 +1450,7 @@ Bar[int] # error: too few arguments Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1480,7 +1480,7 @@ TYPE_CHECKING = '' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1510,7 +1510,7 @@ b: Annotated[int] # `Annotated` expects at least two arguments Default level: error · Added in 0.0.1-alpha.11 · Related issues · -View source +View source @@ -1544,7 +1544,7 @@ f(10) # Error Default level: error · Added in 0.0.1-alpha.11 · Related issues · -View source +View source @@ -1578,7 +1578,7 @@ class C: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1613,7 +1613,7 @@ T = TypeVar('T', bound=str) # valid bound TypeVar Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1638,7 +1638,7 @@ func() # TypeError: func() missing 1 required positional argument: 'x' Default level: error · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -1671,7 +1671,7 @@ alice["age"] # KeyError Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1700,7 +1700,7 @@ func("string") # error: [no-matching-overload] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1724,7 +1724,7 @@ Subscripting an object that does not support it will raise a `TypeError` at runt Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1750,7 +1750,7 @@ for i in 34: # TypeError: 'int' object is not iterable Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1777,7 +1777,7 @@ f(1, x=2) # Error raised here Default level: error · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -1835,7 +1835,7 @@ def test(): -> "int": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1865,7 +1865,7 @@ static_assert(int(2.0 * 3.0) == 6) # error: does not have a statically known tr Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1894,7 +1894,7 @@ class B(A): ... # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1921,7 +1921,7 @@ f("foo") # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1949,7 +1949,7 @@ def _(x: int): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1995,7 +1995,7 @@ class A: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2022,7 +2022,7 @@ f(x=1, y=2) # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2050,7 +2050,7 @@ A().foo # AttributeError: 'A' object has no attribute 'foo' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2075,7 +2075,7 @@ import foo # ModuleNotFoundError: No module named 'foo' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2100,7 +2100,7 @@ print(x) # NameError: name 'x' is not defined Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2137,7 +2137,7 @@ b1 < b2 < b1 # exception raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2165,7 +2165,7 @@ A() + A() # TypeError: unsupported operand type(s) for +: 'A' and 'A' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2190,7 +2190,7 @@ l[1:10:0] # ValueError: slice step cannot be zero Default level: warn · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -2231,7 +2231,7 @@ class SubProto(BaseProto, Protocol): Default level: warn · Added in 0.0.1-alpha.16 · Related issues · -View source +View source @@ -2319,7 +2319,7 @@ a = 20 / 0 # type: ignore Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2347,7 +2347,7 @@ A.c # AttributeError: type object 'A' has no attribute 'c' Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2379,7 +2379,7 @@ A()[0] # TypeError: 'A' object is not subscriptable Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2411,7 +2411,7 @@ from module import a # ImportError: cannot import name 'a' from 'module' Default level: warn · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2438,7 +2438,7 @@ cast(int, f()) # Redundant Default level: warn · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2462,7 +2462,7 @@ reveal_type(1) # NameError: name 'reveal_type' is not defined Default level: warn · Added in 0.0.1-alpha.15 · Related issues · -View source +View source @@ -2520,7 +2520,7 @@ def g(): Default level: warn · Added in 0.0.1-alpha.7 · Related issues · -View source +View source @@ -2559,7 +2559,7 @@ class D(C): ... # error: [unsupported-base] Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2622,7 +2622,7 @@ def foo(x: int | str) -> int | str: Default level: ignore · Preview (since 0.0.1-alpha.1) · Related issues · -View source +View source @@ -2646,7 +2646,7 @@ Dividing by zero raises a `ZeroDivisionError` at runtime. Default level: ignore · Added in 0.0.1-alpha.1 · Related issues · -View source +View source diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/assignment_diagnosti…_-_Subscript_assignment…_-_Misspelled_key_for_`…_(7cf0fa634e2a2d59).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/assignment_diagnosti…_-_Subscript_assignment…_-_Misspelled_key_for_`…_(7cf0fa634e2a2d59).snap index ca95ce1675..029b325cc1 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/assignment_diagnosti…_-_Subscript_assignment…_-_Misspelled_key_for_`…_(7cf0fa634e2a2d59).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/assignment_diagnosti…_-_Subscript_assignment…_-_Misspelled_key_for_`…_(7cf0fa634e2a2d59).snap @@ -34,5 +34,11 @@ error[invalid-key]: Unknown key "Retries" for TypedDict `Config` | TypedDict `Config` | info: rule `invalid-key` is enabled by default +4 | retries: int +5 | +6 | def _(config: Config) -> None: + - config["Retries"] = 30.0 # error: [invalid-key] +7 + config["retries"] = 30.0 # error: [invalid-key] +note: This is an unsafe fix and may change runtime behavior ``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/assignment_diagnosti…_-_Subscript_assignment…_-_Unknown_key_for_all_…_(8a0f0e8ceccc51b2).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/assignment_diagnosti…_-_Subscript_assignment…_-_Unknown_key_for_all_…_(8a0f0e8ceccc51b2).snap index 17a005b9c2..d3e9c7a656 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/assignment_diagnosti…_-_Subscript_assignment…_-_Unknown_key_for_all_…_(8a0f0e8ceccc51b2).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/assignment_diagnosti…_-_Subscript_assignment…_-_Unknown_key_for_all_…_(8a0f0e8ceccc51b2).snap @@ -42,6 +42,12 @@ error[invalid-key]: Unknown key "surname" for TypedDict `Person` | TypedDict `Person` in union type `Person | Animal` | info: rule `invalid-key` is enabled by default +11 | def _(being: Person | Animal) -> None: +12 | # error: [invalid-key] +13 | # error: [invalid-key] + - being["surname"] = "unknown" +14 + being["name"] = "unknown" +note: This is an unsafe fix and may change runtime behavior ``` @@ -57,5 +63,11 @@ error[invalid-key]: Unknown key "surname" for TypedDict `Animal` | TypedDict `Animal` in union type `Person | Animal` | info: rule `invalid-key` is enabled by default +11 | def _(being: Person | Animal) -> None: +12 | # error: [invalid-key] +13 | # error: [invalid-key] + - being["surname"] = "unknown" +14 + being["name"] = "unknown" +note: This is an unsafe fix and may change runtime behavior ``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/invalid.md_-_Tests_for_invalid_ty…_-_Diagnostics_for_comm…_-_Module-literal_used_…_(652fec4fd4a6c63a).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/invalid.md_-_Tests_for_invalid_ty…_-_Diagnostics_for_comm…_-_Module-literal_used_…_(652fec4fd4a6c63a).snap index 957a2d13f8..8d13cb887f 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/invalid.md_-_Tests_for_invalid_ty…_-_Diagnostics_for_comm…_-_Module-literal_used_…_(652fec4fd4a6c63a).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/invalid.md_-_Tests_for_invalid_ty…_-_Diagnostics_for_comm…_-_Module-literal_used_…_(652fec4fd4a6c63a).snap @@ -43,6 +43,11 @@ error[invalid-type-form]: Module `datetime` is not valid in a type expression | ^^^^^^^^ Did you mean to use the module's member `datetime.datetime`? | info: rule `invalid-type-form` is enabled by default +1 | import datetime +2 | + - def f(x: datetime): ... # error: [invalid-type-form] +3 + def f(x: datetime.datetime): ... # error: [invalid-type-form] +note: This is an unsafe fix and may change runtime behavior ``` @@ -56,5 +61,10 @@ error[invalid-type-form]: Module `PIL.Image` is not valid in a type expression | ^^^^^ Did you mean to use the module's member `Image.Image`? | info: rule `invalid-type-form` is enabled by default +1 | from PIL import Image +2 | + - def g(x: Image): ... # error: [invalid-type-form] +3 + def g(x: Image.Image): ... # error: [invalid-type-form] +note: This is an unsafe fix and may change runtime behavior ``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/typed_dict.md_-_`TypedDict`_-_Diagnostics_(e5289abf5c570c29).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/typed_dict.md_-_`TypedDict`_-_Diagnostics_(e5289abf5c570c29).snap index 697188d2be..0fc0bbd2a6 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/typed_dict.md_-_`TypedDict`_-_Diagnostics_(e5289abf5c570c29).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/typed_dict.md_-_`TypedDict`_-_Diagnostics_(e5289abf5c570c29).snap @@ -69,6 +69,15 @@ error[invalid-key]: Unknown key "naem" for TypedDict `Person` 10 | NAME_KEY: Final = "naem" | info: rule `invalid-key` is enabled by default +5 | age: int | None +6 | +7 | def access_invalid_literal_string_key(person: Person): + - person["naem"] # error: [invalid-key] +8 + person["name"] # error: [invalid-key] +9 | +10 | NAME_KEY: Final = "naem" +11 | +note: This is an unsafe fix and may change runtime behavior ``` @@ -142,6 +151,15 @@ error[invalid-key]: Unknown key "naem" for TypedDict `Person` 24 | def write_to_non_literal_string_key(person: Person, str_key: str): | info: rule `invalid-key` is enabled by default +19 | person["age"] = "42" # error: [invalid-assignment] +20 | +21 | def write_to_non_existing_key(person: Person): + - person["naem"] = "Alice" # error: [invalid-key] +22 + person["name"] = "Alice" # error: [invalid-key] +23 | +24 | def write_to_non_literal_string_key(person: Person, str_key: str): +25 | person[str_key] = "Alice" # error: [invalid-key] +note: This is an unsafe fix and may change runtime behavior ``` diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 998a8dd134..56b794e96b 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -1,6 +1,7 @@ use compact_str::{CompactString, ToCompactString}; use infer::nearest_enclosing_class; use itertools::{Either, Itertools}; +use ruff_diagnostics::{Edit, Fix}; use std::borrow::Cow; use std::time::Duration; @@ -8752,7 +8753,7 @@ impl<'db> InvalidTypeExpressionError<'db> { continue; }; let diagnostic = builder.into_diagnostic(error.reason(context.db())); - error.add_subdiagnostics(context.db(), diagnostic); + error.add_subdiagnostics(context.db(), diagnostic, node); } } fallback_type @@ -8878,7 +8879,12 @@ impl<'db> InvalidTypeExpression<'db> { Display { error: self, db } } - fn add_subdiagnostics(self, db: &'db dyn Db, mut diagnostic: LintDiagnosticGuard) { + fn add_subdiagnostics( + self, + db: &'db dyn Db, + mut diagnostic: LintDiagnosticGuard, + node: &impl Ranged, + ) { if let InvalidTypeExpression::InvalidType(Type::Never, _) = self { diagnostic.help( "The variable may have been inferred as `Never` because \ @@ -8904,12 +8910,14 @@ impl<'db> InvalidTypeExpression<'db> { { return; } - - // TODO: showing a diff (and even having an autofix) would be even better diagnostic.set_primary_message(format_args!( "Did you mean to use the module's member \ `{module_name_final_part}.{module_name_final_part}`?" )); + diagnostic.set_fix(Fix::unsafe_edit(Edit::insertion( + format!(".{module_name_final_part}"), + node.end(), + ))); } else if let InvalidTypeExpression::TypedDict = self { diagnostic.help( "You might have meant to use a concrete TypedDict \ diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index 4e9c5b96df..368c04601f 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -37,6 +37,7 @@ use ruff_db::{ parsed::parsed_module, source::source_text, }; +use ruff_diagnostics::{Edit, Fix}; use ruff_python_ast::name::Name; use ruff_python_ast::parenthesize::parentheses_iterator; use ruff_python_ast::{self as ast, AnyNodeRef}; @@ -3430,6 +3431,10 @@ pub(crate) fn report_invalid_key_on_typed_dict<'db>( if key_node.is_expr_string_literal() { diagnostic .set_primary_message(format_args!("Did you mean \"{suggestion}\"?")); + diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement( + format!("\"{suggestion}\""), + key_node.range(), + ))); } else { diagnostic.set_primary_message(format_args!( "Unknown key \"{key}\" - did you mean \"{suggestion}\"?", diff --git a/crates/ty_test/Cargo.toml b/crates/ty_test/Cargo.toml index 271ca8f084..f300b614a0 100644 --- a/crates/ty_test/Cargo.toml +++ b/crates/ty_test/Cargo.toml @@ -12,6 +12,7 @@ license.workspace = true [dependencies] ruff_db = { workspace = true, features = ["os", "testing"] } +ruff_diagnostics = { workspace = true } ruff_index = { workspace = true } ruff_notebook = { workspace = true } ruff_python_trivia = { workspace = true } diff --git a/crates/ty_test/src/lib.rs b/crates/ty_test/src/lib.rs index 182d4b206e..800d4e4c4d 100644 --- a/crates/ty_test/src/lib.rs +++ b/crates/ty_test/src/lib.rs @@ -12,6 +12,7 @@ use ruff_db::panic::{PanicError, catch_unwind}; use ruff_db::parsed::parsed_module; use ruff_db::system::{DbWithWritableSystem as _, SystemPath, SystemPathBuf}; use ruff_db::testing::{setup_logging, setup_logging_with_filter}; +use ruff_diagnostics::Applicability; use ruff_source_file::{LineIndex, OneIndexed}; use std::backtrace::BacktraceStatus; use std::fmt::{Display, Write}; @@ -643,7 +644,8 @@ fn create_diagnostic_snapshot( ) -> String { let display_config = DisplayDiagnosticConfig::default() .color(false) - .show_fix_diff(true); + .show_fix_diff(true) + .with_fix_applicability(Applicability::DisplayOnly); let mut snapshot = String::new(); writeln!(snapshot).unwrap(); From 666f488f1b8e5c12bb5e29995f4386ad7162098a Mon Sep 17 00:00:00 2001 From: Shahar Naveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Thu, 27 Nov 2025 20:57:39 +0200 Subject: [PATCH 12/67] Add python 3.14 as a supported version for PyPi (#21669) --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 441d64b6ff..9647c886dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Rust", "Topic :: Software Development :: Libraries :: Python Modules", From 53efc8298910c5ab6ef46d81ab106686a6ed99ef Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 27 Nov 2025 19:29:25 +0000 Subject: [PATCH 13/67] [ty] Include all members on `type` in autocompletion suggestions for `type[]` types (#21670) --- .../mdtest/ide_support/all_members.md | 40 +++++++++++++++++++ .../src/types/ide_support.rs | 34 ++++++++++------ 2 files changed, 62 insertions(+), 12 deletions(-) diff --git a/crates/ty_python_semantic/resources/mdtest/ide_support/all_members.md b/crates/ty_python_semantic/resources/mdtest/ide_support/all_members.md index 38404c0457..1a20940c0e 100644 --- a/crates/ty_python_semantic/resources/mdtest/ide_support/all_members.md +++ b/crates/ty_python_semantic/resources/mdtest/ide_support/all_members.md @@ -153,6 +153,12 @@ static_assert(has_member(D, "meta_base_attr")) static_assert(has_member(D, "meta_attr")) static_assert(has_member(D, "base_attr")) static_assert(has_member(D, "class_attr")) + +def f(x: type[D]): + static_assert(has_member(x, "meta_base_attr")) + static_assert(has_member(x, "meta_attr")) + static_assert(has_member(x, "base_attr")) + static_assert(has_member(x, "class_attr")) ``` ### Generic classes @@ -170,6 +176,40 @@ static_assert(has_member(C[int], "base_attr")) static_assert(has_member(C[int](), "base_attr")) ``` +Generic classes can also have metaclasses: + +```py +class Meta(type): + FOO = 42 + +class E(Generic[T], metaclass=Meta): ... + +static_assert(has_member(E[int], "FOO")) + +def f(x: type[E[str]]): + static_assert(has_member(x, "FOO")) +``` + +### `type[Any]` and `Any` + +`type[Any]` has all members of `type`. + +```py +from typing import Any +from ty_extensions import has_member, static_assert + +def f(x: type[Any]): + static_assert(has_member(x, "__base__")) + static_assert(has_member(x, "__qualname__")) +``` + +`Any` has all members of `object`, since it is a subtype of `object`: + +```py +def f(x: Any): + static_assert(has_member(x, "__repr__")) +``` + ### Other instance-like types ```py diff --git a/crates/ty_python_semantic/src/types/ide_support.rs b/crates/ty_python_semantic/src/types/ide_support.rs index 3f70a0d10d..a6e33011f6 100644 --- a/crates/ty_python_semantic/src/types/ide_support.rs +++ b/crates/ty_python_semantic/src/types/ide_support.rs @@ -13,7 +13,7 @@ use crate::semantic_index::{ use crate::types::call::{CallArguments, MatchedArgument}; use crate::types::generics::Specialization; use crate::types::signatures::Signature; -use crate::types::{CallDunderError, UnionType}; +use crate::types::{CallDunderError, SubclassOfInner, UnionType}; use crate::types::{ CallableTypes, ClassBase, ClassLiteral, KnownClass, KnownInstanceType, Type, TypeContext, TypeVarBoundOrConstraints, class::CodeGeneratorKind, @@ -161,9 +161,8 @@ impl<'db> AllMembers<'db> { Type::ClassLiteral(class_literal) => { self.extend_with_class_members(db, ty, class_literal); self.extend_with_synthetic_members(db, ty, class_literal, None); - - if let Type::ClassLiteral(meta_class_literal) = ty.to_meta_type(db) { - self.extend_with_class_members(db, ty, meta_class_literal); + if let Type::ClassLiteral(metaclass) = class_literal.metaclass(db) { + self.extend_with_class_members(db, ty, metaclass); } } @@ -171,17 +170,28 @@ impl<'db> AllMembers<'db> { let class_literal = generic_alias.origin(db); self.extend_with_class_members(db, ty, class_literal); self.extend_with_synthetic_members(db, ty, class_literal, None); - } - - Type::SubclassOf(subclass_of_type) => { - if let Some(class_type) = subclass_of_type.subclass_of().into_class() { - let (class_literal, specialization) = class_type.class_literal(db); - self.extend_with_class_members(db, ty, class_literal); - self.extend_with_synthetic_members(db, ty, class_literal, specialization); + if let Type::ClassLiteral(metaclass) = class_literal.metaclass(db) { + self.extend_with_class_members(db, ty, metaclass); } } - Type::Dynamic(_) | Type::Never | Type::AlwaysTruthy | Type::AlwaysFalsy => {} + Type::SubclassOf(subclass_of_type) => match subclass_of_type.subclass_of() { + SubclassOfInner::Class(class_type) => { + let (class_literal, specialization) = class_type.class_literal(db); + self.extend_with_class_members(db, ty, class_literal); + self.extend_with_synthetic_members(db, ty, class_literal, specialization); + if let Type::ClassLiteral(metaclass) = class_literal.metaclass(db) { + self.extend_with_class_members(db, ty, metaclass); + } + } + SubclassOfInner::Dynamic(_) => { + self.extend_with_type(db, KnownClass::Type.to_instance(db)); + } + }, + + Type::Dynamic(_) | Type::Never | Type::AlwaysTruthy | Type::AlwaysFalsy => { + self.extend_with_type(db, Type::object()); + } Type::TypeAlias(alias) => self.extend_with_type(db, alias.value_type(db)), From 3ed537e9f1a166d51f4ec4f94191645e695a5a25 Mon Sep 17 00:00:00 2001 From: Ibraheem Ahmed Date: Fri, 28 Nov 2025 03:20:24 -0500 Subject: [PATCH 14/67] [ty] Support `type[T]` with type variables (#21650) ## Summary Adds support for `type[T]`, where `T` is a type variable. - Resolves https://github.com/astral-sh/ty/issues/501 - Resolves https://github.com/astral-sh/ty/issues/783 - Resolves https://github.com/astral-sh/ty/issues/662 --- crates/ty_ide/src/completion.rs | 2 +- .../resources/mdtest/annotations/self.md | 6 +- .../resources/mdtest/attributes.md | 4 +- .../resources/mdtest/class/super.md | 12 +- .../resources/mdtest/enums.md | 4 +- .../mdtest/generics/legacy/functions.md | 2 +- .../mdtest/generics/legacy/variables.md | 11 +- .../mdtest/generics/pep695/functions.md | 2 +- .../mdtest/generics/pep695/variables.md | 11 +- .../mdtest/ide_support/all_members.md | 13 +- .../resources/mdtest/protocols.md | 6 +- ...licit_Super_Objec…_(f9e5e48e3a4a4c12).snap | 210 ++++++------ .../resources/mdtest/type_of/generics.md | 247 ++++++++++++++ crates/ty_python_semantic/src/types.rs | 322 +++++++++++++----- .../src/types/bound_super.rs | 22 +- .../src/types/diagnostic.rs | 2 +- .../ty_python_semantic/src/types/display.rs | 5 + .../ty_python_semantic/src/types/generics.rs | 13 +- .../src/types/ide_support.rs | 22 +- .../src/types/infer/builder.rs | 4 +- .../types/infer/builder/type_expression.rs | 23 +- crates/ty_python_semantic/src/types/narrow.rs | 4 + .../src/types/subclass_of.rs | 211 ++++++++++-- .../src/types/type_ordering.rs | 5 + 24 files changed, 867 insertions(+), 296 deletions(-) create mode 100644 crates/ty_python_semantic/resources/mdtest/type_of/generics.md diff --git a/crates/ty_ide/src/completion.rs b/crates/ty_ide/src/completion.rs index 9e1233cce1..4387c09346 100644 --- a/crates/ty_ide/src/completion.rs +++ b/crates/ty_ide/src/completion.rs @@ -2898,7 +2898,7 @@ Answer. __itemsize__ :: int __iter__ :: bound method .__iter__[_EnumMemberT]() -> Iterator[_EnumMemberT@__iter__] __len__ :: bound method .__len__() -> int - __members__ :: MappingProxyType[str, Unknown] + __members__ :: MappingProxyType[str, Answer] __module__ :: str __mro__ :: tuple[type, ...] __name__ :: str diff --git a/crates/ty_python_semantic/resources/mdtest/annotations/self.md b/crates/ty_python_semantic/resources/mdtest/annotations/self.md index 8fc0802bac..4be59a5a63 100644 --- a/crates/ty_python_semantic/resources/mdtest/annotations/self.md +++ b/crates/ty_python_semantic/resources/mdtest/annotations/self.md @@ -260,15 +260,13 @@ class Shape: @classmethod def bar(cls: type[Self]) -> Self: - # TODO: type[Shape] - reveal_type(cls) # revealed: @Todo(unsupported type[X] special form) + reveal_type(cls) # revealed: type[Self@bar] return cls() class Circle(Shape): ... reveal_type(Shape().foo()) # revealed: Shape -# TODO: Shape -reveal_type(Shape.bar()) # revealed: Unknown +reveal_type(Shape.bar()) # revealed: Shape ``` ## Attributes diff --git a/crates/ty_python_semantic/resources/mdtest/attributes.md b/crates/ty_python_semantic/resources/mdtest/attributes.md index bef0451ea2..f2eb886223 100644 --- a/crates/ty_python_semantic/resources/mdtest/attributes.md +++ b/crates/ty_python_semantic/resources/mdtest/attributes.md @@ -2650,7 +2650,7 @@ reveal_type(C().x) # revealed: int ```py import enum -reveal_type(enum.Enum.__members__) # revealed: MappingProxyType[str, Unknown] +reveal_type(enum.Enum.__members__) # revealed: MappingProxyType[str, Enum] class Answer(enum.Enum): NO = 0 @@ -2658,7 +2658,7 @@ class Answer(enum.Enum): reveal_type(Answer.NO) # revealed: Literal[Answer.NO] reveal_type(Answer.NO.value) # revealed: Literal[0] -reveal_type(Answer.__members__) # revealed: MappingProxyType[str, Unknown] +reveal_type(Answer.__members__) # revealed: MappingProxyType[str, Answer] ``` ## Divergent inferred implicit instance attribute types diff --git a/crates/ty_python_semantic/resources/mdtest/class/super.md b/crates/ty_python_semantic/resources/mdtest/class/super.md index b3996159ba..e4dd9b77bc 100644 --- a/crates/ty_python_semantic/resources/mdtest/class/super.md +++ b/crates/ty_python_semantic/resources/mdtest/class/super.md @@ -210,9 +210,7 @@ class BuilderMeta2(type): ) -> BuilderMeta2: # revealed: , > s = reveal_type(super()) - # TODO: should be `BuilderMeta2` (needs https://github.com/astral-sh/ty/issues/501) - # revealed: Unknown - return reveal_type(s.__new__(cls, name, bases, dct)) + return reveal_type(s.__new__(cls, name, bases, dct)) # revealed: BuilderMeta2 class Foo[T]: x: T @@ -395,6 +393,14 @@ class E(Enum): reveal_type(super(E, E.X)) # revealed: , E> ``` +## `type[Self]` + +```py +class Foo: + def method(self): + super(self.__class__, self) +``` + ## Descriptor Behavior with Super Accessing attributes through `super` still invokes descriptor protocol. However, the behavior can diff --git a/crates/ty_python_semantic/resources/mdtest/enums.md b/crates/ty_python_semantic/resources/mdtest/enums.md index 8ae0dce62f..43cd712a1d 100644 --- a/crates/ty_python_semantic/resources/mdtest/enums.md +++ b/crates/ty_python_semantic/resources/mdtest/enums.md @@ -15,10 +15,8 @@ reveal_type(Color.RED) # revealed: Literal[Color.RED] reveal_type(Color.RED.name) # revealed: Literal["RED"] reveal_type(Color.RED.value) # revealed: Literal[1] -# TODO: Should be `Color` or `Literal[Color.RED]` -reveal_type(Color["RED"]) # revealed: Unknown - # TODO: Could be `Literal[Color.RED]` to be more precise +reveal_type(Color["RED"]) # revealed: Color reveal_type(Color(1)) # revealed: Color reveal_type(Color.RED in Color) # revealed: bool diff --git a/crates/ty_python_semantic/resources/mdtest/generics/legacy/functions.md b/crates/ty_python_semantic/resources/mdtest/generics/legacy/functions.md index 2bbe85b5ec..2fce911026 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/legacy/functions.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/legacy/functions.md @@ -106,7 +106,7 @@ def deeper_explicit(x: ExplicitlyImplements[set[str]]) -> None: def takes_in_type(x: type[T]) -> type[T]: return x -reveal_type(takes_in_type(int)) # revealed: @Todo(unsupported type[X] special form) +reveal_type(takes_in_type(int)) # revealed: type[int] ``` This also works when passing in arguments that are subclasses of the parameter type. diff --git a/crates/ty_python_semantic/resources/mdtest/generics/legacy/variables.md b/crates/ty_python_semantic/resources/mdtest/generics/legacy/variables.md index 5485fe4477..5917e340ab 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/legacy/variables.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/legacy/variables.md @@ -383,8 +383,7 @@ def constrained(f: T): ## Meta-type -The meta-type of a typevar is the same as the meta-type of the upper bound, or the union of the -meta-types of the constraints: +The meta-type of a typevar is `type[T]`. ```py from typing import TypeVar @@ -392,22 +391,22 @@ from typing import TypeVar T_normal = TypeVar("T_normal") def normal(x: T_normal): - reveal_type(type(x)) # revealed: type + reveal_type(type(x)) # revealed: type[T_normal@normal] T_bound_object = TypeVar("T_bound_object", bound=object) def bound_object(x: T_bound_object): - reveal_type(type(x)) # revealed: type + reveal_type(type(x)) # revealed: type[T_bound_object@bound_object] T_bound_int = TypeVar("T_bound_int", bound=int) def bound_int(x: T_bound_int): - reveal_type(type(x)) # revealed: type[int] + reveal_type(type(x)) # revealed: type[T_bound_int@bound_int] T_constrained = TypeVar("T_constrained", int, str) def constrained(x: T_constrained): - reveal_type(type(x)) # revealed: type[int] | type[str] + reveal_type(type(x)) # revealed: type[T_constrained@constrained] ``` ## Cycles diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/functions.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/functions.md index 5db84cfd5a..8af1b948ee 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/pep695/functions.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/functions.md @@ -101,7 +101,7 @@ def deeper_explicit(x: ExplicitlyImplements[set[str]]) -> None: def takes_in_type[T](x: type[T]) -> type[T]: return x -reveal_type(takes_in_type(int)) # revealed: @Todo(unsupported type[X] special form) +reveal_type(takes_in_type(int)) # revealed: type[int] ``` This also works when passing in arguments that are subclasses of the parameter type. diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/variables.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/variables.md index 6c13dc559b..eaa4b8923e 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/pep695/variables.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/variables.md @@ -754,21 +754,20 @@ def constrained[T: (Callable[[], int], Callable[[], str])](f: T): ## Meta-type -The meta-type of a typevar is the same as the meta-type of the upper bound, or the union of the -meta-types of the constraints: +The meta-type of a typevar is `type[T]`. ```py def normal[T](x: T): - reveal_type(type(x)) # revealed: type + reveal_type(type(x)) # revealed: type[T@normal] def bound_object[T: object](x: T): - reveal_type(type(x)) # revealed: type + reveal_type(type(x)) # revealed: type[T@bound_object] def bound_int[T: int](x: T): - reveal_type(type(x)) # revealed: type[int] + reveal_type(type(x)) # revealed: type[T@bound_int] def constrained[T: (int, str)](x: T): - reveal_type(type(x)) # revealed: type[int] | type[str] + reveal_type(type(x)) # revealed: type[T@constrained] ``` ## Cycles diff --git a/crates/ty_python_semantic/resources/mdtest/ide_support/all_members.md b/crates/ty_python_semantic/resources/mdtest/ide_support/all_members.md index 1a20940c0e..f0f7db664c 100644 --- a/crates/ty_python_semantic/resources/mdtest/ide_support/all_members.md +++ b/crates/ty_python_semantic/resources/mdtest/ide_support/all_members.md @@ -110,6 +110,11 @@ static_assert(not has_member(C(), "non_existent")) ### Class objects +```toml +[environment] +python-version = "3.12" +``` + Class-level attributes can also be accessed through the class itself: ```py @@ -154,7 +159,13 @@ static_assert(has_member(D, "meta_attr")) static_assert(has_member(D, "base_attr")) static_assert(has_member(D, "class_attr")) -def f(x: type[D]): +def _(x: type[D]): + static_assert(has_member(x, "meta_base_attr")) + static_assert(has_member(x, "meta_attr")) + static_assert(has_member(x, "base_attr")) + static_assert(has_member(x, "class_attr")) + +def _[T: D](x: type[T]): static_assert(has_member(x, "meta_base_attr")) static_assert(has_member(x, "meta_attr")) static_assert(has_member(x, "base_attr")) diff --git a/crates/ty_python_semantic/resources/mdtest/protocols.md b/crates/ty_python_semantic/resources/mdtest/protocols.md index 1e1ac07aab..cfa4c68914 100644 --- a/crates/ty_python_semantic/resources/mdtest/protocols.md +++ b/crates/ty_python_semantic/resources/mdtest/protocols.md @@ -255,12 +255,10 @@ And it is also an error to use `Protocol` in type expressions: def f( x: Protocol, # error: [invalid-type-form] "`typing.Protocol` is not allowed in type expressions" - y: type[Protocol], # TODO: should emit `[invalid-type-form]` here too + y: type[Protocol], # error: [invalid-type-form] "`typing.Protocol` is not allowed in type expressions" ): reveal_type(x) # revealed: Unknown - - # TODO: should be `type[Unknown]` - reveal_type(y) # revealed: @Todo(unsupported type[X] special form) + reveal_type(y) # revealed: type[Unknown] # fmt: on ``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/super.md_-_Super_-_Basic_Usage_-_Implicit_Super_Objec…_(f9e5e48e3a4a4c12).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/super.md_-_Super_-_Basic_Usage_-_Implicit_Super_Objec…_(f9e5e48e3a4a4c12).snap index c9fcea3d5a..75eefd748b 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/super.md_-_Super_-_Basic_Usage_-_Implicit_Super_Objec…_(f9e5e48e3a4a4c12).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/super.md_-_Super_-_Basic_Usage_-_Implicit_Super_Objec…_(f9e5e48e3a4a4c12).snap @@ -58,106 +58,104 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/class/super.md 44 | ) -> BuilderMeta2: 45 | # revealed: , > 46 | s = reveal_type(super()) - 47 | # TODO: should be `BuilderMeta2` (needs https://github.com/astral-sh/ty/issues/501) - 48 | # revealed: Unknown - 49 | return reveal_type(s.__new__(cls, name, bases, dct)) - 50 | - 51 | class Foo[T]: - 52 | x: T - 53 | - 54 | def method(self: Any): - 55 | reveal_type(super()) # revealed: , Any> - 56 | - 57 | if isinstance(self, Foo): - 58 | reveal_type(super()) # revealed: , Any> - 59 | - 60 | def method2(self: Foo[T]): - 61 | # revealed: , Foo[T@Foo]> - 62 | reveal_type(super()) - 63 | - 64 | def method3(self: Foo): - 65 | # revealed: , Foo[Unknown]> - 66 | reveal_type(super()) - 67 | - 68 | def method4(self: Self): - 69 | # revealed: , Foo[T@Foo]> - 70 | reveal_type(super()) - 71 | - 72 | def method5[S: Foo[int]](self: S, other: S) -> S: - 73 | # revealed: , Foo[int]> - 74 | reveal_type(super()) - 75 | return self - 76 | - 77 | def method6[S: (Foo[int], Foo[str])](self: S, other: S) -> S: - 78 | # revealed: , Foo[int]> | , Foo[str]> - 79 | reveal_type(super()) - 80 | return self - 81 | - 82 | def method7[S](self: S, other: S) -> S: - 83 | # error: [invalid-super-argument] - 84 | # revealed: Unknown - 85 | reveal_type(super()) - 86 | return self - 87 | - 88 | def method8[S: int](self: S, other: S) -> S: - 89 | # error: [invalid-super-argument] - 90 | # revealed: Unknown - 91 | reveal_type(super()) - 92 | return self - 93 | - 94 | def method9[S: (int, str)](self: S, other: S) -> S: - 95 | # error: [invalid-super-argument] - 96 | # revealed: Unknown - 97 | reveal_type(super()) - 98 | return self - 99 | -100 | def method10[S: Callable[..., str]](self: S, other: S) -> S: -101 | # error: [invalid-super-argument] -102 | # revealed: Unknown -103 | reveal_type(super()) -104 | return self + 47 | return reveal_type(s.__new__(cls, name, bases, dct)) # revealed: BuilderMeta2 + 48 | + 49 | class Foo[T]: + 50 | x: T + 51 | + 52 | def method(self: Any): + 53 | reveal_type(super()) # revealed: , Any> + 54 | + 55 | if isinstance(self, Foo): + 56 | reveal_type(super()) # revealed: , Any> + 57 | + 58 | def method2(self: Foo[T]): + 59 | # revealed: , Foo[T@Foo]> + 60 | reveal_type(super()) + 61 | + 62 | def method3(self: Foo): + 63 | # revealed: , Foo[Unknown]> + 64 | reveal_type(super()) + 65 | + 66 | def method4(self: Self): + 67 | # revealed: , Foo[T@Foo]> + 68 | reveal_type(super()) + 69 | + 70 | def method5[S: Foo[int]](self: S, other: S) -> S: + 71 | # revealed: , Foo[int]> + 72 | reveal_type(super()) + 73 | return self + 74 | + 75 | def method6[S: (Foo[int], Foo[str])](self: S, other: S) -> S: + 76 | # revealed: , Foo[int]> | , Foo[str]> + 77 | reveal_type(super()) + 78 | return self + 79 | + 80 | def method7[S](self: S, other: S) -> S: + 81 | # error: [invalid-super-argument] + 82 | # revealed: Unknown + 83 | reveal_type(super()) + 84 | return self + 85 | + 86 | def method8[S: int](self: S, other: S) -> S: + 87 | # error: [invalid-super-argument] + 88 | # revealed: Unknown + 89 | reveal_type(super()) + 90 | return self + 91 | + 92 | def method9[S: (int, str)](self: S, other: S) -> S: + 93 | # error: [invalid-super-argument] + 94 | # revealed: Unknown + 95 | reveal_type(super()) + 96 | return self + 97 | + 98 | def method10[S: Callable[..., str]](self: S, other: S) -> S: + 99 | # error: [invalid-super-argument] +100 | # revealed: Unknown +101 | reveal_type(super()) +102 | return self +103 | +104 | type Alias = Bar 105 | -106 | type Alias = Bar -107 | -108 | class Bar: -109 | def method(self: Alias): -110 | # revealed: , Bar> -111 | reveal_type(super()) -112 | -113 | def pls_dont_call_me(self: Never): -114 | # revealed: , Unknown> -115 | reveal_type(super()) -116 | -117 | def only_call_me_on_callable_subclasses(self: Intersection[Bar, Callable[..., object]]): -118 | # revealed: , Bar> -119 | reveal_type(super()) -120 | -121 | class P(Protocol): -122 | def method(self: P): -123 | # revealed: , P> -124 | reveal_type(super()) -125 | -126 | class E(enum.Enum): -127 | X = 1 -128 | -129 | def method(self: E): -130 | match self: -131 | case E.X: -132 | # revealed: , E> -133 | reveal_type(super()) +106 | class Bar: +107 | def method(self: Alias): +108 | # revealed: , Bar> +109 | reveal_type(super()) +110 | +111 | def pls_dont_call_me(self: Never): +112 | # revealed: , Unknown> +113 | reveal_type(super()) +114 | +115 | def only_call_me_on_callable_subclasses(self: Intersection[Bar, Callable[..., object]]): +116 | # revealed: , Bar> +117 | reveal_type(super()) +118 | +119 | class P(Protocol): +120 | def method(self: P): +121 | # revealed: , P> +122 | reveal_type(super()) +123 | +124 | class E(enum.Enum): +125 | X = 1 +126 | +127 | def method(self: E): +128 | match self: +129 | case E.X: +130 | # revealed: , E> +131 | reveal_type(super()) ``` # Diagnostics ``` error[invalid-super-argument]: `S@method7` is not an instance or subclass of `` in `super(, S@method7)` call - --> src/mdtest_snippet.py:85:21 + --> src/mdtest_snippet.py:83:21 | -83 | # error: [invalid-super-argument] -84 | # revealed: Unknown -85 | reveal_type(super()) +81 | # error: [invalid-super-argument] +82 | # revealed: Unknown +83 | reveal_type(super()) | ^^^^^^^ -86 | return self +84 | return self | info: Type variable `S` has `object` as its implicit upper bound info: `object` is not an instance or subclass of `` @@ -168,13 +166,13 @@ info: rule `invalid-super-argument` is enabled by default ``` error[invalid-super-argument]: `S@method8` is not an instance or subclass of `` in `super(, S@method8)` call - --> src/mdtest_snippet.py:91:21 + --> src/mdtest_snippet.py:89:21 | -89 | # error: [invalid-super-argument] -90 | # revealed: Unknown -91 | reveal_type(super()) +87 | # error: [invalid-super-argument] +88 | # revealed: Unknown +89 | reveal_type(super()) | ^^^^^^^ -92 | return self +90 | return self | info: Type variable `S` has upper bound `int` info: `int` is not an instance or subclass of `` @@ -184,13 +182,13 @@ info: rule `invalid-super-argument` is enabled by default ``` error[invalid-super-argument]: `S@method9` is not an instance or subclass of `` in `super(, S@method9)` call - --> src/mdtest_snippet.py:97:21 + --> src/mdtest_snippet.py:95:21 | -95 | # error: [invalid-super-argument] -96 | # revealed: Unknown -97 | reveal_type(super()) +93 | # error: [invalid-super-argument] +94 | # revealed: Unknown +95 | reveal_type(super()) | ^^^^^^^ -98 | return self +96 | return self | info: Type variable `S` has constraints `int, str` info: `int | str` is not an instance or subclass of `` @@ -200,13 +198,13 @@ info: rule `invalid-super-argument` is enabled by default ``` error[invalid-super-argument]: `S@method10` is a type variable with an abstract/structural type as its bounds or constraints, in `super(, S@method10)` call - --> src/mdtest_snippet.py:103:21 + --> src/mdtest_snippet.py:101:21 | -101 | # error: [invalid-super-argument] -102 | # revealed: Unknown -103 | reveal_type(super()) + 99 | # error: [invalid-super-argument] +100 | # revealed: Unknown +101 | reveal_type(super()) | ^^^^^^^ -104 | return self +102 | return self | info: Type variable `S` has upper bound `(...) -> str` info: rule `invalid-super-argument` is enabled by default diff --git a/crates/ty_python_semantic/resources/mdtest/type_of/generics.md b/crates/ty_python_semantic/resources/mdtest/type_of/generics.md new file mode 100644 index 0000000000..c134e2f533 --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/type_of/generics.md @@ -0,0 +1,247 @@ +# `type[T]` + +`type[T]` with a type variable represents the class objects of `T`. + +```toml +[environment] +python-version = "3.13" +``` + +## Basic + +The meta-type of a typevar is `type[T]`. + +```py +def _[T](x: T): + reveal_type(type(x)) # revealed: type[T@_] +``` + +`type[T]` with an unbounded type variable represents any subclass of `object`. + +```py +def unbounded[T](x: type[T]) -> T: + reveal_type(x) # revealed: type[T@unbounded] + reveal_type(x.__repr__) # revealed: def __repr__(self) -> str + reveal_type(x.__init__) # revealed: def __init__(self) -> None + reveal_type(x.__qualname__) # revealed: str + reveal_type(x()) # revealed: T@unbounded + + return x() +``` + +`type[T]` with an upper bound of `T: A` represents any subclass of `A`. + +```py +class A: + x: str + + def __init__(self, value: str): ... + +class B(A): ... +class C: ... + +def upper_bound[T: A](x: type[T]) -> T: + reveal_type(x) # revealed: type[T@upper_bound] + reveal_type(x.__qualname__) # revealed: str + reveal_type(x("hello")) # revealed: T@upper_bound + + return x("hello") + +reveal_type(upper_bound(A)) # revealed: A +reveal_type(upper_bound(B)) # revealed: B + +# error: [invalid-argument-type] "Argument to function `upper_bound` is incorrect: Argument type `C` does not satisfy upper bound `A` of type variable `T`" +upper_bound(C) +``` + +`type[T]` with a constraints `T: (A, B)` represents exactly the class object `A`, or exactly `B`: + +```py +def constrained[T: (int, str)](x: type[T]) -> T: + reveal_type(x) # revealed: type[T@constrained] + reveal_type(x.__qualname__) # revealed: str + reveal_type(x("hello")) # revealed: T@constrained + + return x("hello") + +reveal_type(constrained(int)) # revealed: int +reveal_type(constrained(str)) # revealed: str + +# error: [invalid-argument-type] "Argument to function `constrained` is incorrect: Argument type `A` does not satisfy constraints (`int`, `str`) of type variable `T`" +constrained(A) +``` + +## Union + +```py +from ty_extensions import Intersection, Unknown + +def _[T: int](x: type | type[T]): + reveal_type(x()) # revealed: Any + +def _[T: int](x: type[int] | type[T]): + reveal_type(x()) # revealed: int + +def _[T](x: type[int] | type[T]): + reveal_type(x()) # revealed: int | T@_ +``` + +## Narrowing + +```py +from typing import TypeVar + +class A: ... + +def narrow_a[B: A](a: A, b: B): + type_of_a = type(a) + + reveal_type(a) # revealed: A + reveal_type(type_of_a) # revealed: type[A] + + if isinstance(a, type(b)): + reveal_type(a) # revealed: B@narrow_a + + if issubclass(type_of_a, type(b)): + reveal_type(type_of_a) # revealed: type[B@narrow_a] +``` + +## `__class__` + +```py +from typing import Self + +class A: + def copy(self: Self) -> Self: + reveal_type(self.__class__) # revealed: type[Self@copy] + reveal_type(self.__class__()) # revealed: Self@copy + return self.__class__() +``` + +## Subtyping + +A class `A` is a subtype of `type[T]` if any instance of `A` is a subtype of `T`. + +```py +from typing import Callable, Protocol +from ty_extensions import is_assignable_to, is_subtype_of, is_disjoint_from, static_assert + +class IntCallback(Protocol): + def __call__(self, *args, **kwargs) -> int: ... + +def _[T](_: T): + static_assert(not is_subtype_of(type[T], T)) + static_assert(not is_subtype_of(T, type[T])) + static_assert(not is_disjoint_from(type[T], T)) + static_assert(not is_disjoint_from(type[type], type)) + + static_assert(is_subtype_of(type[T], type[T])) + static_assert(not is_disjoint_from(type[T], type[T])) + + static_assert(is_assignable_to(type[T], Callable[..., T])) + static_assert(not is_disjoint_from(type[T], Callable[..., T])) + + static_assert(not is_assignable_to(type[T], IntCallback)) + static_assert(not is_disjoint_from(type[T], IntCallback)) + +def _[T: int](_: T): + static_assert(not is_subtype_of(type[T], T)) + static_assert(not is_subtype_of(T, type[T])) + static_assert(is_disjoint_from(type[T], T)) + + static_assert(not is_subtype_of(type[T], int)) + static_assert(not is_subtype_of(int, type[T])) + static_assert(is_disjoint_from(type[T], int)) + + static_assert(not is_subtype_of(type[int], type[T])) + static_assert(is_subtype_of(type[T], type[int])) + static_assert(not is_disjoint_from(type[T], type[int])) + + static_assert(is_subtype_of(type[T], type[T])) + static_assert(not is_disjoint_from(type[T], type[T])) + + static_assert(is_assignable_to(type[T], Callable[..., T])) + static_assert(not is_disjoint_from(type[T], Callable[..., T])) + + static_assert(is_assignable_to(type[T], IntCallback)) + static_assert(not is_disjoint_from(type[T], IntCallback)) + + static_assert(is_subtype_of(type[T], type[T] | None)) + static_assert(not is_disjoint_from(type[T], type[T] | None)) + + static_assert(is_subtype_of(type[T], type[T] | type[float])) + static_assert(not is_disjoint_from(type[T], type[T] | type[float])) + +def _[T: (int, str)](_: T): + static_assert(not is_subtype_of(type[T], T)) + static_assert(not is_subtype_of(T, type[T])) + static_assert(is_disjoint_from(type[T], T)) + + static_assert(is_subtype_of(type[T], type[T])) + static_assert(not is_disjoint_from(type[T], type[T])) + + static_assert(is_assignable_to(type[T], Callable[..., T])) + static_assert(not is_disjoint_from(type[T], Callable[..., T])) + + static_assert(not is_assignable_to(type[T], IntCallback)) + static_assert(not is_disjoint_from(type[T], IntCallback)) + + static_assert(is_subtype_of(type[T], type[T] | None)) + static_assert(not is_disjoint_from(type[T], type[T] | None)) + + static_assert(is_subtype_of(type[T], type[T] | type[float])) + static_assert(not is_disjoint_from(type[T], type[T] | type[float])) + + static_assert(not is_subtype_of(type[T], type[int])) + static_assert(not is_subtype_of(type[int], type[T])) + static_assert(not is_subtype_of(type[T], type[str])) + static_assert(not is_subtype_of(type[str], type[T])) + static_assert(not is_disjoint_from(type[T], type[int])) + static_assert(not is_disjoint_from(type[T], type[str])) + + static_assert(is_subtype_of(type[T], type[int] | type[str])) + static_assert(is_subtype_of(type[T], type[int | str])) + static_assert(not is_disjoint_from(type[T], type[int | str])) + static_assert(not is_disjoint_from(type[T], type[int] | type[str])) + +def _[T: (int | str, int)](_: T): + static_assert(is_subtype_of(type[int], type[T])) + static_assert(not is_disjoint_from(type[int], type[T])) +``` + +## Generic Type Inference + +```py +def f1[T](x: type[T]) -> type[T]: + return x + +reveal_type(f1(int)) # revealed: type[int] +reveal_type(f1(object)) # revealed: type + +def f2[T](x: T) -> type[T]: + return type(x) + +reveal_type(f2(int(1))) # revealed: type[int] +reveal_type(f2(object())) # revealed: type + +# TODO: This should reveal `type[Literal[1]]`. +reveal_type(f2(1)) # revealed: type[Unknown] + +def f3[T](x: type[T]) -> T: + return x() + +reveal_type(f3(int)) # revealed: int +reveal_type(f3(object)) # revealed: object +``` + +## Default Parameter + +```py +from typing import Any + +class Foo[T]: ... + +# TODO: This should not error. +# error: [invalid-parameter-default] "Default value of type `` is not assignable to annotated parameter type `type[T@f]`" +def f[T: Foo[Any]](x: type[T] = Foo): ... +``` diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 56b794e96b..01385a776d 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -1787,10 +1787,11 @@ impl<'db> Type<'db> { // TODO: This is unsound so in future we can consider an opt-in option to disable it. Type::SubclassOf(subclass_of_ty) => match subclass_of_ty.subclass_of() { SubclassOfInner::Class(class) => Some(class.into_callable(db)), - SubclassOfInner::Dynamic(dynamic) => { + + SubclassOfInner::Dynamic(_) | SubclassOfInner::TypeVar(_) => { Some(CallableTypes::one(CallableType::single( db, - Signature::new(Parameters::unknown(), Some(Type::Dynamic(dynamic))), + Signature::new(Parameters::unknown(), Some(Type::from(subclass_of_ty))), ))) } }, @@ -2075,13 +2076,14 @@ impl<'db> Type<'db> { // // However, there is one exception to this general rule: for any given typevar `T`, // `T` will always be a subtype of any union containing `T`. - // A similar rule applies in reverse to intersection types. (Type::TypeVar(bound_typevar), Type::Union(union)) if !bound_typevar.is_inferable(db, inferable) && union.elements(db).contains(&self) => { ConstraintSet::from(true) } + + // A similar rule applies in reverse to intersection types. (Type::Intersection(intersection), Type::TypeVar(bound_typevar)) if !bound_typevar.is_inferable(db, inferable) && intersection.positive(db).contains(&target) => @@ -2107,6 +2109,45 @@ impl<'db> Type<'db> { ConstraintSet::from(true) } + // `type[T]` is a subtype of the class object `A` if every instance of `T` is a subtype of an instance + // of `A`, and vice versa. + (Type::SubclassOf(subclass_of), _) + if subclass_of.is_type_var() + && !matches!(target, Type::Callable(_) | Type::ProtocolInstance(_)) => + { + let this_instance = Type::TypeVar(subclass_of.into_type_var().unwrap()); + let other_instance = match target { + Type::Union(union) => Some( + union.map(db, |element| element.to_instance(db).unwrap_or(Type::Never)), + ), + _ => target.to_instance(db), + }; + + other_instance.when_some_and(|other_instance| { + this_instance.has_relation_to_impl( + db, + other_instance, + inferable, + relation, + relation_visitor, + disjointness_visitor, + ) + }) + } + (_, Type::SubclassOf(subclass_of)) if subclass_of.is_type_var() => { + let other_instance = Type::TypeVar(subclass_of.into_type_var().unwrap()); + self.to_instance(db).when_some_and(|this_instance| { + this_instance.has_relation_to_impl( + db, + other_instance, + inferable, + relation, + relation_visitor, + disjointness_visitor, + ) + }) + } + // A fully static typevar is a subtype of its upper bound, and to something similar to // the union of its constraints. An unbound, unconstrained, fully static typevar has an // implicit upper bound of `object` (which is handled above). @@ -2613,7 +2654,7 @@ impl<'db> Type<'db> { // since `type[B]` describes all possible runtime subclasses of the class object `B`. (Type::ClassLiteral(class), Type::SubclassOf(target_subclass_ty)) => target_subclass_ty .subclass_of() - .into_class() + .into_class(db) .map(|subclass_of_class| { class.default_specialization(db).has_relation_to_impl( db, @@ -2627,7 +2668,7 @@ impl<'db> Type<'db> { .unwrap_or_else(|| ConstraintSet::from(relation.is_assignability())), (Type::GenericAlias(alias), Type::SubclassOf(target_subclass_ty)) => target_subclass_ty .subclass_of() - .into_class() + .into_class(db) .map(|subclass_of_class| { ClassType::Generic(alias).has_relation_to_impl( db, @@ -2725,7 +2766,7 @@ impl<'db> Type<'db> { // however, as they are not fully static types. (Type::SubclassOf(subclass_of_ty), _) => subclass_of_ty .subclass_of() - .into_class() + .into_class(db) .map(|class| class.metaclass_instance_type(db)) .unwrap_or_else(|| KnownClass::Type.to_instance(db)) .has_relation_to_impl( @@ -3043,6 +3084,57 @@ impl<'db> Type<'db> { ConstraintSet::from(false) } + // `type[T]` is disjoint from a callable or protocol instance if its upper bound or + // constraints are. + (Type::SubclassOf(subclass_of), Type::Callable(_) | Type::ProtocolInstance(_)) + | (Type::Callable(_) | Type::ProtocolInstance(_), Type::SubclassOf(subclass_of)) + if subclass_of.is_type_var() => + { + let type_var = subclass_of + .subclass_of() + .with_transposed_type_var(db) + .into_type_var() + .unwrap(); + + Type::TypeVar(type_var).is_disjoint_from_impl( + db, + other, + inferable, + disjointness_visitor, + relation_visitor, + ) + } + + // `type[T]` is disjoint from a class object `A` if every instance of `T` is disjoint from an instance of `A`. + (Type::SubclassOf(subclass_of), other) | (other, Type::SubclassOf(subclass_of)) + if subclass_of.is_type_var() => + { + let this_instance = Type::TypeVar(subclass_of.into_type_var().unwrap()); + let other_instance = match other { + Type::Union(union) => Some( + union.map(db, |element| element.to_instance(db).unwrap_or(Type::Never)), + ), + // An unbounded typevar `U` may have instances of type `object` if specialized to + // an instance of `type`. + Type::TypeVar(typevar) + if typevar.typevar(db).bound_or_constraints(db).is_none() => + { + Some(Type::object()) + } + _ => other.to_instance(db), + }; + + other_instance.when_none_or(|other_instance| { + this_instance.is_disjoint_from_impl( + db, + other_instance, + inferable, + disjointness_visitor, + relation_visitor, + ) + }) + } + // A typevar is never disjoint from itself, since all occurrences of the typevar must // be specialized to the same type. (This is an important difference between typevars // and `Any`!) Different typevars might be disjoint, depending on their bounds and @@ -3382,6 +3474,7 @@ impl<'db> Type<'db> { SubclassOfInner::Class(class_a) => { class_b.when_subclass_of(db, None, class_a).negate(db) } + SubclassOfInner::TypeVar(_) => unreachable!(), } } @@ -3392,6 +3485,7 @@ impl<'db> Type<'db> { SubclassOfInner::Class(class_a) => ClassType::from(alias_b) .when_subclass_of(db, class_a, inferable) .negate(db), + SubclassOfInner::TypeVar(_) => unreachable!(), } } @@ -3402,26 +3496,31 @@ impl<'db> Type<'db> { // for `type[Any]`/`type[Unknown]`/`type[Todo]`, we know the type cannot be any larger than `type`, // so although the type is dynamic we can still determine disjointedness in some situations (Type::SubclassOf(subclass_of_ty), other) - | (other, Type::SubclassOf(subclass_of_ty)) => match subclass_of_ty.subclass_of() { - SubclassOfInner::Dynamic(_) => { - KnownClass::Type.to_instance(db).is_disjoint_from_impl( - db, - other, - inferable, - disjointness_visitor, - relation_visitor, - ) + | (other, Type::SubclassOf(subclass_of_ty)) + if !subclass_of_ty.is_type_var() => + { + match subclass_of_ty.subclass_of() { + SubclassOfInner::Dynamic(_) => { + KnownClass::Type.to_instance(db).is_disjoint_from_impl( + db, + other, + inferable, + disjointness_visitor, + relation_visitor, + ) + } + SubclassOfInner::Class(class) => { + class.metaclass_instance_type(db).is_disjoint_from_impl( + db, + other, + inferable, + disjointness_visitor, + relation_visitor, + ) + } + SubclassOfInner::TypeVar(_) => unreachable!(), } - SubclassOfInner::Class(class) => { - class.metaclass_instance_type(db).is_disjoint_from_impl( - db, - other, - inferable, - disjointness_visitor, - relation_visitor, - ) - } - }, + } (Type::SpecialForm(special_form), Type::NominalInstance(instance)) | (Type::NominalInstance(instance), Type::SpecialForm(special_form)) => { @@ -3683,6 +3782,11 @@ impl<'db> Type<'db> { relation_visitor, ) } + + (Type::SubclassOf(_), _) | (_, Type::SubclassOf(_)) => { + // All cases should have been handled above. + unreachable!() + } } } @@ -4959,7 +5063,7 @@ impl<'db> Type<'db> { Type::ClassLiteral(literal) => Some(literal), Type::SubclassOf(subclass_of) => subclass_of .subclass_of() - .into_class() + .into_class(db) .map(|class| class.class_literal(db).0), _ => None, } { @@ -4975,7 +5079,7 @@ impl<'db> Type<'db> { } } - let class_attr_plain = self.find_name_in_mro_with_policy(db, name_str,policy).expect( + let class_attr_plain = self.find_name_in_mro_with_policy(db, name_str, policy).expect( "Calling `find_name_in_mro` on class literals and subclass-of types should always return `Some`", ); @@ -5245,12 +5349,16 @@ impl<'db> Type<'db> { .metaclass_instance_type(db) .try_bool_impl(db, allow_short_circuit, visitor)?, - Type::SubclassOf(subclass_of_ty) => match subclass_of_ty.subclass_of() { - SubclassOfInner::Dynamic(_) => Truthiness::Ambiguous, - SubclassOfInner::Class(class) => { - Type::from(class).try_bool_impl(db, allow_short_circuit, visitor)? + Type::SubclassOf(subclass_of_ty) => { + match subclass_of_ty.subclass_of().with_transposed_type_var(db) { + SubclassOfInner::Dynamic(_) => Truthiness::Ambiguous, + SubclassOfInner::Class(class) => { + Type::from(class).try_bool_impl(db, allow_short_circuit, visitor)? + } + SubclassOfInner::TypeVar(bound_typevar) => Type::TypeVar(bound_typevar) + .try_bool_impl(db, allow_short_circuit, visitor)?, } - }, + } Type::TypeVar(bound_typevar) => { match bound_typevar.typevar(db).bound_or_constraints(db) { @@ -5980,6 +6088,14 @@ impl<'db> Type<'db> { // evaluating callable subtyping). TODO improve this definition (intersection of // `__new__` and `__init__` signatures? and respect metaclass `__call__`). SubclassOfInner::Class(class) => Type::from(class).bindings(db), + + // TODO annotated return type on `__new__` or metaclass `__call__` + // TODO check call vs signatures of `__new__` and/or `__init__` + SubclassOfInner::TypeVar(_) => Binding::single( + self, + Signature::new(Parameters::gradual_form(), self.to_instance(db)), + ) + .into(), }, Type::NominalInstance(_) | Type::ProtocolInstance(_) | Type::NewTypeInstance(_) => { @@ -6853,6 +6969,17 @@ impl<'db> Type<'db> { Type::TypeVar(bound_typevar) => Some(Type::TypeVar(bound_typevar.to_instance(db)?)), Type::TypeAlias(alias) => alias.value_type(db).to_instance(db), Type::Intersection(_) => Some(todo_type!("Type::Intersection.to_instance")), + // An instance of class `C` may itself have instances if `C` is a subclass of `type`. + Type::NominalInstance(instance) + if KnownClass::Type + .to_class_literal(db) + .to_class_type(db) + .is_some_and(|type_class| { + instance.class(db).is_subclass_of(db, type_class) + }) => + { + Some(Type::object()) + } Type::BooleanLiteral(_) | Type::BytesLiteral(_) | Type::EnumLiteral(_) @@ -7254,35 +7381,22 @@ impl<'db> Type<'db> { Type::Callable(_) | Type::DataclassTransformer(_) => KnownClass::Type.to_instance(db), Type::ModuleLiteral(_) => KnownClass::ModuleType.to_class_literal(db), Type::TypeVar(bound_typevar) => { - match bound_typevar.typevar(db).bound_or_constraints(db) { - None => KnownClass::Type.to_instance(db), - Some(TypeVarBoundOrConstraints::UpperBound(bound)) => bound.to_meta_type(db), - Some(TypeVarBoundOrConstraints::Constraints(constraints)) => { - // TODO: If we add a proper `OneOf` connector, we should use that here instead - // of union. (Using a union here doesn't break anything, but it is imprecise.) - constraints.map(db, |constraint| constraint.to_meta_type(db)) - } - } + SubclassOfType::from(db, SubclassOfInner::TypeVar(bound_typevar)) } - Type::ClassLiteral(class) => class.metaclass(db), Type::GenericAlias(alias) => ClassType::from(alias).metaclass(db), - Type::SubclassOf(subclass_of_ty) => match subclass_of_ty.subclass_of() { - SubclassOfInner::Dynamic(_) => self, - SubclassOfInner::Class(class) => SubclassOfType::from( - db, - SubclassOfInner::try_from_type(db, class.metaclass(db)) - .unwrap_or(SubclassOfInner::unknown()), - ), + Type::SubclassOf(subclass_of_ty) => match subclass_of_ty.subclass_of().into_class(db) { + None => self, + Some(class) => SubclassOfType::try_from_type(db, class.metaclass(db)) + .unwrap_or(SubclassOfType::subclass_of_unknown()), }, Type::StringLiteral(_) | Type::LiteralString => KnownClass::Str.to_class_literal(db), Type::Dynamic(dynamic) => SubclassOfType::from(db, SubclassOfInner::Dynamic(dynamic)), // TODO intersections - Type::Intersection(_) => SubclassOfType::from( - db, - SubclassOfInner::try_from_type(db, todo_type!("Intersection meta-type")) - .expect("Type::Todo should be a valid `SubclassOfInner`"), - ), + Type::Intersection(_) => { + SubclassOfType::try_from_type(db, todo_type!("Intersection meta-type")) + .expect("Type::Todo should be a valid `SubclassOfInner`") + } Type::AlwaysTruthy | Type::AlwaysFalsy => KnownClass::Type.to_instance(db), Type::BoundSuper(_) => KnownClass::Super.to_class_literal(db), Type::ProtocolInstance(protocol) => protocol.to_meta_type(db), @@ -7378,41 +7492,7 @@ impl<'db> Type<'db> { } match self { - Type::TypeVar(bound_typevar) => match type_mapping { - TypeMapping::Specialization(specialization) => { - specialization.get(db, bound_typevar).unwrap_or(self) - } - TypeMapping::PartialSpecialization(partial) => { - partial.get(db, bound_typevar).unwrap_or(self) - } - TypeMapping::BindSelf(self_type) => { - if bound_typevar.typevar(db).is_self(db) { - *self_type - } else { - self - } - } - TypeMapping::ReplaceSelf { new_upper_bound } => { - if bound_typevar.typevar(db).is_self(db) { - Type::TypeVar( - BoundTypeVarInstance::synthetic_self( - db, - *new_upper_bound, - bound_typevar.binding_context(db) - ) - ) - } else { - self - } - } - TypeMapping::PromoteLiterals(_) - | TypeMapping::ReplaceParameterDefaults - | TypeMapping::BindLegacyTypevars(_) - | TypeMapping::EagerExpansion => self, - TypeMapping::Materialize(materialization_kind) => { - Type::TypeVar(bound_typevar.materialize_impl(db, *materialization_kind, visitor)) - } - } + Type::TypeVar(bound_typevar) => bound_typevar.apply_type_mapping_impl(db, type_mapping, visitor), Type::KnownInstance(KnownInstanceType::TypeVar(typevar)) => match type_mapping { TypeMapping::BindLegacyTypevars(binding_context) => { @@ -7869,6 +7949,7 @@ impl<'db> Type<'db> { Self::SubclassOf(subclass_of_type) => match subclass_of_type.subclass_of() { SubclassOfInner::Class(class) => Some(TypeDefinition::Class(class.definition(db))), SubclassOfInner::Dynamic(_) => None, + SubclassOfInner::TypeVar(bound_typevar) => Some(TypeDefinition::TypeVar(bound_typevar.typevar(db).definition(db)?)), }, Self::TypeAlias(alias) => alias.value_type(db).definition(db), @@ -9556,6 +9637,25 @@ impl<'db> BoundTypeVarInstance<'db> { Self::new(db, typevar, binding_context) } + /// Returns an identical type variable with its `TypeVarBoundOrConstraints` mapped by the + /// provided closure. + pub(crate) fn map_bound_or_constraints( + self, + db: &'db dyn Db, + f: impl FnOnce(Option>) -> Option>, + ) -> Self { + let bound_or_constraints = f(self.typevar(db).bound_or_constraints(db)); + let typevar = TypeVarInstance::new( + db, + self.typevar(db).identity(db), + bound_or_constraints.map(TypeVarBoundOrConstraintsEvaluation::Eager), + self.typevar(db).explicit_variance(db), + self.typevar(db)._default(db), + ); + + Self::new(db, typevar, self.binding_context(db)) + } + pub(crate) fn variance_with_polarity( self, db: &'db dyn Db, @@ -9576,6 +9676,47 @@ impl<'db> BoundTypeVarInstance<'db> { pub fn variance(self, db: &'db dyn Db) -> TypeVarVariance { self.variance_with_polarity(db, TypeVarVariance::Covariant) } + + fn apply_type_mapping_impl<'a>( + self, + db: &'db dyn Db, + type_mapping: &TypeMapping<'a, 'db>, + visitor: &ApplyTypeMappingVisitor<'db>, + ) -> Type<'db> { + match type_mapping { + TypeMapping::Specialization(specialization) => { + specialization.get(db, self).unwrap_or(Type::TypeVar(self)) + } + TypeMapping::PartialSpecialization(partial) => { + partial.get(db, self).unwrap_or(Type::TypeVar(self)) + } + TypeMapping::BindSelf(self_type) => { + if self.typevar(db).is_self(db) { + *self_type + } else { + Type::TypeVar(self) + } + } + TypeMapping::ReplaceSelf { new_upper_bound } => { + if self.typevar(db).is_self(db) { + Type::TypeVar(BoundTypeVarInstance::synthetic_self( + db, + *new_upper_bound, + self.binding_context(db), + )) + } else { + Type::TypeVar(self) + } + } + TypeMapping::PromoteLiterals(_) + | TypeMapping::ReplaceParameterDefaults + | TypeMapping::BindLegacyTypevars(_) + | TypeMapping::EagerExpansion => Type::TypeVar(self), + TypeMapping::Materialize(materialization_kind) => { + Type::TypeVar(self.materialize_impl(db, *materialization_kind, visitor)) + } + } + } } fn walk_bound_type_var_type<'db, V: visitor::TypeVisitor<'db> + ?Sized>( @@ -9741,8 +9882,7 @@ impl<'db> TypeVarBoundOrConstraints<'db> { .elements(db) .iter() .map(|ty| ty.materialize(db, materialization_kind, visitor)) - .collect::>() - .into_boxed_slice(), + .collect::>(), )) } } diff --git a/crates/ty_python_semantic/src/types/bound_super.rs b/crates/ty_python_semantic/src/types/bound_super.rs index 95ac7b6148..e963e6a366 100644 --- a/crates/ty_python_semantic/src/types/bound_super.rs +++ b/crates/ty_python_semantic/src/types/bound_super.rs @@ -310,10 +310,15 @@ impl<'db> BoundSuperType<'db> { Type::Never => SuperOwnerKind::Dynamic(DynamicType::Unknown), Type::Dynamic(dynamic) => SuperOwnerKind::Dynamic(dynamic), Type::ClassLiteral(class) => SuperOwnerKind::Class(ClassType::NonGeneric(class)), - Type::SubclassOf(subclass_of_type) => match subclass_of_type.subclass_of() { - SubclassOfInner::Class(class) => SuperOwnerKind::Class(class), - SubclassOfInner::Dynamic(dynamic) => SuperOwnerKind::Dynamic(dynamic), - }, + Type::SubclassOf(subclass_of_type) => { + match subclass_of_type.subclass_of().with_transposed_type_var(db) { + SubclassOfInner::Class(class) => SuperOwnerKind::Class(class), + SubclassOfInner::Dynamic(dynamic) => SuperOwnerKind::Dynamic(dynamic), + SubclassOfInner::TypeVar(bound_typevar) => { + return delegate_to(Type::TypeVar(bound_typevar)); + } + } + } Type::NominalInstance(instance) => SuperOwnerKind::Instance(instance), Type::ProtocolInstance(protocol) => { @@ -450,8 +455,15 @@ impl<'db> BoundSuperType<'db> { let pivot_class = match pivot_class_type { Type::ClassLiteral(class) => ClassBase::Class(ClassType::NonGeneric(class)), Type::SubclassOf(subclass_of) => match subclass_of.subclass_of() { - SubclassOfInner::Class(class) => ClassBase::Class(class), SubclassOfInner::Dynamic(dynamic) => ClassBase::Dynamic(dynamic), + _ => match subclass_of.subclass_of().into_class(db) { + Some(class) => ClassBase::Class(class), + None => { + return Err(BoundSuperError::InvalidPivotClassType { + pivot_class: pivot_class_type, + }); + } + }, }, Type::SpecialForm(SpecialFormType::Protocol) => ClassBase::Protocol, Type::SpecialForm(SpecialFormType::Generic) => ClassBase::Generic, diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index 368c04601f..ae33d378a2 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -3122,7 +3122,7 @@ pub(crate) fn report_undeclared_protocol_member( Type::SubclassOf(subclass_of) => match subclass_of.subclass_of() { SubclassOfInner::Class(class) => class, SubclassOfInner::Dynamic(DynamicType::Any) => return true, - SubclassOfInner::Dynamic(_) => return false, + SubclassOfInner::Dynamic(_) | SubclassOfInner::TypeVar(_) => return false, }, Type::NominalInstance(instance) => instance.class(db), Type::Union(union) => { diff --git a/crates/ty_python_semantic/src/types/display.rs b/crates/ty_python_semantic/src/types/display.rs index 10912385bf..428a65ca9c 100644 --- a/crates/ty_python_semantic/src/types/display.rs +++ b/crates/ty_python_semantic/src/types/display.rs @@ -688,6 +688,11 @@ impl<'db> FmtDetailed<'db> for DisplayRepresentation<'db> { write!(f.with_type(Type::Dynamic(dynamic)), "{dynamic}")?; f.write_char(']') } + SubclassOfInner::TypeVar(bound_typevar) => write!( + f, + "type[{}]", + bound_typevar.identity(self.db).display(self.db) + ), }, Type::SpecialForm(special_form) => { write!(f.with_type(self.ty), "{special_form}") diff --git a/crates/ty_python_semantic/src/types/generics.rs b/crates/ty_python_semantic/src/types/generics.rs index 47b9b51cd7..cf14bc861a 100644 --- a/crates/ty_python_semantic/src/types/generics.rs +++ b/crates/ty_python_semantic/src/types/generics.rs @@ -1557,9 +1557,16 @@ impl<'db> SpecializationBuilder<'db> { argument: ty, }); } - _ => { - self.add_type_mapping(bound_typevar, ty, polarity, f); - } + _ => self.add_type_mapping(bound_typevar, ty, polarity, f), + } + } + + (Type::SubclassOf(subclass_of), ty) | (ty, Type::SubclassOf(subclass_of)) + if subclass_of.is_type_var() => + { + let formal_instance = Type::TypeVar(subclass_of.into_type_var().unwrap()); + if let Some(actual_instance) = ty.to_instance(self.db) { + return self.infer_map_impl(formal_instance, actual_instance, polarity, f); } } diff --git a/crates/ty_python_semantic/src/types/ide_support.rs b/crates/ty_python_semantic/src/types/ide_support.rs index a6e33011f6..74eab52e72 100644 --- a/crates/ty_python_semantic/src/types/ide_support.rs +++ b/crates/ty_python_semantic/src/types/ide_support.rs @@ -176,17 +176,19 @@ impl<'db> AllMembers<'db> { } Type::SubclassOf(subclass_of_type) => match subclass_of_type.subclass_of() { - SubclassOfInner::Class(class_type) => { - let (class_literal, specialization) = class_type.class_literal(db); - self.extend_with_class_members(db, ty, class_literal); - self.extend_with_synthetic_members(db, ty, class_literal, specialization); - if let Type::ClassLiteral(metaclass) = class_literal.metaclass(db) { - self.extend_with_class_members(db, ty, metaclass); - } - } SubclassOfInner::Dynamic(_) => { self.extend_with_type(db, KnownClass::Type.to_instance(db)); } + _ => { + if let Some(class_type) = subclass_of_type.subclass_of().into_class(db) { + let (class_literal, specialization) = class_type.class_literal(db); + self.extend_with_class_members(db, ty, class_literal); + self.extend_with_synthetic_members(db, ty, class_literal, specialization); + if let Type::ClassLiteral(metaclass) = class_literal.metaclass(db) { + self.extend_with_class_members(db, ty, metaclass); + } + } + } }, Type::Dynamic(_) | Type::Never | Type::AlwaysTruthy | Type::AlwaysFalsy => { @@ -241,7 +243,7 @@ impl<'db> AllMembers<'db> { self.extend_with_class_members(db, ty, class_literal); } Type::SubclassOf(subclass_of) => { - if let Some(class) = subclass_of.subclass_of().into_class() { + if let Some(class) = subclass_of.subclass_of().into_class(db) { self.extend_with_class_members(db, ty, class.class_literal(db).0); } } @@ -777,7 +779,7 @@ pub fn definitions_for_attribute<'db>( }; let class_literal = match meta_type { Type::ClassLiteral(class_literal) => class_literal, - Type::SubclassOf(subclass) => match subclass.subclass_of().into_class() { + Type::SubclassOf(subclass) => match subclass.subclass_of().into_class(db) { Some(cls) => cls.class_literal(db).0, None => continue, }, diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index b8005da421..68b35bec62 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -8133,7 +8133,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { let class = match callable_type { Type::ClassLiteral(class) => Some(ClassType::NonGeneric(class)), Type::GenericAlias(generic) => Some(ClassType::Generic(generic)), - Type::SubclassOf(subclass) => subclass.subclass_of().into_class(), + Type::SubclassOf(subclass) => subclass.subclass_of().into_class(self.db()), _ => None, }; @@ -9112,7 +9112,6 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { }); let attr_name = &attr.id; - let resolved_type = fallback_place.unwrap_with_diagnostic(|lookup_err| match lookup_err { LookupError::Undefined(_) => { let fallback = || { @@ -9140,6 +9139,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { "Attribute lookup on a dynamic `SubclassOf` type \ should always return a bound symbol" ), + SubclassOfInner::TypeVar(_) => false, } } _ => false, diff --git a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs index 7c2addf9f1..14a4079eb4 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs @@ -641,27 +641,8 @@ impl<'db> TypeInferenceBuilder<'db, '_> { fn infer_subclass_of_type_expression(&mut self, slice: &ast::Expr) -> Type<'db> { match slice { ast::Expr::Name(_) | ast::Expr::Attribute(_) => { - let name_ty = self.infer_expression(slice, TypeContext::default()); - match name_ty { - Type::ClassLiteral(class_literal) => { - if class_literal.is_protocol(self.db()) { - SubclassOfType::from( - self.db(), - todo_type!("type[T] for protocols").expect_dynamic(), - ) - } else { - SubclassOfType::from( - self.db(), - class_literal.default_specialization(self.db()), - ) - } - } - Type::SpecialForm(SpecialFormType::Any) => SubclassOfType::subclass_of_any(), - Type::SpecialForm(SpecialFormType::Unknown) => { - SubclassOfType::subclass_of_unknown() - } - _ => todo_type!("unsupported type[X] special form"), - } + SubclassOfType::try_from_instance(self.db(), self.infer_type_expression(slice)) + .unwrap_or(todo_type!("unsupported type[X] special form")) } ast::Expr::BinOp(binary) if binary.op == ast::Operator::BitOr => { let union_ty = UnionType::from_elements_leave_aliases( diff --git a/crates/ty_python_semantic/src/types/narrow.rs b/crates/ty_python_semantic/src/types/narrow.rs index ae5ec4a4d6..32ac648dc4 100644 --- a/crates/ty_python_semantic/src/types/narrow.rs +++ b/crates/ty_python_semantic/src/types/narrow.rs @@ -171,6 +171,10 @@ impl ClassInfoConstraintFunction { // e.g. `isinstance(x, list[int])` fails at runtime. SubclassOfInner::Class(ClassType::Generic(_)) => None, SubclassOfInner::Dynamic(dynamic) => Some(Type::Dynamic(dynamic)), + SubclassOfInner::TypeVar(bound_typevar) => match self { + ClassInfoConstraintFunction::IsSubclass => Some(classinfo), + ClassInfoConstraintFunction::IsInstance => Some(Type::TypeVar(bound_typevar)), + }, }, Type::Dynamic(_) => Some(classinfo), Type::Intersection(intersection) => { diff --git a/crates/ty_python_semantic/src/types/subclass_of.rs b/crates/ty_python_semantic/src/types/subclass_of.rs index b5b9e00c06..ed69554c8c 100644 --- a/crates/ty_python_semantic/src/types/subclass_of.rs +++ b/crates/ty_python_semantic/src/types/subclass_of.rs @@ -8,7 +8,7 @@ use crate::types::{ ApplyTypeMappingVisitor, BoundTypeVarInstance, ClassType, DynamicType, FindLegacyTypeVarsVisitor, HasRelationToVisitor, IsDisjointVisitor, KnownClass, MaterializationKind, MemberLookupPolicy, NormalizedVisitor, SpecialFormType, Type, TypeContext, - TypeMapping, TypeRelation, + TypeMapping, TypeRelation, TypeVarBoundOrConstraints, UnionType, todo_type, }; use crate::{Db, FxOrderSet}; @@ -26,7 +26,7 @@ pub(super) fn walk_subclass_of_type<'db, V: super::visitor::TypeVisitor<'db> + ? subclass_of: SubclassOfType<'db>, visitor: &V, ) { - visitor.visit_type(db, Type::from(subclass_of.subclass_of)); + visitor.visit_type(db, Type::from(subclass_of)); } impl<'db> SubclassOfType<'db> { @@ -44,19 +44,44 @@ impl<'db> SubclassOfType<'db> { pub(crate) fn from(db: &'db dyn Db, subclass_of: impl Into>) -> Type<'db> { let subclass_of = subclass_of.into(); match subclass_of { - SubclassOfInner::Dynamic(_) => Type::SubclassOf(Self { subclass_of }), SubclassOfInner::Class(class) => { if class.is_final(db) { Type::from(class) } else if class.is_object(db) { - KnownClass::Type.to_instance(db) + Self::subclass_of_object(db) } else { Type::SubclassOf(Self { subclass_of }) } } + SubclassOfInner::Dynamic(_) | SubclassOfInner::TypeVar(_) => { + Type::SubclassOf(Self { subclass_of }) + } } } + /// Given the class object `T`, returns a [`Type`] instance representing `type[T]`. + pub(crate) fn try_from_type(db: &'db dyn Db, ty: Type<'db>) -> Option> { + let subclass_of = match ty { + Type::Dynamic(dynamic) => SubclassOfInner::Dynamic(dynamic), + Type::ClassLiteral(literal) => { + SubclassOfInner::Class(literal.default_specialization(db)) + } + Type::GenericAlias(generic) => SubclassOfInner::Class(ClassType::Generic(generic)), + Type::SpecialForm(SpecialFormType::Any) => SubclassOfInner::Dynamic(DynamicType::Any), + Type::SpecialForm(SpecialFormType::Unknown) => { + SubclassOfInner::Dynamic(DynamicType::Unknown) + } + _ => return None, + }; + + Some(Self::from(db, subclass_of)) + } + + /// Given an instance of the class or type variable `T`, returns a [`Type`] instance representing `type[T]`. + pub(crate) fn try_from_instance(db: &'db dyn Db, ty: Type<'db>) -> Option> { + SubclassOfInner::try_from_instance(db, ty).map(|subclass_of| Self::from(db, subclass_of)) + } + /// Return a [`Type`] instance representing the type `type[Unknown]`. pub(crate) const fn subclass_of_unknown() -> Type<'db> { Type::SubclassOf(SubclassOfType { @@ -65,12 +90,19 @@ impl<'db> SubclassOfType<'db> { } /// Return a [`Type`] instance representing the type `type[Any]`. + #[cfg(test)] pub(crate) const fn subclass_of_any() -> Type<'db> { Type::SubclassOf(SubclassOfType { subclass_of: SubclassOfInner::Dynamic(DynamicType::Any), }) } + /// Return a [`Type`] instance representing the type `type[object]`. + pub(crate) fn subclass_of_object(db: &'db dyn Db) -> Type<'db> { + // See the documentation of `SubclassOfType::from` for details. + KnownClass::Type.to_instance(db) + } + /// Return the inner [`SubclassOfInner`] value wrapped by this `SubclassOfType`. pub(crate) const fn subclass_of(self) -> SubclassOfInner<'db> { self.subclass_of @@ -82,6 +114,15 @@ impl<'db> SubclassOfType<'db> { subclass_of.is_dynamic() } + pub(crate) const fn is_type_var(self) -> bool { + let Self { subclass_of } = self; + subclass_of.is_type_var() + } + + pub(crate) const fn into_type_var(self) -> Option> { + self.subclass_of.into_type_var() + } + pub(super) fn apply_type_mapping_impl<'a>( self, db: &'db dyn Db, @@ -105,6 +146,11 @@ impl<'db> SubclassOfType<'db> { }, _ => Type::SubclassOf(self), }, + SubclassOfInner::TypeVar(typevar) => SubclassOfType::try_from_instance( + db, + typevar.apply_type_mapping_impl(db, type_mapping, visitor), + ) + .unwrap_or(SubclassOfType::subclass_of_unknown()), } } @@ -116,10 +162,18 @@ impl<'db> SubclassOfType<'db> { visitor: &FindLegacyTypeVarsVisitor<'db>, ) { match self.subclass_of { + SubclassOfInner::Dynamic(_) => {} SubclassOfInner::Class(class) => { class.find_legacy_typevars_impl(db, binding_context, typevars, visitor); } - SubclassOfInner::Dynamic(_) => {} + SubclassOfInner::TypeVar(typevar) => { + Type::TypeVar(typevar).find_legacy_typevars_impl( + db, + binding_context, + typevars, + visitor, + ); + } } } @@ -129,7 +183,19 @@ impl<'db> SubclassOfType<'db> { name: &str, policy: MemberLookupPolicy, ) -> Option> { - Type::from(self.subclass_of).find_name_in_mro_with_policy(db, name, policy) + let class_like = match self.subclass_of.with_transposed_type_var(db) { + SubclassOfInner::Class(class) => Type::from(class), + SubclassOfInner::Dynamic(dynamic) => Type::Dynamic(dynamic), + SubclassOfInner::TypeVar(bound_typevar) => { + match bound_typevar.typevar(db).bound_or_constraints(db) { + None => unreachable!(), + Some(TypeVarBoundOrConstraints::UpperBound(bound)) => bound, + Some(TypeVarBoundOrConstraints::Constraints(union)) => Type::Union(union), + } + } + }; + + class_like.find_name_in_mro_with_policy(db, name, policy) } /// Return `true` if `self` has a certain relation to `other`. @@ -165,6 +231,10 @@ impl<'db> SubclassOfType<'db> { relation_visitor, disjointness_visitor, ), + + (SubclassOfInner::TypeVar(_), _) | (_, SubclassOfInner::TypeVar(_)) => { + unreachable!() + } } } @@ -185,6 +255,9 @@ impl<'db> SubclassOfType<'db> { (SubclassOfInner::Class(self_class), SubclassOfInner::Class(other_class)) => { ConstraintSet::from(!self_class.could_coexist_in_mro_with(db, other_class)) } + (SubclassOfInner::TypeVar(_), _) | (_, SubclassOfInner::TypeVar(_)) => { + unreachable!() + } } } @@ -212,12 +285,13 @@ impl<'db> SubclassOfType<'db> { match self.subclass_of { SubclassOfInner::Class(class) => Type::instance(db, class), SubclassOfInner::Dynamic(dynamic_type) => Type::Dynamic(dynamic_type), + SubclassOfInner::TypeVar(bound_typevar) => Type::TypeVar(bound_typevar), } } pub(crate) fn is_typed_dict(self, db: &'db dyn Db) -> bool { self.subclass_of - .into_class() + .into_class(db) .is_some_and(|class| class.class_literal(db).0.is_typed_dict(db)) } } @@ -225,8 +299,8 @@ impl<'db> SubclassOfType<'db> { impl<'db> VarianceInferable<'db> for SubclassOfType<'db> { fn variance_of(self, db: &dyn Db, typevar: BoundTypeVarInstance<'_>) -> TypeVarVariance { match self.subclass_of { - SubclassOfInner::Dynamic(_) => TypeVarVariance::Bivariant, SubclassOfInner::Class(class) => class.variance_of(db, typevar), + SubclassOfInner::Dynamic(_) | SubclassOfInner::TypeVar(_) => TypeVarVariance::Bivariant, } } } @@ -235,6 +309,7 @@ impl<'db> VarianceInferable<'db> for SubclassOfType<'db> { /// /// 1. A "subclass of a class": `type[C]` for any class object `C` /// 2. A "subclass of a dynamic type": `type[Any]`, `type[Unknown]` and `type[@Todo]` +/// 3. A "subclass of a type variable": `type[T]` for any type variable `T` /// /// In the long term, we may want to implement . /// Doing this would allow us to get rid of this enum, @@ -249,6 +324,7 @@ impl<'db> VarianceInferable<'db> for SubclassOfType<'db> { pub(crate) enum SubclassOfInner<'db> { Class(ClassType<'db>), Dynamic(DynamicType), + TypeVar(BoundTypeVarInstance<'db>), } impl<'db> SubclassOfInner<'db> { @@ -260,24 +336,111 @@ impl<'db> SubclassOfInner<'db> { matches!(self, Self::Dynamic(_)) } - pub(crate) const fn into_class(self) -> Option> { + pub(crate) const fn is_type_var(self) -> bool { + matches!(self, Self::TypeVar(_)) + } + + pub(crate) fn into_class(self, db: &'db dyn Db) -> Option> { match self { - Self::Class(class) => Some(class), Self::Dynamic(_) => None, + Self::Class(class) => Some(class), + Self::TypeVar(bound_typevar) => { + match bound_typevar.typevar(db).bound_or_constraints(db) { + None => Some(ClassType::object(db)), + Some(TypeVarBoundOrConstraints::UpperBound(bound)) => { + Self::try_from_instance(db, bound) + .and_then(|subclass_of| subclass_of.into_class(db)) + } + Some(TypeVarBoundOrConstraints::Constraints(constraints)) => { + match constraints.elements(db) { + [bound] => Self::try_from_instance(db, *bound) + .and_then(|subclass_of| subclass_of.into_class(db)), + _ => Some(ClassType::object(db)), + } + } + } + } } } pub(crate) const fn into_dynamic(self) -> Option { match self { - Self::Class(_) => None, + Self::Class(_) | Self::TypeVar(_) => None, Self::Dynamic(dynamic) => Some(dynamic), } } + pub(crate) const fn into_type_var(self) -> Option> { + match self { + Self::Class(_) | Self::Dynamic(_) => None, + Self::TypeVar(bound_typevar) => Some(bound_typevar), + } + } + + pub(crate) fn try_from_instance(db: &'db dyn Db, ty: Type<'db>) -> Option { + Some(match ty { + Type::NominalInstance(instance) => SubclassOfInner::Class(instance.class(db)), + Type::TypedDict(typed_dict) => SubclassOfInner::Class(typed_dict.defining_class()), + Type::TypeVar(bound_typevar) => SubclassOfInner::TypeVar(bound_typevar), + Type::Dynamic(DynamicType::Any) => SubclassOfInner::Dynamic(DynamicType::Any), + Type::Dynamic(DynamicType::Unknown) => SubclassOfInner::Dynamic(DynamicType::Unknown), + Type::ProtocolInstance(_) => { + SubclassOfInner::Dynamic(todo_type!("type[T] for protocols").expect_dynamic()) + } + _ => return None, + }) + } + + /// Transposes `type[T]` with a type variable `T` into `T: type[...]`. + /// + /// In particular: + /// - If `T` has an upper bound of `T: Bound`, this returns `T: type[Bound]`. + /// - If `T` has constraints `T: (A, B)`, this returns `T: (type[A], type[B])`. + /// - Otherwise, for an unbounded type variable, this returns `type[object]`. + /// + /// If this is type of a concrete type `C`, returns the type unchanged. + pub(crate) fn with_transposed_type_var(self, db: &'db dyn Db) -> Self { + let Some(bound_typevar) = self.into_type_var() else { + return self; + }; + + let bound_typevar = bound_typevar.map_bound_or_constraints(db, |bound_or_constraints| { + Some(match bound_or_constraints { + None => TypeVarBoundOrConstraints::UpperBound( + SubclassOfType::try_from_instance(db, Type::object()) + .unwrap_or(SubclassOfType::subclass_of_unknown()), + ), + Some(TypeVarBoundOrConstraints::UpperBound(bound)) => { + TypeVarBoundOrConstraints::UpperBound( + SubclassOfType::try_from_instance(db, bound) + .unwrap_or(SubclassOfType::subclass_of_unknown()), + ) + } + Some(TypeVarBoundOrConstraints::Constraints(constraints)) => { + let constraints = constraints + .elements(db) + .iter() + .map(|constraint| { + SubclassOfType::try_from_instance(db, *constraint) + .unwrap_or(SubclassOfType::subclass_of_unknown()) + }) + .collect::>(); + + TypeVarBoundOrConstraints::Constraints(UnionType::new(db, constraints)) + } + }) + }); + + Self::TypeVar(bound_typevar) + } + pub(crate) fn normalized_impl(self, db: &'db dyn Db, visitor: &NormalizedVisitor<'db>) -> Self { match self { Self::Class(class) => Self::Class(class.normalized_impl(db, visitor)), Self::Dynamic(dynamic) => Self::Dynamic(dynamic.normalized()), + Self::TypeVar(bound_typevar) => { + Self::TypeVar(bound_typevar.normalized_impl(db, visitor)) + } } } @@ -293,16 +456,7 @@ impl<'db> SubclassOfInner<'db> { class.recursive_type_normalized_impl(db, div, nested, visitor)?, )), Self::Dynamic(dynamic) => Some(Self::Dynamic(dynamic.recursive_type_normalized())), - } - } - - pub(crate) fn try_from_type(db: &'db dyn Db, ty: Type<'db>) -> Option { - match ty { - Type::Dynamic(dynamic) => Some(Self::Dynamic(dynamic)), - Type::ClassLiteral(literal) => Some(Self::Class(literal.default_specialization(db))), - Type::GenericAlias(generic) => Some(Self::Class(ClassType::Generic(generic))), - Type::SpecialForm(SpecialFormType::Any) => Some(Self::Dynamic(DynamicType::Any)), - _ => None, + Self::TypeVar(_) => Some(self), } } } @@ -325,11 +479,18 @@ impl<'db> From> for SubclassOfInner<'db> { } } -impl<'db> From> for Type<'db> { - fn from(value: SubclassOfInner<'db>) -> Self { - match value { - SubclassOfInner::Dynamic(dynamic) => Type::Dynamic(dynamic), +impl<'db> From> for SubclassOfInner<'db> { + fn from(value: BoundTypeVarInstance<'db>) -> Self { + SubclassOfInner::TypeVar(value) + } +} + +impl<'db> From> for Type<'db> { + fn from(value: SubclassOfType<'db>) -> Self { + match value.subclass_of { SubclassOfInner::Class(class) => class.into(), + SubclassOfInner::Dynamic(dynamic) => Type::Dynamic(dynamic), + SubclassOfInner::TypeVar(bound_typevar) => Type::TypeVar(bound_typevar), } } } diff --git a/crates/ty_python_semantic/src/types/type_ordering.rs b/crates/ty_python_semantic/src/types/type_ordering.rs index cb2f75b108..d2c9a71208 100644 --- a/crates/ty_python_semantic/src/types/type_ordering.rs +++ b/crates/ty_python_semantic/src/types/type_ordering.rs @@ -117,6 +117,11 @@ pub(super) fn union_or_intersection_elements_ordering<'db>( (SubclassOfInner::Dynamic(left), SubclassOfInner::Dynamic(right)) => { dynamic_elements_ordering(left, right) } + (SubclassOfInner::TypeVar(left), SubclassOfInner::TypeVar(right)) => { + left.as_id().cmp(&right.as_id()) + } + (SubclassOfInner::TypeVar(_), _) => Ordering::Less, + (_, SubclassOfInner::TypeVar(_)) => Ordering::Greater, } } From 98681b9356bd0b8ef086cc54118b58de532c5310 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Fri, 28 Nov 2025 17:59:58 +0530 Subject: [PATCH 15/67] [ty] Add `db` parameter to `Parameters::new` method (#21674) ## Summary This PR adds a new `db` parameter to `Parameters::new` for https://github.com/astral-sh/ruff/pull/21445. This change creates a large diff so thought to split it out as it's just a mechanical change. The `Parameters::new` method not only creates the `Parameters` but also analyses the parameters to check what kind it is. For `ParamSpec` support, it's going to require the `db` to check whether the annotated type is `ParamSpec` or not. For the current set of parameters that isn't required because it's only checking whether it's dynamic or not which doesn't require `db`. --- crates/ty_python_semantic/src/place.rs | 1 + crates/ty_python_semantic/src/types.rs | 761 ++++++++++-------- crates/ty_python_semantic/src/types/class.rs | 268 +++--- .../ty_python_semantic/src/types/display.rs | 8 +- .../src/types/infer/builder.rs | 10 +- .../types/infer/builder/type_expression.rs | 9 +- .../types/property_tests/type_generation.rs | 39 +- .../src/types/protocol_class.rs | 5 +- .../src/types/signatures.rs | 38 +- 9 files changed, 656 insertions(+), 483 deletions(-) diff --git a/crates/ty_python_semantic/src/place.rs b/crates/ty_python_semantic/src/place.rs index 589a4720f4..6e46819b14 100644 --- a/crates/ty_python_semantic/src/place.rs +++ b/crates/ty_python_semantic/src/place.rs @@ -1509,6 +1509,7 @@ mod implicit_globals { "__annotate__" if Program::get(db).python_version(db) >= PythonVersion::PY314 => { let signature = Signature::new( Parameters::new( + db, [Parameter::positional_only(Some(Name::new_static("format"))) .with_annotated_type(KnownClass::Int.to_instance(db))], ), diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 01385a776d..2b509ce6dc 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -1829,8 +1829,11 @@ impl<'db> Type<'db> { Some(CallableTypes::one(CallableType::single( db, Signature::new( - Parameters::new([Parameter::positional_only(None) - .with_annotated_type(newtype.base(db).instance_type(db))]), + Parameters::new( + db, + [Parameter::positional_only(None) + .with_annotated_type(newtype.base(db).instance_type(db))], + ), Some(Type::NewTypeInstance(newtype)), ), ))) @@ -5505,8 +5508,11 @@ impl<'db> Type<'db> { Type::DataclassTransformer(_) => Binding::single( self, Signature::new( - Parameters::new([Parameter::positional_only(Some(Name::new_static("func"))) - .with_annotated_type(Type::object())]), + Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static("func"))) + .with_annotated_type(Type::object())], + ), None, ), ) @@ -5521,14 +5527,17 @@ impl<'db> Type<'db> { ) => Binding::single( self, Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("a"))) - .type_form() - .with_annotated_type(Type::any()), - Parameter::positional_only(Some(Name::new_static("b"))) - .type_form() - .with_annotated_type(Type::any()), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("a"))) + .type_form() + .with_annotated_type(Type::any()), + Parameter::positional_only(Some(Name::new_static("b"))) + .type_form() + .with_annotated_type(Type::any()), + ], + ), Some(KnownClass::ConstraintSet.to_instance(db)), ), ) @@ -5538,11 +5547,12 @@ impl<'db> Type<'db> { Binding::single( self, Signature::new( - Parameters::new([Parameter::positional_only(Some(Name::new_static( - "a", - ))) - .type_form() - .with_annotated_type(Type::any())]), + Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static("a"))) + .type_form() + .with_annotated_type(Type::any())], + ), Some(KnownClass::Bool.to_instance(db)), ), ) @@ -5557,13 +5567,16 @@ impl<'db> Type<'db> { self, Signature::new_generic( Some(GenericContext::from_typevar_instances(db, [val_ty])), - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("value"))) - .with_annotated_type(Type::TypeVar(val_ty)), - Parameter::positional_only(Some(Name::new_static("type"))) - .type_form() - .with_annotated_type(Type::any()), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("value"))) + .with_annotated_type(Type::TypeVar(val_ty)), + Parameter::positional_only(Some(Name::new_static("type"))) + .type_form() + .with_annotated_type(Type::any()), + ], + ), Some(Type::TypeVar(val_ty)), ), ) @@ -5574,14 +5587,15 @@ impl<'db> Type<'db> { Binding::single( self, Signature::new( - Parameters::new([Parameter::positional_only(Some(Name::new_static( - "arg", - ))) - // We need to set the type to `Any` here (instead of `Never`), - // in order for every `assert_never` call to pass the argument - // check. If we set it to `Never`, we'll get invalid-argument-type - // errors instead of `type-assertion-failure` errors. - .with_annotated_type(Type::any())]), + Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static("arg"))) + // We need to set the type to `Any` here (instead of `Never`), + // in order for every `assert_never` call to pass the argument + // check. If we set it to `Never`, we'll get invalid-argument-type + // errors instead of `type-assertion-failure` errors. + .with_annotated_type(Type::any())], + ), Some(Type::none(db)), ), ) @@ -5591,13 +5605,16 @@ impl<'db> Type<'db> { Some(KnownFunction::Cast) => Binding::single( self, Signature::new( - Parameters::new([ - Parameter::positional_or_keyword(Name::new_static("typ")) - .type_form() - .with_annotated_type(Type::any()), - Parameter::positional_or_keyword(Name::new_static("val")) - .with_annotated_type(Type::any()), - ]), + Parameters::new( + db, + [ + Parameter::positional_or_keyword(Name::new_static("typ")) + .type_form() + .with_annotated_type(Type::any()), + Parameter::positional_or_keyword(Name::new_static("val")) + .with_annotated_type(Type::any()), + ], + ), Some(Type::any()), ), ) @@ -5609,18 +5626,20 @@ impl<'db> Type<'db> { [ // def dataclass(cls: None, /) -> Callable[[type[_T]], type[_T]]: ... Signature::new( - Parameters::new([Parameter::positional_only(Some( - Name::new_static("cls"), - )) - .with_annotated_type(Type::none(db))]), + Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static("cls"))) + .with_annotated_type(Type::none(db))], + ), None, ), // def dataclass(cls: type[_T], /) -> type[_T]: ... Signature::new( - Parameters::new([Parameter::positional_only(Some( - Name::new_static("cls"), - )) - .with_annotated_type(KnownClass::Type.to_instance(db))]), + Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static("cls"))) + .with_annotated_type(KnownClass::Type.to_instance(db))], + ), None, ), // TODO: make this overload Python-version-dependent @@ -5639,38 +5658,41 @@ impl<'db> Type<'db> { // weakref_slot: bool = False, // ) -> Callable[[type[_T]], type[_T]]: ... Signature::new( - Parameters::new([ - Parameter::keyword_only(Name::new_static("init")) - .with_annotated_type(KnownClass::Bool.to_instance(db)) - .with_default_type(Type::BooleanLiteral(true)), - Parameter::keyword_only(Name::new_static("repr")) - .with_annotated_type(KnownClass::Bool.to_instance(db)) - .with_default_type(Type::BooleanLiteral(true)), - Parameter::keyword_only(Name::new_static("eq")) - .with_annotated_type(KnownClass::Bool.to_instance(db)) - .with_default_type(Type::BooleanLiteral(true)), - Parameter::keyword_only(Name::new_static("order")) - .with_annotated_type(KnownClass::Bool.to_instance(db)) - .with_default_type(Type::BooleanLiteral(false)), - Parameter::keyword_only(Name::new_static("unsafe_hash")) - .with_annotated_type(KnownClass::Bool.to_instance(db)) - .with_default_type(Type::BooleanLiteral(false)), - Parameter::keyword_only(Name::new_static("frozen")) - .with_annotated_type(KnownClass::Bool.to_instance(db)) - .with_default_type(Type::BooleanLiteral(false)), - Parameter::keyword_only(Name::new_static("match_args")) - .with_annotated_type(KnownClass::Bool.to_instance(db)) - .with_default_type(Type::BooleanLiteral(true)), - Parameter::keyword_only(Name::new_static("kw_only")) - .with_annotated_type(KnownClass::Bool.to_instance(db)) - .with_default_type(Type::BooleanLiteral(false)), - Parameter::keyword_only(Name::new_static("slots")) - .with_annotated_type(KnownClass::Bool.to_instance(db)) - .with_default_type(Type::BooleanLiteral(false)), - Parameter::keyword_only(Name::new_static("weakref_slot")) - .with_annotated_type(KnownClass::Bool.to_instance(db)) - .with_default_type(Type::BooleanLiteral(false)), - ]), + Parameters::new( + db, + [ + Parameter::keyword_only(Name::new_static("init")) + .with_annotated_type(KnownClass::Bool.to_instance(db)) + .with_default_type(Type::BooleanLiteral(true)), + Parameter::keyword_only(Name::new_static("repr")) + .with_annotated_type(KnownClass::Bool.to_instance(db)) + .with_default_type(Type::BooleanLiteral(true)), + Parameter::keyword_only(Name::new_static("eq")) + .with_annotated_type(KnownClass::Bool.to_instance(db)) + .with_default_type(Type::BooleanLiteral(true)), + Parameter::keyword_only(Name::new_static("order")) + .with_annotated_type(KnownClass::Bool.to_instance(db)) + .with_default_type(Type::BooleanLiteral(false)), + Parameter::keyword_only(Name::new_static("unsafe_hash")) + .with_annotated_type(KnownClass::Bool.to_instance(db)) + .with_default_type(Type::BooleanLiteral(false)), + Parameter::keyword_only(Name::new_static("frozen")) + .with_annotated_type(KnownClass::Bool.to_instance(db)) + .with_default_type(Type::BooleanLiteral(false)), + Parameter::keyword_only(Name::new_static("match_args")) + .with_annotated_type(KnownClass::Bool.to_instance(db)) + .with_default_type(Type::BooleanLiteral(true)), + Parameter::keyword_only(Name::new_static("kw_only")) + .with_annotated_type(KnownClass::Bool.to_instance(db)) + .with_default_type(Type::BooleanLiteral(false)), + Parameter::keyword_only(Name::new_static("slots")) + .with_annotated_type(KnownClass::Bool.to_instance(db)) + .with_default_type(Type::BooleanLiteral(false)), + Parameter::keyword_only(Name::new_static("weakref_slot")) + .with_annotated_type(KnownClass::Bool.to_instance(db)) + .with_default_type(Type::BooleanLiteral(false)), + ], + ), None, ), ], @@ -5700,11 +5722,12 @@ impl<'db> Type<'db> { Binding::single( self, Signature::new( - Parameters::new([Parameter::positional_only(Some(Name::new_static( - "o", - ))) - .with_annotated_type(Type::any()) - .with_default_type(Type::BooleanLiteral(false))]), + Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static("o"))) + .with_annotated_type(Type::any()) + .with_default_type(Type::BooleanLiteral(false))], + ), Some(KnownClass::Bool.to_instance(db)), ), ) @@ -5723,16 +5746,21 @@ impl<'db> Type<'db> { self, [ Signature::new( - Parameters::new([Parameter::positional_or_keyword( - Name::new_static("object"), - ) - .with_annotated_type(Type::object()) - .with_default_type(Type::string_literal(db, ""))]), + Parameters::new( + db, + [Parameter::positional_or_keyword(Name::new_static("object")) + .with_annotated_type(Type::object()) + .with_default_type(Type::string_literal(db, ""))], + ), Some(KnownClass::Str.to_instance(db)), ), Signature::new( - Parameters::new([ - Parameter::positional_or_keyword(Name::new_static("object")) + Parameters::new( + db, + [ + Parameter::positional_or_keyword(Name::new_static( + "object", + )) // TODO: Should be `ReadableBuffer` instead of this union type: .with_annotated_type(UnionType::from_elements( db, @@ -5742,13 +5770,18 @@ impl<'db> Type<'db> { ], )) .with_default_type(Type::bytes_literal(db, b"")), - Parameter::positional_or_keyword(Name::new_static("encoding")) + Parameter::positional_or_keyword(Name::new_static( + "encoding", + )) .with_annotated_type(KnownClass::Str.to_instance(db)) .with_default_type(Type::string_literal(db, "utf-8")), - Parameter::positional_or_keyword(Name::new_static("errors")) + Parameter::positional_or_keyword(Name::new_static( + "errors", + )) .with_annotated_type(KnownClass::Str.to_instance(db)) .with_default_type(Type::string_literal(db, "strict")), - ]), + ], + ), Some(KnownClass::Str.to_instance(db)), ), ], @@ -5771,29 +5804,33 @@ impl<'db> Type<'db> { self, [ Signature::new( - Parameters::new([Parameter::positional_only(Some( - Name::new_static("o"), - )) - .with_annotated_type(Type::any())]), + Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static("o"))) + .with_annotated_type(Type::any())], + ), Some(type_instance), ), Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("name"))) - .with_annotated_type(str_instance), - Parameter::positional_only(Some(Name::new_static("bases"))) - .with_annotated_type(Type::homogeneous_tuple( - db, - type_instance, - )), - Parameter::positional_only(Some(Name::new_static("dict"))) - .with_annotated_type( - KnownClass::Dict.to_specialized_instance( + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("name"))) + .with_annotated_type(str_instance), + Parameter::positional_only(Some(Name::new_static("bases"))) + .with_annotated_type(Type::homogeneous_tuple( db, - [str_instance, Type::any()], + type_instance, + )), + Parameter::positional_only(Some(Name::new_static("dict"))) + .with_annotated_type( + KnownClass::Dict.to_specialized_instance( + db, + [str_instance, Type::any()], + ), ), - ), - ]), + ], + ), Some(type_instance), ), ], @@ -5832,19 +5869,23 @@ impl<'db> Type<'db> { self, [ Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("t"))) - .with_annotated_type(Type::any()), - Parameter::positional_only(Some(Name::new_static("obj"))) - .with_annotated_type(Type::any()), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("t"))) + .with_annotated_type(Type::any()), + Parameter::positional_only(Some(Name::new_static("obj"))) + .with_annotated_type(Type::any()), + ], + ), Some(KnownClass::Super.to_instance(db)), ), Signature::new( - Parameters::new([Parameter::positional_only(Some( - Name::new_static("t"), - )) - .with_annotated_type(Type::any())]), + Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static("t"))) + .with_annotated_type(Type::any())], + ), Some(KnownClass::Super.to_instance(db)), ), Signature::new( @@ -5871,24 +5912,27 @@ impl<'db> Type<'db> { Binding::single( self, Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("message"))) - .with_annotated_type(Type::LiteralString), - Parameter::keyword_only(Name::new_static("category")) - .with_annotated_type(UnionType::from_elements( - db, - [ - // TODO: should be `type[Warning]` - Type::any(), - KnownClass::NoneType.to_instance(db), - ], - )) - // TODO: should be `type[Warning]` - .with_default_type(Type::any()), - Parameter::keyword_only(Name::new_static("stacklevel")) - .with_annotated_type(KnownClass::Int.to_instance(db)) - .with_default_type(Type::IntLiteral(1)), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("message"))) + .with_annotated_type(Type::LiteralString), + Parameter::keyword_only(Name::new_static("category")) + .with_annotated_type(UnionType::from_elements( + db, + [ + // TODO: should be `type[Warning]` + Type::any(), + KnownClass::NoneType.to_instance(db), + ], + )) + // TODO: should be `type[Warning]` + .with_default_type(Type::any()), + Parameter::keyword_only(Name::new_static("stacklevel")) + .with_annotated_type(KnownClass::Int.to_instance(db)) + .with_default_type(Type::IntLiteral(1)), + ], + ), Some(KnownClass::Deprecated.to_instance(db)), ), ) @@ -5908,26 +5952,29 @@ impl<'db> Type<'db> { Binding::single( self, Signature::new( - Parameters::new([ - Parameter::positional_or_keyword(Name::new_static("name")) - .with_annotated_type(KnownClass::Str.to_instance(db)), - Parameter::positional_or_keyword(Name::new_static("value")) - .with_annotated_type(Type::any()) - .type_form(), - Parameter::keyword_only(Name::new_static("type_params")) - .with_annotated_type(Type::homogeneous_tuple( - db, - UnionType::from_elements( + Parameters::new( + db, + [ + Parameter::positional_or_keyword(Name::new_static("name")) + .with_annotated_type(KnownClass::Str.to_instance(db)), + Parameter::positional_or_keyword(Name::new_static("value")) + .with_annotated_type(Type::any()) + .type_form(), + Parameter::keyword_only(Name::new_static("type_params")) + .with_annotated_type(Type::homogeneous_tuple( db, - [ - KnownClass::TypeVar.to_instance(db), - KnownClass::ParamSpec.to_instance(db), - KnownClass::TypeVarTuple.to_instance(db), - ], - ), - )) - .with_default_type(Type::empty_tuple(db)), - ]), + UnionType::from_elements( + db, + [ + KnownClass::TypeVar.to_instance(db), + KnownClass::ParamSpec.to_instance(db), + KnownClass::TypeVarTuple.to_instance(db), + ], + ), + )) + .with_default_type(Type::empty_tuple(db)), + ], + ), None, ), ) @@ -5936,63 +5983,71 @@ impl<'db> Type<'db> { Some(KnownClass::Property) => { let getter_signature = Signature::new( - Parameters::new([ - Parameter::positional_only(None).with_annotated_type(Type::any()) - ]), + Parameters::new( + db, + [Parameter::positional_only(None).with_annotated_type(Type::any())], + ), Some(Type::any()), ); let setter_signature = Signature::new( - Parameters::new([ - Parameter::positional_only(None).with_annotated_type(Type::any()), - Parameter::positional_only(None).with_annotated_type(Type::any()), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(None).with_annotated_type(Type::any()), + Parameter::positional_only(None).with_annotated_type(Type::any()), + ], + ), Some(Type::none(db)), ); let deleter_signature = Signature::new( - Parameters::new([ - Parameter::positional_only(None).with_annotated_type(Type::any()) - ]), + Parameters::new( + db, + [Parameter::positional_only(None).with_annotated_type(Type::any())], + ), Some(Type::any()), ); Binding::single( self, Signature::new( - Parameters::new([ - Parameter::positional_or_keyword(Name::new_static("fget")) - .with_annotated_type(UnionType::from_elements( - db, - [ - Type::single_callable(db, getter_signature), - Type::none(db), - ], - )) - .with_default_type(Type::none(db)), - Parameter::positional_or_keyword(Name::new_static("fset")) - .with_annotated_type(UnionType::from_elements( - db, - [ - Type::single_callable(db, setter_signature), - Type::none(db), - ], - )) - .with_default_type(Type::none(db)), - Parameter::positional_or_keyword(Name::new_static("fdel")) - .with_annotated_type(UnionType::from_elements( - db, - [ - Type::single_callable(db, deleter_signature), - Type::none(db), - ], - )) - .with_default_type(Type::none(db)), - Parameter::positional_or_keyword(Name::new_static("doc")) - .with_annotated_type(UnionType::from_elements( - db, - [KnownClass::Str.to_instance(db), Type::none(db)], - )) - .with_default_type(Type::none(db)), - ]), + Parameters::new( + db, + [ + Parameter::positional_or_keyword(Name::new_static("fget")) + .with_annotated_type(UnionType::from_elements( + db, + [ + Type::single_callable(db, getter_signature), + Type::none(db), + ], + )) + .with_default_type(Type::none(db)), + Parameter::positional_or_keyword(Name::new_static("fset")) + .with_annotated_type(UnionType::from_elements( + db, + [ + Type::single_callable(db, setter_signature), + Type::none(db), + ], + )) + .with_default_type(Type::none(db)), + Parameter::positional_or_keyword(Name::new_static("fdel")) + .with_annotated_type(UnionType::from_elements( + db, + [ + Type::single_callable(db, deleter_signature), + Type::none(db), + ], + )) + .with_default_type(Type::none(db)), + Parameter::positional_or_keyword(Name::new_static("doc")) + .with_annotated_type(UnionType::from_elements( + db, + [KnownClass::Str.to_instance(db), Type::none(db)], + )) + .with_default_type(Type::none(db)), + ], + ), None, ), ) @@ -6014,12 +6069,15 @@ impl<'db> Type<'db> { [ Signature::new(Parameters::empty(), Some(Type::empty_tuple(db))), Signature::new( - Parameters::new([Parameter::positional_only(Some( - Name::new_static("iterable"), - )) - .with_annotated_type( - KnownClass::Iterable.to_specialized_instance(db, [object]), - )]), + Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static( + "iterable", + ))) + .with_annotated_type( + KnownClass::Iterable.to_specialized_instance(db, [object]), + )], + ), Some(Type::homogeneous_tuple(db, object)), ), ], @@ -6047,19 +6105,22 @@ impl<'db> Type<'db> { Binding::single( self, Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("typename"))) - .with_annotated_type(KnownClass::Str.to_instance(db)), - Parameter::positional_only(Some(Name::new_static("fields"))) - .with_annotated_type(KnownClass::Dict.to_instance(db)) - .with_default_type(Type::any()), - Parameter::keyword_only(Name::new_static("total")) - .with_annotated_type(KnownClass::Bool.to_instance(db)) - .with_default_type(Type::BooleanLiteral(true)), - // Future compatibility, in case new keyword arguments will be added: - Parameter::keyword_variadic(Name::new_static("kwargs")) - .with_annotated_type(Type::any()), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("typename"))) + .with_annotated_type(KnownClass::Str.to_instance(db)), + Parameter::positional_only(Some(Name::new_static("fields"))) + .with_annotated_type(KnownClass::Dict.to_instance(db)) + .with_default_type(Type::any()), + Parameter::keyword_only(Name::new_static("total")) + .with_annotated_type(KnownClass::Bool.to_instance(db)) + .with_default_type(Type::BooleanLiteral(true)), + // Future compatibility, in case new keyword arguments will be added: + Parameter::keyword_variadic(Name::new_static("kwargs")) + .with_annotated_type(Type::any()), + ], + ), None, ), ) @@ -6154,8 +6215,11 @@ impl<'db> Type<'db> { Type::KnownInstance(KnownInstanceType::NewType(newtype)) => Binding::single( self, Signature::new( - Parameters::new([Parameter::positional_only(None) - .with_annotated_type(newtype.base(db).instance_type(db))]), + Parameters::new( + db, + [Parameter::positional_only(None) + .with_annotated_type(newtype.base(db).instance_type(db))], + ), Some(Type::NewTypeInstance(newtype)), ), ) @@ -12084,25 +12148,31 @@ impl<'db> KnownBoundMethodType<'db> { | KnownBoundMethodType::PropertyDunderGet(_) => Either::Left(Either::Left( [ Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("instance"))) - .with_annotated_type(Type::none(db)), - Parameter::positional_only(Some(Name::new_static("owner"))) - .with_annotated_type(KnownClass::Type.to_instance(db)), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("instance"))) + .with_annotated_type(Type::none(db)), + Parameter::positional_only(Some(Name::new_static("owner"))) + .with_annotated_type(KnownClass::Type.to_instance(db)), + ], + ), None, ), Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("instance"))) - .with_annotated_type(Type::object()), - Parameter::positional_only(Some(Name::new_static("owner"))) - .with_annotated_type(UnionType::from_elements( - db, - [KnownClass::Type.to_instance(db), Type::none(db)], - )) - .with_default_type(Type::none(db)), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("instance"))) + .with_annotated_type(Type::object()), + Parameter::positional_only(Some(Name::new_static("owner"))) + .with_annotated_type(UnionType::from_elements( + db, + [KnownClass::Type.to_instance(db), Type::none(db)], + )) + .with_default_type(Type::none(db)), + ], + ), None, ), ] @@ -12113,56 +12183,68 @@ impl<'db> KnownBoundMethodType<'db> { )), KnownBoundMethodType::PropertyDunderSet(_) => { Either::Right(std::iter::once(Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("instance"))) - .with_annotated_type(Type::object()), - Parameter::positional_only(Some(Name::new_static("value"))) - .with_annotated_type(Type::object()), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("instance"))) + .with_annotated_type(Type::object()), + Parameter::positional_only(Some(Name::new_static("value"))) + .with_annotated_type(Type::object()), + ], + ), None, ))) } KnownBoundMethodType::StrStartswith(_) => { Either::Right(std::iter::once(Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("prefix"))) - .with_annotated_type(UnionType::from_elements( - db, - [ - KnownClass::Str.to_instance(db), - Type::homogeneous_tuple(db, KnownClass::Str.to_instance(db)), - ], - )), - Parameter::positional_only(Some(Name::new_static("start"))) - .with_annotated_type(UnionType::from_elements( - db, - [KnownClass::SupportsIndex.to_instance(db), Type::none(db)], - )) - .with_default_type(Type::none(db)), - Parameter::positional_only(Some(Name::new_static("end"))) - .with_annotated_type(UnionType::from_elements( - db, - [KnownClass::SupportsIndex.to_instance(db), Type::none(db)], - )) - .with_default_type(Type::none(db)), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("prefix"))) + .with_annotated_type(UnionType::from_elements( + db, + [ + KnownClass::Str.to_instance(db), + Type::homogeneous_tuple( + db, + KnownClass::Str.to_instance(db), + ), + ], + )), + Parameter::positional_only(Some(Name::new_static("start"))) + .with_annotated_type(UnionType::from_elements( + db, + [KnownClass::SupportsIndex.to_instance(db), Type::none(db)], + )) + .with_default_type(Type::none(db)), + Parameter::positional_only(Some(Name::new_static("end"))) + .with_annotated_type(UnionType::from_elements( + db, + [KnownClass::SupportsIndex.to_instance(db), Type::none(db)], + )) + .with_default_type(Type::none(db)), + ], + ), Some(KnownClass::Bool.to_instance(db)), ))) } KnownBoundMethodType::ConstraintSetRange => { Either::Right(std::iter::once(Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("lower_bound"))) - .type_form() - .with_annotated_type(Type::any()), - Parameter::positional_only(Some(Name::new_static("typevar"))) - .type_form() - .with_annotated_type(Type::any()), - Parameter::positional_only(Some(Name::new_static("upper_bound"))) - .type_form() - .with_annotated_type(Type::any()), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("lower_bound"))) + .type_form() + .with_annotated_type(Type::any()), + Parameter::positional_only(Some(Name::new_static("typevar"))) + .type_form() + .with_annotated_type(Type::any()), + Parameter::positional_only(Some(Name::new_static("upper_bound"))) + .type_form() + .with_annotated_type(Type::any()), + ], + ), Some(KnownClass::ConstraintSet.to_instance(db)), ))) } @@ -12177,45 +12259,57 @@ impl<'db> KnownBoundMethodType<'db> { KnownBoundMethodType::ConstraintSetImpliesSubtypeOf(_) => { Either::Right(std::iter::once(Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("ty"))) - .type_form() - .with_annotated_type(Type::any()), - Parameter::positional_only(Some(Name::new_static("of"))) - .type_form() - .with_annotated_type(Type::any()), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("ty"))) + .type_form() + .with_annotated_type(Type::any()), + Parameter::positional_only(Some(Name::new_static("of"))) + .type_form() + .with_annotated_type(Type::any()), + ], + ), Some(KnownClass::ConstraintSet.to_instance(db)), ))) } KnownBoundMethodType::ConstraintSetSatisfies(_) => { Either::Right(std::iter::once(Signature::new( - Parameters::new([Parameter::positional_only(Some(Name::new_static("other"))) - .with_annotated_type(KnownClass::ConstraintSet.to_instance(db))]), + Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static("other"))) + .with_annotated_type(KnownClass::ConstraintSet.to_instance(db))], + ), Some(KnownClass::ConstraintSet.to_instance(db)), ))) } KnownBoundMethodType::ConstraintSetSatisfiedByAllTypeVars(_) => { Either::Right(std::iter::once(Signature::new( - Parameters::new([Parameter::keyword_only(Name::new_static("inferable")) - .type_form() - .with_annotated_type(UnionType::from_elements( - db, - [Type::homogeneous_tuple(db, Type::any()), Type::none(db)], - )) - .with_default_type(Type::none(db))]), + Parameters::new( + db, + [Parameter::keyword_only(Name::new_static("inferable")) + .type_form() + .with_annotated_type(UnionType::from_elements( + db, + [Type::homogeneous_tuple(db, Type::any()), Type::none(db)], + )) + .with_default_type(Type::none(db))], + ), Some(KnownClass::Bool.to_instance(db)), ))) } KnownBoundMethodType::GenericContextSpecializeConstrained(_) => { Either::Right(std::iter::once(Signature::new( - Parameters::new([Parameter::positional_only(Some(Name::new_static( - "constraints", - ))) - .with_annotated_type(KnownClass::ConstraintSet.to_instance(db))]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("constraints"))) + .with_annotated_type(KnownClass::ConstraintSet.to_instance(db)), + ], + ), Some(UnionType::from_elements( db, [KnownClass::Specialization.to_instance(db), Type::none(db)], @@ -12255,29 +12349,35 @@ impl WrapperDescriptorKind { let descriptor = class.to_instance(db); [ Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(descriptor), - Parameter::positional_only(Some(Name::new_static("instance"))) - .with_annotated_type(none), - Parameter::positional_only(Some(Name::new_static("owner"))) - .with_annotated_type(type_instance), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(descriptor), + Parameter::positional_only(Some(Name::new_static("instance"))) + .with_annotated_type(none), + Parameter::positional_only(Some(Name::new_static("owner"))) + .with_annotated_type(type_instance), + ], + ), None, ), Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(descriptor), - Parameter::positional_only(Some(Name::new_static("instance"))) - .with_annotated_type(Type::object()), - Parameter::positional_only(Some(Name::new_static("owner"))) - .with_annotated_type(UnionType::from_elements( - db, - [type_instance, none], - )) - .with_default_type(none), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(descriptor), + Parameter::positional_only(Some(Name::new_static("instance"))) + .with_annotated_type(Type::object()), + Parameter::positional_only(Some(Name::new_static("owner"))) + .with_annotated_type(UnionType::from_elements( + db, + [type_instance, none], + )) + .with_default_type(none), + ], + ), None, ), ] @@ -12293,14 +12393,17 @@ impl WrapperDescriptorKind { WrapperDescriptorKind::PropertyDunderSet => { let object = Type::object(); Either::Right(std::iter::once(Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(KnownClass::Property.to_instance(db)), - Parameter::positional_only(Some(Name::new_static("instance"))) - .with_annotated_type(object), - Parameter::positional_only(Some(Name::new_static("value"))) - .with_annotated_type(object), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(KnownClass::Property.to_instance(db)), + Parameter::positional_only(Some(Name::new_static("instance"))) + .with_annotated_type(object), + Parameter::positional_only(Some(Name::new_static("value"))) + .with_annotated_type(object), + ], + ), None, ))) } diff --git a/crates/ty_python_semantic/src/types/class.rs b/crates/ty_python_semantic/src/types/class.rs index 033f326c39..26a7a2c42c 100644 --- a/crates/ty_python_semantic/src/types/class.rs +++ b/crates/ty_python_semantic/src/types/class.rs @@ -808,13 +808,14 @@ impl<'db> ClassType<'db> { name: &str, ) -> Member<'db> { fn synthesize_getitem_overload_signature<'db>( + db: &'db dyn Db, index_annotation: Type<'db>, return_annotation: Type<'db>, ) -> Signature<'db> { let self_parameter = Parameter::positional_only(Some(Name::new_static("self"))); let index_parameter = Parameter::positional_only(Some(Name::new_static("index"))) .with_annotated_type(index_annotation); - let parameters = Parameters::new([self_parameter, index_parameter]); + let parameters = Parameters::new(db, [self_parameter, index_parameter]); Signature::new(parameters, Some(return_annotation)) } @@ -845,9 +846,11 @@ impl<'db> ClassType<'db> { .map(Type::IntLiteral) .unwrap_or_else(|| KnownClass::Int.to_instance(db)); - let parameters = - Parameters::new([Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(Type::instance(db, self))]); + let parameters = Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(Type::instance(db, self))], + ); let synthesized_dunder_method = Type::function_like_callable(db, Signature::new(parameters, Some(return_type))); @@ -975,6 +978,7 @@ impl<'db> ClassType<'db> { ); Some(synthesize_getitem_overload_signature( + db, index_annotation, return_type, )) @@ -992,11 +996,13 @@ impl<'db> ClassType<'db> { // __getitem__(self, index: slice[Any, Any, Any], /) -> tuple[str | float | bytes, ...] // overload_signatures.push(synthesize_getitem_overload_signature( + db, KnownClass::SupportsIndex.to_instance(db), all_elements_unioned, )); overload_signatures.push(synthesize_getitem_overload_signature( + db, KnownClass::Slice.to_instance(db), Type::homogeneous_tuple(db, all_elements_unioned), )); @@ -1066,11 +1072,14 @@ impl<'db> ClassType<'db> { iterable_parameter.with_default_type(Type::empty_tuple(db)); } - let parameters = Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(SubclassOfType::from(db, self)), - iterable_parameter, - ]); + let parameters = Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(SubclassOfType::from(db, self)), + iterable_parameter, + ], + ); let synthesized_dunder = Type::function_like_callable( db, @@ -2212,7 +2221,10 @@ impl<'db> ClassLiteral<'db> { .get(name) { let property_getter_signature = Signature::new( - Parameters::new([Parameter::positional_only(Some(Name::new_static("self")))]), + Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static("self")))], + ), Some(field.declared_ty), ); let property_getter = Type::single_callable(db, property_getter_signature); @@ -2424,10 +2436,10 @@ impl<'db> ClassLiteral<'db> { let signature = match name { "__new__" | "__init__" => Signature::new_generic( inherited_generic_context.or_else(|| self.inherited_generic_context(db)), - Parameters::new(parameters), + Parameters::new(db, parameters), return_ty, ), - _ => Signature::new(Parameters::new(parameters), return_ty), + _ => Signature::new(Parameters::new(db, parameters), return_ty), }; Some(Type::function_like_callable(db, signature)) }; @@ -2454,14 +2466,17 @@ impl<'db> ClassLiteral<'db> { } let signature = Signature::new( - Parameters::new([ - Parameter::positional_or_keyword(Name::new_static("self")) - // TODO: could be `Self`. - .with_annotated_type(instance_ty), - Parameter::positional_or_keyword(Name::new_static("other")) - // TODO: could be `Self`. - .with_annotated_type(instance_ty), - ]), + Parameters::new( + db, + [ + Parameter::positional_or_keyword(Name::new_static("self")) + // TODO: could be `Self`. + .with_annotated_type(instance_ty), + Parameter::positional_or_keyword(Name::new_static("other")) + // TODO: could be `Self`. + .with_annotated_type(instance_ty), + ], + ), Some(KnownClass::Bool.to_instance(db)), ); @@ -2474,10 +2489,11 @@ impl<'db> ClassLiteral<'db> { if unsafe_hash || (frozen && eq) { let signature = Signature::new( - Parameters::new([Parameter::positional_or_keyword(Name::new_static( - "self", - )) - .with_annotated_type(instance_ty)]), + Parameters::new( + db, + [Parameter::positional_or_keyword(Name::new_static("self")) + .with_annotated_type(instance_ty)], + ), Some(KnownClass::Int.to_instance(db)), ); @@ -2559,12 +2575,15 @@ impl<'db> ClassLiteral<'db> { (CodeGeneratorKind::DataclassLike(_), "__setattr__") => { if has_dataclass_param(DataclassFlags::FROZEN) { let signature = Signature::new( - Parameters::new([ - Parameter::positional_or_keyword(Name::new_static("self")) - .with_annotated_type(instance_ty), - Parameter::positional_or_keyword(Name::new_static("name")), - Parameter::positional_or_keyword(Name::new_static("value")), - ]), + Parameters::new( + db, + [ + Parameter::positional_or_keyword(Name::new_static("self")) + .with_annotated_type(instance_ty), + Parameter::positional_or_keyword(Name::new_static("name")), + Parameter::positional_or_keyword(Name::new_static("value")), + ], + ), Some(Type::Never), ); @@ -2599,14 +2618,17 @@ impl<'db> ClassLiteral<'db> { return Some(Type::Callable(CallableType::new( db, CallableSignature::single(Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(instance_ty), - Parameter::positional_only(Some(Name::new_static("key"))) - .with_annotated_type(Type::Never), - Parameter::positional_only(Some(Name::new_static("value"))) - .with_annotated_type(Type::any()), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(instance_ty), + Parameter::positional_only(Some(Name::new_static("key"))) + .with_annotated_type(Type::Never), + Parameter::positional_only(Some(Name::new_static("value"))) + .with_annotated_type(Type::any()), + ], + ), Some(Type::none(db)), )), true, @@ -2617,14 +2639,17 @@ impl<'db> ClassLiteral<'db> { let key_type = Type::StringLiteral(StringLiteralType::new(db, name.as_str())); Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(instance_ty), - Parameter::positional_only(Some(Name::new_static("key"))) - .with_annotated_type(key_type), - Parameter::positional_only(Some(Name::new_static("value"))) - .with_annotated_type(field.declared_ty), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(instance_ty), + Parameter::positional_only(Some(Name::new_static("key"))) + .with_annotated_type(key_type), + Parameter::positional_only(Some(Name::new_static("value"))) + .with_annotated_type(field.declared_ty), + ], + ), Some(Type::none(db)), ) }); @@ -2643,12 +2668,15 @@ impl<'db> ClassLiteral<'db> { let key_type = Type::StringLiteral(StringLiteralType::new(db, name.as_str())); Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(instance_ty), - Parameter::positional_only(Some(Name::new_static("key"))) - .with_annotated_type(key_type), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(instance_ty), + Parameter::positional_only(Some(Name::new_static("key"))) + .with_annotated_type(key_type), + ], + ), Some(field.declared_ty), ) }); @@ -2675,12 +2703,15 @@ impl<'db> ClassLiteral<'db> { // once the generics solver takes default arguments into account. let get_sig = Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(instance_ty), - Parameter::positional_only(Some(Name::new_static("key"))) - .with_annotated_type(key_type), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(instance_ty), + Parameter::positional_only(Some(Name::new_static("key"))) + .with_annotated_type(key_type), + ], + ), Some(if field.is_required() { field.declared_ty } else { @@ -2693,14 +2724,17 @@ impl<'db> ClassLiteral<'db> { let get_with_default_sig = Signature::new_generic( Some(GenericContext::from_typevar_instances(db, [t_default])), - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(instance_ty), - Parameter::positional_only(Some(Name::new_static("key"))) - .with_annotated_type(key_type), - Parameter::positional_only(Some(Name::new_static("default"))) - .with_annotated_type(Type::TypeVar(t_default)), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(instance_ty), + Parameter::positional_only(Some(Name::new_static("key"))) + .with_annotated_type(key_type), + Parameter::positional_only(Some(Name::new_static("default"))) + .with_annotated_type(Type::TypeVar(t_default)), + ], + ), Some(if field.is_required() { field.declared_ty } else { @@ -2716,12 +2750,15 @@ impl<'db> ClassLiteral<'db> { // Fallback overloads for unknown keys .chain(std::iter::once({ Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(instance_ty), - Parameter::positional_only(Some(Name::new_static("key"))) - .with_annotated_type(KnownClass::Str.to_instance(db)), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(instance_ty), + Parameter::positional_only(Some(Name::new_static("key"))) + .with_annotated_type(KnownClass::Str.to_instance(db)), + ], + ), Some(UnionType::from_elements( db, [Type::unknown(), Type::none(db)], @@ -2734,14 +2771,17 @@ impl<'db> ClassLiteral<'db> { Signature::new_generic( Some(GenericContext::from_typevar_instances(db, [t_default])), - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(instance_ty), - Parameter::positional_only(Some(Name::new_static("key"))) - .with_annotated_type(KnownClass::Str.to_instance(db)), - Parameter::positional_only(Some(Name::new_static("default"))) - .with_annotated_type(Type::TypeVar(t_default)), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(instance_ty), + Parameter::positional_only(Some(Name::new_static("key"))) + .with_annotated_type(KnownClass::Str.to_instance(db)), + Parameter::positional_only(Some(Name::new_static("default"))) + .with_annotated_type(Type::TypeVar(t_default)), + ], + ), Some(UnionType::from_elements( db, [Type::unknown(), Type::TypeVar(t_default)], @@ -2771,12 +2811,15 @@ impl<'db> ClassLiteral<'db> { // `.pop()` without default let pop_sig = Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(instance_ty), - Parameter::positional_only(Some(Name::new_static("key"))) - .with_annotated_type(key_type), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(instance_ty), + Parameter::positional_only(Some(Name::new_static("key"))) + .with_annotated_type(key_type), + ], + ), Some(field.declared_ty), ); @@ -2786,14 +2829,17 @@ impl<'db> ClassLiteral<'db> { let pop_with_default_sig = Signature::new_generic( Some(GenericContext::from_typevar_instances(db, [t_default])), - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(instance_ty), - Parameter::positional_only(Some(Name::new_static("key"))) - .with_annotated_type(key_type), - Parameter::positional_only(Some(Name::new_static("default"))) - .with_annotated_type(Type::TypeVar(t_default)), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(instance_ty), + Parameter::positional_only(Some(Name::new_static("key"))) + .with_annotated_type(key_type), + Parameter::positional_only(Some(Name::new_static("default"))) + .with_annotated_type(Type::TypeVar(t_default)), + ], + ), Some(UnionType::from_elements( db, [field.declared_ty, Type::TypeVar(t_default)], @@ -2816,14 +2862,17 @@ impl<'db> ClassLiteral<'db> { // `setdefault` always returns the field type Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(instance_ty), - Parameter::positional_only(Some(Name::new_static("key"))) - .with_annotated_type(key_type), - Parameter::positional_only(Some(Name::new_static("default"))) - .with_annotated_type(field.declared_ty), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(instance_ty), + Parameter::positional_only(Some(Name::new_static("key"))) + .with_annotated_type(key_type), + Parameter::positional_only(Some(Name::new_static("default"))) + .with_annotated_type(field.declared_ty), + ], + ), Some(field.declared_ty), ) }); @@ -2837,12 +2886,15 @@ impl<'db> ClassLiteral<'db> { (CodeGeneratorKind::TypedDict, "update") => { // TODO: synthesize a set of overloads with precise types let signature = Signature::new( - Parameters::new([ - Parameter::positional_only(Some(Name::new_static("self"))) - .with_annotated_type(instance_ty), - Parameter::variadic(Name::new_static("args")), - Parameter::keyword_variadic(Name::new_static("kwargs")), - ]), + Parameters::new( + db, + [ + Parameter::positional_only(Some(Name::new_static("self"))) + .with_annotated_type(instance_ty), + Parameter::variadic(Name::new_static("args")), + Parameter::keyword_variadic(Name::new_static("kwargs")), + ], + ), Some(Type::none(db)), ); diff --git a/crates/ty_python_semantic/src/types/display.rs b/crates/ty_python_semantic/src/types/display.rs index 428a65ca9c..217e0f9a7c 100644 --- a/crates/ty_python_semantic/src/types/display.rs +++ b/crates/ty_python_semantic/src/types/display.rs @@ -2302,21 +2302,21 @@ mod tests { } fn display_signature<'db>( - db: &dyn Db, + db: &'db dyn Db, parameters: impl IntoIterator>, return_ty: Option>, ) -> String { - Signature::new(Parameters::new(parameters), return_ty) + Signature::new(Parameters::new(db, parameters), return_ty) .display(db) .to_string() } fn display_signature_multiline<'db>( - db: &dyn Db, + db: &'db dyn Db, parameters: impl IntoIterator>, return_ty: Option>, ) -> String { - Signature::new(Parameters::new(parameters), return_ty) + Signature::new(Parameters::new(db, parameters), return_ty) .display_with(db, super::DisplaySettings::default().multiline()) .to_string() } diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index 68b35bec62..af98132015 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -3361,9 +3361,12 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { // TODO: `Unpack` Parameters::todo() } else { - Parameters::new(parameter_types.iter().map(|param_type| { - Parameter::positional_only(None).with_annotated_type(*param_type) - })) + Parameters::new( + self.db(), + parameter_types.iter().map(|param_type| { + Parameter::positional_only(None).with_annotated_type(*param_type) + }), + ) }; Type::single_callable(self.db(), Signature::new(parameters, None)) @@ -7993,6 +7996,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { .map(|param| Parameter::keyword_variadic(param.name().id.clone())); Parameters::new( + self.db(), positional_only .into_iter() .chain(positional_or_keyword) diff --git a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs index 14a4079eb4..af23bc646e 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs @@ -1636,9 +1636,12 @@ impl<'db> TypeInferenceBuilder<'db, '_> { // TODO: `Unpack` Parameters::todo() } else { - Parameters::new(parameter_types.iter().map(|param_type| { - Parameter::positional_only(None).with_annotated_type(*param_type) - })) + Parameters::new( + self.db(), + parameter_types.iter().map(|param_type| { + Parameter::positional_only(None).with_annotated_type(*param_type) + }), + ) }); } ast::Expr::Subscript(subscript) => { diff --git a/crates/ty_python_semantic/src/types/property_tests/type_generation.rs b/crates/ty_python_semantic/src/types/property_tests/type_generation.rs index 58808e48c2..ecc274546a 100644 --- a/crates/ty_python_semantic/src/types/property_tests/type_generation.rs +++ b/crates/ty_python_semantic/src/types/property_tests/type_generation.rs @@ -76,24 +76,29 @@ impl CallableParams { pub(crate) fn into_parameters(self, db: &TestDb) -> Parameters<'_> { match self { CallableParams::GradualForm => Parameters::gradual_form(), - CallableParams::List(params) => Parameters::new(params.into_iter().map(|param| { - let mut parameter = match param.kind { - ParamKind::PositionalOnly => Parameter::positional_only(param.name), - ParamKind::PositionalOrKeyword => { - Parameter::positional_or_keyword(param.name.unwrap()) + CallableParams::List(params) => Parameters::new( + db, + params.into_iter().map(|param| { + let mut parameter = match param.kind { + ParamKind::PositionalOnly => Parameter::positional_only(param.name), + ParamKind::PositionalOrKeyword => { + Parameter::positional_or_keyword(param.name.unwrap()) + } + ParamKind::Variadic => Parameter::variadic(param.name.unwrap()), + ParamKind::KeywordOnly => Parameter::keyword_only(param.name.unwrap()), + ParamKind::KeywordVariadic => { + Parameter::keyword_variadic(param.name.unwrap()) + } + }; + if let Some(annotated_ty) = param.annotated_ty { + parameter = parameter.with_annotated_type(annotated_ty.into_type(db)); } - ParamKind::Variadic => Parameter::variadic(param.name.unwrap()), - ParamKind::KeywordOnly => Parameter::keyword_only(param.name.unwrap()), - ParamKind::KeywordVariadic => Parameter::keyword_variadic(param.name.unwrap()), - }; - if let Some(annotated_ty) = param.annotated_ty { - parameter = parameter.with_annotated_type(annotated_ty.into_type(db)); - } - if let Some(default_ty) = param.default_ty { - parameter = parameter.with_default_type(default_ty.into_type(db)); - } - parameter - })), + if let Some(default_ty) = param.default_ty { + parameter = parameter.with_default_type(default_ty.into_type(db)); + } + parameter + }), + ), } } } diff --git a/crates/ty_python_semantic/src/types/protocol_class.rs b/crates/ty_python_semantic/src/types/protocol_class.rs index 48b76bf98d..45ef664a2f 100644 --- a/crates/ty_python_semantic/src/types/protocol_class.rs +++ b/crates/ty_python_semantic/src/types/protocol_class.rs @@ -212,7 +212,10 @@ impl<'db> ProtocolInterface<'db> { // Synthesize a read-only property (one that has a getter but no setter) // which returns the specified type from its getter. let property_getter_signature = Signature::new( - Parameters::new([Parameter::positional_only(Some(Name::new_static("self")))]), + Parameters::new( + db, + [Parameter::positional_only(Some(Name::new_static("self")))], + ), Some(ty.normalized(db)), ); let property_getter = Type::single_callable(db, property_getter_signature); diff --git a/crates/ty_python_semantic/src/types/signatures.rs b/crates/ty_python_semantic/src/types/signatures.rs index ebe2945693..612a7cf324 100644 --- a/crates/ty_python_semantic/src/types/signatures.rs +++ b/crates/ty_python_semantic/src/types/signatures.rs @@ -558,11 +558,12 @@ impl<'db> Signature<'db> { // Discard the definition when normalizing, so that two equivalent signatures // with different `Definition`s share the same Salsa ID when normalized definition: None, - parameters: self - .parameters - .iter() - .map(|param| param.normalized_impl(db, visitor)) - .collect(), + parameters: Parameters::new( + db, + self.parameters + .iter() + .map(|param| param.normalized_impl(db, visitor)), + ), return_ty: self .return_ty .map(|return_ty| return_ty.normalized_impl(db, visitor)), @@ -587,14 +588,17 @@ impl<'db> Signature<'db> { ), None => None, }; + let parameters = { + let mut parameters = Vec::with_capacity(self.parameters.len()); + for param in &self.parameters { + parameters.push(param.recursive_type_normalized_impl(db, div, nested, visitor)?); + } + Parameters::new(db, parameters) + }; Some(Self { generic_context: self.generic_context, definition: self.definition, - parameters: self - .parameters - .iter() - .map(|param| param.recursive_type_normalized_impl(db, div, nested, visitor)) - .collect::>()?, + parameters, return_ty, }) } @@ -662,7 +666,7 @@ impl<'db> Signature<'db> { parameters.next(); } - let mut parameters = Parameters::new(parameters); + let mut parameters = Parameters::new(db, parameters); let mut return_ty = self.return_ty; if let Some(self_type) = self_type { parameters = parameters.apply_type_mapping_impl( @@ -1344,7 +1348,10 @@ pub(crate) struct Parameters<'db> { } impl<'db> Parameters<'db> { - pub(crate) fn new(parameters: impl IntoIterator>) -> Self { + pub(crate) fn new( + _db: &'db dyn Db, + parameters: impl IntoIterator>, + ) -> Self { let value: Vec> = parameters.into_iter().collect(); let is_gradual = value.len() == 2 && value @@ -1598,6 +1605,7 @@ impl<'db> Parameters<'db> { }); Self::new( + db, positional_only .into_iter() .chain(positional_or_keyword) @@ -1715,12 +1723,6 @@ impl<'db, 'a> IntoIterator for &'a Parameters<'db> { } } -impl<'db> FromIterator> for Parameters<'db> { - fn from_iter>>(iter: T) -> Self { - Self::new(iter) - } -} - impl<'db> std::ops::Index for Parameters<'db> { type Output = Parameter<'db>; From 5e1b2eef5797b00de8329bf38ceacf5cacd00c87 Mon Sep 17 00:00:00 2001 From: Aria Desires Date: Fri, 28 Nov 2025 08:27:52 -0500 Subject: [PATCH 16/67] [ty] implement rendering of `.. code:: lang` in docstrings (#21665) ## Summary * Fixes https://github.com/astral-sh/ty/issues/1650 * Part of https://github.com/astral-sh/ty/issues/1610 We now handle: * `.. warning::` (and friends) by bolding the line and rendering the block as normal (non-code) text * `.. code::` (and friends) by treating it the same as `::` (fully deleted if seen, introduce a code block) * `.. code:: lang` (and friends) by letting it set the language on the codefence * `.. versionchanged:: 1.2.3` (and friends) by rendering it like `warning` but with the version included and italicized * `.. dsfsdf-unknown:: (lang)` by assuming it's the same as `.. code:: (lang)` ## Test Plan Snapshots added/updated. I also deleted a bunch of useless checks on plaintext rendering. It's important for some edge-case tests but not for the vast majority of tests. --- crates/ty_ide/src/docstring.rs | 518 +++++++++++++++++++++------------ 1 file changed, 328 insertions(+), 190 deletions(-) diff --git a/crates/ty_ide/src/docstring.rs b/crates/ty_ide/src/docstring.rs index 163dbe1ae2..40c94ec5cb 100644 --- a/crates/ty_ide/src/docstring.rs +++ b/crates/ty_ide/src/docstring.rs @@ -182,6 +182,11 @@ fn documentation_trim(docs: &str) -> String { /// /// ``` fn render_markdown(docstring: &str) -> String { + // Here lies a monumemnt to robust parsing and escaping: + // a codefence with SO MANY backticks that surely no one will ever accidentally + // break out of it, even if they're writing python documentation about markdown + // code fences and are showing off how you can use more than 3 backticks. + const FENCE: &str = "```````````"; // TODO: there is a convention that `singletick` is for items that can // be looked up in-scope while ``multitick`` is for opaque inline code. // While rendering this we should make note of all the `singletick` locations @@ -191,9 +196,10 @@ fn render_markdown(docstring: &str) -> String { let mut first_line = true; let mut block_indent = 0; let mut in_doctest = false; - let mut starting_literal = false; + let mut starting_literal = None; let mut in_literal = false; let mut in_any_code = false; + let mut temp_owned_line; for untrimmed_line in docstring.lines() { // We can assume leading whitespace has been normalized let mut line = untrimmed_line.trim_start_matches(' '); @@ -207,7 +213,7 @@ fn render_markdown(docstring: &str) -> String { output.push_str(" "); } // Only push newlines if we're not scanning for a real line - if !starting_literal { + if starting_literal.is_none() { output.push('\n'); } } @@ -219,21 +225,23 @@ fn render_markdown(docstring: &str) -> String { in_literal = false; in_any_code = false; block_indent = 0; - output.push_str("```\n"); + output.push_str(FENCE); + output.push('\n'); } // We previously entered a literal block and we just found our first non-blank line // So now we're actually in the literal block - if starting_literal && !line.is_empty() { - starting_literal = false; + if let Some(literal) = starting_literal + && !line.is_empty() + { + starting_literal = None; in_literal = true; in_any_code = true; block_indent = line_indent; - // TODO: I hope people don't have literal blocks about markdown code fence syntax - // TODO: should we not be this aggressive? Let it autodetect? - // TODO: respect `.. code-block::` directives: - // - output.push_str("\n```python\n"); + output.push('\n'); + output.push_str(FENCE); + output.push_str(literal); + output.push('\n'); } // If we're not in a codeblock and we see something that signals a doctest, start one @@ -242,25 +250,79 @@ fn render_markdown(docstring: &str) -> String { in_doctest = true; in_any_code = true; // TODO: is there something more specific? `pycon`? - output.push_str("```python\n"); + output.push_str(FENCE); + output.push_str("python\n"); } // If we're not in a codeblock and we see something that signals a literal block, start one - if !in_any_code && let Some(without_lit) = line.strip_suffix("::") { - let trimmed_without_lit = without_lit.trim(); - if let Some(character) = trimmed_without_lit.chars().next_back() { - if character.is_whitespace() { - // Remove the marker completely - line = trimmed_without_lit; - } else { - // Only remove the first `:` - line = line.strip_suffix(":").unwrap(); - } + let parsed_lit = line + // first check for a line ending with `::` + .strip_suffix("::") + .map(|prefix| (prefix, None)) + // if that fails, look for a line ending with `:: lang` + .or_else(|| { + let (prefix, lang) = line.rsplit_once(' ')?; + let prefix = prefix.trim_end().strip_suffix("::")?; + Some((prefix, Some(lang))) + }); + if !in_any_code && let Some((without_lit, lang)) = parsed_lit { + let mut without_directive = without_lit; + let mut directive = None; + // Parse out a directive like `.. warning::` + if let Some((prefix, directive_str)) = without_lit.rsplit_once(' ') + && let Some(without_directive_str) = prefix.strip_suffix("..") + { + directive = Some(directive_str); + without_directive = without_directive_str; + } + + // Whether the `::` should become `:` or be erased + let include_colon = if let Some(character) = without_directive.chars().next_back() { + // If lang is set then we're either deleting the whole line or + // the special rendering below will add it itself + lang.is_none() && !character.is_whitespace() } else { // Delete whole line - line = trimmed_without_lit; + false + }; + + if include_colon { + line = line.strip_suffix(":").unwrap(); + } else { + line = without_directive.trim_end(); } - starting_literal = true; + + starting_literal = match directive { + // Special directives that should be plaintext + Some( + "attention" | "caution" | "danger" | "error" | "hint" | "important" | "note" + | "tip" | "warning" | "admonition" | "versionadded" | "version-added" + | "versionchanged" | "version-changed" | "version-deprecated" | "deprecated" + | "version-removed" | "versionremoved", + ) => { + // Render the argument of things like `.. version-added:: 4.0` + let suffix = if let Some(lang) = lang { + format!(" *{lang}*") + } else { + String::new() + }; + // We prepend without_directive here out of caution for preserving input. + // This is probably gibberish/invalid syntax? But it's a no-op in normal cases. + temp_owned_line = + format!("**{without_directive}{}:**{suffix}", directive.unwrap()); + + line = temp_owned_line.as_str(); + None + } + // Things that just mean "it's code" + Some( + "code-block" | "sourcecode" | "code" | "testcode" | "testsetup" | "testcleanup", + ) => lang.or(Some("python")), + // Unknown (python I guess?) + Some(_) => lang.or(Some("python")), + // default to python + None => lang.or(Some("python")), + }; } // Add this line's indentation. @@ -349,7 +411,7 @@ fn render_markdown(docstring: &str) -> String { block_indent = 0; in_any_code = false; in_literal = false; - output.push_str("```"); + output.push_str(FENCE); } } else { // Print the line verbatim, it's in code @@ -360,7 +422,8 @@ fn render_markdown(docstring: &str) -> String { } // Flush codeblock if in_any_code { - output.push_str("\n```"); + output.push('\n'); + output.push_str(FENCE); } output @@ -730,28 +793,6 @@ mod tests { let docstring = Docstring::new(docstring.to_owned()); - assert_snapshot!(docstring.render_plaintext(), @r" - Here _this_ and ___that__ should be escaped - Here *this* and **that** should be untouched - Here `this` and ``that`` should be untouched - - Here `_this_` and ``__that__`` should be untouched - Here `_this_` ``__that__`` should be untouched - `_this_too_should_be_untouched_` - - Here `_this_```__that__`` should be untouched but this_is_escaped - Here ``_this_```__that__` should be untouched but this_is_escaped - - Here `_this_ and _that_ should be escaped (but isn't) - Here _this_ and _that_` should be escaped - `Here _this_ and _that_ should be escaped (but isn't) - Here _this_ and _that_ should be escaped` - - Here ```_is_``__a__`_balanced_``_mess_``` - Here ```_is_`````__a__``_random_````_mess__```` - ```_is_`````__a__``_random_````_mess__```` - "); - assert_snapshot!(docstring.render_markdown(), @r" Here \_this\_ and \_\_\_that\_\_ should be escaped Here *this* and **that** should be untouched @@ -796,24 +837,9 @@ mod tests { let docstring = Docstring::new(docstring.to_owned()); - assert_snapshot!(docstring.render_plaintext(), @r#" - Check out this great example code:: - - x_y = "hello" - - if len(x_y) > 4: - print(x_y) - else: - print("too short :(") - - print("done") - - You love to see it. - "#); - assert_snapshot!(docstring.render_markdown(), @r#" Check out this great example code: - ```python + ```````````python x_y = "hello" if len(x_y) > 4: @@ -823,7 +849,7 @@ mod tests { print("done") - ``` + ``````````` You love to see it. "#); } @@ -849,24 +875,9 @@ mod tests { let docstring = Docstring::new(docstring.to_owned()); - assert_snapshot!(docstring.render_plaintext(), @r#" - Check out this great example code :: - - x_y = "hello" - - if len(x_y) > 4: - print(x_y) - else: - print("too short :(") - - print("done") - - You love to see it. - "#); - assert_snapshot!(docstring.render_markdown(), @r#" - Check out this great example code : - ```python + Check out this great example code + ```````````python x_y = "hello" if len(x_y) > 4: @@ -876,7 +887,7 @@ mod tests { print("done") - ``` + ``````````` You love to see it. "#); } @@ -903,26 +914,10 @@ mod tests { let docstring = Docstring::new(docstring.to_owned()); - assert_snapshot!(docstring.render_plaintext(), @r#" - Check out this great example code - :: - - x_y = "hello" - - if len(x_y) > 4: - print(x_y) - else: - print("too short :(") - - print("done") - - You love to see it. - "#); - assert_snapshot!(docstring.render_markdown(), @r#" Check out this great example code      - ```python + ```````````python x_y = "hello" if len(x_y) > 4: @@ -932,7 +927,7 @@ mod tests { print("done") - ``` + ``````````` You love to see it. "#); } @@ -956,22 +951,9 @@ mod tests { let docstring = Docstring::new(docstring.to_owned()); - assert_snapshot!(docstring.render_plaintext(), @r#" - Check out this great example code:: - x_y = "hello" - - if len(x_y) > 4: - print(x_y) - else: - print("too short :(") - - print("done") - You love to see it. - "#); - assert_snapshot!(docstring.render_markdown(), @r#" Check out this great example code: - ```python + ```````````python x_y = "hello" if len(x_y) > 4: @@ -980,7 +962,7 @@ mod tests { print("too short :(") print("done") - ``` + ``````````` You love to see it. "#); } @@ -1003,22 +985,9 @@ mod tests { let docstring = Docstring::new(docstring.to_owned()); - assert_snapshot!(docstring.render_plaintext(), @r#" - Check out this great example code:: - - x_y = "hello" - - if len(x_y) > 4: - print(x_y) - else: - print("too short :(") - - print("done") - "#); - assert_snapshot!(docstring.render_markdown(), @r#" Check out this great example code: - ```python + ```````````python x_y = "hello" if len(x_y) > 4: @@ -1027,7 +996,224 @@ mod tests { print("too short :(") print("done") - ``` + ``````````` + "#); + } + + // `warning` and several other directives are special languages that should actually + // still be shown as text and not ```code```. + #[test] + fn warning_block() { + let docstring = r#" + The thing you need to understand is that computers are hard. + + .. warning:: + Now listen here buckaroo you might have seen me say computers are hard, + and though "yeah I know computers are hard but NO you DON'T KNOW. + + Listen: + + - Computers + - Are + - Hard + + Ok!?!?!? + "#; + + let docstring = Docstring::new(docstring.to_owned()); + + assert_snapshot!(docstring.render_markdown(), @r#" + The thing you need to understand is that computers are hard. + + **warning:** +     Now listen here buckaroo you might have seen me say computers are hard, +     and though "yeah I know computers are hard but NO you DON'T KNOW. + +     Listen: + +     - Computers +     - Are +     - Hard + +     Ok!?!?!? + "#); + } + + // `warning` and several other directives are special languages that should actually + // still be shown as text and not ```code```. + #[test] + fn version_blocks() { + let docstring = r#" + Some much-updated docs + + .. version-added:: 3.0 + Function added + + .. version-changed:: 4.0 + The `spam` argument was added + .. version-changed:: 4.1 + The `spam` argument is considered evil now. + + You really shouldnt use it + + And that's the docs + "#; + + let docstring = Docstring::new(docstring.to_owned()); + + assert_snapshot!(docstring.render_markdown(), @r" + Some much-updated docs + + **version-added:** *3.0* +    Function added + + **version-changed:** *4.0* +    The `spam` argument was added + **version-changed:** *4.1* +    The `spam` argument is considered evil now. + +    You really shouldnt use it + + And that's the docs + "); + } + + // I don't know if this is valid syntax but we preserve stuff before non-code blocks like + // `..deprecated ::` + #[test] + fn deprecated_prefix_gunk() { + let docstring = r#" + wow this is some changes .. deprecated:: 1.2.3 + x = 2 + "#; + + let docstring = Docstring::new(docstring.to_owned()); + + assert_snapshot!(docstring.render_markdown(), @r" + **wow this is some changes deprecated:** *1.2.3* +     x = 2 + "); + } + + // `.. code::` is a literal block and the `.. code::` should be deleted + #[test] + fn code_block() { + let docstring = r#" + Here's some code! + + .. code:: + def main() { + print("hello world!") + } + "#; + + let docstring = Docstring::new(docstring.to_owned()); + + assert_snapshot!(docstring.render_markdown(), @r#" + Here's some code! + + + ```````````python + def main() { + print("hello world!") + } + ``````````` + "#); + } + + // `.. code:: rust` is a literal block with rust syntax highlighting + #[test] + fn code_block_lang() { + let docstring = r#" + Here's some Rust code! + + .. code:: rust + fn main() { + println!("hello world!"); + } + "#; + + let docstring = Docstring::new(docstring.to_owned()); + + assert_snapshot!(docstring.render_markdown(), @r#" + Here's some Rust code! + + + ```````````rust + fn main() { + println!("hello world!"); + } + ``````````` + "#); + } + + // I don't know if this is valid syntax but we preserve stuff before `..code ::` + #[test] + fn code_block_prefix_gunk() { + let docstring = r#" + wow this is some code.. code:: abc + x = 2 + "#; + + let docstring = Docstring::new(docstring.to_owned()); + + assert_snapshot!(docstring.render_markdown(), @r" + wow this is some code + ```````````abc + x = 2 + ``````````` + "); + } + + // `.. asdgfhjkl-unknown::` is treated the same as `.. code::` + #[test] + fn unknown_block() { + let docstring = r#" + Here's some code! + + .. asdgfhjkl-unknown:: + fn main() { + println!("hello world!"); + } + "#; + + let docstring = Docstring::new(docstring.to_owned()); + + assert_snapshot!(docstring.render_markdown(), @r#" + Here's some code! + + + ```````````python + fn main() { + println!("hello world!"); + } + ``````````` + "#); + } + + // `.. asdgfhjkl-unknown:: rust` is treated the same as `.. code:: rust` + #[test] + fn unknown_block_lang() { + let docstring = r#" + Here's some Rust code! + + .. asdgfhjkl-unknown:: rust + fn main() { + print("hello world!") + } + "#; + + let docstring = Docstring::new(docstring.to_owned()); + + assert_snapshot!(docstring.render_markdown(), @r#" + Here's some Rust code! + + + ```````````rust + fn main() { + print("hello world!") + } + ``````````` "#); } @@ -1047,26 +1233,15 @@ mod tests { let docstring = Docstring::new(docstring.to_owned()); - assert_snapshot!(docstring.render_plaintext(), @r" - This is a function description - - >>> thing.do_thing() - wow it did the thing - >>> thing.do_other_thing() - it sure did the thing - - As you can see it did the thing! - "); - assert_snapshot!(docstring.render_markdown(), @r" This is a function description - ```python + ```````````python >>> thing.do_thing() wow it did the thing >>> thing.do_other_thing() it sure did the thing - ``` + ``````````` As you can see it did the thing! "); } @@ -1087,26 +1262,15 @@ mod tests { let docstring = Docstring::new(docstring.to_owned()); - assert_snapshot!(docstring.render_plaintext(), @r" - This is a function description - - >>> thing.do_thing() - wow it did the thing - >>> thing.do_other_thing() - it sure did the thing - - As you can see it did the thing! - "); - assert_snapshot!(docstring.render_markdown(), @r" This is a function description - ```python + ```````````python >>> thing.do_thing() wow it did the thing >>> thing.do_other_thing() it sure did the thing - ``` + ``````````` As you can see it did the thing! "); } @@ -1121,20 +1285,13 @@ mod tests { let docstring = Docstring::new(docstring.to_owned()); - assert_snapshot!(docstring.render_plaintext(), @r" - >>> thing.do_thing() - wow it did the thing - >>> thing.do_other_thing() - it sure did the thing - "); - assert_snapshot!(docstring.render_markdown(), @r" - ```python + ```````````python >>> thing.do_thing() wow it did the thing >>> thing.do_other_thing() it sure did the thing - ``` + ``````````` "); } @@ -1154,26 +1311,15 @@ mod tests { let docstring = Docstring::new(docstring.to_owned()); - assert_snapshot!(docstring.render_plaintext(), @r" - This is a function description:: - - >>> thing.do_thing() - wow it did the thing - >>> thing.do_other_thing() - it sure did the thing - - As you can see it did the thing! - "); - assert_snapshot!(docstring.render_markdown(), @r" This is a function description: - ```python + ```````````python >>> thing.do_thing() wow it did the thing >>> thing.do_other_thing() it sure did the thing - ``` + ``````````` As you can see it did the thing! "); } @@ -1189,22 +1335,14 @@ mod tests { let docstring = Docstring::new(docstring.to_owned()); - assert_snapshot!(docstring.render_plaintext(), @r" - And so you can see that - >>> thing.do_thing() - wow it did the thing - >>> thing.do_other_thing() - it sure did the thing - "); - assert_snapshot!(docstring.render_markdown(), @r" And so you can see that - ```python + ```````````python >>> thing.do_thing() wow it did the thing >>> thing.do_other_thing() it sure did the thing - ``` + ``````````` "); } @@ -1383,14 +1521,14 @@ mod tests {             This is a continuation of param2 description. 'param3' -- A parameter without type annotation - ```python + ```````````python >>> print repr(foo.__doc__) '\n This is the second line of the docstring.\n ' >>> foo.__doc__.splitlines() ['', ' This is the second line of the docstring.', ' '] >>> trim(foo.__doc__) 'This is the second line of the docstring.' - ``` + ``````````` "); } From c534bfaf01671b8020edd440bc7f4f22070af583 Mon Sep 17 00:00:00 2001 From: Aria Desires Date: Fri, 28 Nov 2025 08:41:21 -0500 Subject: [PATCH 17/67] [ty] Implement patterns and typevars in the LSP (#21671) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary **This is the final goto-targets with missing goto-definition/declaration implementations! You can now theoretically click on all the user-defined names in all the syntax. 🎉** This adds: * goto definition/declaration on patterns/typevars * find-references/rename on patterns/typevars * fixes syntax highlighting of `*rest` patterns This notably *does not* add: * goto-type for patterns/typevars * hover for patterns/typevars (because that's just goto-type for names) Also I realized we were at the precipice of one of the great GotoTarget sins being resolved, and so I made import aliases also resolve to a ResolvedDefinition. This removes a ton of cruft and prevents further backsliding. Note however that import aliases are, in general, completely jacked up when it comes to find-references/renames (both before and after this PR). Previously you could try to rename an import alias and it just wouldn't do anything. With this change we instead refuse to even let you try to rename it. Sorting out why import aliases are jacked up is an ongoing thing I hope to handle in a followup. ## Test Plan You'll surely not regret checking in 86 snapshot tests --- crates/ty_ide/src/completion.rs | 6 +- crates/ty_ide/src/goto.rs | 201 +++---- crates/ty_ide/src/goto_declaration.rs | 480 +++++++++++++++ crates/ty_ide/src/goto_references.rs | 546 ++++++++++++++++++ crates/ty_ide/src/goto_type_definition.rs | 276 +++++++++ crates/ty_ide/src/hover.rs | 392 +++++++++++++ crates/ty_ide/src/inlay_hints.rs | 125 ++++ crates/ty_ide/src/references.rs | 14 + crates/ty_ide/src/rename.rs | 384 ++++++++++++ crates/ty_ide/src/semantic_tokens.rs | 11 + crates/ty_ide/src/signature_help.rs | 5 +- .../src/semantic_index/builder.rs | 2 + 12 files changed, 2329 insertions(+), 113 deletions(-) diff --git a/crates/ty_ide/src/completion.rs b/crates/ty_ide/src/completion.rs index 4387c09346..8b4c38beb4 100644 --- a/crates/ty_ide/src/completion.rs +++ b/crates/ty_ide/src/completion.rs @@ -17,7 +17,7 @@ use ty_python_semantic::{ use crate::docstring::Docstring; use crate::find_node::covering_node; -use crate::goto::DefinitionsOrTargets; +use crate::goto::Definitions; use crate::importer::{ImportRequest, Importer}; use crate::symbols::QueryPattern; use crate::{Db, all_symbols}; @@ -220,9 +220,7 @@ impl<'db> Completion<'db> { db: &'db dyn Db, semantic: SemanticCompletion<'db>, ) -> Completion<'db> { - let definition = semantic - .ty - .and_then(|ty| DefinitionsOrTargets::from_ty(db, ty)); + let definition = semantic.ty.and_then(|ty| Definitions::from_ty(db, ty)); let documentation = definition.and_then(|def| def.docstring(db)); let is_type_check_only = semantic.is_type_check_only(db); Completion { diff --git a/crates/ty_ide/src/goto.rs b/crates/ty_ide/src/goto.rs index ab589ba5c5..3b086b91fd 100644 --- a/crates/ty_ide/src/goto.rs +++ b/crates/ty_ide/src/goto.rs @@ -212,16 +212,9 @@ pub(crate) enum GotoTarget<'a> { /// The resolved definitions for a `GotoTarget` #[derive(Debug, Clone)] -pub(crate) enum DefinitionsOrTargets<'db> { - /// We computed actual Definitions we can do followup queries on. - Definitions(Vec>), - /// We directly computed a navigation. - /// - /// We can't get docs or usefully compute goto-definition for this. - Targets(crate::NavigationTargets), -} +pub(crate) struct Definitions<'db>(pub Vec>); -impl<'db> DefinitionsOrTargets<'db> { +impl<'db> Definitions<'db> { pub(crate) fn from_ty(db: &'db dyn crate::Db, ty: Type<'db>) -> Option { let ty_def = ty.definition(db)?; let resolved = match ty_def { @@ -237,7 +230,7 @@ impl<'db> DefinitionsOrTargets<'db> { ResolvedDefinition::Definition(definition) } }; - Some(DefinitionsOrTargets::Definitions(vec![resolved])) + Some(Definitions(vec![resolved])) } /// Get the "goto-declaration" interpretation of this definition @@ -247,12 +240,7 @@ impl<'db> DefinitionsOrTargets<'db> { self, db: &'db dyn ty_python_semantic::Db, ) -> Option { - match self { - DefinitionsOrTargets::Definitions(definitions) => { - definitions_to_navigation_targets(db, None, definitions) - } - DefinitionsOrTargets::Targets(targets) => Some(targets), - } + definitions_to_navigation_targets(db, None, self.0) } /// Get the "goto-definition" interpretation of this definition @@ -263,12 +251,7 @@ impl<'db> DefinitionsOrTargets<'db> { self, db: &'db dyn ty_python_semantic::Db, ) -> Option { - match self { - DefinitionsOrTargets::Definitions(definitions) => { - definitions_to_navigation_targets(db, Some(&StubMapper::new(db)), definitions) - } - DefinitionsOrTargets::Targets(targets) => Some(targets), - } + definitions_to_navigation_targets(db, Some(&StubMapper::new(db)), self.0) } /// Get the docstring for this definition @@ -277,13 +260,7 @@ impl<'db> DefinitionsOrTargets<'db> { /// so this will check both the goto-declarations and goto-definitions (in that order) /// and return the first one found. pub(crate) fn docstring(self, db: &'db dyn crate::Db) -> Option { - let definitions = match self { - DefinitionsOrTargets::Definitions(definitions) => definitions, - // Can't find docs for these - // (make more cases DefinitionOrTargets::Definitions to get more docs!) - DefinitionsOrTargets::Targets(_) => return None, - }; - for definition in &definitions { + for definition in &self.0 { // If we got a docstring from the original definition, use it if let Some(docstring) = definition.docstring(db) { return Some(Docstring::new(docstring)); @@ -296,7 +273,7 @@ impl<'db> DefinitionsOrTargets<'db> { let stub_mapper = StubMapper::new(db); // Try to find the corresponding implementation definition - for definition in stub_mapper.map_definitions(definitions) { + for definition in stub_mapper.map_definitions(self.0) { if let Some(docstring) = definition.docstring(db) { return Some(Docstring::new(docstring)); } @@ -399,36 +376,32 @@ impl GotoTarget<'_> { &self, model: &SemanticModel<'db>, alias_resolution: ImportAliasResolution, - ) -> Option> { - use crate::NavigationTarget; - match self { - GotoTarget::Expression(expression) => definitions_for_expression(model, *expression) - .map(DefinitionsOrTargets::Definitions), + ) -> Option> { + let definitions = match self { + GotoTarget::Expression(expression) => definitions_for_expression(model, *expression), // For already-defined symbols, they are their own definitions - GotoTarget::FunctionDef(function) => Some(DefinitionsOrTargets::Definitions(vec![ - ResolvedDefinition::Definition(function.definition(model)), - ])), + GotoTarget::FunctionDef(function) => Some(vec![ResolvedDefinition::Definition( + function.definition(model), + )]), - GotoTarget::ClassDef(class) => Some(DefinitionsOrTargets::Definitions(vec![ - ResolvedDefinition::Definition(class.definition(model)), - ])), + GotoTarget::ClassDef(class) => Some(vec![ResolvedDefinition::Definition( + class.definition(model), + )]), - GotoTarget::Parameter(parameter) => Some(DefinitionsOrTargets::Definitions(vec![ - ResolvedDefinition::Definition(parameter.definition(model)), - ])), + GotoTarget::Parameter(parameter) => Some(vec![ResolvedDefinition::Definition( + parameter.definition(model), + )]), // For import aliases (offset within 'y' or 'z' in "from x import y as z") GotoTarget::ImportSymbolAlias { alias, import_from, .. } => { let symbol_name = alias.name.as_str(); - Some(DefinitionsOrTargets::Definitions( - definitions_for_imported_symbol( - model, - import_from, - symbol_name, - alias_resolution, - ), + Some(definitions_for_imported_symbol( + model, + import_from, + symbol_name, + alias_resolution, )) } @@ -448,14 +421,9 @@ impl GotoTarget<'_> { if alias_resolution == ImportAliasResolution::ResolveAliases { definitions_for_module(model, Some(alias.name.as_str()), 0) } else { - let alias_range = alias.asname.as_ref().unwrap().range; - Some(DefinitionsOrTargets::Targets( - crate::NavigationTargets::single(NavigationTarget { - file: model.file(), - focus_range: alias_range, - full_range: alias.range(), - }), - )) + alias.asname.as_ref().map(|name| { + definitions_for_name(model, name.as_str(), AnyNodeRef::Identifier(name)) + }) } } @@ -463,45 +431,44 @@ impl GotoTarget<'_> { GotoTarget::KeywordArgument { keyword, call_expression, - } => Some(DefinitionsOrTargets::Definitions( - definitions_for_keyword_argument(model, keyword, call_expression), + } => Some(definitions_for_keyword_argument( + model, + keyword, + call_expression, )), // For exception variables, they are their own definitions (like parameters) GotoTarget::ExceptVariable(except_handler) => { - Some(DefinitionsOrTargets::Definitions(vec![ - ResolvedDefinition::Definition(except_handler.definition(model)), - ])) + Some(vec![ResolvedDefinition::Definition( + except_handler.definition(model), + )]) } - // For pattern match rest variables, they are their own definitions + // Patterns are glorified assignments but we have to look them up by ident + // because they're not expressions GotoTarget::PatternMatchRest(pattern_mapping) => { - if let Some(rest_name) = &pattern_mapping.rest { - let range = rest_name.range; - Some(DefinitionsOrTargets::Targets( - crate::NavigationTargets::single(NavigationTarget::new( - model.file(), - range, - )), - )) - } else { - None - } + pattern_mapping.rest.as_ref().map(|name| { + definitions_for_name(model, name.as_str(), AnyNodeRef::Identifier(name)) + }) } - // For pattern match as names, they are their own definitions - GotoTarget::PatternMatchAsName(pattern_as) => { - if let Some(name) = &pattern_as.name { - let range = name.range; - Some(DefinitionsOrTargets::Targets( - crate::NavigationTargets::single(NavigationTarget::new( - model.file(), - range, - )), - )) - } else { - None - } + GotoTarget::PatternMatchAsName(pattern_as) => pattern_as.name.as_ref().map(|name| { + definitions_for_name(model, name.as_str(), AnyNodeRef::Identifier(name)) + }), + + GotoTarget::PatternKeywordArgument(pattern_keyword) => { + let name = &pattern_keyword.attr; + Some(definitions_for_name( + model, + name.as_str(), + AnyNodeRef::Identifier(name), + )) + } + + GotoTarget::PatternMatchStarName(pattern_star) => { + pattern_star.name.as_ref().map(|name| { + definitions_for_name(model, name.as_str(), AnyNodeRef::Identifier(name)) + }) } // For callables, both the definition of the callable and the actual function impl are relevant. @@ -516,7 +483,7 @@ impl GotoTarget<'_> { if definitions.is_empty() { None } else { - Some(DefinitionsOrTargets::Definitions(definitions)) + Some(definitions) } } @@ -524,14 +491,14 @@ impl GotoTarget<'_> { let (definitions, _) = ty_python_semantic::definitions_for_bin_op(model, expression)?; - Some(DefinitionsOrTargets::Definitions(definitions)) + Some(definitions) } GotoTarget::UnaryOp { expression, .. } => { let (definitions, _) = ty_python_semantic::definitions_for_unary_op(model, expression)?; - Some(DefinitionsOrTargets::Definitions(definitions)) + Some(definitions) } // String annotations sub-expressions require us to recurse into the sub-AST @@ -545,23 +512,47 @@ impl GotoTarget<'_> { .node() .as_expr_ref()?; definitions_for_expression(&submodel, subexpr) - .map(DefinitionsOrTargets::Definitions) } + + // nonlocal and global are essentially loads, but again they're statements, + // so we need to look them up by ident GotoTarget::NonLocal { identifier } | GotoTarget::Globals { identifier } => { - Some(DefinitionsOrTargets::Definitions(definitions_for_name( + Some(definitions_for_name( model, identifier.as_str(), AnyNodeRef::Identifier(identifier), - ))) + )) } - // TODO: implement these - GotoTarget::PatternKeywordArgument(..) - | GotoTarget::PatternMatchStarName(..) - | GotoTarget::TypeParamTypeVarName(..) - | GotoTarget::TypeParamParamSpecName(..) - | GotoTarget::TypeParamTypeVarTupleName(..) => None, - } + // These are declarations of sorts, but they're stmts and not exprs, so look up by ident. + GotoTarget::TypeParamTypeVarName(type_var) => { + let name = &type_var.name; + Some(definitions_for_name( + model, + name.as_str(), + AnyNodeRef::Identifier(name), + )) + } + + GotoTarget::TypeParamParamSpecName(name) => { + let name = &name.name; + Some(definitions_for_name( + model, + name.as_str(), + AnyNodeRef::Identifier(name), + )) + } + + GotoTarget::TypeParamTypeVarTupleName(name) => { + let name = &name.name; + Some(definitions_for_name( + model, + name.as_str(), + AnyNodeRef::Identifier(name), + )) + } + }; + definitions.map(Definitions) } /// Returns the text representation of this goto target. @@ -1050,12 +1041,10 @@ fn definitions_for_module<'db>( model: &SemanticModel<'db>, module: Option<&str>, level: u32, -) -> Option> { +) -> Option>> { let module = model.resolve_module(module, level)?; let file = module.file(model.db())?; - Some(DefinitionsOrTargets::Definitions(vec![ - ResolvedDefinition::Module(file), - ])) + Some(vec![ResolvedDefinition::Module(file)]) } /// Helper function to extract module component information from a dotted module name diff --git a/crates/ty_ide/src/goto_declaration.rs b/crates/ty_ide/src/goto_declaration.rs index 296a667f53..45efa4ae22 100644 --- a/crates/ty_ide/src/goto_declaration.rs +++ b/crates/ty_ide/src/goto_declaration.rs @@ -1397,6 +1397,486 @@ def function(): "); } + #[test] + fn goto_declaration_match_name_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ab]: + x = ab + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r#" + info[goto-declaration]: Declaration + --> main.py:4:22 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ab]: + | ^^ + 5 | x = ab + | + info: Source + --> main.py:4:22 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ab]: + | ^^ + 5 | x = ab + | + "#); + } + + #[test] + fn goto_declaration_match_name_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ab]: + x = ab + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r#" + info[goto-declaration]: Declaration + --> main.py:4:22 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ab]: + | ^^ + 5 | x = ab + | + info: Source + --> main.py:5:17 + | + 3 | match command.split(): + 4 | case ["get", ab]: + 5 | x = ab + | ^^ + | + "#); + } + + #[test] + fn goto_declaration_match_rest_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", *ab]: + x = ab + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r#" + info[goto-declaration]: Declaration + --> main.py:4:23 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", *ab]: + | ^^ + 5 | x = ab + | + info: Source + --> main.py:4:23 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", *ab]: + | ^^ + 5 | x = ab + | + "#); + } + + #[test] + fn goto_declaration_match_rest_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", *ab]: + x = ab + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r#" + info[goto-declaration]: Declaration + --> main.py:4:23 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", *ab]: + | ^^ + 5 | x = ab + | + info: Source + --> main.py:5:17 + | + 3 | match command.split(): + 4 | case ["get", *ab]: + 5 | x = ab + | ^^ + | + "#); + } + + #[test] + fn goto_declaration_match_as_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ("a" | "b") as ab]: + x = ab + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r#" + info[goto-declaration]: Declaration + --> main.py:4:37 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ("a" | "b") as ab]: + | ^^ + 5 | x = ab + | + info: Source + --> main.py:4:37 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ("a" | "b") as ab]: + | ^^ + 5 | x = ab + | + "#); + } + + #[test] + fn goto_declaration_match_as_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ("a" | "b") as ab]: + x = ab + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r#" + info[goto-declaration]: Declaration + --> main.py:4:37 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ("a" | "b") as ab]: + | ^^ + 5 | x = ab + | + info: Source + --> main.py:5:17 + | + 3 | match command.split(): + 4 | case ["get", ("a" | "b") as ab]: + 5 | x = ab + | ^^ + | + "#); + } + + #[test] + fn goto_declaration_match_keyword_stmt() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r" + info[goto-declaration]: Declaration + --> main.py:10:30 + | + 8 | def my_func(event: Click): + 9 | match event: + 10 | case Click(x, button=ab): + | ^^ + 11 | x = ab + | + info: Source + --> main.py:10:30 + | + 8 | def my_func(event: Click): + 9 | match event: + 10 | case Click(x, button=ab): + | ^^ + 11 | x = ab + | + "); + } + + #[test] + fn goto_declaration_match_keyword_binding() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r" + info[goto-declaration]: Declaration + --> main.py:10:30 + | + 8 | def my_func(event: Click): + 9 | match event: + 10 | case Click(x, button=ab): + | ^^ + 11 | x = ab + | + info: Source + --> main.py:11:17 + | + 9 | match event: + 10 | case Click(x, button=ab): + 11 | x = ab + | ^^ + | + "); + } + + #[test] + fn goto_declaration_match_class_name() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r#" + info[goto-declaration]: Declaration + --> main.py:2:7 + | + 2 | class Click: + | ^^^^^ + 3 | __match_args__ = ("position", "button") + 4 | def __init__(self, pos, btn): + | + info: Source + --> main.py:10:14 + | + 8 | def my_func(event: Click): + 9 | match event: + 10 | case Click(x, button=ab): + | ^^^^^ + 11 | x = ab + | + "#); + } + + #[test] + fn goto_declaration_match_class_field_name() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.goto_declaration(), @"No goto target found"); + } + + #[test] + fn goto_declaration_typevar_name_stmt() { + let test = cursor_test( + r#" + type Alias1[AB: int = bool] = tuple[AB, list[AB]] + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r" + info[goto-declaration]: Declaration + --> main.py:2:13 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + info: Source + --> main.py:2:13 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + "); + } + + #[test] + fn goto_declaration_typevar_name_binding() { + let test = cursor_test( + r#" + type Alias1[AB: int = bool] = tuple[AB, list[AB]] + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r" + info[goto-declaration]: Declaration + --> main.py:2:13 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + info: Source + --> main.py:2:37 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + "); + } + + #[test] + fn goto_declaration_typevar_spec_stmt() { + let test = cursor_test( + r#" + from typing import Callable + type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r" + info[goto-declaration]: Declaration + --> main.py:3:15 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^^ + | + info: Source + --> main.py:3:15 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^^ + | + "); + } + + #[test] + fn goto_declaration_typevar_spec_binding() { + let test = cursor_test( + r#" + from typing import Callable + type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r" + info[goto-declaration]: Declaration + --> main.py:3:15 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^^ + | + info: Source + --> main.py:3:43 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^^ + | + "); + } + + #[test] + fn goto_declaration_typevar_tuple_stmt() { + let test = cursor_test( + r#" + type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r" + info[goto-declaration]: Declaration + --> main.py:2:14 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^^ + | + info: Source + --> main.py:2:14 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^^ + | + "); + } + + #[test] + fn goto_declaration_typevar_tuple_binding() { + let test = cursor_test( + r#" + type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + "#, + ); + + assert_snapshot!(test.goto_declaration(), @r" + info[goto-declaration]: Declaration + --> main.py:2:14 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^^ + | + info: Source + --> main.py:2:38 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^^ + | + "); + } + #[test] fn goto_declaration_property_getter_setter() { let test = cursor_test( diff --git a/crates/ty_ide/src/goto_references.rs b/crates/ty_ide/src/goto_references.rs index e8be7b35c3..514ebfc75b 100644 --- a/crates/ty_ide/src/goto_references.rs +++ b/crates/ty_ide/src/goto_references.rs @@ -898,6 +898,552 @@ cls = MyClass assert_snapshot!(test.references(), @"No references found"); } + #[test] + fn references_match_name_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ab]: + x = ab + "#, + ); + + assert_snapshot!(test.references(), @r#" + info[references]: Reference 1 + --> main.py:4:22 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ab]: + | ^^ + 5 | x = ab + | + + info[references]: Reference 2 + --> main.py:5:17 + | + 3 | match command.split(): + 4 | case ["get", ab]: + 5 | x = ab + | ^^ + | + "#); + } + + #[test] + fn references_match_name_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ab]: + x = ab + "#, + ); + + assert_snapshot!(test.references(), @r#" + info[references]: Reference 1 + --> main.py:4:22 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ab]: + | ^^ + 5 | x = ab + | + + info[references]: Reference 2 + --> main.py:5:17 + | + 3 | match command.split(): + 4 | case ["get", ab]: + 5 | x = ab + | ^^ + | + "#); + } + + #[test] + fn references_match_rest_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", *ab]: + x = ab + "#, + ); + + assert_snapshot!(test.references(), @r#" + info[references]: Reference 1 + --> main.py:4:23 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", *ab]: + | ^^ + 5 | x = ab + | + + info[references]: Reference 2 + --> main.py:5:17 + | + 3 | match command.split(): + 4 | case ["get", *ab]: + 5 | x = ab + | ^^ + | + "#); + } + + #[test] + fn references_match_rest_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", *ab]: + x = ab + "#, + ); + + assert_snapshot!(test.references(), @r#" + info[references]: Reference 1 + --> main.py:4:23 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", *ab]: + | ^^ + 5 | x = ab + | + + info[references]: Reference 2 + --> main.py:5:17 + | + 3 | match command.split(): + 4 | case ["get", *ab]: + 5 | x = ab + | ^^ + | + "#); + } + + #[test] + fn references_match_as_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ("a" | "b") as ab]: + x = ab + "#, + ); + + assert_snapshot!(test.references(), @r#" + info[references]: Reference 1 + --> main.py:4:37 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ("a" | "b") as ab]: + | ^^ + 5 | x = ab + | + + info[references]: Reference 2 + --> main.py:5:17 + | + 3 | match command.split(): + 4 | case ["get", ("a" | "b") as ab]: + 5 | x = ab + | ^^ + | + "#); + } + + #[test] + fn references_match_as_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ("a" | "b") as ab]: + x = ab + "#, + ); + + assert_snapshot!(test.references(), @r#" + info[references]: Reference 1 + --> main.py:4:37 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ("a" | "b") as ab]: + | ^^ + 5 | x = ab + | + + info[references]: Reference 2 + --> main.py:5:17 + | + 3 | match command.split(): + 4 | case ["get", ("a" | "b") as ab]: + 5 | x = ab + | ^^ + | + "#); + } + + #[test] + fn references_match_keyword_stmt() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.references(), @r" + info[references]: Reference 1 + --> main.py:10:30 + | + 8 | def my_func(event: Click): + 9 | match event: + 10 | case Click(x, button=ab): + | ^^ + 11 | x = ab + | + + info[references]: Reference 2 + --> main.py:11:17 + | + 9 | match event: + 10 | case Click(x, button=ab): + 11 | x = ab + | ^^ + | + "); + } + + #[test] + fn references_match_keyword_binding() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.references(), @r" + info[references]: Reference 1 + --> main.py:10:30 + | + 8 | def my_func(event: Click): + 9 | match event: + 10 | case Click(x, button=ab): + | ^^ + 11 | x = ab + | + + info[references]: Reference 2 + --> main.py:11:17 + | + 9 | match event: + 10 | case Click(x, button=ab): + 11 | x = ab + | ^^ + | + "); + } + + #[test] + fn references_match_class_name() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.references(), @r#" + info[references]: Reference 1 + --> main.py:2:7 + | + 2 | class Click: + | ^^^^^ + 3 | __match_args__ = ("position", "button") + 4 | def __init__(self, pos, btn): + | + + info[references]: Reference 2 + --> main.py:8:20 + | + 6 | self.button: str = btn + 7 | + 8 | def my_func(event: Click): + | ^^^^^ + 9 | match event: + 10 | case Click(x, button=ab): + | + + info[references]: Reference 3 + --> main.py:10:14 + | + 8 | def my_func(event: Click): + 9 | match event: + 10 | case Click(x, button=ab): + | ^^^^^ + 11 | x = ab + | + "#); + } + + #[test] + fn references_match_class_field_name() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.references(), @"No references found"); + } + + #[test] + fn references_typevar_name_stmt() { + let test = cursor_test( + r#" + type Alias1[AB: int = bool] = tuple[AB, list[AB]] + "#, + ); + + assert_snapshot!(test.references(), @r" + info[references]: Reference 1 + --> main.py:2:13 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + + info[references]: Reference 2 + --> main.py:2:37 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + + info[references]: Reference 3 + --> main.py:2:46 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + "); + } + + #[test] + fn references_typevar_name_binding() { + let test = cursor_test( + r#" + type Alias1[AB: int = bool] = tuple[AB, list[AB]] + "#, + ); + + assert_snapshot!(test.references(), @r" + info[references]: Reference 1 + --> main.py:2:13 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + + info[references]: Reference 2 + --> main.py:2:37 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + + info[references]: Reference 3 + --> main.py:2:46 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + "); + } + + #[test] + fn references_typevar_spec_stmt() { + let test = cursor_test( + r#" + from typing import Callable + type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + "#, + ); + + assert_snapshot!(test.references(), @r" + info[references]: Reference 1 + --> main.py:3:15 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^^ + | + + info[references]: Reference 2 + --> main.py:3:43 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^^ + | + + info[references]: Reference 3 + --> main.py:3:53 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^^ + | + "); + } + + #[test] + fn references_typevar_spec_binding() { + let test = cursor_test( + r#" + from typing import Callable + type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + "#, + ); + + assert_snapshot!(test.references(), @r" + info[references]: Reference 1 + --> main.py:3:15 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^^ + | + + info[references]: Reference 2 + --> main.py:3:43 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^^ + | + + info[references]: Reference 3 + --> main.py:3:53 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^^ + | + "); + } + + #[test] + fn references_typevar_tuple_stmt() { + let test = cursor_test( + r#" + type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + "#, + ); + + assert_snapshot!(test.references(), @r" + info[references]: Reference 1 + --> main.py:2:14 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^^ + | + + info[references]: Reference 2 + --> main.py:2:38 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^^ + | + + info[references]: Reference 3 + --> main.py:2:50 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^^ + | + "); + } + + #[test] + fn references_typevar_tuple_binding() { + let test = cursor_test( + r#" + type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + "#, + ); + + assert_snapshot!(test.references(), @r" + info[references]: Reference 1 + --> main.py:2:14 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^^ + | + + info[references]: Reference 2 + --> main.py:2:38 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^^ + | + + info[references]: Reference 3 + --> main.py:2:50 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^^ + | + "); + } + #[test] fn test_multi_file_function_references() { let test = CursorTest::builder() diff --git a/crates/ty_ide/src/goto_type_definition.rs b/crates/ty_ide/src/goto_type_definition.rs index 3a8f80b643..fe85f44095 100644 --- a/crates/ty_ide/src/goto_type_definition.rs +++ b/crates/ty_ide/src/goto_type_definition.rs @@ -964,6 +964,282 @@ mod tests { assert_snapshot!(test.goto_type_definition(), @"No goto target found"); } + #[test] + fn goto_type_match_name_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ab]: + x = ab + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No goto target found"); + } + + #[test] + fn goto_type_match_name_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ab]: + x = ab + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No type definitions found"); + } + + #[test] + fn goto_type_match_rest_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", *ab]: + x = ab + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No goto target found"); + } + + #[test] + fn goto_type_match_rest_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", *ab]: + x = ab + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No type definitions found"); + } + + #[test] + fn goto_type_match_as_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ("a" | "b") as ab]: + x = ab + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No goto target found"); + } + + #[test] + fn goto_type_match_as_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ("a" | "b") as ab]: + x = ab + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No type definitions found"); + } + + #[test] + fn goto_type_match_keyword_stmt() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No goto target found"); + } + + #[test] + fn goto_type_match_keyword_binding() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No type definitions found"); + } + + #[test] + fn goto_type_match_class_name() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @r#" + info[goto-type-definition]: Type definition + --> main.py:2:7 + | + 2 | class Click: + | ^^^^^ + 3 | __match_args__ = ("position", "button") + 4 | def __init__(self, pos, btn): + | + info: Source + --> main.py:10:14 + | + 8 | def my_func(event: Click): + 9 | match event: + 10 | case Click(x, button=ab): + | ^^^^^ + 11 | x = ab + | + "#); + } + + #[test] + fn goto_type_match_class_field_name() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No goto target found"); + } + + #[test] + fn goto_type_typevar_name_stmt() { + let test = cursor_test( + r#" + type Alias1[AB: int = bool] = tuple[AB, list[AB]] + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @r" + info[goto-type-definition]: Type definition + --> main.py:2:13 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + info: Source + --> main.py:2:13 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + "); + } + + #[test] + fn goto_type_typevar_name_binding() { + let test = cursor_test( + r#" + type Alias1[AB: int = bool] = tuple[AB, list[AB]] + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @r" + info[goto-type-definition]: Type definition + --> main.py:2:13 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + info: Source + --> main.py:2:37 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ + | + "); + } + + #[test] + fn goto_type_typevar_spec_stmt() { + let test = cursor_test( + r#" + from typing import Callable + type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No goto target found"); + } + + #[test] + fn goto_type_typevar_spec_binding() { + let test = cursor_test( + r#" + from typing import Callable + type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No type definitions found"); + } + + #[test] + fn goto_type_typevar_tuple_stmt() { + let test = cursor_test( + r#" + type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No goto target found"); + } + + #[test] + fn goto_type_typevar_tuple_binding() { + let test = cursor_test( + r#" + type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + "#, + ); + + assert_snapshot!(test.goto_type_definition(), @"No type definitions found"); + } + #[test] fn goto_type_on_keyword_argument() { let test = cursor_test( diff --git a/crates/ty_ide/src/hover.rs b/crates/ty_ide/src/hover.rs index 2f96f7b061..3b4b463ee2 100644 --- a/crates/ty_ide/src/hover.rs +++ b/crates/ty_ide/src/hover.rs @@ -1759,6 +1759,398 @@ def function(): assert_snapshot!(test.hover(), @"Hover provided no content"); } + #[test] + fn hover_match_name_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ab]: + x = ab + "#, + ); + + assert_snapshot!(test.hover(), @"Hover provided no content"); + } + + #[test] + fn hover_match_name_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ab]: + x = ab + "#, + ); + + assert_snapshot!(test.hover(), @r#" + @Todo + --------------------------------------------- + ```python + @Todo + ``` + --------------------------------------------- + info[hover]: Hovered content is + --> main.py:5:17 + | + 3 | match command.split(): + 4 | case ["get", ab]: + 5 | x = ab + | ^- + | || + | |Cursor offset + | source + | + "#); + } + + #[test] + fn hover_match_rest_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", *ab]: + x = ab + "#, + ); + + assert_snapshot!(test.hover(), @"Hover provided no content"); + } + + #[test] + fn hover_match_rest_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", *ab]: + x = ab + "#, + ); + + assert_snapshot!(test.hover(), @r#" + @Todo + --------------------------------------------- + ```python + @Todo + ``` + --------------------------------------------- + info[hover]: Hovered content is + --> main.py:5:17 + | + 3 | match command.split(): + 4 | case ["get", *ab]: + 5 | x = ab + | ^- + | || + | |Cursor offset + | source + | + "#); + } + + #[test] + fn hover_match_as_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ("a" | "b") as ab]: + x = ab + "#, + ); + + assert_snapshot!(test.hover(), @"Hover provided no content"); + } + + #[test] + fn hover_match_as_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ("a" | "b") as ab]: + x = ab + "#, + ); + + assert_snapshot!(test.hover(), @r#" + @Todo + --------------------------------------------- + ```python + @Todo + ``` + --------------------------------------------- + info[hover]: Hovered content is + --> main.py:5:17 + | + 3 | match command.split(): + 4 | case ["get", ("a" | "b") as ab]: + 5 | x = ab + | ^- + | || + | |Cursor offset + | source + | + "#); + } + + #[test] + fn hover_match_keyword_stmt() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.hover(), @"Hover provided no content"); + } + + #[test] + fn hover_match_keyword_binding() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.hover(), @r" + @Todo + --------------------------------------------- + ```python + @Todo + ``` + --------------------------------------------- + info[hover]: Hovered content is + --> main.py:11:17 + | + 9 | match event: + 10 | case Click(x, button=ab): + 11 | x = ab + | ^- + | || + | |Cursor offset + | source + | + "); + } + + #[test] + fn hover_match_class_name() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.hover(), @r" + + --------------------------------------------- + ```python + + ``` + --------------------------------------------- + info[hover]: Hovered content is + --> main.py:10:14 + | + 8 | def my_func(event: Click): + 9 | match event: + 10 | case Click(x, button=ab): + | ^^-^^ + | | | + | | Cursor offset + | source + 11 | x = ab + | + "); + } + + #[test] + fn hover_match_class_field_name() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.hover(), @"Hover provided no content"); + } + + #[test] + fn hover_typevar_name_stmt() { + let test = cursor_test( + r#" + type Alias1[AB: int = bool] = tuple[AB, list[AB]] + "#, + ); + + assert_snapshot!(test.hover(), @r" + AB@Alias1 (invariant) + --------------------------------------------- + ```python + AB@Alias1 (invariant) + ``` + --------------------------------------------- + info[hover]: Hovered content is + --> main.py:2:13 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^- + | || + | |Cursor offset + | source + | + "); + } + + #[test] + fn hover_typevar_name_binding() { + let test = cursor_test( + r#" + type Alias1[AB: int = bool] = tuple[AB, list[AB]] + "#, + ); + + assert_snapshot!(test.hover(), @r" + AB@Alias1 (invariant) + --------------------------------------------- + ```python + AB@Alias1 (invariant) + ``` + --------------------------------------------- + info[hover]: Hovered content is + --> main.py:2:37 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^- + | || + | |Cursor offset + | source + | + "); + } + + #[test] + fn hover_typevar_spec_stmt() { + let test = cursor_test( + r#" + from typing import Callable + type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + "#, + ); + + assert_snapshot!(test.hover(), @"Hover provided no content"); + } + + #[test] + fn hover_typevar_spec_binding() { + let test = cursor_test( + r#" + from typing import Callable + type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + "#, + ); + + assert_snapshot!(test.hover(), @r" + ( + ... + ) -> tuple[typing.ParamSpec] + --------------------------------------------- + ```python + ( + ... + ) -> tuple[typing.ParamSpec] + ``` + --------------------------------------------- + info[hover]: Hovered content is + --> main.py:3:43 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^- + | || + | |Cursor offset + | source + | + "); + } + + #[test] + fn hover_typevar_tuple_stmt() { + let test = cursor_test( + r#" + type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + "#, + ); + + assert_snapshot!(test.hover(), @"Hover provided no content"); + } + + #[test] + fn hover_typevar_tuple_binding() { + let test = cursor_test( + r#" + type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + "#, + ); + + assert_snapshot!(test.hover(), @r" + @Todo + --------------------------------------------- + ```python + @Todo + ``` + --------------------------------------------- + info[hover]: Hovered content is + --> main.py:2:38 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^- + | || + | |Cursor offset + | source + | + "); + } + #[test] fn hover_module_import() { let mut test = cursor_test( diff --git a/crates/ty_ide/src/inlay_hints.rs b/crates/ty_ide/src/inlay_hints.rs index a661ff1b9c..fea9b2030f 100644 --- a/crates/ty_ide/src/inlay_hints.rs +++ b/crates/ty_ide/src/inlay_hints.rs @@ -1946,6 +1946,131 @@ mod tests { "#); } + #[test] + fn test_match_name_binding() { + let mut test = inlay_hint_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ab]: + x = ab + "#, + ); + + assert_snapshot!(test.inlay_hints(), @r#" + def my_func(command: str): + match command.split(): + case ["get", ab]: + x[: @Todo] = ab + "#); + } + + #[test] + fn test_match_rest_binding() { + let mut test = inlay_hint_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", *ab]: + x = ab + "#, + ); + + assert_snapshot!(test.inlay_hints(), @r#" + def my_func(command: str): + match command.split(): + case ["get", *ab]: + x[: @Todo] = ab + "#); + } + + #[test] + fn test_match_as_binding() { + let mut test = inlay_hint_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ("a" | "b") as ab]: + x = ab + "#, + ); + + assert_snapshot!(test.inlay_hints(), @r#" + def my_func(command: str): + match command.split(): + case ["get", ("a" | "b") as ab]: + x[: @Todo] = ab + "#); + } + + #[test] + fn test_match_keyword_binding() { + let mut test = inlay_hint_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.inlay_hints(), @r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x[: @Todo] = ab + "#); + } + + #[test] + fn test_typevar_name_binding() { + let mut test = inlay_hint_test( + r#" + type Alias1[AB: int = bool] = tuple[AB, list[AB]] + "#, + ); + + assert_snapshot!(test.inlay_hints(), @"type Alias1[AB: int = bool] = tuple[AB, list[AB]]"); + } + + #[test] + fn test_typevar_spec_binding() { + let mut test = inlay_hint_test( + r#" + from typing import Callable + type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + "#, + ); + + assert_snapshot!(test.inlay_hints(), @r" + from typing import Callable + type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + "); + } + + #[test] + fn test_typevar_tuple_binding() { + let mut test = inlay_hint_test( + r#" + type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + "#, + ); + + assert_snapshot!(test.inlay_hints(), @"type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]]"); + } + #[test] fn test_many_literals() { let mut test = inlay_hint_test( diff --git a/crates/ty_ide/src/references.rs b/crates/ty_ide/src/references.rs index 8e29279fa5..79d111155a 100644 --- a/crates/ty_ide/src/references.rs +++ b/crates/ty_ide/src/references.rs @@ -219,6 +219,11 @@ impl<'a> SourceOrderVisitor<'a> for LocalReferencesFinder<'a> { self.check_identifier_reference(name); } } + AnyNodeRef::PatternMatchStar(pattern_star) if self.should_include_declaration() => { + if let Some(name) = &pattern_star.name { + self.check_identifier_reference(name); + } + } AnyNodeRef::PatternMatchMapping(pattern_mapping) if self.should_include_declaration() => { @@ -226,6 +231,15 @@ impl<'a> SourceOrderVisitor<'a> for LocalReferencesFinder<'a> { self.check_identifier_reference(rest_name); } } + AnyNodeRef::TypeParamParamSpec(param_spec) if self.should_include_declaration() => { + self.check_identifier_reference(¶m_spec.name); + } + AnyNodeRef::TypeParamTypeVarTuple(param_tuple) if self.should_include_declaration() => { + self.check_identifier_reference(¶m_tuple.name); + } + AnyNodeRef::TypeParamTypeVar(param_var) if self.should_include_declaration() => { + self.check_identifier_reference(¶m_var.name); + } AnyNodeRef::ExprStringLiteral(string_expr) if self.should_include_declaration() => { // Highlight the sub-AST of a string annotation if let Some((sub_ast, sub_model)) = self.model.enter_string_annotation(string_expr) diff --git a/crates/ty_ide/src/rename.rs b/crates/ty_ide/src/rename.rs index 463255f500..156f38fee4 100644 --- a/crates/ty_ide/src/rename.rs +++ b/crates/ty_ide/src/rename.rs @@ -495,6 +495,390 @@ class DataProcessor: assert_snapshot!(test.rename("MyNewClass"), @"Cannot rename"); } + #[test] + fn rename_match_name_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ab]: + x = ab + "#, + ); + + assert_snapshot!(test.rename("XY"), @r#" + info[rename]: Rename symbol (found 2 locations) + --> main.py:4:22 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ab]: + | ^^ + 5 | x = ab + | -- + | + "#); + } + + #[test] + fn rename_match_name_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ab]: + x = ab + "#, + ); + + assert_snapshot!(test.rename("XY"), @r#" + info[rename]: Rename symbol (found 2 locations) + --> main.py:4:22 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ab]: + | ^^ + 5 | x = ab + | -- + | + "#); + } + + #[test] + fn rename_match_rest_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", *ab]: + x = ab + "#, + ); + + assert_snapshot!(test.rename("XY"), @r#" + info[rename]: Rename symbol (found 2 locations) + --> main.py:4:23 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", *ab]: + | ^^ + 5 | x = ab + | -- + | + "#); + } + + #[test] + fn rename_match_rest_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", *ab]: + x = ab + "#, + ); + + assert_snapshot!(test.rename("XY"), @r#" + info[rename]: Rename symbol (found 2 locations) + --> main.py:4:23 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", *ab]: + | ^^ + 5 | x = ab + | -- + | + "#); + } + + #[test] + fn rename_match_as_stmt() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ("a" | "b") as ab]: + x = ab + "#, + ); + + assert_snapshot!(test.rename("XY"), @r#" + info[rename]: Rename symbol (found 2 locations) + --> main.py:4:37 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ("a" | "b") as ab]: + | ^^ + 5 | x = ab + | -- + | + "#); + } + + #[test] + fn rename_match_as_binding() { + let test = cursor_test( + r#" + def my_func(command: str): + match command.split(): + case ["get", ("a" | "b") as ab]: + x = ab + "#, + ); + + assert_snapshot!(test.rename("XY"), @r#" + info[rename]: Rename symbol (found 2 locations) + --> main.py:4:37 + | + 2 | def my_func(command: str): + 3 | match command.split(): + 4 | case ["get", ("a" | "b") as ab]: + | ^^ + 5 | x = ab + | -- + | + "#); + } + + #[test] + fn rename_match_keyword_stmt() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.rename("XY"), @r" + info[rename]: Rename symbol (found 2 locations) + --> main.py:10:30 + | + 8 | def my_func(event: Click): + 9 | match event: + 10 | case Click(x, button=ab): + | ^^ + 11 | x = ab + | -- + | + "); + } + + #[test] + fn rename_match_keyword_binding() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.rename("XY"), @r" + info[rename]: Rename symbol (found 2 locations) + --> main.py:10:30 + | + 8 | def my_func(event: Click): + 9 | match event: + 10 | case Click(x, button=ab): + | ^^ + 11 | x = ab + | -- + | + "); + } + + #[test] + fn rename_match_class_name() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.rename("XY"), @r#" + info[rename]: Rename symbol (found 3 locations) + --> main.py:2:7 + | + 2 | class Click: + | ^^^^^ + 3 | __match_args__ = ("position", "button") + 4 | def __init__(self, pos, btn): + | + ::: main.py:8:20 + | + 6 | self.button: str = btn + 7 | + 8 | def my_func(event: Click): + | ----- + 9 | match event: + 10 | case Click(x, button=ab): + | ----- + 11 | x = ab + | + "#); + } + + #[test] + fn rename_match_class_field_name() { + let test = cursor_test( + r#" + class Click: + __match_args__ = ("position", "button") + def __init__(self, pos, btn): + self.position: int = pos + self.button: str = btn + + def my_func(event: Click): + match event: + case Click(x, button=ab): + x = ab + "#, + ); + + assert_snapshot!(test.rename("XY"), @"Cannot rename"); + } + + #[test] + fn rename_typevar_name_stmt() { + let test = cursor_test( + r#" + type Alias1[AB: int = bool] = tuple[AB, list[AB]] + "#, + ); + + assert_snapshot!(test.rename("XY"), @r" + info[rename]: Rename symbol (found 3 locations) + --> main.py:2:13 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ -- -- + | + "); + } + + #[test] + fn rename_typevar_name_binding() { + let test = cursor_test( + r#" + type Alias1[AB: int = bool] = tuple[AB, list[AB]] + "#, + ); + + assert_snapshot!(test.rename("XY"), @r" + info[rename]: Rename symbol (found 3 locations) + --> main.py:2:13 + | + 2 | type Alias1[AB: int = bool] = tuple[AB, list[AB]] + | ^^ -- -- + | + "); + } + + #[test] + fn rename_typevar_spec_stmt() { + let test = cursor_test( + r#" + from typing import Callable + type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + "#, + ); + + assert_snapshot!(test.rename("XY"), @r" + info[rename]: Rename symbol (found 3 locations) + --> main.py:3:15 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^^ -- -- + | + "); + } + + #[test] + fn rename_typevar_spec_binding() { + let test = cursor_test( + r#" + from typing import Callable + type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + "#, + ); + + assert_snapshot!(test.rename("XY"), @r" + info[rename]: Rename symbol (found 3 locations) + --> main.py:3:15 + | + 2 | from typing import Callable + 3 | type Alias2[**AB = [int, str]] = Callable[AB, tuple[AB]] + | ^^ -- -- + | + "); + } + + #[test] + fn rename_typevar_tuple_stmt() { + let test = cursor_test( + r#" + type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + "#, + ); + + assert_snapshot!(test.rename("XY"), @r" + info[rename]: Rename symbol (found 3 locations) + --> main.py:2:14 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^^ -- -- + | + "); + } + + #[test] + fn rename_typevar_tuple_binding() { + let test = cursor_test( + r#" + type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + "#, + ); + + assert_snapshot!(test.rename("XY"), @r" + info[rename]: Rename symbol (found 3 locations) + --> main.py:2:14 + | + 2 | type Alias3[*AB = ()] = tuple[tuple[*AB], tuple[*AB]] + | ^^ -- -- + | + "); + } + #[test] fn test_cannot_rename_import_module_component() { // Test that we cannot rename parts of module names in import statements diff --git a/crates/ty_ide/src/semantic_tokens.rs b/crates/ty_ide/src/semantic_tokens.rs index 5c793d62dc..88e48d1470 100644 --- a/crates/ty_ide/src/semantic_tokens.rs +++ b/crates/ty_ide/src/semantic_tokens.rs @@ -1060,6 +1060,16 @@ impl SourceOrderVisitor<'_> for SemanticTokenVisitor<'_> { ); } } + ast::Pattern::MatchStar(pattern_star) => { + // Just the one ident here + if let Some(rest_name) = &pattern_star.name { + self.add_token( + rest_name.range(), + SemanticTokenType::Variable, + SemanticTokenModifier::empty(), + ); + } + } _ => { // For all other pattern types, use the default walker ruff_python_ast::visitor::source_order::walk_pattern(self, pattern); @@ -2485,6 +2495,7 @@ def process_data(data): "rest" @ 154..158: Variable "person" @ 181..187: Variable "first" @ 202..207: Variable + "remaining" @ 210..219: Variable "sequence" @ 224..232: Variable "print" @ 246..251: Function "First: " @ 254..261: String diff --git a/crates/ty_ide/src/signature_help.rs b/crates/ty_ide/src/signature_help.rs index 1e5199bc0e..1f7041eaab 100644 --- a/crates/ty_ide/src/signature_help.rs +++ b/crates/ty_ide/src/signature_help.rs @@ -7,7 +7,7 @@ //! and overloads. use crate::docstring::Docstring; -use crate::goto::DefinitionsOrTargets; +use crate::goto::Definitions; use crate::{Db, find_node::covering_node}; use ruff_db::files::File; use ruff_db::parsed::parsed_module; @@ -214,8 +214,7 @@ fn get_callable_documentation( db: &dyn crate::Db, definition: Option, ) -> Option { - DefinitionsOrTargets::Definitions(vec![ResolvedDefinition::Definition(definition?)]) - .docstring(db) + Definitions(vec![ResolvedDefinition::Definition(definition?)]).docstring(db) } /// Create `ParameterDetails` objects from parameter label offsets. diff --git a/crates/ty_python_semantic/src/semantic_index/builder.rs b/crates/ty_python_semantic/src/semantic_index/builder.rs index d285a035fc..f7b6da1a0f 100644 --- a/crates/ty_python_semantic/src/semantic_index/builder.rs +++ b/crates/ty_python_semantic/src/semantic_index/builder.rs @@ -1064,6 +1064,8 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> { .. }) => (name, &None, default), }; + self.scopes_by_expression + .record_expression(name, self.current_scope()); let symbol = self.add_symbol(name.id.clone()); // TODO create Definition for PEP 695 typevars // note that the "bound" on the typevar is a totally different thing than whether From 8bcfc198b83051db0c8a3c7b8f0c8a8c339947c7 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 28 Nov 2025 15:18:02 +0000 Subject: [PATCH 18/67] [ty] Implement `typing.final` for methods (#21646) Co-authored-by: Micha Reiser --- crates/ty/docs/rules.md | 177 +++--- .../resources/mdtest/final.md | 455 +++++++++++++- ..._possibly-undefined…_(fc7b496fd1986deb).snap | 320 ++++++++++ ...annot_override_a_me…_(338615109711a91b).snap | 545 +++++++++++++++++ ...iagnostic_edge_case…_(2389d52c5ecfa2bd).snap | 59 ++ ...nly_the_first_`@fin…_(9863b583f4c651c5).snap | 101 ++++ ...verloaded_methods_d…_(861757f48340ed92).snap | 565 ++++++++++++++++++ crates/ty_python_semantic/src/types/class.rs | 5 + .../src/types/diagnostic.rs | 151 ++++- .../ty_python_semantic/src/types/function.rs | 103 +++- .../src/types/infer/builder.rs | 4 +- crates/ty_python_semantic/src/types/liskov.rs | 270 +++++++-- .../e2e__commands__debug_command.snap | 1 + ty.schema.json | 10 + 14 files changed, 2607 insertions(+), 159 deletions(-) create mode 100644 crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_A_possibly-undefined…_(fc7b496fd1986deb).snap create mode 100644 crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Cannot_override_a_me…_(338615109711a91b).snap create mode 100644 crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Diagnostic_edge_case…_(2389d52c5ecfa2bd).snap create mode 100644 crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Only_the_first_`@fin…_(9863b583f4c651c5).snap create mode 100644 crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Overloaded_methods_d…_(861757f48340ed92).snap diff --git a/crates/ty/docs/rules.md b/crates/ty/docs/rules.md index 16c4c225dc..6923aeef6f 100644 --- a/crates/ty/docs/rules.md +++ b/crates/ty/docs/rules.md @@ -39,7 +39,7 @@ def test(): -> "int": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -63,7 +63,7 @@ Calling a non-callable object will raise a `TypeError` at runtime. Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -95,7 +95,7 @@ f(int) # error Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -126,7 +126,7 @@ a = 1 Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -158,7 +158,7 @@ class C(A, B): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -190,7 +190,7 @@ class B(A): ... Default level: error · Preview (since 1.0.0) · Related issues · -View source +View source @@ -218,7 +218,7 @@ type B = A Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -245,7 +245,7 @@ class B(A, A): ... Default level: error · Added in 0.0.1-alpha.12 · Related issues · -View source +View source @@ -357,7 +357,7 @@ def test(): -> "Literal[5]": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -387,7 +387,7 @@ class C(A, B): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -413,7 +413,7 @@ t[3] # IndexError: tuple index out of range Default level: error · Added in 0.0.1-alpha.12 · Related issues · -View source +View source @@ -502,7 +502,7 @@ an atypical memory layout. Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -529,7 +529,7 @@ func("foo") # error: [invalid-argument-type] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -557,7 +557,7 @@ a: int = '' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -591,7 +591,7 @@ C.instance_var = 3 # error: Cannot assign to instance variable Default level: error · Added in 0.0.1-alpha.19 · Related issues · -View source +View source @@ -627,7 +627,7 @@ asyncio.run(main()) Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -651,7 +651,7 @@ class A(42): ... # error: [invalid-base] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -678,7 +678,7 @@ with 1: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -707,7 +707,7 @@ a: str Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -751,7 +751,7 @@ except ZeroDivisionError: Default level: error · Added in 0.0.1-alpha.28 · Related issues · -View source +View source @@ -793,7 +793,7 @@ class D(A): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -826,7 +826,7 @@ class C[U](Generic[T]): ... Default level: error · Added in 0.0.1-alpha.17 · Related issues · -View source +View source @@ -865,7 +865,7 @@ carol = Person(name="Carol", age=25) # typo! Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -900,7 +900,7 @@ def f(t: TypeVar("U")): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -934,7 +934,7 @@ class B(metaclass=f): ... Default level: error · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -1041,7 +1041,7 @@ Correct use of `@override` is enforced by ty's `invalid-explicit-override` rule. Default level: error · Added in 0.0.1-alpha.19 · Related issues · -View source +View source @@ -1073,7 +1073,7 @@ TypeError: can only inherit from a NamedTuple type and Generic Default level: error · Preview (since 1.0.0) · Related issues · -View source +View source @@ -1103,7 +1103,7 @@ Baz = NewType("Baz", int | str) # error: invalid base for `typing.NewType` Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1153,7 +1153,7 @@ def foo(x: int) -> int: ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1179,7 +1179,7 @@ def f(a: int = ''): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1210,7 +1210,7 @@ P2 = ParamSpec("S2") # error: ParamSpec name must match the variable it's assig Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1244,7 +1244,7 @@ TypeError: Protocols can only inherit from other protocols, got Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1293,7 +1293,7 @@ def g(): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1318,7 +1318,7 @@ def func() -> int: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1376,7 +1376,7 @@ TODO #14889 Default level: error · Added in 0.0.1-alpha.6 · Related issues · -View source +View source @@ -1403,7 +1403,7 @@ NewAlias = TypeAliasType(get_name(), int) # error: TypeAliasType name mus Default level: error · Added in 0.0.1-alpha.29 · Related issues · -View source +View source @@ -1450,7 +1450,7 @@ Bar[int] # error: too few arguments Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1480,7 +1480,7 @@ TYPE_CHECKING = '' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1510,7 +1510,7 @@ b: Annotated[int] # `Annotated` expects at least two arguments Default level: error · Added in 0.0.1-alpha.11 · Related issues · -View source +View source @@ -1544,7 +1544,7 @@ f(10) # Error Default level: error · Added in 0.0.1-alpha.11 · Related issues · -View source +View source @@ -1578,7 +1578,7 @@ class C: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1613,7 +1613,7 @@ T = TypeVar('T', bound=str) # valid bound TypeVar Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1638,7 +1638,7 @@ func() # TypeError: func() missing 1 required positional argument: 'x' Default level: error · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -1671,7 +1671,7 @@ alice["age"] # KeyError Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1700,7 +1700,7 @@ func("string") # error: [no-matching-overload] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1724,7 +1724,7 @@ Subscripting an object that does not support it will raise a `TypeError` at runt Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1744,13 +1744,46 @@ for i in 34: # TypeError: 'int' object is not iterable pass ``` +## `override-of-final-method` + + +Default level: error · +Added in 0.0.1-alpha.29 · +Related issues · +View source + + + +**What it does** + +Checks for methods on subclasses that override superclass methods decorated with `@final`. + +**Why is this bad?** + +Decorating a method with `@final` declares to the type checker that it should not be +overridden on any subclass. + +**Example** + + +```python +from typing import final + +class A: + @final + def foo(self): ... + +class B(A): + def foo(self): ... # Error raised here +``` + ## `parameter-already-assigned` Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1777,7 +1810,7 @@ f(1, x=2) # Error raised here Default level: error · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -1835,7 +1868,7 @@ def test(): -> "int": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1865,7 +1898,7 @@ static_assert(int(2.0 * 3.0) == 6) # error: does not have a statically known tr Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1894,7 +1927,7 @@ class B(A): ... # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1921,7 +1954,7 @@ f("foo") # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1949,7 +1982,7 @@ def _(x: int): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1995,7 +2028,7 @@ class A: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2022,7 +2055,7 @@ f(x=1, y=2) # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2050,7 +2083,7 @@ A().foo # AttributeError: 'A' object has no attribute 'foo' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2075,7 +2108,7 @@ import foo # ModuleNotFoundError: No module named 'foo' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2100,7 +2133,7 @@ print(x) # NameError: name 'x' is not defined Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2137,7 +2170,7 @@ b1 < b2 < b1 # exception raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2165,7 +2198,7 @@ A() + A() # TypeError: unsupported operand type(s) for +: 'A' and 'A' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2190,7 +2223,7 @@ l[1:10:0] # ValueError: slice step cannot be zero Default level: warn · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -2231,7 +2264,7 @@ class SubProto(BaseProto, Protocol): Default level: warn · Added in 0.0.1-alpha.16 · Related issues · -View source +View source @@ -2319,7 +2352,7 @@ a = 20 / 0 # type: ignore Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2347,7 +2380,7 @@ A.c # AttributeError: type object 'A' has no attribute 'c' Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2379,7 +2412,7 @@ A()[0] # TypeError: 'A' object is not subscriptable Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2411,7 +2444,7 @@ from module import a # ImportError: cannot import name 'a' from 'module' Default level: warn · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2438,7 +2471,7 @@ cast(int, f()) # Redundant Default level: warn · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2462,7 +2495,7 @@ reveal_type(1) # NameError: name 'reveal_type' is not defined Default level: warn · Added in 0.0.1-alpha.15 · Related issues · -View source +View source @@ -2520,7 +2553,7 @@ def g(): Default level: warn · Added in 0.0.1-alpha.7 · Related issues · -View source +View source @@ -2559,7 +2592,7 @@ class D(C): ... # error: [unsupported-base] Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2622,7 +2655,7 @@ def foo(x: int | str) -> int | str: Default level: ignore · Preview (since 0.0.1-alpha.1) · Related issues · -View source +View source @@ -2646,7 +2679,7 @@ Dividing by zero raises a `ZeroDivisionError` at runtime. Default level: ignore · Added in 0.0.1-alpha.1 · Related issues · -View source +View source diff --git a/crates/ty_python_semantic/resources/mdtest/final.md b/crates/ty_python_semantic/resources/mdtest/final.md index e37cf41c8c..1ccb647e4d 100644 --- a/crates/ty_python_semantic/resources/mdtest/final.md +++ b/crates/ty_python_semantic/resources/mdtest/final.md @@ -1,6 +1,6 @@ # Tests for the `@typing(_extensions).final` decorator -## Cannot subclass +## Cannot subclass a class decorated with `@final` Don't do this: @@ -29,3 +29,456 @@ class H( G, ): ... ``` + +## Cannot override a method decorated with `@final` + + + +```pyi +from typing_extensions import final, Callable, TypeVar + +def lossy_decorator(fn: Callable) -> Callable: ... + +class Parent: + @final + def foo(self): ... + + @final + @property + def my_property1(self) -> int: ... + + @property + @final + def my_property2(self) -> int: ... + + @final + @classmethod + def class_method1(cls) -> int: ... + + @classmethod + @final + def class_method2(cls) -> int: ... + + @final + @staticmethod + def static_method1() -> int: ... + + @staticmethod + @final + def static_method2() -> int: ... + + @lossy_decorator + @final + def decorated_1(self): ... + + @final + @lossy_decorator + def decorated_2(self): ... + +class Child(Parent): + # explicitly test the concise diagnostic message, + # which is different to the verbose diagnostic summary message: + # + # error: [override-of-final-method] "Cannot override final member `foo` from superclass `Parent`" + def foo(self): ... + @property + def my_property1(self) -> int: ... # error: [override-of-final-method] + + @property + def my_property2(self) -> int: ... # error: [override-of-final-method] + + @classmethod + def class_method1(cls) -> int: ... # error: [override-of-final-method] + + @staticmethod + def static_method1() -> int: ... # error: [override-of-final-method] + + @classmethod + def class_method2(cls) -> int: ... # error: [override-of-final-method] + + @staticmethod + def static_method2() -> int: ... # error: [override-of-final-method] + + def decorated_1(self): ... # TODO: should emit [override-of-final-method] + + @lossy_decorator + def decorated_2(self): ... # TODO: should emit [override-of-final-method] + +class OtherChild(Parent): ... + +class Grandchild(OtherChild): + @staticmethod + # TODO: we should emit a Liskov violation here too + # error: [override-of-final-method] + def foo(): ... + @property + # TODO: we should emit a Liskov violation here too + # error: [override-of-final-method] + def my_property1(self) -> str: ... + # TODO: we should emit a Liskov violation here too + # error: [override-of-final-method] + class_method1 = None + +# Diagnostic edge case: `final` is very far away from the method definition in the source code: + +T = TypeVar("T") + +def identity(x: T) -> T: ... + +class Foo: + @final + @identity + @identity + @identity + @identity + @identity + @identity + @identity + @identity + @identity + @identity + @identity + @identity + @identity + @identity + @identity + @identity + @identity + @identity + def bar(self): ... + +class Baz(Foo): + def bar(self): ... # error: [override-of-final-method] +``` + +## Diagnostic edge case: superclass with `@final` method has the same name as the subclass + + + +`module1.py`: + +```py +from typing import final + +class Foo: + @final + def f(self): ... +``` + +`module2.py`: + +```py +import module1 + +class Foo(module1.Foo): + def f(self): ... # error: [override-of-final-method] +``` + +## Overloaded methods decorated with `@final` + +In a stub file, `@final` should be applied to the first overload. In a runtime file, `@final` should +only be applied to the implementation function. + + + +`stub.pyi`: + +```pyi +from typing import final, overload + +class Good: + @overload + @final + def bar(self, x: str) -> str: ... + @overload + def bar(self, x: int) -> int: ... + + @final + @overload + def baz(self, x: str) -> str: ... + @overload + def baz(self, x: int) -> int: ... + +class ChildOfGood(Good): + @overload + def bar(self, x: str) -> str: ... + @overload + def bar(self, x: int) -> int: ... # error: [override-of-final-method] + + @overload + def baz(self, x: str) -> str: ... + @overload + def baz(self, x: int) -> int: ... # error: [override-of-final-method] + +class Bad: + @overload + def bar(self, x: str) -> str: ... + @overload + @final + # error: [invalid-overload] + def bar(self, x: int) -> int: ... + + @overload + def baz(self, x: str) -> str: ... + @final + @overload + # error: [invalid-overload] + def baz(self, x: int) -> int: ... + +class ChildOfBad(Bad): + @overload + def bar(self, x: str) -> str: ... + @overload + def bar(self, x: int) -> int: ... # error: [override-of-final-method] + + @overload + def baz(self, x: str) -> str: ... + @overload + def baz(self, x: int) -> int: ... # error: [override-of-final-method] +``` + +`main.py`: + +```py +from typing import overload, final + +class Good: + @overload + def f(self, x: str) -> str: ... + @overload + def f(self, x: int) -> int: ... + @final + def f(self, x: int | str) -> int | str: + return x + +class ChildOfGood(Good): + @overload + def f(self, x: str) -> str: ... + @overload + def f(self, x: int) -> int: ... + # error: [override-of-final-method] + def f(self, x: int | str) -> int | str: + return x + +class Bad: + @overload + @final + def f(self, x: str) -> str: ... + @overload + def f(self, x: int) -> int: ... + # error: [invalid-overload] + def f(self, x: int | str) -> int | str: + return x + + @final + @overload + def g(self, x: str) -> str: ... + @overload + def g(self, x: int) -> int: ... + # error: [invalid-overload] + def g(self, x: int | str) -> int | str: + return x + + @overload + def h(self, x: str) -> str: ... + @overload + @final + def h(self, x: int) -> int: ... + # error: [invalid-overload] + def h(self, x: int | str) -> int | str: + return x + + @overload + def i(self, x: str) -> str: ... + @final + @overload + def i(self, x: int) -> int: ... + # error: [invalid-overload] + def i(self, x: int | str) -> int | str: + return x + +class ChildOfBad(Bad): + # TODO: these should all cause us to emit Liskov violations as well + f = None # error: [override-of-final-method] + g = None # error: [override-of-final-method] + h = None # error: [override-of-final-method] + i = None # error: [override-of-final-method] +``` + +## Edge case: the function is decorated with `@final` but originally defined elsewhere + +As of 2025-11-26, pyrefly emits a diagnostic on this, but mypy and pyright do not. For mypy and +pyright to emit a diagnostic, the superclass definition decorated with `@final` must be a literal +function definition: an assignment definition where the right-hand side of the assignment is a +`@final-decorated` function is not sufficient for them to consider the superclass definition as +being `@final`. + +For now, we choose to follow mypy's and pyright's behaviour here, in order to maximise compatibility +with other type checkers. We may decide to change this in the future, however, as it would simplify +our implementation. Mypy's and pyright's behaviour here is also arguably inconsistent with their +treatment of other type qualifiers such as `Final`. As discussed in +, both type checkers view the `Final` +type qualifier as travelling *across* scopes. + +```py +from typing import final + +class A: + @final + def method(self) -> None: ... + +class B: + method = A.method + +class C(B): + def method(self) -> None: ... # no diagnostic here (see prose discussion above) +``` + +## Constructor methods are also checked + +```py +from typing import final + +class A: + @final + def __init__(self) -> None: ... + +class B(A): + def __init__(self) -> None: ... # error: [override-of-final-method] +``` + +## Only the first `@final` violation is reported + +(Don't do this.) + + + +```py +from typing import final + +class A: + @final + def f(self): ... + +class B(A): + @final + def f(self): ... # error: [override-of-final-method] + +class C(B): + @final + # we only emit one error here, not two + def f(self): ... # error: [override-of-final-method] +``` + +## For when you just really want to drive the point home + +```py +from typing import final, Final + +@final +@final +@final +@final +@final +@final +class A: + @final + @final + @final + @final + @final + def method(self): ... + +@final +@final +@final +@final +@final +class B: + method: Final = A.method + +class C(A): # error: [subclass-of-final-class] + def method(self): ... # error: [override-of-final-method] + +class D(B): # error: [subclass-of-final-class] + # TODO: we should emit a diagnostic here + def method(self): ... +``` + +## An `@final` method is overridden by an implicit instance attribute + +```py +from typing import final, Any + +class Parent: + @final + def method(self) -> None: ... + +class Child(Parent): + def __init__(self) -> None: + self.method: Any = 42 # TODO: we should emit `[override-of-final-method]` here +``` + +## A possibly-undefined `@final` method is overridden + + + +```py +from typing import final + +def coinflip() -> bool: + return False + +class A: + if coinflip(): + @final + def method1(self) -> None: ... + else: + def method1(self) -> None: ... + + if coinflip(): + def method2(self) -> None: ... + else: + @final + def method2(self) -> None: ... + + if coinflip(): + @final + def method3(self) -> None: ... + else: + @final + def method3(self) -> None: ... + + if coinflip(): + def method4(self) -> None: ... + elif coinflip(): + @final + def method4(self) -> None: ... + else: + def method4(self) -> None: ... + +class B(A): + def method1(self) -> None: ... # error: [override-of-final-method] + def method2(self) -> None: ... # error: [override-of-final-method] + def method3(self) -> None: ... # error: [override-of-final-method] + def method4(self) -> None: ... # error: [override-of-final-method] + +# Possible overrides of possibly `@final` methods... +class C(A): + if coinflip(): + # TODO: the autofix here introduces invalid syntax because there are now no + # statements inside the `if:` branch + # (but it might still be a useful autofix in an IDE context?) + def method1(self) -> None: ... # error: [override-of-final-method] + else: + pass + + if coinflip(): + def method2(self) -> None: ... # TODO: should emit [override-of-final-method] + else: + def method2(self) -> None: ... # TODO: should emit [override-of-final-method] + + if coinflip(): + def method3(self) -> None: ... # error: [override-of-final-method] + def method4(self) -> None: ... # error: [override-of-final-method] +``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_A_possibly-undefined…_(fc7b496fd1986deb).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_A_possibly-undefined…_(fc7b496fd1986deb).snap new file mode 100644 index 0000000000..41b39fef34 --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_A_possibly-undefined…_(fc7b496fd1986deb).snap @@ -0,0 +1,320 @@ +--- +source: crates/ty_test/src/lib.rs +expression: snapshot +--- +--- +mdtest name: final.md - Tests for the `@typing(_extensions).final` decorator - A possibly-undefined `@final` method is overridden +mdtest path: crates/ty_python_semantic/resources/mdtest/final.md +--- + +# Python source files + +## mdtest_snippet.py + +``` + 1 | from typing import final + 2 | + 3 | def coinflip() -> bool: + 4 | return False + 5 | + 6 | class A: + 7 | if coinflip(): + 8 | @final + 9 | def method1(self) -> None: ... +10 | else: +11 | def method1(self) -> None: ... +12 | +13 | if coinflip(): +14 | def method2(self) -> None: ... +15 | else: +16 | @final +17 | def method2(self) -> None: ... +18 | +19 | if coinflip(): +20 | @final +21 | def method3(self) -> None: ... +22 | else: +23 | @final +24 | def method3(self) -> None: ... +25 | +26 | if coinflip(): +27 | def method4(self) -> None: ... +28 | elif coinflip(): +29 | @final +30 | def method4(self) -> None: ... +31 | else: +32 | def method4(self) -> None: ... +33 | +34 | class B(A): +35 | def method1(self) -> None: ... # error: [override-of-final-method] +36 | def method2(self) -> None: ... # error: [override-of-final-method] +37 | def method3(self) -> None: ... # error: [override-of-final-method] +38 | def method4(self) -> None: ... # error: [override-of-final-method] +39 | +40 | # Possible overrides of possibly `@final` methods... +41 | class C(A): +42 | if coinflip(): +43 | # TODO: the autofix here introduces invalid syntax because there are now no +44 | # statements inside the `if:` branch +45 | # (but it might still be a useful autofix in an IDE context?) +46 | def method1(self) -> None: ... # error: [override-of-final-method] +47 | else: +48 | pass +49 | +50 | if coinflip(): +51 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method] +52 | else: +53 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method] +54 | +55 | if coinflip(): +56 | def method3(self) -> None: ... # error: [override-of-final-method] +57 | def method4(self) -> None: ... # error: [override-of-final-method] +``` + +# Diagnostics + +``` +error[override-of-final-method]: Cannot override `A.method1` + --> src/mdtest_snippet.py:35:9 + | +34 | class B(A): +35 | def method1(self) -> None: ... # error: [override-of-final-method] + | ^^^^^^^ Overrides a definition from superclass `A` +36 | def method2(self) -> None: ... # error: [override-of-final-method] +37 | def method3(self) -> None: ... # error: [override-of-final-method] + | +info: `A.method1` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.py:8:9 + | + 6 | class A: + 7 | if coinflip(): + 8 | @final + | ------ + 9 | def method1(self) -> None: ... + | ------- `A.method1` defined here +10 | else: +11 | def method1(self) -> None: ... + | +help: Remove the override of `method1` +info: rule `override-of-final-method` is enabled by default +32 | def method4(self) -> None: ... +33 | +34 | class B(A): + - def method1(self) -> None: ... # error: [override-of-final-method] +35 + # error: [override-of-final-method] +36 | def method2(self) -> None: ... # error: [override-of-final-method] +37 | def method3(self) -> None: ... # error: [override-of-final-method] +38 | def method4(self) -> None: ... # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `A.method2` + --> src/mdtest_snippet.py:36:9 + | +34 | class B(A): +35 | def method1(self) -> None: ... # error: [override-of-final-method] +36 | def method2(self) -> None: ... # error: [override-of-final-method] + | ^^^^^^^ Overrides a definition from superclass `A` +37 | def method3(self) -> None: ... # error: [override-of-final-method] +38 | def method4(self) -> None: ... # error: [override-of-final-method] + | +info: `A.method2` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.py:16:9 + | +14 | def method2(self) -> None: ... +15 | else: +16 | @final + | ------ +17 | def method2(self) -> None: ... + | ------- `A.method2` defined here +18 | +19 | if coinflip(): + | +help: Remove the override of `method2` +info: rule `override-of-final-method` is enabled by default +33 | +34 | class B(A): +35 | def method1(self) -> None: ... # error: [override-of-final-method] + - def method2(self) -> None: ... # error: [override-of-final-method] +36 + # error: [override-of-final-method] +37 | def method3(self) -> None: ... # error: [override-of-final-method] +38 | def method4(self) -> None: ... # error: [override-of-final-method] +39 | +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `A.method3` + --> src/mdtest_snippet.py:37:9 + | +35 | def method1(self) -> None: ... # error: [override-of-final-method] +36 | def method2(self) -> None: ... # error: [override-of-final-method] +37 | def method3(self) -> None: ... # error: [override-of-final-method] + | ^^^^^^^ Overrides a definition from superclass `A` +38 | def method4(self) -> None: ... # error: [override-of-final-method] + | +info: `A.method3` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.py:20:9 + | +19 | if coinflip(): +20 | @final + | ------ +21 | def method3(self) -> None: ... + | ------- `A.method3` defined here +22 | else: +23 | @final + | +help: Remove the override of `method3` +info: rule `override-of-final-method` is enabled by default +34 | class B(A): +35 | def method1(self) -> None: ... # error: [override-of-final-method] +36 | def method2(self) -> None: ... # error: [override-of-final-method] + - def method3(self) -> None: ... # error: [override-of-final-method] +37 + # error: [override-of-final-method] +38 | def method4(self) -> None: ... # error: [override-of-final-method] +39 | +40 | # Possible overrides of possibly `@final` methods... +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `A.method4` + --> src/mdtest_snippet.py:38:9 + | +36 | def method2(self) -> None: ... # error: [override-of-final-method] +37 | def method3(self) -> None: ... # error: [override-of-final-method] +38 | def method4(self) -> None: ... # error: [override-of-final-method] + | ^^^^^^^ Overrides a definition from superclass `A` +39 | +40 | # Possible overrides of possibly `@final` methods... + | +info: `A.method4` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.py:29:9 + | +27 | def method4(self) -> None: ... +28 | elif coinflip(): +29 | @final + | ------ +30 | def method4(self) -> None: ... + | ------- `A.method4` defined here +31 | else: +32 | def method4(self) -> None: ... + | +help: Remove the override of `method4` +info: rule `override-of-final-method` is enabled by default +35 | def method1(self) -> None: ... # error: [override-of-final-method] +36 | def method2(self) -> None: ... # error: [override-of-final-method] +37 | def method3(self) -> None: ... # error: [override-of-final-method] + - def method4(self) -> None: ... # error: [override-of-final-method] +38 + # error: [override-of-final-method] +39 | +40 | # Possible overrides of possibly `@final` methods... +41 | class C(A): +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `A.method1` + --> src/mdtest_snippet.py:46:13 + | +44 | # statements inside the `if:` branch +45 | # (but it might still be a useful autofix in an IDE context?) +46 | def method1(self) -> None: ... # error: [override-of-final-method] + | ^^^^^^^ Overrides a definition from superclass `A` +47 | else: +48 | pass + | +info: `A.method1` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.py:8:9 + | + 6 | class A: + 7 | if coinflip(): + 8 | @final + | ------ + 9 | def method1(self) -> None: ... + | ------- `A.method1` defined here +10 | else: +11 | def method1(self) -> None: ... + | +help: Remove the override of `method1` +info: rule `override-of-final-method` is enabled by default +43 | # TODO: the autofix here introduces invalid syntax because there are now no +44 | # statements inside the `if:` branch +45 | # (but it might still be a useful autofix in an IDE context?) + - def method1(self) -> None: ... # error: [override-of-final-method] +46 + # error: [override-of-final-method] +47 | else: +48 | pass +49 | +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `A.method3` + --> src/mdtest_snippet.py:56:13 + | +55 | if coinflip(): +56 | def method3(self) -> None: ... # error: [override-of-final-method] + | ^^^^^^^ Overrides a definition from superclass `A` +57 | def method4(self) -> None: ... # error: [override-of-final-method] + | +info: `A.method3` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.py:20:9 + | +19 | if coinflip(): +20 | @final + | ------ +21 | def method3(self) -> None: ... + | ------- `A.method3` defined here +22 | else: +23 | @final + | +help: Remove the override of `method3` +info: rule `override-of-final-method` is enabled by default +53 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method] +54 | +55 | if coinflip(): + - def method3(self) -> None: ... # error: [override-of-final-method] +56 + # error: [override-of-final-method] +57 | def method4(self) -> None: ... # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `A.method4` + --> src/mdtest_snippet.py:57:13 + | +55 | if coinflip(): +56 | def method3(self) -> None: ... # error: [override-of-final-method] +57 | def method4(self) -> None: ... # error: [override-of-final-method] + | ^^^^^^^ Overrides a definition from superclass `A` + | +info: `A.method4` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.py:29:9 + | +27 | def method4(self) -> None: ... +28 | elif coinflip(): +29 | @final + | ------ +30 | def method4(self) -> None: ... + | ------- `A.method4` defined here +31 | else: +32 | def method4(self) -> None: ... + | +help: Remove the override of `method4` +info: rule `override-of-final-method` is enabled by default +54 | +55 | if coinflip(): +56 | def method3(self) -> None: ... # error: [override-of-final-method] + - def method4(self) -> None: ... # error: [override-of-final-method] +57 + # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Cannot_override_a_me…_(338615109711a91b).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Cannot_override_a_me…_(338615109711a91b).snap new file mode 100644 index 0000000000..ad51738ec5 --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Cannot_override_a_me…_(338615109711a91b).snap @@ -0,0 +1,545 @@ +--- +source: crates/ty_test/src/lib.rs +expression: snapshot +--- +--- +mdtest name: final.md - Tests for the `@typing(_extensions).final` decorator - Cannot override a method decorated with `@final` +mdtest path: crates/ty_python_semantic/resources/mdtest/final.md +--- + +# Python source files + +## mdtest_snippet.pyi + +``` + 1 | from typing_extensions import final, Callable, TypeVar + 2 | + 3 | def lossy_decorator(fn: Callable) -> Callable: ... + 4 | + 5 | class Parent: + 6 | @final + 7 | def foo(self): ... + 8 | + 9 | @final + 10 | @property + 11 | def my_property1(self) -> int: ... + 12 | + 13 | @property + 14 | @final + 15 | def my_property2(self) -> int: ... + 16 | + 17 | @final + 18 | @classmethod + 19 | def class_method1(cls) -> int: ... + 20 | + 21 | @classmethod + 22 | @final + 23 | def class_method2(cls) -> int: ... + 24 | + 25 | @final + 26 | @staticmethod + 27 | def static_method1() -> int: ... + 28 | + 29 | @staticmethod + 30 | @final + 31 | def static_method2() -> int: ... + 32 | + 33 | @lossy_decorator + 34 | @final + 35 | def decorated_1(self): ... + 36 | + 37 | @final + 38 | @lossy_decorator + 39 | def decorated_2(self): ... + 40 | + 41 | class Child(Parent): + 42 | # explicitly test the concise diagnostic message, + 43 | # which is different to the verbose diagnostic summary message: + 44 | # + 45 | # error: [override-of-final-method] "Cannot override final member `foo` from superclass `Parent`" + 46 | def foo(self): ... + 47 | @property + 48 | def my_property1(self) -> int: ... # error: [override-of-final-method] + 49 | + 50 | @property + 51 | def my_property2(self) -> int: ... # error: [override-of-final-method] + 52 | + 53 | @classmethod + 54 | def class_method1(cls) -> int: ... # error: [override-of-final-method] + 55 | + 56 | @staticmethod + 57 | def static_method1() -> int: ... # error: [override-of-final-method] + 58 | + 59 | @classmethod + 60 | def class_method2(cls) -> int: ... # error: [override-of-final-method] + 61 | + 62 | @staticmethod + 63 | def static_method2() -> int: ... # error: [override-of-final-method] + 64 | + 65 | def decorated_1(self): ... # TODO: should emit [override-of-final-method] + 66 | + 67 | @lossy_decorator + 68 | def decorated_2(self): ... # TODO: should emit [override-of-final-method] + 69 | + 70 | class OtherChild(Parent): ... + 71 | + 72 | class Grandchild(OtherChild): + 73 | @staticmethod + 74 | # TODO: we should emit a Liskov violation here too + 75 | # error: [override-of-final-method] + 76 | def foo(): ... + 77 | @property + 78 | # TODO: we should emit a Liskov violation here too + 79 | # error: [override-of-final-method] + 80 | def my_property1(self) -> str: ... + 81 | # TODO: we should emit a Liskov violation here too + 82 | # error: [override-of-final-method] + 83 | class_method1 = None + 84 | + 85 | # Diagnostic edge case: `final` is very far away from the method definition in the source code: + 86 | + 87 | T = TypeVar("T") + 88 | + 89 | def identity(x: T) -> T: ... + 90 | + 91 | class Foo: + 92 | @final + 93 | @identity + 94 | @identity + 95 | @identity + 96 | @identity + 97 | @identity + 98 | @identity + 99 | @identity +100 | @identity +101 | @identity +102 | @identity +103 | @identity +104 | @identity +105 | @identity +106 | @identity +107 | @identity +108 | @identity +109 | @identity +110 | @identity +111 | def bar(self): ... +112 | +113 | class Baz(Foo): +114 | def bar(self): ... # error: [override-of-final-method] +``` + +# Diagnostics + +``` +error[override-of-final-method]: Cannot override `Parent.foo` + --> src/mdtest_snippet.pyi:46:9 + | +44 | # +45 | # error: [override-of-final-method] "Cannot override final member `foo` from superclass `Parent`" +46 | def foo(self): ... + | ^^^ Overrides a definition from superclass `Parent` +47 | @property +48 | def my_property1(self) -> int: ... # error: [override-of-final-method] + | +info: `Parent.foo` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.pyi:6:5 + | +5 | class Parent: +6 | @final + | ------ +7 | def foo(self): ... + | --- `Parent.foo` defined here +8 | +9 | @final + | +help: Remove the override of `foo` +info: rule `override-of-final-method` is enabled by default +43 | # which is different to the verbose diagnostic summary message: +44 | # +45 | # error: [override-of-final-method] "Cannot override final member `foo` from superclass `Parent`" + - def foo(self): ... +46 + +47 | @property +48 | def my_property1(self) -> int: ... # error: [override-of-final-method] +49 | +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Parent.my_property1` + --> src/mdtest_snippet.pyi:48:9 + | +46 | def foo(self): ... +47 | @property +48 | def my_property1(self) -> int: ... # error: [override-of-final-method] + | ^^^^^^^^^^^^ Overrides a definition from superclass `Parent` +49 | +50 | @property + | +info: `Parent.my_property1` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.pyi:9:5 + | + 7 | def foo(self): ... + 8 | + 9 | @final + | ------ +10 | @property +11 | def my_property1(self) -> int: ... + | ------------ `Parent.my_property1` defined here +12 | +13 | @property + | +help: Remove the override of `my_property1` +info: rule `override-of-final-method` is enabled by default +44 | # +45 | # error: [override-of-final-method] "Cannot override final member `foo` from superclass `Parent`" +46 | def foo(self): ... + - @property + - def my_property1(self) -> int: ... # error: [override-of-final-method] +47 + # error: [override-of-final-method] +48 | +49 | @property +50 | def my_property2(self) -> int: ... # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Parent.my_property2` + --> src/mdtest_snippet.pyi:51:9 + | +50 | @property +51 | def my_property2(self) -> int: ... # error: [override-of-final-method] + | ^^^^^^^^^^^^ Overrides a definition from superclass `Parent` +52 | +53 | @classmethod + | +info: `Parent.my_property2` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.pyi:14:5 + | +13 | @property +14 | @final + | ------ +15 | def my_property2(self) -> int: ... + | ------------ `Parent.my_property2` defined here +16 | +17 | @final + | +help: Remove the override of `my_property2` +info: rule `override-of-final-method` is enabled by default +47 | @property +48 | def my_property1(self) -> int: ... # error: [override-of-final-method] +49 | + - @property + - def my_property2(self) -> int: ... # error: [override-of-final-method] +50 + # error: [override-of-final-method] +51 | +52 | @classmethod +53 | def class_method1(cls) -> int: ... # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Parent.class_method1` + --> src/mdtest_snippet.pyi:54:9 + | +53 | @classmethod +54 | def class_method1(cls) -> int: ... # error: [override-of-final-method] + | ^^^^^^^^^^^^^ Overrides a definition from superclass `Parent` +55 | +56 | @staticmethod + | +info: `Parent.class_method1` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.pyi:17:5 + | +15 | def my_property2(self) -> int: ... +16 | +17 | @final + | ------ +18 | @classmethod +19 | def class_method1(cls) -> int: ... + | ------------- `Parent.class_method1` defined here +20 | +21 | @classmethod + | +help: Remove the override of `class_method1` +info: rule `override-of-final-method` is enabled by default +50 | @property +51 | def my_property2(self) -> int: ... # error: [override-of-final-method] +52 | + - @classmethod + - def class_method1(cls) -> int: ... # error: [override-of-final-method] +53 + # error: [override-of-final-method] +54 | +55 | @staticmethod +56 | def static_method1() -> int: ... # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Parent.static_method1` + --> src/mdtest_snippet.pyi:57:9 + | +56 | @staticmethod +57 | def static_method1() -> int: ... # error: [override-of-final-method] + | ^^^^^^^^^^^^^^ Overrides a definition from superclass `Parent` +58 | +59 | @classmethod + | +info: `Parent.static_method1` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.pyi:25:5 + | +23 | def class_method2(cls) -> int: ... +24 | +25 | @final + | ------ +26 | @staticmethod +27 | def static_method1() -> int: ... + | -------------- `Parent.static_method1` defined here +28 | +29 | @staticmethod + | +help: Remove the override of `static_method1` +info: rule `override-of-final-method` is enabled by default +53 | @classmethod +54 | def class_method1(cls) -> int: ... # error: [override-of-final-method] +55 | + - @staticmethod + - def static_method1() -> int: ... # error: [override-of-final-method] +56 + # error: [override-of-final-method] +57 | +58 | @classmethod +59 | def class_method2(cls) -> int: ... # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Parent.class_method2` + --> src/mdtest_snippet.pyi:60:9 + | +59 | @classmethod +60 | def class_method2(cls) -> int: ... # error: [override-of-final-method] + | ^^^^^^^^^^^^^ Overrides a definition from superclass `Parent` +61 | +62 | @staticmethod + | +info: `Parent.class_method2` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.pyi:22:5 + | +21 | @classmethod +22 | @final + | ------ +23 | def class_method2(cls) -> int: ... + | ------------- `Parent.class_method2` defined here +24 | +25 | @final + | +help: Remove the override of `class_method2` +info: rule `override-of-final-method` is enabled by default +56 | @staticmethod +57 | def static_method1() -> int: ... # error: [override-of-final-method] +58 | + - @classmethod + - def class_method2(cls) -> int: ... # error: [override-of-final-method] +59 + # error: [override-of-final-method] +60 | +61 | @staticmethod +62 | def static_method2() -> int: ... # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Parent.static_method2` + --> src/mdtest_snippet.pyi:63:9 + | +62 | @staticmethod +63 | def static_method2() -> int: ... # error: [override-of-final-method] + | ^^^^^^^^^^^^^^ Overrides a definition from superclass `Parent` +64 | +65 | def decorated_1(self): ... # TODO: should emit [override-of-final-method] + | +info: `Parent.static_method2` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.pyi:30:5 + | +29 | @staticmethod +30 | @final + | ------ +31 | def static_method2() -> int: ... + | -------------- `Parent.static_method2` defined here +32 | +33 | @lossy_decorator + | +help: Remove the override of `static_method2` +info: rule `override-of-final-method` is enabled by default +59 | @classmethod +60 | def class_method2(cls) -> int: ... # error: [override-of-final-method] +61 | + - @staticmethod + - def static_method2() -> int: ... # error: [override-of-final-method] +62 + # error: [override-of-final-method] +63 | +64 | def decorated_1(self): ... # TODO: should emit [override-of-final-method] +65 | +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Parent.foo` + --> src/mdtest_snippet.pyi:76:9 + | +74 | # TODO: we should emit a Liskov violation here too +75 | # error: [override-of-final-method] +76 | def foo(): ... + | ^^^ Overrides a definition from superclass `Parent` +77 | @property +78 | # TODO: we should emit a Liskov violation here too + | +info: `Parent.foo` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.pyi:6:5 + | +5 | class Parent: +6 | @final + | ------ +7 | def foo(self): ... + | --- `Parent.foo` defined here +8 | +9 | @final + | +help: Remove the override of `foo` +info: rule `override-of-final-method` is enabled by default +70 | class OtherChild(Parent): ... +71 | +72 | class Grandchild(OtherChild): + - @staticmethod + - # TODO: we should emit a Liskov violation here too + - # error: [override-of-final-method] + - def foo(): ... +73 + +74 | @property +75 | # TODO: we should emit a Liskov violation here too +76 | # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Parent.my_property1` + --> src/mdtest_snippet.pyi:80:9 + | +78 | # TODO: we should emit a Liskov violation here too +79 | # error: [override-of-final-method] +80 | def my_property1(self) -> str: ... + | ^^^^^^^^^^^^ Overrides a definition from superclass `Parent` +81 | # TODO: we should emit a Liskov violation here too +82 | # error: [override-of-final-method] + | +info: `Parent.my_property1` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.pyi:9:5 + | + 7 | def foo(self): ... + 8 | + 9 | @final + | ------ +10 | @property +11 | def my_property1(self) -> int: ... + | ------------ `Parent.my_property1` defined here +12 | +13 | @property + | +help: Remove the override of `my_property1` +info: rule `override-of-final-method` is enabled by default +74 | # TODO: we should emit a Liskov violation here too +75 | # error: [override-of-final-method] +76 | def foo(): ... + - @property + - # TODO: we should emit a Liskov violation here too + - # error: [override-of-final-method] + - def my_property1(self) -> str: ... +77 + +78 | # TODO: we should emit a Liskov violation here too +79 | # error: [override-of-final-method] +80 | class_method1 = None +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Parent.class_method1` + --> src/mdtest_snippet.pyi:83:5 + | +81 | # TODO: we should emit a Liskov violation here too +82 | # error: [override-of-final-method] +83 | class_method1 = None + | ^^^^^^^^^^^^^ Overrides a definition from superclass `Parent` +84 | +85 | # Diagnostic edge case: `final` is very far away from the method definition in the source code: + | +info: `Parent.class_method1` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.pyi:17:5 + | +15 | def my_property2(self) -> int: ... +16 | +17 | @final + | ------ +18 | @classmethod +19 | def class_method1(cls) -> int: ... + | ------------- `Parent.class_method1` defined here +20 | +21 | @classmethod + | +help: Remove the override of `class_method1` +info: rule `override-of-final-method` is enabled by default +80 | def my_property1(self) -> str: ... +81 | # TODO: we should emit a Liskov violation here too +82 | # error: [override-of-final-method] + - class_method1 = None +83 + +84 | +85 | # Diagnostic edge case: `final` is very far away from the method definition in the source code: +86 | +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Foo.bar` + --> src/mdtest_snippet.pyi:114:9 + | +113 | class Baz(Foo): +114 | def bar(self): ... # error: [override-of-final-method] + | ^^^ Overrides a definition from superclass `Foo` + | +info: `Foo.bar` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.pyi:92:5 + | + 91 | class Foo: + 92 | @final + | ------ + 93 | @identity + 94 | @identity + | + ::: src/mdtest_snippet.pyi:111:9 + | +109 | @identity +110 | @identity +111 | def bar(self): ... + | --- `Foo.bar` defined here +112 | +113 | class Baz(Foo): + | +help: Remove the override of `bar` +info: rule `override-of-final-method` is enabled by default +111 | def bar(self): ... +112 | +113 | class Baz(Foo): + - def bar(self): ... # error: [override-of-final-method] +114 + # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Diagnostic_edge_case…_(2389d52c5ecfa2bd).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Diagnostic_edge_case…_(2389d52c5ecfa2bd).snap new file mode 100644 index 0000000000..5e7f11ca02 --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Diagnostic_edge_case…_(2389d52c5ecfa2bd).snap @@ -0,0 +1,59 @@ +--- +source: crates/ty_test/src/lib.rs +expression: snapshot +--- +--- +mdtest name: final.md - Tests for the `@typing(_extensions).final` decorator - Diagnostic edge case: superclass with `@final` method has the same name as the subclass +mdtest path: crates/ty_python_semantic/resources/mdtest/final.md +--- + +# Python source files + +## module1.py + +``` +1 | from typing import final +2 | +3 | class Foo: +4 | @final +5 | def f(self): ... +``` + +## module2.py + +``` +1 | import module1 +2 | +3 | class Foo(module1.Foo): +4 | def f(self): ... # error: [override-of-final-method] +``` + +# Diagnostics + +``` +error[override-of-final-method]: Cannot override `module1.Foo.f` + --> src/module2.py:4:9 + | +3 | class Foo(module1.Foo): +4 | def f(self): ... # error: [override-of-final-method] + | ^ Overrides a definition from superclass `module1.Foo` + | +info: `module1.Foo.f` is decorated with `@final`, forbidding overrides + --> src/module1.py:4:5 + | +3 | class Foo: +4 | @final + | ------ +5 | def f(self): ... + | - `module1.Foo.f` defined here + | +help: Remove the override of `f` +info: rule `override-of-final-method` is enabled by default +1 | import module1 +2 | +3 | class Foo(module1.Foo): + - def f(self): ... # error: [override-of-final-method] +4 + # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Only_the_first_`@fin…_(9863b583f4c651c5).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Only_the_first_`@fin…_(9863b583f4c651c5).snap new file mode 100644 index 0000000000..342b7ec8b6 --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Only_the_first_`@fin…_(9863b583f4c651c5).snap @@ -0,0 +1,101 @@ +--- +source: crates/ty_test/src/lib.rs +expression: snapshot +--- +--- +mdtest name: final.md - Tests for the `@typing(_extensions).final` decorator - Only the first `@final` violation is reported +mdtest path: crates/ty_python_semantic/resources/mdtest/final.md +--- + +# Python source files + +## mdtest_snippet.py + +``` + 1 | from typing import final + 2 | + 3 | class A: + 4 | @final + 5 | def f(self): ... + 6 | + 7 | class B(A): + 8 | @final + 9 | def f(self): ... # error: [override-of-final-method] +10 | +11 | class C(B): +12 | @final +13 | # we only emit one error here, not two +14 | def f(self): ... # error: [override-of-final-method] +``` + +# Diagnostics + +``` +error[override-of-final-method]: Cannot override `A.f` + --> src/mdtest_snippet.py:9:9 + | + 7 | class B(A): + 8 | @final + 9 | def f(self): ... # error: [override-of-final-method] + | ^ Overrides a definition from superclass `A` +10 | +11 | class C(B): + | +info: `A.f` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.py:4:5 + | +3 | class A: +4 | @final + | ------ +5 | def f(self): ... + | - `A.f` defined here +6 | +7 | class B(A): + | +help: Remove the override of `f` +info: rule `override-of-final-method` is enabled by default +5 | def f(self): ... +6 | +7 | class B(A): + - @final + - def f(self): ... # error: [override-of-final-method] +8 + # error: [override-of-final-method] +9 | +10 | class C(B): +11 | @final +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `B.f` + --> src/mdtest_snippet.py:14:9 + | +12 | @final +13 | # we only emit one error here, not two +14 | def f(self): ... # error: [override-of-final-method] + | ^ Overrides a definition from superclass `B` + | +info: `B.f` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.py:8:5 + | + 7 | class B(A): + 8 | @final + | ------ + 9 | def f(self): ... # error: [override-of-final-method] + | - `B.f` defined here +10 | +11 | class C(B): + | +help: Remove the override of `f` +info: rule `override-of-final-method` is enabled by default +9 | def f(self): ... # error: [override-of-final-method] +10 | +11 | class C(B): + - @final + - # we only emit one error here, not two + - def f(self): ... # error: [override-of-final-method] +12 + # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Overloaded_methods_d…_(861757f48340ed92).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Overloaded_methods_d…_(861757f48340ed92).snap new file mode 100644 index 0000000000..38ec75b003 --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Overloaded_methods_d…_(861757f48340ed92).snap @@ -0,0 +1,565 @@ +--- +source: crates/ty_test/src/lib.rs +expression: snapshot +--- +--- +mdtest name: final.md - Tests for the `@typing(_extensions).final` decorator - Overloaded methods decorated with `@final` +mdtest path: crates/ty_python_semantic/resources/mdtest/final.md +--- + +# Python source files + +## stub.pyi + +``` + 1 | from typing import final, overload + 2 | + 3 | class Good: + 4 | @overload + 5 | @final + 6 | def bar(self, x: str) -> str: ... + 7 | @overload + 8 | def bar(self, x: int) -> int: ... + 9 | +10 | @final +11 | @overload +12 | def baz(self, x: str) -> str: ... +13 | @overload +14 | def baz(self, x: int) -> int: ... +15 | +16 | class ChildOfGood(Good): +17 | @overload +18 | def bar(self, x: str) -> str: ... +19 | @overload +20 | def bar(self, x: int) -> int: ... # error: [override-of-final-method] +21 | +22 | @overload +23 | def baz(self, x: str) -> str: ... +24 | @overload +25 | def baz(self, x: int) -> int: ... # error: [override-of-final-method] +26 | +27 | class Bad: +28 | @overload +29 | def bar(self, x: str) -> str: ... +30 | @overload +31 | @final +32 | # error: [invalid-overload] +33 | def bar(self, x: int) -> int: ... +34 | +35 | @overload +36 | def baz(self, x: str) -> str: ... +37 | @final +38 | @overload +39 | # error: [invalid-overload] +40 | def baz(self, x: int) -> int: ... +41 | +42 | class ChildOfBad(Bad): +43 | @overload +44 | def bar(self, x: str) -> str: ... +45 | @overload +46 | def bar(self, x: int) -> int: ... # error: [override-of-final-method] +47 | +48 | @overload +49 | def baz(self, x: str) -> str: ... +50 | @overload +51 | def baz(self, x: int) -> int: ... # error: [override-of-final-method] +``` + +## main.py + +``` + 1 | from typing import overload, final + 2 | + 3 | class Good: + 4 | @overload + 5 | def f(self, x: str) -> str: ... + 6 | @overload + 7 | def f(self, x: int) -> int: ... + 8 | @final + 9 | def f(self, x: int | str) -> int | str: +10 | return x +11 | +12 | class ChildOfGood(Good): +13 | @overload +14 | def f(self, x: str) -> str: ... +15 | @overload +16 | def f(self, x: int) -> int: ... +17 | # error: [override-of-final-method] +18 | def f(self, x: int | str) -> int | str: +19 | return x +20 | +21 | class Bad: +22 | @overload +23 | @final +24 | def f(self, x: str) -> str: ... +25 | @overload +26 | def f(self, x: int) -> int: ... +27 | # error: [invalid-overload] +28 | def f(self, x: int | str) -> int | str: +29 | return x +30 | +31 | @final +32 | @overload +33 | def g(self, x: str) -> str: ... +34 | @overload +35 | def g(self, x: int) -> int: ... +36 | # error: [invalid-overload] +37 | def g(self, x: int | str) -> int | str: +38 | return x +39 | +40 | @overload +41 | def h(self, x: str) -> str: ... +42 | @overload +43 | @final +44 | def h(self, x: int) -> int: ... +45 | # error: [invalid-overload] +46 | def h(self, x: int | str) -> int | str: +47 | return x +48 | +49 | @overload +50 | def i(self, x: str) -> str: ... +51 | @final +52 | @overload +53 | def i(self, x: int) -> int: ... +54 | # error: [invalid-overload] +55 | def i(self, x: int | str) -> int | str: +56 | return x +57 | +58 | class ChildOfBad(Bad): +59 | # TODO: these should all cause us to emit Liskov violations as well +60 | f = None # error: [override-of-final-method] +61 | g = None # error: [override-of-final-method] +62 | h = None # error: [override-of-final-method] +63 | i = None # error: [override-of-final-method] +``` + +# Diagnostics + +``` +error[override-of-final-method]: Cannot override `Good.bar` + --> src/stub.pyi:20:9 + | +18 | def bar(self, x: str) -> str: ... +19 | @overload +20 | def bar(self, x: int) -> int: ... # error: [override-of-final-method] + | ^^^ Overrides a definition from superclass `Good` +21 | +22 | @overload + | +info: `Good.bar` is decorated with `@final`, forbidding overrides + --> src/stub.pyi:5:5 + | +3 | class Good: +4 | @overload +5 | @final + | ------ +6 | def bar(self, x: str) -> str: ... + | --- `Good.bar` defined here +7 | @overload +8 | def bar(self, x: int) -> int: ... + | +help: Remove all overloads for `bar` +info: rule `override-of-final-method` is enabled by default +14 | def baz(self, x: int) -> int: ... +15 | +16 | class ChildOfGood(Good): + - @overload + - def bar(self, x: str) -> str: ... + - @overload + - def bar(self, x: int) -> int: ... # error: [override-of-final-method] +17 + +18 + # error: [override-of-final-method] +19 | +20 | @overload +21 | def baz(self, x: str) -> str: ... +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Good.baz` + --> src/stub.pyi:25:9 + | +23 | def baz(self, x: str) -> str: ... +24 | @overload +25 | def baz(self, x: int) -> int: ... # error: [override-of-final-method] + | ^^^ Overrides a definition from superclass `Good` +26 | +27 | class Bad: + | +info: `Good.baz` is decorated with `@final`, forbidding overrides + --> src/stub.pyi:10:5 + | + 8 | def bar(self, x: int) -> int: ... + 9 | +10 | @final + | ------ +11 | @overload +12 | def baz(self, x: str) -> str: ... + | --- `Good.baz` defined here +13 | @overload +14 | def baz(self, x: int) -> int: ... + | +help: Remove all overloads for `baz` +info: rule `override-of-final-method` is enabled by default +19 | @overload +20 | def bar(self, x: int) -> int: ... # error: [override-of-final-method] +21 | + - @overload + - def baz(self, x: str) -> str: ... + - @overload + - def baz(self, x: int) -> int: ... # error: [override-of-final-method] +22 + +23 + # error: [override-of-final-method] +24 | +25 | class Bad: +26 | @overload +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[invalid-overload]: `@final` decorator should be applied only to the first overload + --> src/stub.pyi:29:9 + | +27 | class Bad: +28 | @overload +29 | def bar(self, x: str) -> str: ... + | --- First overload defined here +30 | @overload +31 | @final +32 | # error: [invalid-overload] +33 | def bar(self, x: int) -> int: ... + | ^^^ +34 | +35 | @overload + | +info: rule `invalid-overload` is enabled by default + +``` + +``` +error[invalid-overload]: `@final` decorator should be applied only to the first overload + --> src/stub.pyi:36:9 + | +35 | @overload +36 | def baz(self, x: str) -> str: ... + | --- First overload defined here +37 | @final +38 | @overload +39 | # error: [invalid-overload] +40 | def baz(self, x: int) -> int: ... + | ^^^ +41 | +42 | class ChildOfBad(Bad): + | +info: rule `invalid-overload` is enabled by default + +``` + +``` +error[override-of-final-method]: Cannot override `Bad.bar` + --> src/stub.pyi:46:9 + | +44 | def bar(self, x: str) -> str: ... +45 | @overload +46 | def bar(self, x: int) -> int: ... # error: [override-of-final-method] + | ^^^ Overrides a definition from superclass `Bad` +47 | +48 | @overload + | +info: `Bad.bar` is decorated with `@final`, forbidding overrides + --> src/stub.pyi:29:9 + | +27 | class Bad: +28 | @overload +29 | def bar(self, x: str) -> str: ... + | --- `Bad.bar` defined here +30 | @overload +31 | @final + | +help: Remove all overloads for `bar` +info: rule `override-of-final-method` is enabled by default +40 | def baz(self, x: int) -> int: ... +41 | +42 | class ChildOfBad(Bad): + - @overload + - def bar(self, x: str) -> str: ... + - @overload + - def bar(self, x: int) -> int: ... # error: [override-of-final-method] +43 | +44 + # error: [override-of-final-method] +45 + +46 | @overload +47 | def baz(self, x: str) -> str: ... +48 | @overload +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Bad.baz` + --> src/stub.pyi:51:9 + | +49 | def baz(self, x: str) -> str: ... +50 | @overload +51 | def baz(self, x: int) -> int: ... # error: [override-of-final-method] + | ^^^ Overrides a definition from superclass `Bad` + | +info: `Bad.baz` is decorated with `@final`, forbidding overrides + --> src/stub.pyi:36:9 + | +35 | @overload +36 | def baz(self, x: str) -> str: ... + | --- `Bad.baz` defined here +37 | @final +38 | @overload + | +help: Remove all overloads for `baz` +info: rule `override-of-final-method` is enabled by default +45 | @overload +46 | def bar(self, x: int) -> int: ... # error: [override-of-final-method] +47 | + - @overload + - def baz(self, x: str) -> str: ... + - @overload + - def baz(self, x: int) -> int: ... # error: [override-of-final-method] +48 + +49 + # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Good.f` + --> src/main.py:18:9 + | +16 | def f(self, x: int) -> int: ... +17 | # error: [override-of-final-method] +18 | def f(self, x: int | str) -> int | str: + | ^ Overrides a definition from superclass `Good` +19 | return x + | +info: `Good.f` is decorated with `@final`, forbidding overrides + --> src/main.py:8:5 + | + 6 | @overload + 7 | def f(self, x: int) -> int: ... + 8 | @final + | ------ + 9 | def f(self, x: int | str) -> int | str: + | - `Good.f` defined here +10 | return x + | +help: Remove all overloads and the implementation for `f` +info: rule `override-of-final-method` is enabled by default +10 | return x +11 | +12 | class ChildOfGood(Good): + - @overload + - def f(self, x: str) -> str: ... + - @overload + - def f(self, x: int) -> int: ... +13 + +14 + +15 | # error: [override-of-final-method] + - def f(self, x: int | str) -> int | str: + - return x +16 + +17 | +18 | class Bad: +19 | @overload +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[invalid-overload]: `@final` decorator should be applied only to the overload implementation + --> src/main.py:28:9 + | +26 | def f(self, x: int) -> int: ... +27 | # error: [invalid-overload] +28 | def f(self, x: int | str) -> int | str: + | - + | | + | Implementation defined here +29 | return x + | +info: rule `invalid-overload` is enabled by default + +``` + +``` +error[invalid-overload]: `@final` decorator should be applied only to the overload implementation + --> src/main.py:37:9 + | +35 | def g(self, x: int) -> int: ... +36 | # error: [invalid-overload] +37 | def g(self, x: int | str) -> int | str: + | - + | | + | Implementation defined here +38 | return x + | +info: rule `invalid-overload` is enabled by default + +``` + +``` +error[invalid-overload]: `@final` decorator should be applied only to the overload implementation + --> src/main.py:46:9 + | +44 | def h(self, x: int) -> int: ... +45 | # error: [invalid-overload] +46 | def h(self, x: int | str) -> int | str: + | - + | | + | Implementation defined here +47 | return x + | +info: rule `invalid-overload` is enabled by default + +``` + +``` +error[invalid-overload]: `@final` decorator should be applied only to the overload implementation + --> src/main.py:55:9 + | +53 | def i(self, x: int) -> int: ... +54 | # error: [invalid-overload] +55 | def i(self, x: int | str) -> int | str: + | - + | | + | Implementation defined here +56 | return x + | +info: rule `invalid-overload` is enabled by default + +``` + +``` +error[override-of-final-method]: Cannot override `Bad.f` + --> src/main.py:60:5 + | +58 | class ChildOfBad(Bad): +59 | # TODO: these should all cause us to emit Liskov violations as well +60 | f = None # error: [override-of-final-method] + | ^ Overrides a definition from superclass `Bad` +61 | g = None # error: [override-of-final-method] +62 | h = None # error: [override-of-final-method] + | +info: `Bad.f` is decorated with `@final`, forbidding overrides + --> src/main.py:28:9 + | +26 | def f(self, x: int) -> int: ... +27 | # error: [invalid-overload] +28 | def f(self, x: int | str) -> int | str: + | - `Bad.f` defined here +29 | return x + | +help: Remove the override of `f` +info: rule `override-of-final-method` is enabled by default +57 | +58 | class ChildOfBad(Bad): +59 | # TODO: these should all cause us to emit Liskov violations as well + - f = None # error: [override-of-final-method] +60 + # error: [override-of-final-method] +61 | g = None # error: [override-of-final-method] +62 | h = None # error: [override-of-final-method] +63 | i = None # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Bad.g` + --> src/main.py:61:5 + | +59 | # TODO: these should all cause us to emit Liskov violations as well +60 | f = None # error: [override-of-final-method] +61 | g = None # error: [override-of-final-method] + | ^ Overrides a definition from superclass `Bad` +62 | h = None # error: [override-of-final-method] +63 | i = None # error: [override-of-final-method] + | +info: `Bad.g` is decorated with `@final`, forbidding overrides + --> src/main.py:37:9 + | +35 | def g(self, x: int) -> int: ... +36 | # error: [invalid-overload] +37 | def g(self, x: int | str) -> int | str: + | - `Bad.g` defined here +38 | return x + | +help: Remove the override of `g` +info: rule `override-of-final-method` is enabled by default +58 | class ChildOfBad(Bad): +59 | # TODO: these should all cause us to emit Liskov violations as well +60 | f = None # error: [override-of-final-method] + - g = None # error: [override-of-final-method] +61 + # error: [override-of-final-method] +62 | h = None # error: [override-of-final-method] +63 | i = None # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Bad.h` + --> src/main.py:62:5 + | +60 | f = None # error: [override-of-final-method] +61 | g = None # error: [override-of-final-method] +62 | h = None # error: [override-of-final-method] + | ^ Overrides a definition from superclass `Bad` +63 | i = None # error: [override-of-final-method] + | +info: `Bad.h` is decorated with `@final`, forbidding overrides + --> src/main.py:46:9 + | +44 | def h(self, x: int) -> int: ... +45 | # error: [invalid-overload] +46 | def h(self, x: int | str) -> int | str: + | - `Bad.h` defined here +47 | return x + | +help: Remove the override of `h` +info: rule `override-of-final-method` is enabled by default +59 | # TODO: these should all cause us to emit Liskov violations as well +60 | f = None # error: [override-of-final-method] +61 | g = None # error: [override-of-final-method] + - h = None # error: [override-of-final-method] +62 + # error: [override-of-final-method] +63 | i = None # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` + +``` +error[override-of-final-method]: Cannot override `Bad.i` + --> src/main.py:63:5 + | +61 | g = None # error: [override-of-final-method] +62 | h = None # error: [override-of-final-method] +63 | i = None # error: [override-of-final-method] + | ^ Overrides a definition from superclass `Bad` + | +info: `Bad.i` is decorated with `@final`, forbidding overrides + --> src/main.py:55:9 + | +53 | def i(self, x: int) -> int: ... +54 | # error: [invalid-overload] +55 | def i(self, x: int | str) -> int | str: + | - `Bad.i` defined here +56 | return x + | +help: Remove the override of `i` +info: rule `override-of-final-method` is enabled by default +60 | f = None # error: [override-of-final-method] +61 | g = None # error: [override-of-final-method] +62 | h = None # error: [override-of-final-method] + - i = None # error: [override-of-final-method] +63 + # error: [override-of-final-method] +note: This is an unsafe fix and may change runtime behavior + +``` diff --git a/crates/ty_python_semantic/src/types/class.rs b/crates/ty_python_semantic/src/types/class.rs index 26a7a2c42c..1f613fa568 100644 --- a/crates/ty_python_semantic/src/types/class.rs +++ b/crates/ty_python_semantic/src/types/class.rs @@ -497,6 +497,11 @@ impl<'db> ClassType<'db> { class_literal.name(db) } + pub(super) fn qualified_name(self, db: &'db dyn Db) -> QualifiedClassName<'db> { + let (class_literal, _) = self.class_literal(db); + class_literal.qualified_name(db) + } + pub(crate) fn known(self, db: &'db dyn Db) -> Option { let (class_literal, _) = self.class_literal(db); class_literal.known(db) diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index ae33d378a2..e3bc4d755d 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -17,7 +17,7 @@ use crate::types::call::CallError; use crate::types::class::{ CodeGeneratorKind, DisjointBase, DisjointBaseKind, Field, MethodDecorator, }; -use crate::types::function::{FunctionType, KnownFunction}; +use crate::types::function::{FunctionDecorators, FunctionType, KnownFunction, OverloadLiteral}; use crate::types::liskov::MethodKind; use crate::types::string_annotation::{ BYTE_STRING_TYPE_ANNOTATION, ESCAPE_CHARACTER_IN_FORWARD_ANNOTATION, FSTRING_TYPE_ANNOTATION, @@ -101,6 +101,7 @@ pub(crate) fn register_lints(registry: &mut LintRegistryBuilder) { registry.register_lint(&POSSIBLY_MISSING_IMPORT); registry.register_lint(&POSSIBLY_UNRESOLVED_REFERENCE); registry.register_lint(&SUBCLASS_OF_FINAL_CLASS); + registry.register_lint(&OVERRIDE_OF_FINAL_METHOD); registry.register_lint(&TYPE_ASSERTION_FAILURE); registry.register_lint(&TOO_MANY_POSITIONAL_ARGUMENTS); registry.register_lint(&UNAVAILABLE_IMPLICIT_SUPER_ARGUMENTS); @@ -1614,6 +1615,33 @@ declare_lint! { } } +declare_lint! { + /// ## What it does + /// Checks for methods on subclasses that override superclass methods decorated with `@final`. + /// + /// ## Why is this bad? + /// Decorating a method with `@final` declares to the type checker that it should not be + /// overridden on any subclass. + /// + /// ## Example + /// + /// ```python + /// from typing import final + /// + /// class A: + /// @final + /// def foo(self): ... + /// + /// class B(A): + /// def foo(self): ... # Error raised here + /// ``` + pub(crate) static OVERRIDE_OF_FINAL_METHOD = { + summary: "detects subclasses of final classes", + status: LintStatus::stable("0.0.1-alpha.29"), + default_level: Level::Error, + } +} + declare_lint! { /// ## What it does /// Checks for methods that are decorated with `@override` but do not override any method in a superclass. @@ -3625,7 +3653,7 @@ pub(super) fn report_invalid_method_override<'db>( let overridden_method = if class_name == superclass_name { format!( "{superclass}.{member}", - superclass = superclass.class_literal(db).0.qualified_name(db), + superclass = superclass.qualified_name(db), ) } else { format!("{superclass_name}.{member}") @@ -3768,6 +3796,125 @@ pub(super) fn report_invalid_method_override<'db>( } } +pub(super) fn report_overridden_final_method<'db>( + context: &InferContext<'db, '_>, + member: &str, + subclass_definition: Definition<'db>, + subclass_type: Type<'db>, + superclass: ClassType<'db>, + subclass: ClassType<'db>, + superclass_method_defs: &[FunctionType<'db>], +) { + let db = context.db(); + + let Some(builder) = context.report_lint( + &OVERRIDE_OF_FINAL_METHOD, + subclass_definition.focus_range(db, context.module()), + ) else { + return; + }; + + let superclass_name = if superclass.name(db) == subclass.name(db) { + superclass.qualified_name(db).to_string() + } else { + superclass.name(db).to_string() + }; + + let mut diagnostic = + builder.into_diagnostic(format_args!("Cannot override `{superclass_name}.{member}`")); + diagnostic.set_primary_message(format_args!( + "Overrides a definition from superclass `{superclass_name}`" + )); + diagnostic.set_concise_message(format_args!( + "Cannot override final member `{member}` from superclass `{superclass_name}`" + )); + + let mut sub = SubDiagnostic::new( + SubDiagnosticSeverity::Info, + format_args!( + "`{superclass_name}.{member}` is decorated with `@final`, forbidding overrides" + ), + ); + + let first_final_superclass_definition = superclass_method_defs + .iter() + .find(|function| function.has_known_decorator(db, FunctionDecorators::FINAL)) + .expect( + "At least one function definition in the superclass should be decorated with `@final`", + ); + + let superclass_function_literal = if first_final_superclass_definition.file(db).is_stub(db) { + first_final_superclass_definition.first_overload_or_implementation(db) + } else { + first_final_superclass_definition + .literal(db) + .last_definition(db) + }; + + sub.annotate( + Annotation::secondary(Span::from(superclass_function_literal.focus_range( + db, + &parsed_module(db, first_final_superclass_definition.file(db)).load(db), + ))) + .message(format_args!("`{superclass_name}.{member}` defined here")), + ); + + if let Some(decorator_span) = + superclass_function_literal.find_known_decorator_span(db, KnownFunction::Final) + { + sub.annotate(Annotation::secondary(decorator_span)); + } + + diagnostic.sub(sub); + + let underlying_function = match subclass_type { + Type::FunctionLiteral(function) => Some(function), + Type::BoundMethod(method) => Some(method.function(db)), + _ => None, + }; + + if let Some(function) = underlying_function { + let overload_deletion = |overload: &OverloadLiteral<'db>| { + Edit::range_deletion(overload.node(db, context.file(), context.module()).range()) + }; + + match function.overloads_and_implementation(db) { + ([first_overload, rest @ ..], None) => { + diagnostic.help(format_args!("Remove all overloads for `{member}`")); + diagnostic.set_fix(Fix::unsafe_edits( + overload_deletion(first_overload), + rest.iter().map(overload_deletion), + )); + } + ([first_overload, rest @ ..], Some(implementation)) => { + diagnostic.help(format_args!( + "Remove all overloads and the implementation for `{member}`" + )); + diagnostic.set_fix(Fix::unsafe_edits( + overload_deletion(first_overload), + rest.iter().chain([&implementation]).map(overload_deletion), + )); + } + ([], Some(implementation)) => { + diagnostic.help(format_args!("Remove the override of `{member}`")); + diagnostic.set_fix(Fix::unsafe_edit(overload_deletion(&implementation))); + } + ([], None) => { + // Should be impossible to get here: how would we even infer a function as a function + // if it has 0 overloads and no implementation? + unreachable!( + "A function should always have an implementation and/or >=1 overloads" + ); + } + } + } else { + diagnostic.help(format_args!("Remove the override of `{member}`")); + diagnostic.set_fix(Fix::unsafe_edit(Edit::range_deletion( + subclass_definition.full_range(db, context.module()).range(), + ))); + } +} + /// This function receives an unresolved `from foo import bar` import, /// where `foo` can be resolved to a module but that module does not /// have a `bar` member or submodule. diff --git a/crates/ty_python_semantic/src/types/function.rs b/crates/ty_python_semantic/src/types/function.rs index 262868b7b5..7c07a86af1 100644 --- a/crates/ty_python_semantic/src/types/function.rs +++ b/crates/ty_python_semantic/src/types/function.rs @@ -83,7 +83,7 @@ use crate::types::{ ClassLiteral, ClassType, DeprecatedInstance, DynamicType, FindLegacyTypeVarsVisitor, HasRelationToVisitor, IsDisjointVisitor, IsEquivalentVisitor, KnownClass, KnownInstanceType, NormalizedVisitor, SpecialFormType, Truthiness, Type, TypeContext, TypeMapping, TypeRelation, - UnionBuilder, binding_type, walk_signature, + UnionBuilder, binding_type, definition_expression_type, walk_signature, }; use crate::{Db, FxOrderSet, ModuleName, resolve_module}; @@ -278,7 +278,7 @@ impl<'db> OverloadLiteral<'db> { || is_implicit_classmethod(self.name(db)) } - pub(super) fn node<'ast>( + pub(crate) fn node<'ast>( self, db: &dyn Db, file: File, @@ -294,6 +294,41 @@ impl<'db> OverloadLiteral<'db> { self.body_scope(db).node(db).expect_function().node(module) } + /// Iterate through the decorators on this function, returning the span of the first one + /// that matches the given predicate. + pub(super) fn find_decorator_span( + self, + db: &'db dyn Db, + predicate: impl Fn(Type<'db>) -> bool, + ) -> Option { + let definition = self.definition(db); + let file = definition.file(db); + self.node(db, file, &parsed_module(db, file).load(db)) + .decorator_list + .iter() + .find(|decorator| { + predicate(definition_expression_type( + db, + definition, + &decorator.expression, + )) + }) + .map(|decorator| Span::from(file).with_range(decorator.range)) + } + + /// Iterate through the decorators on this function, returning the span of the first one + /// that matches the given [`KnownFunction`]. + pub(super) fn find_known_decorator_span( + self, + db: &'db dyn Db, + needle: KnownFunction, + ) -> Option { + self.find_decorator_span(db, |ty| { + ty.as_function_literal() + .is_some_and(|f| f.is_known(db, needle)) + }) + } + /// Returns the [`FileRange`] of the function's name. pub(crate) fn focus_range(self, db: &dyn Db, module: &ParsedModuleRef) -> FileRange { FileRange::new( @@ -584,32 +619,44 @@ impl<'db> FunctionLiteral<'db> { self.last_definition(db).spans(db) } - #[salsa::tracked(returns(ref), heap_size=ruff_memory_usage::heap_size, cycle_initial=overloads_and_implementation_cycle_initial)] fn overloads_and_implementation( self, db: &'db dyn Db, - ) -> (Box<[OverloadLiteral<'db>]>, Option>) { - let self_overload = self.last_definition(db); - let mut current = self_overload; - let mut overloads = vec![]; + ) -> (&'db [OverloadLiteral<'db>], Option>) { + #[salsa::tracked( + returns(ref), + heap_size=ruff_memory_usage::heap_size, + cycle_initial=overloads_and_implementation_cycle_initial + )] + fn overloads_and_implementation_inner<'db>( + db: &'db dyn Db, + function: FunctionLiteral<'db>, + ) -> (Box<[OverloadLiteral<'db>]>, Option>) { + let self_overload = function.last_definition(db); + let mut current = self_overload; + let mut overloads = vec![]; - while let Some(previous) = current.previous_overload(db) { - let overload = previous.last_definition(db); - overloads.push(overload); - current = overload; + while let Some(previous) = current.previous_overload(db) { + let overload = previous.last_definition(db); + overloads.push(overload); + current = overload; + } + + // Overloads are inserted in reverse order, from bottom to top. + overloads.reverse(); + + let implementation = if self_overload.is_overload(db) { + overloads.push(self_overload); + None + } else { + Some(self_overload) + }; + + (overloads.into_boxed_slice(), implementation) } - // Overloads are inserted in reverse order, from bottom to top. - overloads.reverse(); - - let implementation = if self_overload.is_overload(db) { - overloads.push(self_overload); - None - } else { - Some(self_overload) - }; - - (overloads.into_boxed_slice(), implementation) + let (overloads, implementation) = overloads_and_implementation_inner(db, self); + (overloads.as_ref(), *implementation) } fn iter_overloads_and_implementation( @@ -617,7 +664,7 @@ impl<'db> FunctionLiteral<'db> { db: &'db dyn Db, ) -> impl Iterator> + 'db { let (implementation, overloads) = self.overloads_and_implementation(db); - overloads.iter().chain(implementation).copied() + overloads.into_iter().chain(implementation.iter().copied()) } /// Typed externally-visible signature for this function. @@ -773,7 +820,7 @@ impl<'db> FunctionType<'db> { } /// Returns the AST node for this function. - pub(crate) fn node<'ast>( + pub(super) fn node<'ast>( self, db: &dyn Db, file: File, @@ -892,7 +939,7 @@ impl<'db> FunctionType<'db> { pub(crate) fn overloads_and_implementation( self, db: &'db dyn Db, - ) -> &'db (Box<[OverloadLiteral<'db>]>, Option>) { + ) -> (&'db [OverloadLiteral<'db>], Option>) { self.literal(db).overloads_and_implementation(db) } @@ -905,6 +952,12 @@ impl<'db> FunctionType<'db> { self.literal(db).iter_overloads_and_implementation(db) } + pub(crate) fn first_overload_or_implementation(self, db: &'db dyn Db) -> OverloadLiteral<'db> { + self.iter_overloads_and_implementation(db) + .next() + .expect("A function must have at least one overload/implementation") + } + /// Typed externally-visible signature for this function. /// /// This is the signature as seen by external callers, possibly modified by decorators and/or diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index af98132015..71d4dfec17 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -1044,7 +1044,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { } // Check that the overloaded function has at least two overloads - if let [single_overload] = overloads.as_ref() { + if let [single_overload] = overloads { let function_node = function.node(self.db(), self.file(), self.module()); if let Some(builder) = self .context @@ -1164,7 +1164,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { (FunctionDecorators::OVERRIDE, "override"), ] { if let Some(implementation) = implementation { - for overload in overloads.as_ref() { + for overload in overloads { if !overload.has_known_decorator(self.db(), decorator) { continue; } diff --git a/crates/ty_python_semantic/src/types/liskov.rs b/crates/ty_python_semantic/src/types/liskov.rs index 75b9f11a01..79b79889fc 100644 --- a/crates/ty_python_semantic/src/types/liskov.rs +++ b/crates/ty_python_semantic/src/types/liskov.rs @@ -2,26 +2,32 @@ //! //! [Liskov Substitution Principle]: https://en.wikipedia.org/wiki/Liskov_substitution_principle +use bitflags::bitflags; use ruff_db::diagnostic::Annotation; use rustc_hash::FxHashSet; use crate::{ + Db, + lint::LintId, place::Place, - semantic_index::place_table, + semantic_index::{place_table, scope::ScopeId, symbol::ScopedSymbolId, use_def_map}, types::{ ClassBase, ClassLiteral, ClassType, KnownClass, Type, class::CodeGeneratorKind, context::InferContext, - definition_expression_type, - diagnostic::{INVALID_EXPLICIT_OVERRIDE, report_invalid_method_override}, - function::{FunctionDecorators, KnownFunction}, + diagnostic::{ + INVALID_EXPLICIT_OVERRIDE, INVALID_METHOD_OVERRIDE, OVERRIDE_OF_FINAL_METHOD, + report_invalid_method_override, report_overridden_final_method, + }, + function::{FunctionDecorators, FunctionType, KnownFunction}, ide_support::{MemberWithDefinition, all_declarations_and_bindings}, }, }; pub(super) fn check_class<'db>(context: &InferContext<'db, '_>, class: ClassLiteral<'db>) { let db = context.db(); - if class.is_known(db, KnownClass::Object) { + let configuration = OverrideRulesConfig::from(context); + if configuration.no_rules_enabled() { return; } @@ -30,56 +36,100 @@ pub(super) fn check_class<'db>(context: &InferContext<'db, '_>, class: ClassLite all_declarations_and_bindings(db, class.body_scope(db)).collect(); for member in own_class_members { - check_class_declaration(context, class_specialized, &member); + check_class_declaration(context, configuration, class_specialized, &member); } } fn check_class_declaration<'db>( context: &InferContext<'db, '_>, + configuration: OverrideRulesConfig, class: ClassType<'db>, member: &MemberWithDefinition<'db>, ) { + /// Salsa-tracked query to check whether any of the definitions of a symbol + /// in a superclass scope are function definitions. + /// + /// We need to know this for compatibility with pyright and mypy, neither of which emit an error + /// on `C.f` here: + /// + /// ```python + /// from typing import final + /// + /// class A: + /// @final + /// def f(self) -> None: ... + /// + /// class B: + /// f = A.f + /// + /// class C(B): + /// def f(self) -> None: ... # no error here + /// ``` + /// + /// This is a Salsa-tracked query because it has to look at the AST node for the definition, + /// which might be in a different Python module. If this weren't a tracked query, we could + /// introduce cross-module dependencies and over-invalidation. + #[salsa::tracked(heap_size=ruff_memory_usage::heap_size)] + fn is_function_definition<'db>( + db: &'db dyn Db, + scope: ScopeId<'db>, + symbol: ScopedSymbolId, + ) -> bool { + use_def_map(db, scope) + .end_of_scope_symbol_bindings(symbol) + .filter_map(|binding| binding.binding.definition()) + .any(|definition| definition.kind(db).is_function_def()) + } + + fn extract_underlying_functions<'db>( + db: &'db dyn Db, + ty: Type<'db>, + ) -> Option; 1]>> { + match ty { + Type::FunctionLiteral(function) => Some(smallvec::smallvec_inline![function]), + Type::BoundMethod(method) => Some(smallvec::smallvec_inline![method.function(db)]), + Type::PropertyInstance(property) => { + extract_underlying_functions(db, property.getter(db)?) + } + Type::Union(union) => { + let mut functions = smallvec::smallvec![]; + for member in union.elements(db) { + if let Some(mut member_functions) = extract_underlying_functions(db, *member) { + functions.append(&mut member_functions); + } + } + if functions.is_empty() { + None + } else { + Some(functions) + } + } + _ => None, + } + } + let db = context.db(); let MemberWithDefinition { member, definition } = member; - // TODO: Check Liskov on non-methods too - let Type::FunctionLiteral(function) = member.ty else { - return; - }; - let Some(definition) = definition else { return; }; - // Constructor methods are not checked for Liskov compliance - if matches!( - &*member.name, - "__init__" | "__new__" | "__post_init__" | "__init_subclass__" - ) { - return; - } - - let (literal, specialization) = class.class_literal(db); - let class_kind = CodeGeneratorKind::from_class(db, literal, specialization); - - // Synthesized `__replace__` methods on dataclasses are not checked - if &member.name == "__replace__" - && matches!(class_kind, Some(CodeGeneratorKind::DataclassLike(_))) - { - return; - } - let Place::Defined(type_on_subclass_instance, _, _) = Type::instance(db, class).member(db, &member.name).place else { return; }; + let (literal, specialization) = class.class_literal(db); + let class_kind = CodeGeneratorKind::from_class(db, literal, specialization); + let mut subclass_overrides_superclass_declaration = false; let mut has_dynamic_superclass = false; let mut has_typeddict_in_mro = false; let mut liskov_diagnostic_emitted = false; + let mut overridden_final_method = None; for class_base in class.iter_mro(db).skip(1) { let superclass = match class_base { @@ -96,11 +146,15 @@ fn check_class_declaration<'db>( }; let (superclass_literal, superclass_specialization) = superclass.class_literal(db); - let superclass_symbol_table = place_table(db, superclass_literal.body_scope(db)); + let superclass_scope = superclass_literal.body_scope(db); + let superclass_symbol_table = place_table(db, superclass_scope); + let superclass_symbol_id = superclass_symbol_table.symbol_id(&member.name); + let mut method_kind = MethodKind::default(); // If the member is not defined on the class itself, skip it - if let Some(superclass_symbol) = superclass_symbol_table.symbol_by_name(&member.name) { + if let Some(id) = superclass_symbol_id { + let superclass_symbol = superclass_symbol_table.symbol(id); if !(superclass_symbol.is_bound() || superclass_symbol.is_declared()) { continue; } @@ -119,12 +173,6 @@ fn check_class_declaration<'db>( subclass_overrides_superclass_declaration = true; - // Only one Liskov diagnostic should be emitted per each invalid override, - // even if it overrides multiple superclasses incorrectly! - if liskov_diagnostic_emitted { - continue; - } - let Place::Defined(superclass_type, _, _) = Type::instance(db, superclass) .member(db, &member.name) .place @@ -133,14 +181,74 @@ fn check_class_declaration<'db>( break; }; - let Some(superclass_type_as_callable) = superclass_type - .try_upcast_to_callable(db) - .map(|callables| callables.into_type(db)) - else { + if configuration.check_final_method_overridden() { + overridden_final_method = overridden_final_method.or_else(|| { + let superclass_symbol_id = superclass_symbol_id?; + + // TODO: `@final` should be more like a type qualifier: + // we should also recognise `@final`-decorated methods that don't end up + // as being function- or property-types (because they're wrapped by other + // decorators that transform the type into something else). + let underlying_functions = extract_underlying_functions( + db, + superclass + .own_class_member(db, None, &member.name) + .ignore_possibly_undefined()?, + )?; + + if underlying_functions + .iter() + .any(|function| function.has_known_decorator(db, FunctionDecorators::FINAL)) + && is_function_definition(db, superclass_scope, superclass_symbol_id) + { + Some((superclass, underlying_functions)) + } else { + None + } + }); + } + + // ********************************************************** + // Everything below this point in the loop + // is about Liskov Substitution Principle checks + // ********************************************************** + + // Only one Liskov diagnostic should be emitted per each invalid override, + // even if it overrides multiple superclasses incorrectly! + if liskov_diagnostic_emitted { + continue; + } + + if !configuration.check_method_liskov_violations() { + continue; + } + + // TODO: Check Liskov on non-methods too + let Type::FunctionLiteral(subclass_function) = member.ty else { continue; }; - if type_on_subclass_instance.is_assignable_to(db, superclass_type_as_callable) { + // Constructor methods are not checked for Liskov compliance + if matches!( + &*member.name, + "__init__" | "__new__" | "__post_init__" | "__init_subclass__" + ) { + continue; + } + + // Synthesized `__replace__` methods on dataclasses are not checked + if &member.name == "__replace__" + && matches!(class_kind, Some(CodeGeneratorKind::DataclassLike(_))) + { + continue; + } + + let Some(superclass_type_as_callable) = superclass_type.try_upcast_to_callable(db) else { + continue; + }; + + if type_on_subclass_instance.is_assignable_to(db, superclass_type_as_callable.into_type(db)) + { continue; } @@ -149,7 +257,7 @@ fn check_class_declaration<'db>( &member.name, class, *definition, - function, + subclass_function, superclass, superclass_type, method_kind, @@ -187,13 +295,11 @@ fn check_class_declaration<'db>( && function.has_known_decorator(db, FunctionDecorators::OVERRIDE) { let function_literal = if context.in_stub() { - function - .iter_overloads_and_implementation(db) - .next() - .expect("There should always be at least one overload or implementation") + function.first_overload_or_implementation(db) } else { function.literal(db).last_definition(db) }; + if let Some(builder) = context.report_lint( &INVALID_EXPLICIT_OVERRIDE, function_literal.focus_range(db, context.module()), @@ -202,17 +308,10 @@ fn check_class_declaration<'db>( "Method `{}` is decorated with `@override` but does not override anything", member.name )); - if let Some(decorator) = function_literal - .node(db, context.file(), context.module()) - .decorator_list - .iter() - .find(|decorator| { - definition_expression_type(db, *definition, &decorator.expression) - .as_function_literal() - .is_some_and(|function| function.is_known(db, KnownFunction::Override)) - }) + if let Some(decorator_span) = + function_literal.find_known_decorator_span(db, KnownFunction::Override) { - diagnostic.annotate(Annotation::secondary(context.span(decorator))); + diagnostic.annotate(Annotation::secondary(decorator_span)); } diagnostic.info(format_args!( "No `{member}` definitions were found on any superclasses of `{class}`", @@ -221,6 +320,18 @@ fn check_class_declaration<'db>( )); } } + + if let Some((superclass, superclass_method)) = overridden_final_method { + report_overridden_final_method( + context, + &member.name, + *definition, + type_on_subclass_instance, + superclass, + class, + &superclass_method, + ); + } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] @@ -229,3 +340,48 @@ pub(super) enum MethodKind<'db> { #[default] NotSynthesized, } + +bitflags! { + /// Bitflags representing which override-related rules have been enabled. + #[derive(Default, Debug, Copy, Clone)] + struct OverrideRulesConfig: u8 { + const LISKOV_METHODS = 1 << 0; + const EXPLICIT_OVERRIDE = 1 << 1; + const FINAL_METHOD_OVERRIDDEN = 1 << 2; + } +} + +impl From<&InferContext<'_, '_>> for OverrideRulesConfig { + fn from(value: &InferContext<'_, '_>) -> Self { + let db = value.db(); + let rule_selection = db.rule_selection(value.file()); + + let mut config = OverrideRulesConfig::empty(); + + if rule_selection.is_enabled(LintId::of(&INVALID_METHOD_OVERRIDE)) { + config |= OverrideRulesConfig::LISKOV_METHODS; + } + if rule_selection.is_enabled(LintId::of(&INVALID_EXPLICIT_OVERRIDE)) { + config |= OverrideRulesConfig::EXPLICIT_OVERRIDE; + } + if rule_selection.is_enabled(LintId::of(&OVERRIDE_OF_FINAL_METHOD)) { + config |= OverrideRulesConfig::FINAL_METHOD_OVERRIDDEN; + } + + config + } +} + +impl OverrideRulesConfig { + const fn no_rules_enabled(self) -> bool { + self.is_empty() + } + + const fn check_method_liskov_violations(self) -> bool { + self.contains(OverrideRulesConfig::LISKOV_METHODS) + } + + const fn check_final_method_overridden(self) -> bool { + self.contains(OverrideRulesConfig::FINAL_METHOD_OVERRIDDEN) + } +} diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__commands__debug_command.snap b/crates/ty_server/tests/e2e/snapshots/e2e__commands__debug_command.snap index 0676f15fd7..5505fbd5f2 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__commands__debug_command.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__commands__debug_command.snap @@ -83,6 +83,7 @@ Settings: Settings { "no-matching-overload": Error (Default), "non-subscriptable": Error (Default), "not-iterable": Error (Default), + "override-of-final-method": Error (Default), "parameter-already-assigned": Error (Default), "positional-only-parameter-as-kwarg": Error (Default), "possibly-missing-attribute": Warning (Default), diff --git a/ty.schema.json b/ty.schema.json index 919b0e8dfc..8a19ce44cf 100644 --- a/ty.schema.json +++ b/ty.schema.json @@ -863,6 +863,16 @@ } ] }, + "override-of-final-method": { + "title": "detects subclasses of final classes", + "description": "## What it does\nChecks for methods on subclasses that override superclass methods decorated with `@final`.\n\n## Why is this bad?\nDecorating a method with `@final` declares to the type checker that it should not be\noverridden on any subclass.\n\n## Example\n\n```python\nfrom typing import final\n\nclass A:\n @final\n def foo(self): ...\n\nclass B(A):\n def foo(self): ... # Error raised here\n```", + "default": "error", + "oneOf": [ + { + "$ref": "#/definitions/Level" + } + ] + }, "parameter-already-assigned": { "title": "detects multiple arguments for the same parameter", "description": "## What it does\nChecks for calls which provide more than one argument for a single parameter.\n\n## Why is this bad?\nProviding multiple values for a single parameter will raise a `TypeError` at runtime.\n\n## Examples\n\n```python\ndef f(x: int) -> int: ...\n\nf(1, x=2) # Error raised here\n```", From 566c959add8c5aa5d25fd14db513c792e4048b50 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Fri, 28 Nov 2025 16:23:29 +0100 Subject: [PATCH 19/67] [ty] Rename `ReferenceRequestHandler` file (#21680) --- ...{goto_references.rs => find_references.rs} | 46 +++++++++---------- crates/ty_ide/src/lib.rs | 4 +- crates/ty_server/src/server/api/requests.rs | 4 +- .../{goto_references.rs => references.rs} | 4 +- crates/ty_wasm/src/lib.rs | 6 +-- 5 files changed, 32 insertions(+), 32 deletions(-) rename crates/ty_ide/src/{goto_references.rs => find_references.rs} (98%) rename crates/ty_server/src/server/api/requests/{goto_references.rs => references.rs} (95%) diff --git a/crates/ty_ide/src/goto_references.rs b/crates/ty_ide/src/find_references.rs similarity index 98% rename from crates/ty_ide/src/goto_references.rs rename to crates/ty_ide/src/find_references.rs index 514ebfc75b..856e1b8b2c 100644 --- a/crates/ty_ide/src/goto_references.rs +++ b/crates/ty_ide/src/find_references.rs @@ -7,7 +7,7 @@ use ty_python_semantic::SemanticModel; /// Find all references to a symbol at the given position. /// Search for references across all files in the project. -pub fn goto_references( +pub fn find_references( db: &dyn Db, file: File, offset: TextSize, @@ -41,7 +41,7 @@ mod tests { impl CursorTest { fn references(&self) -> String { let Some(mut reference_results) = - goto_references(&self.db, self.cursor.file, self.cursor.offset, true) + find_references(&self.db, self.cursor.file, self.cursor.offset, true) else { return "No references found".to_string(); }; @@ -84,7 +84,7 @@ mod tests { } #[test] - fn test_parameter_references_in_function() { + fn parameter_references_in_function() { let test = cursor_test( " def calculate_sum(value: int) -> int: @@ -149,28 +149,28 @@ result = calculate_sum(value=42) } #[test] - fn test_nonlocal_variable_references() { + fn nonlocal_variable_references() { let test = cursor_test( " def outer_function(): counter = 0 - + def increment(): nonlocal counter counter += 1 return counter - + def decrement(): nonlocal counter counter -= 1 return counter - + # Use counter in outer scope initial = counter increment() decrement() final = counter - + return increment, decrement ", ); @@ -272,7 +272,7 @@ def outer_function(): } #[test] - fn test_global_variable_references() { + fn global_variable_references() { let test = cursor_test( " global_counter = 0 @@ -389,7 +389,7 @@ final_value = global_counter } #[test] - fn test_except_handler_variable_references() { + fn except_handler_variable_references() { let test = cursor_test( " try: @@ -450,7 +450,7 @@ except ValueError as err: } #[test] - fn test_pattern_match_as_references() { + fn pattern_match_as_references() { let test = cursor_test( " match x: @@ -498,7 +498,7 @@ match x: } #[test] - fn test_pattern_match_mapping_rest_references() { + fn pattern_match_mapping_rest_references() { let test = cursor_test( " match data: @@ -553,7 +553,7 @@ match data: } #[test] - fn test_function_definition_references() { + fn function_definition_references() { let test = cursor_test( " def my_function(): @@ -632,7 +632,7 @@ value = my_function } #[test] - fn test_class_definition_references() { + fn class_definition_references() { let test = cursor_test( " class MyClass: @@ -1105,7 +1105,7 @@ cls = MyClass def __init__(self, pos, btn): self.position: int = pos self.button: str = btn - + def my_func(event: Click): match event: case Click(x, button=ab): @@ -1144,7 +1144,7 @@ cls = MyClass def __init__(self, pos, btn): self.position: int = pos self.button: str = btn - + def my_func(event: Click): match event: case Click(x, button=ab): @@ -1183,7 +1183,7 @@ cls = MyClass def __init__(self, pos, btn): self.position: int = pos self.button: str = btn - + def my_func(event: Click): match event: case Click(x, button=ab): @@ -1233,7 +1233,7 @@ cls = MyClass def __init__(self, pos, btn): self.position: int = pos self.button: str = btn - + def my_func(event: Click): match event: case Click(x, button=ab): @@ -1445,7 +1445,7 @@ cls = MyClass } #[test] - fn test_multi_file_function_references() { + fn multi_file_function_references() { let test = CursorTest::builder() .source( "utils.py", @@ -1471,7 +1471,7 @@ from utils import func class DataProcessor: def __init__(self): self.multiplier = func - + def process(self, value): return func(value) ", @@ -1535,14 +1535,14 @@ class DataProcessor: } #[test] - fn test_multi_file_class_attribute_references() { + fn multi_file_class_attribute_references() { let test = CursorTest::builder() .source( "models.py", " class MyModel: attr = 42 - + def get_attribute(self): return MyModel.attr ", @@ -1613,7 +1613,7 @@ def process_model(): } #[test] - fn test_import_alias_references_should_not_resolve_to_original() { + fn import_alias_references_should_not_resolve_to_original() { let test = CursorTest::builder() .source( "original.py", diff --git a/crates/ty_ide/src/lib.rs b/crates/ty_ide/src/lib.rs index 28e2eddc03..28989dcf8f 100644 --- a/crates/ty_ide/src/lib.rs +++ b/crates/ty_ide/src/lib.rs @@ -9,10 +9,10 @@ mod doc_highlights; mod docstring; mod document_symbols; mod find_node; +mod find_references; mod goto; mod goto_declaration; mod goto_definition; -mod goto_references; mod goto_type_definition; mod hover; mod importer; @@ -32,8 +32,8 @@ pub use code_action::{QuickFix, code_actions}; pub use completion::{Completion, CompletionKind, CompletionSettings, completion}; pub use doc_highlights::document_highlights; pub use document_symbols::document_symbols; +pub use find_references::find_references; pub use goto::{goto_declaration, goto_definition, goto_type_definition}; -pub use goto_references::goto_references; pub use hover::hover; pub use inlay_hints::{ InlayHintKind, InlayHintLabel, InlayHintSettings, InlayHintTextEdit, inlay_hints, diff --git a/crates/ty_server/src/server/api/requests.rs b/crates/ty_server/src/server/api/requests.rs index 355b0fd859..52d94f8bbf 100644 --- a/crates/ty_server/src/server/api/requests.rs +++ b/crates/ty_server/src/server/api/requests.rs @@ -6,11 +6,11 @@ mod document_symbols; mod execute_command; mod goto_declaration; mod goto_definition; -mod goto_references; mod goto_type_definition; mod hover; mod inlay_hints; mod prepare_rename; +mod references; mod rename; mod selection_range; mod semantic_tokens; @@ -28,11 +28,11 @@ pub(super) use document_symbols::DocumentSymbolRequestHandler; pub(super) use execute_command::ExecuteCommand; pub(super) use goto_declaration::GotoDeclarationRequestHandler; pub(super) use goto_definition::GotoDefinitionRequestHandler; -pub(super) use goto_references::ReferencesRequestHandler; pub(super) use goto_type_definition::GotoTypeDefinitionRequestHandler; pub(super) use hover::HoverRequestHandler; pub(super) use inlay_hints::InlayHintRequestHandler; pub(super) use prepare_rename::PrepareRenameRequestHandler; +pub(super) use references::ReferencesRequestHandler; pub(super) use rename::RenameRequestHandler; pub(super) use selection_range::SelectionRangeRequestHandler; pub(super) use semantic_tokens::SemanticTokensRequestHandler; diff --git a/crates/ty_server/src/server/api/requests/goto_references.rs b/crates/ty_server/src/server/api/requests/references.rs similarity index 95% rename from crates/ty_server/src/server/api/requests/goto_references.rs rename to crates/ty_server/src/server/api/requests/references.rs index 1a7ca7a98d..c8d0ae5ae1 100644 --- a/crates/ty_server/src/server/api/requests/goto_references.rs +++ b/crates/ty_server/src/server/api/requests/references.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use lsp_types::request::References; use lsp_types::{Location, ReferenceParams, Url}; -use ty_ide::goto_references; +use ty_ide::find_references; use ty_project::ProjectDatabase; use crate::document::{PositionExt, ToLink}; @@ -51,7 +51,7 @@ impl BackgroundDocumentRequestHandler for ReferencesRequestHandler { let include_declaration = params.context.include_declaration; - let Some(references_result) = goto_references(db, file, offset, include_declaration) else { + let Some(references_result) = find_references(db, file, offset, include_declaration) else { return Ok(None); }; diff --git a/crates/ty_wasm/src/lib.rs b/crates/ty_wasm/src/lib.rs index 1930ba9399..daa1f63a21 100644 --- a/crates/ty_wasm/src/lib.rs +++ b/crates/ty_wasm/src/lib.rs @@ -17,8 +17,8 @@ use ruff_python_formatter::formatted_file; use ruff_source_file::{LineIndex, OneIndexed, SourceLocation}; use ruff_text_size::{Ranged, TextSize}; use ty_ide::{ - InlayHintSettings, MarkupKind, RangedValue, document_highlights, goto_declaration, - goto_definition, goto_references, goto_type_definition, hover, inlay_hints, + InlayHintSettings, MarkupKind, RangedValue, document_highlights, find_references, + goto_declaration, goto_definition, goto_type_definition, hover, inlay_hints, }; use ty_ide::{NavigationTarget, NavigationTargets, signature_help}; use ty_project::metadata::options::Options; @@ -351,7 +351,7 @@ impl Workspace { let offset = position.to_text_size(&source, &index, self.position_encoding)?; - let Some(targets) = goto_references(&self.db, file_id.file, offset, true) else { + let Some(targets) = find_references(&self.db, file_id.file, offset, true) else { return Ok(Vec::new()); }; From 0084e94f78742685ddacf2dab28530c2ece3393e Mon Sep 17 00:00:00 2001 From: David Peter Date: Fri, 28 Nov 2025 16:56:22 +0100 Subject: [PATCH 20/67] [ty] Fix subtyping of `type[Any]` / `type[T]` and protocols (#21678) ## Summary This is a bugfix for subtyping of `type[Any]` / `type[T]` and protocols. ## Test Plan Regression test that will only be really meaningful once https://github.com/astral-sh/ruff/pull/21553 lands. --- .../resources/mdtest/libraries/numpy.md | 67 +++++++++++++++++++ crates/ty_python_semantic/src/types.rs | 20 ++++++ 2 files changed, 87 insertions(+) create mode 100644 crates/ty_python_semantic/resources/mdtest/libraries/numpy.md diff --git a/crates/ty_python_semantic/resources/mdtest/libraries/numpy.md b/crates/ty_python_semantic/resources/mdtest/libraries/numpy.md new file mode 100644 index 0000000000..d1afd367ca --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/libraries/numpy.md @@ -0,0 +1,67 @@ +# numpy + +```toml +[environment] +python-version = "3.14" +``` + +## numpy's `dtype` + +numpy functions often accept a `dtype` parameter. For example, one of `np.array`'s overloads accepts +a `dtype` parameter of type `DTypeLike | None`. Here, we build up something that resembles numpy's +internals in order to model the type `DTypeLike`. Many details have been left out. + +`mini_numpy.py`: + +```py +from typing import TypeVar, Generic, Any, Protocol, TypeAlias, runtime_checkable, final +import builtins + +_ItemT_co = TypeVar("_ItemT_co", default=Any, covariant=True) + +class generic(Generic[_ItemT_co]): + @property + def dtype(self) -> _DTypeT_co: + raise NotImplementedError + +_BoolItemT_co = TypeVar("_BoolItemT_co", bound=builtins.bool, default=builtins.bool, covariant=True) + +class bool(generic[_BoolItemT_co], Generic[_BoolItemT_co]): ... + +@final +class object_(generic): ... + +_ScalarT = TypeVar("_ScalarT", bound=generic) +_ScalarT_co = TypeVar("_ScalarT_co", bound=generic, default=Any, covariant=True) + +@final +class dtype(Generic[_ScalarT_co]): ... + +_DTypeT_co = TypeVar("_DTypeT_co", bound=dtype, default=dtype, covariant=True) + +@runtime_checkable +class _SupportsDType(Protocol[_DTypeT_co]): + @property + def dtype(self) -> _DTypeT_co: ... + +# TODO: no errors here +# error: [invalid-type-arguments] "Type `typing.TypeVar` is not assignable to upper bound `generic[Any]` of type variable `_ScalarT_co@dtype`" +# error: [invalid-type-arguments] "Type `typing.TypeVar` is not assignable to upper bound `generic[Any]` of type variable `_ScalarT_co@dtype`" +_DTypeLike: TypeAlias = type[_ScalarT] | dtype[_ScalarT] | _SupportsDType[dtype[_ScalarT]] + +DTypeLike: TypeAlias = _DTypeLike[Any] | str | None +``` + +Now we can make sure that a function which accepts `DTypeLike | None` works as expected: + +```py +import mini_numpy as np + +def accepts_dtype(dtype: np.DTypeLike | None) -> None: ... + +accepts_dtype(dtype=np.bool) +accepts_dtype(dtype=np.dtype[np.bool]) +accepts_dtype(dtype=object) +accepts_dtype(dtype=np.object_) +accepts_dtype(dtype="U") +``` diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 2b509ce6dc..94ff50f161 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -2468,6 +2468,26 @@ impl<'db> Type<'db> { }) } + // `type[Any]` is assignable to arbitrary protocols as it has arbitrary attributes + // (this is handled by a lower-down branch), but it is only a subtype of a given + // protocol if `type` is a subtype of that protocol. Similarly, `type[T]` will + // always be assignable to any protocol if `type[]` is assignable + // to that protocol (handled lower down), but it is only a subtype of that protocol + // if `type` is a subtype of that protocol. + (Type::SubclassOf(self_subclass_ty), Type::ProtocolInstance(_)) + if (self_subclass_ty.is_dynamic() || self_subclass_ty.is_type_var()) + && !relation.is_assignability() => + { + KnownClass::Type.to_instance(db).has_relation_to_impl( + db, + target, + inferable, + relation, + relation_visitor, + disjointness_visitor, + ) + } + (_, Type::ProtocolInstance(protocol)) => { relation_visitor.visit((self, target, relation), || { self.satisfies_protocol( From b5b4917d7f4a324f5d32cc55dfb1d08e75cc9e6f Mon Sep 17 00:00:00 2001 From: Matthew Mckee Date: Fri, 28 Nov 2025 16:18:22 +0000 Subject: [PATCH 21/67] [ty] Fix override of final method summary (#21681) --- crates/ty_python_semantic/src/types/diagnostic.rs | 2 +- ty.schema.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index e3bc4d755d..1266e62ef2 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -1636,7 +1636,7 @@ declare_lint! { /// def foo(self): ... # Error raised here /// ``` pub(crate) static OVERRIDE_OF_FINAL_METHOD = { - summary: "detects subclasses of final classes", + summary: "detects overrides of final methods", status: LintStatus::stable("0.0.1-alpha.29"), default_level: Level::Error, } diff --git a/ty.schema.json b/ty.schema.json index 8a19ce44cf..38d5fd1326 100644 --- a/ty.schema.json +++ b/ty.schema.json @@ -864,7 +864,7 @@ ] }, "override-of-final-method": { - "title": "detects subclasses of final classes", + "title": "detects overrides of final methods", "description": "## What it does\nChecks for methods on subclasses that override superclass methods decorated with `@final`.\n\n## Why is this bad?\nDecorating a method with `@final` declares to the type checker that it should not be\noverridden on any subclass.\n\n## Example\n\n```python\nfrom typing import final\n\nclass A:\n @final\n def foo(self): ...\n\nclass B(A):\n def foo(self): ... # Error raised here\n```", "default": "error", "oneOf": [ From 594b7b04d3b04bcf42861f86207017c8117678ca Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 28 Nov 2025 18:40:34 +0000 Subject: [PATCH 22/67] [ty] Preserve quoting style when autofixing `TypedDict` keys (#21682) --- ...ict`_-_Diagnostics_(e5289abf5c570c29).snap | 26 +++++++++++++++++++ .../resources/mdtest/typed_dict.md | 8 ++++++ .../src/types/diagnostic.rs | 12 ++++++--- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/typed_dict.md_-_`TypedDict`_-_Diagnostics_(e5289abf5c570c29).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/typed_dict.md_-_`TypedDict`_-_Diagnostics_(e5289abf5c570c29).snap index 0fc0bbd2a6..1f70b8acd3 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/typed_dict.md_-_`TypedDict`_-_Diagnostics_(e5289abf5c570c29).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/typed_dict.md_-_`TypedDict`_-_Diagnostics_(e5289abf5c570c29).snap @@ -52,6 +52,9 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/typed_dict.md 38 | 39 | def write_to_readonly_key(employee: Employee): 40 | employee["id"] = 42 # error: [invalid-assignment] +41 | def write_to_non_existing_key_single_quotes(person: Person): +42 | # error: [invalid-key] +43 | person['naem'] = "Alice" # fmt: skip ``` # Diagnostics @@ -217,6 +220,8 @@ error[invalid-assignment]: Cannot assign to key "id" on TypedDict `Employee` | -------- ^^^^ key is marked read-only | | | TypedDict `Employee` +41 | def write_to_non_existing_key_single_quotes(person: Person): +42 | # error: [invalid-key] | info: Item declaration --> src/mdtest_snippet.py:36:5 @@ -229,3 +234,24 @@ info: Item declaration info: rule `invalid-assignment` is enabled by default ``` + +``` +error[invalid-key]: Unknown key "naem" for TypedDict `Person` + --> src/mdtest_snippet.py:43:5 + | +41 | def write_to_non_existing_key_single_quotes(person: Person): +42 | # error: [invalid-key] +43 | person['naem'] = "Alice" # fmt: skip + | ------ ^^^^^^ Did you mean 'name'? + | | + | TypedDict `Person` + | +info: rule `invalid-key` is enabled by default +40 | employee["id"] = 42 # error: [invalid-assignment] +41 | def write_to_non_existing_key_single_quotes(person: Person): +42 | # error: [invalid-key] + - person['naem'] = "Alice" # fmt: skip +43 + person['name'] = "Alice" # fmt: skip +note: This is an unsafe fix and may change runtime behavior + +``` diff --git a/crates/ty_python_semantic/resources/mdtest/typed_dict.md b/crates/ty_python_semantic/resources/mdtest/typed_dict.md index c843150d41..aadf8249ae 100644 --- a/crates/ty_python_semantic/resources/mdtest/typed_dict.md +++ b/crates/ty_python_semantic/resources/mdtest/typed_dict.md @@ -1502,6 +1502,14 @@ def write_to_readonly_key(employee: Employee): employee["id"] = 42 # error: [invalid-assignment] ``` +If the key uses single quotes, the autofix preserves that quoting style: + +```py +def write_to_non_existing_key_single_quotes(person: Person): + # error: [invalid-key] + person['naem'] = "Alice" # fmt: skip +``` + ## Import aliases `TypedDict` can be imported with aliases and should work correctly: diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index 1266e62ef2..660af238bb 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -40,7 +40,7 @@ use ruff_db::{ use ruff_diagnostics::{Edit, Fix}; use ruff_python_ast::name::Name; use ruff_python_ast::parenthesize::parentheses_iterator; -use ruff_python_ast::{self as ast, AnyNodeRef}; +use ruff_python_ast::{self as ast, AnyNodeRef, StringFlags}; use ruff_python_trivia::CommentRanges; use ruff_text_size::{Ranged, TextRange}; use rustc_hash::FxHashSet; @@ -3456,11 +3456,15 @@ pub(crate) fn report_invalid_key_on_typed_dict<'db>( let existing_keys = items.keys(); if let Some(suggestion) = did_you_mean(existing_keys, key) { - if key_node.is_expr_string_literal() { + if let AnyNodeRef::ExprStringLiteral(literal) = key_node { + let quoted_suggestion = format!( + "{quote}{suggestion}{quote}", + quote = literal.value.first_literal_flags().quote_str() + ); diagnostic - .set_primary_message(format_args!("Did you mean \"{suggestion}\"?")); + .set_primary_message(format_args!("Did you mean {quoted_suggestion}?")); diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement( - format!("\"{suggestion}\""), + quoted_suggestion, key_node.range(), ))); } else { From 42f152108aad444b7d65359aea931be4dd15dffd Mon Sep 17 00:00:00 2001 From: David Peter Date: Fri, 28 Nov 2025 20:38:24 +0100 Subject: [PATCH 23/67] [ty] Generic types aliases (implicit and PEP 613) (#21553) ## Summary Add support for generic PEP 613 type aliases and generic implicit type aliases: ```py from typing import TypeVar T = TypeVar("T") ListOrSet = list[T] | set[T] def _(xs: ListOrSet[int]): reveal_type(xs) # list[int] | set[int] ``` closes https://github.com/astral-sh/ty/issues/1643 closes https://github.com/astral-sh/ty/issues/1629 closes https://github.com/astral-sh/ty/issues/1596 closes https://github.com/astral-sh/ty/issues/573 closes https://github.com/astral-sh/ty/issues/221 ## Typing conformance ```diff -aliases_explicit.py:52:5: error[type-assertion-failure] Type `list[int]` does not match asserted type `@Todo(specialized generic alias in type expression)` -aliases_explicit.py:53:5: error[type-assertion-failure] Type `tuple[str, ...] | list[str]` does not match asserted type `@Todo(Generic specialization of types.UnionType)` -aliases_explicit.py:54:5: error[type-assertion-failure] Type `tuple[int, int, int, str]` does not match asserted type `@Todo(specialized generic alias in type expression)` -aliases_explicit.py:56:5: error[type-assertion-failure] Type `(int, str, /) -> str` does not match asserted type `@Todo(Generic specialization of typing.Callable)` -aliases_explicit.py:59:5: error[type-assertion-failure] Type `int | str | None | list[list[int]]` does not match asserted type `int | str | None | list[@Todo(specialized generic alias in type expression)]` ``` New true negatives :heavy_check_mark: ```diff +aliases_explicit.py:41:36: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 -aliases_explicit.py:57:5: error[type-assertion-failure] Type `(int, str, str, /) -> None` does not match asserted type `@Todo(Generic specialization of typing.Callable)` +aliases_explicit.py:57:5: error[type-assertion-failure] Type `(int, str, str, /) -> None` does not match asserted type `(...) -> Unknown` ``` These require `ParamSpec` ```diff +aliases_explicit.py:67:24: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 +aliases_explicit.py:68:24: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 +aliases_explicit.py:69:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +aliases_explicit.py:70:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +aliases_explicit.py:71:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +aliases_explicit.py:102:20: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 ``` New true positives :heavy_check_mark: ```diff -aliases_implicit.py:63:5: error[type-assertion-failure] Type `list[int]` does not match asserted type `@Todo(specialized generic alias in type expression)` -aliases_implicit.py:64:5: error[type-assertion-failure] Type `tuple[str, ...] | list[str]` does not match asserted type `@Todo(Generic specialization of types.UnionType)` -aliases_implicit.py:65:5: error[type-assertion-failure] Type `tuple[int, int, int, str]` does not match asserted type `@Todo(specialized generic alias in type expression)` -aliases_implicit.py:67:5: error[type-assertion-failure] Type `(int, str, /) -> str` does not match asserted type `@Todo(Generic specialization of typing.Callable)` -aliases_implicit.py:70:5: error[type-assertion-failure] Type `int | str | None | list[list[int]]` does not match asserted type `int | str | None | list[@Todo(specialized generic alias in type expression)]` -aliases_implicit.py:71:5: error[type-assertion-failure] Type `list[bool]` does not match asserted type `@Todo(specialized generic alias in type expression)` ``` New true negatives :heavy_check_mark: ```diff +aliases_implicit.py:54:36: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 -aliases_implicit.py:68:5: error[type-assertion-failure] Type `(int, str, str, /) -> None` does not match asserted type `@Todo(Generic specialization of typing.Callable)` +aliases_implicit.py:68:5: error[type-assertion-failure] Type `(int, str, str, /) -> None` does not match asserted type `(...) -> Unknown` ``` These require `ParamSpec` ```diff +aliases_implicit.py:76:24: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 +aliases_implicit.py:77:24: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 +aliases_implicit.py:78:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +aliases_implicit.py:79:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +aliases_implicit.py:80:29: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +aliases_implicit.py:81:25: error[invalid-type-arguments] Type `str` is not assignable to upper bound `int | float` of type variable `TFloat@GoodTypeAlias12` +aliases_implicit.py:135:20: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 ``` New true positives :heavy_check_mark: ```diff +callables_annotation.py:172:19: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 +callables_annotation.py:175:19: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 +callables_annotation.py:188:25: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 +callables_annotation.py:189:25: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 ``` These require `ParamSpec` and `Concatenate`. ```diff -generics_defaults_specialization.py:26:5: error[type-assertion-failure] Type `SomethingWithNoDefaults[int, str]` does not match asserted type `SomethingWithNoDefaults[int, typing.TypeVar]` +generics_defaults_specialization.py:26:5: error[type-assertion-failure] Type `SomethingWithNoDefaults[int, str]` does not match asserted type `SomethingWithNoDefaults[int, DefaultStrT]` ``` Favorable diagnostic change :heavy_check_mark: ```diff -generics_defaults_specialization.py:27:5: error[type-assertion-failure] Type `SomethingWithNoDefaults[int, bool]` does not match asserted type `@Todo(specialized generic alias in type expression)` ``` New true negative :heavy_check_mark: ```diff -generics_defaults_specialization.py:30:1: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method +generics_defaults_specialization.py:30:15: error[invalid-type-arguments] Too many type arguments: expected between 0 and 1, got 2 ``` Correct new diagnostic :heavy_check_mark: ```diff -generics_variance.py:175:25: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:175:35: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:179:29: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:179:39: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:183:21: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:183:27: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:187:25: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:187:31: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:191:33: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:191:43: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:191:49: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:196:5: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:196:15: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method -generics_variance.py:196:25: error[non-subscriptable] Cannot subscript object of type `` with no `__class_getitem__` method ``` One of these should apparently be an error, but not of this kind, so this is good :heavy_check_mark: ```diff -specialtypes_type.py:152:16: error[invalid-type-form] `typing.TypeVar` is not a generic class -specialtypes_type.py:156:16: error[invalid-type-form] `typing.TypeVar` is not a generic class ``` Good, those were false positives. :heavy_check_mark: I skipped the analysis for everything involving `TypeVarTuple`. ## Ecosystem impact **[Full report with detailed diff](https://david-generic-implicit-alias.ecosystem-663.pages.dev/diff)** Previous iterations of this PR showed all kinds of problems. In it's current state, I do not see any large systematic problems, but it is hard to tell with 5k diagnostic changes. ## Performance * There is a huge 4x regression in `colour-science/colour`, related to [this large file](https://github.com/colour-science/colour/blob/develop/colour/io/luts/tests/test_lut.py) with [many assignments of hard-coded arrays (lists of lists) to `np.NDArray` types](https://github.com/colour-science/colour/blob/83e754c8b6932532f246b9fe1727d14f3600cd83/colour/io/luts/tests/test_lut.py#L701-L781) that we now understand. We now take ~2 seconds to check this file, so definitely not great, but maybe acceptable for now. ## Test Plan Updated and new Markdown tests --- crates/ruff_benchmark/benches/ty_walltime.rs | 2 +- .../resources/mdtest/async.md | 8 +- .../resources/mdtest/implicit_type_aliases.md | 409 ++++++++++++++---- .../resources/mdtest/libraries/numpy.md | 3 - .../resources/mdtest/pep613_type_aliases.md | 44 +- .../src/semantic_index/definition.rs | 6 + crates/ty_python_semantic/src/types.rs | 129 +++++- .../src/types/infer/builder.rs | 65 ++- .../types/infer/builder/type_expression.rs | 124 ++++-- crates/ty_python_semantic/src/types/narrow.rs | 2 +- 10 files changed, 652 insertions(+), 140 deletions(-) diff --git a/crates/ruff_benchmark/benches/ty_walltime.rs b/crates/ruff_benchmark/benches/ty_walltime.rs index 6c8e89de0c..9f29b193a5 100644 --- a/crates/ruff_benchmark/benches/ty_walltime.rs +++ b/crates/ruff_benchmark/benches/ty_walltime.rs @@ -120,7 +120,7 @@ static COLOUR_SCIENCE: Benchmark = Benchmark::new( max_dep_date: "2025-06-17", python_version: PythonVersion::PY310, }, - 600, + 1070, ); static FREQTRADE: Benchmark = Benchmark::new( diff --git a/crates/ty_python_semantic/resources/mdtest/async.md b/crates/ty_python_semantic/resources/mdtest/async.md index 0d57f4d8f8..416c88b09c 100644 --- a/crates/ty_python_semantic/resources/mdtest/async.md +++ b/crates/ty_python_semantic/resources/mdtest/async.md @@ -61,8 +61,7 @@ async def main(): result = await task - # TODO: this should be `int` - reveal_type(result) # revealed: Unknown + reveal_type(result) # revealed: int ``` ### `asyncio.gather` @@ -79,9 +78,8 @@ async def main(): task("B"), ) - # TODO: these should be `int` - reveal_type(a) # revealed: Unknown - reveal_type(b) # revealed: Unknown + reveal_type(a) # revealed: int + reveal_type(b) # revealed: int ``` ## Under the hood diff --git a/crates/ty_python_semantic/resources/mdtest/implicit_type_aliases.md b/crates/ty_python_semantic/resources/mdtest/implicit_type_aliases.md index 4b28f150bc..8207d55bcc 100644 --- a/crates/ty_python_semantic/resources/mdtest/implicit_type_aliases.md +++ b/crates/ty_python_semantic/resources/mdtest/implicit_type_aliases.md @@ -191,13 +191,13 @@ def _( reveal_type(int_or_callable) # revealed: int | ((str, /) -> bytes) reveal_type(callable_or_int) # revealed: ((str, /) -> bytes) | int # TODO should be Unknown | int - reveal_type(type_var_or_int) # revealed: typing.TypeVar | int + reveal_type(type_var_or_int) # revealed: T@TypeVarOrInt | int # TODO should be int | Unknown - reveal_type(int_or_type_var) # revealed: int | typing.TypeVar + reveal_type(int_or_type_var) # revealed: int | T@IntOrTypeVar # TODO should be Unknown | None - reveal_type(type_var_or_none) # revealed: typing.TypeVar | None + reveal_type(type_var_or_none) # revealed: T@TypeVarOrNone | None # TODO should be None | Unknown - reveal_type(none_or_type_var) # revealed: None | typing.TypeVar + reveal_type(none_or_type_var) # revealed: None | T@NoneOrTypeVar ``` If a type is unioned with itself in a value expression, the result is just that type. No @@ -366,7 +366,9 @@ def g(obj: Y): reveal_type(obj) # revealed: list[int | str] ``` -## Generic types +## Generic implicit type aliases + +### Functionality Implicit type aliases can also be generic: @@ -388,73 +390,62 @@ ListOrTuple = list[T] | tuple[T, ...] ListOrTupleLegacy = Union[list[T], tuple[T, ...]] MyCallable = Callable[P, T] AnnotatedType = Annotated[T, "tag"] +TransparentAlias = T +MyOptional = T | None -# TODO: Consider displaying this as ``, … instead? (and similar for some others below) -reveal_type(MyList) # revealed: -reveal_type(MyDict) # revealed: +reveal_type(MyList) # revealed: +reveal_type(MyDict) # revealed: reveal_type(MyType) # revealed: GenericAlias -reveal_type(IntAndType) # revealed: -reveal_type(Pair) # revealed: -reveal_type(Sum) # revealed: +reveal_type(IntAndType) # revealed: +reveal_type(Pair) # revealed: +reveal_type(Sum) # revealed: reveal_type(ListOrTuple) # revealed: types.UnionType reveal_type(ListOrTupleLegacy) # revealed: types.UnionType -reveal_type(MyCallable) # revealed: GenericAlias +reveal_type(MyCallable) # revealed: @Todo(Callable[..] specialized with ParamSpec) reveal_type(AnnotatedType) # revealed: +reveal_type(TransparentAlias) # revealed: typing.TypeVar +reveal_type(MyOptional) # revealed: types.UnionType def _( list_of_ints: MyList[int], dict_str_to_int: MyDict[str, int], - # TODO: no error here - # error: [invalid-type-form] "`typing.TypeVar` is not a generic class" subclass_of_int: MyType[int], int_and_str: IntAndType[str], pair_of_ints: Pair[int], int_and_bytes: Sum[int, bytes], list_or_tuple: ListOrTuple[int], list_or_tuple_legacy: ListOrTupleLegacy[int], - # TODO: no error here - # error: [invalid-type-form] "List literals are not allowed in this context in a type expression: Did you mean `tuple[str, bytes]`?" my_callable: MyCallable[[str, bytes], int], annotated_int: AnnotatedType[int], + transparent_alias: TransparentAlias[int], + optional_int: MyOptional[int], ): - # TODO: This should be `list[int]` - reveal_type(list_of_ints) # revealed: @Todo(specialized generic alias in type expression) - # TODO: This should be `dict[str, int]` - reveal_type(dict_str_to_int) # revealed: @Todo(specialized generic alias in type expression) - # TODO: This should be `type[int]` - reveal_type(subclass_of_int) # revealed: Unknown - # TODO: This should be `tuple[int, str]` - reveal_type(int_and_str) # revealed: @Todo(specialized generic alias in type expression) - # TODO: This should be `tuple[int, int]` - reveal_type(pair_of_ints) # revealed: @Todo(specialized generic alias in type expression) - # TODO: This should be `tuple[int, bytes]` - reveal_type(int_and_bytes) # revealed: @Todo(specialized generic alias in type expression) - # TODO: This should be `list[int] | tuple[int, ...]` - reveal_type(list_or_tuple) # revealed: @Todo(Generic specialization of types.UnionType) - # TODO: This should be `list[int] | tuple[int, ...]` - reveal_type(list_or_tuple_legacy) # revealed: @Todo(Generic specialization of types.UnionType) + reveal_type(list_of_ints) # revealed: list[int] + reveal_type(dict_str_to_int) # revealed: dict[str, int] + reveal_type(subclass_of_int) # revealed: type[int] + reveal_type(int_and_str) # revealed: tuple[int, str] + reveal_type(pair_of_ints) # revealed: tuple[int, int] + reveal_type(int_and_bytes) # revealed: tuple[int, bytes] + reveal_type(list_or_tuple) # revealed: list[int] | tuple[int, ...] + reveal_type(list_or_tuple_legacy) # revealed: list[int] | tuple[int, ...] # TODO: This should be `(str, bytes) -> int` - reveal_type(my_callable) # revealed: @Todo(Generic specialization of typing.Callable) - # TODO: This should be `int` - reveal_type(annotated_int) # revealed: @Todo(Generic specialization of typing.Annotated) + reveal_type(my_callable) # revealed: @Todo(Callable[..] specialized with ParamSpec) + reveal_type(annotated_int) # revealed: int + reveal_type(transparent_alias) # revealed: int + reveal_type(optional_int) # revealed: int | None ``` Generic implicit type aliases can be partially specialized: ```py -U = TypeVar("U") - DictStrTo = MyDict[str, U] -reveal_type(DictStrTo) # revealed: GenericAlias +reveal_type(DictStrTo) # revealed: def _( - # TODO: No error here - # error: [invalid-type-form] "Invalid subscript of object of type `GenericAlias` in type expression" dict_str_to_int: DictStrTo[int], ): - # TODO: This should be `dict[str, int]` - reveal_type(dict_str_to_int) # revealed: Unknown + reveal_type(dict_str_to_int) # revealed: dict[str, int] ``` Using specializations of generic implicit type aliases in other implicit type aliases works as @@ -464,43 +455,118 @@ expected: IntsOrNone = MyList[int] | None IntsOrStrs = Pair[int] | Pair[str] ListOfPairs = MyList[Pair[str]] +ListOrTupleOfInts = ListOrTuple[int] +AnnotatedInt = AnnotatedType[int] +SubclassOfInt = MyType[int] +CallableIntToStr = MyCallable[[int], str] -reveal_type(IntsOrNone) # revealed: UnionType -reveal_type(IntsOrStrs) # revealed: UnionType -reveal_type(ListOfPairs) # revealed: GenericAlias +reveal_type(IntsOrNone) # revealed: types.UnionType +reveal_type(IntsOrStrs) # revealed: types.UnionType +reveal_type(ListOfPairs) # revealed: +reveal_type(ListOrTupleOfInts) # revealed: types.UnionType +reveal_type(AnnotatedInt) # revealed: +reveal_type(SubclassOfInt) # revealed: GenericAlias +reveal_type(CallableIntToStr) # revealed: @Todo(Callable[..] specialized with ParamSpec) def _( - # TODO: This should not be an error - # error: [invalid-type-form] "Variable of type `UnionType` is not allowed in a type expression" ints_or_none: IntsOrNone, - # TODO: This should not be an error - # error: [invalid-type-form] "Variable of type `UnionType` is not allowed in a type expression" ints_or_strs: IntsOrStrs, list_of_pairs: ListOfPairs, + list_or_tuple_of_ints: ListOrTupleOfInts, + annotated_int: AnnotatedInt, + subclass_of_int: SubclassOfInt, + callable_int_to_str: CallableIntToStr, ): - # TODO: This should be `list[int] | None` - reveal_type(ints_or_none) # revealed: Unknown - # TODO: This should be `tuple[int, int] | tuple[str, str]` - reveal_type(ints_or_strs) # revealed: Unknown - # TODO: This should be `list[tuple[str, str]]` - reveal_type(list_of_pairs) # revealed: @Todo(Support for `typing.GenericAlias` instances in type expressions) + reveal_type(ints_or_none) # revealed: list[int] | None + reveal_type(ints_or_strs) # revealed: tuple[int, int] | tuple[str, str] + reveal_type(list_of_pairs) # revealed: list[tuple[str, str]] + reveal_type(list_or_tuple_of_ints) # revealed: list[int] | tuple[int, ...] + reveal_type(annotated_int) # revealed: int + reveal_type(subclass_of_int) # revealed: type[int] + # TODO: This should be `(int, /) -> str` + reveal_type(callable_int_to_str) # revealed: @Todo(Callable[..] specialized with ParamSpec) ``` -If a generic implicit type alias is used unspecialized in a type expression, we treat it as an -`Unknown` specialization: +A generic implicit type alias can also be used in another generic implicit type alias: + +```py +from typing_extensions import Any + +B = TypeVar("B", bound=int) + +MyOtherList = MyList[T] +MyOtherType = MyType[T] +TypeOrList = MyType[B] | MyList[B] + +reveal_type(MyOtherList) # revealed: +reveal_type(MyOtherType) # revealed: GenericAlias +reveal_type(TypeOrList) # revealed: types.UnionType + +def _( + list_of_ints: MyOtherList[int], + subclass_of_int: MyOtherType[int], + type_or_list: TypeOrList[Any], +): + reveal_type(list_of_ints) # revealed: list[int] + reveal_type(subclass_of_int) # revealed: type[int] + reveal_type(type_or_list) # revealed: type[Any] | list[Any] +``` + +If a generic implicit type alias is used unspecialized in a type expression, we use the default +specialization. For type variables without defaults, this is `Unknown`: ```py def _( - my_list: MyList, - my_dict: MyDict, + list_unknown: MyList, + dict_unknown: MyDict, + subclass_of_unknown: MyType, + int_and_unknown: IntAndType, + pair_of_unknown: Pair, + unknown_and_unknown: Sum, + list_or_tuple: ListOrTuple, + list_or_tuple_legacy: ListOrTupleLegacy, my_callable: MyCallable, + annotated_unknown: AnnotatedType, + optional_unknown: MyOptional, ): - # TODO: Should be `list[Unknown]` - reveal_type(my_list) # revealed: list[typing.TypeVar] - # TODO: Should be `dict[Unknown, Unknown]` - reveal_type(my_dict) # revealed: dict[typing.TypeVar, typing.TypeVar] + # TODO: This should be `list[Unknown]` + reveal_type(list_unknown) # revealed: list[T@MyList] + # TODO: This should be `dict[Unknown, Unknown]` + reveal_type(dict_unknown) # revealed: dict[T@MyDict, U@MyDict] + # TODO: Should be `type[Unknown]` + reveal_type(subclass_of_unknown) # revealed: type[T@MyType] + # TODO: Should be `tuple[int, Unknown]` + reveal_type(int_and_unknown) # revealed: tuple[int, T@IntAndType] + # TODO: Should be `tuple[Unknown, Unknown]` + reveal_type(pair_of_unknown) # revealed: tuple[T@Pair, T@Pair] + # TODO: Should be `tuple[Unknown, Unknown]` + reveal_type(unknown_and_unknown) # revealed: tuple[T@Sum, U@Sum] + # TODO: Should be `list[Unknown] | tuple[Unknown, ...]` + reveal_type(list_or_tuple) # revealed: list[T@ListOrTuple] | tuple[T@ListOrTuple, ...] + # TODO: Should be `list[Unknown] | tuple[Unknown, ...]` + reveal_type(list_or_tuple_legacy) # revealed: list[T@ListOrTupleLegacy] | tuple[T@ListOrTupleLegacy, ...] # TODO: Should be `(...) -> Unknown` - reveal_type(my_callable) # revealed: (...) -> typing.TypeVar + reveal_type(my_callable) # revealed: @Todo(Callable[..] specialized with ParamSpec) + # TODO: Should be `Unknown` + reveal_type(annotated_unknown) # revealed: T@AnnotatedType + # TODO: Should be `Unknown | None` + reveal_type(optional_unknown) # revealed: T@MyOptional | None +``` + +For a type variable with a default, we use the default type: + +```py +T_default = TypeVar("T_default", default=int) + +MyListWithDefault = list[T_default] + +def _( + list_of_str: MyListWithDefault[str], + list_of_int: MyListWithDefault, +): + reveal_type(list_of_str) # revealed: list[str] + # TODO: this should be `list[int]` + reveal_type(list_of_int) # revealed: list[T_default@MyListWithDefault] ``` (Generic) implicit type aliases can be used as base classes: @@ -522,37 +588,209 @@ reveal_mro(Derived1) GenericBaseAlias = GenericBase[T] -# TODO: No error here -# error: [non-subscriptable] "Cannot subscript object of type `` with no `__class_getitem__` method" class Derived2(GenericBaseAlias[int]): pass ``` +### Imported aliases + +Generic implicit type aliases can be imported from other modules and specialized: + +`my_types.py`: + +```py +from typing_extensions import TypeVar + +T = TypeVar("T") + +MyList = list[T] +``` + +`main.py`: + +```py +from my_types import MyList +import my_types as mt + +def _( + list_of_ints1: MyList[int], + list_of_ints2: mt.MyList[int], +): + reveal_type(list_of_ints1) # revealed: list[int] + reveal_type(list_of_ints2) # revealed: list[int] +``` + +### In stringified annotations + +Generic implicit type aliases can be specialized in stringified annotations: + +```py +from typing_extensions import TypeVar + +T = TypeVar("T") + +MyList = list[T] + +def _( + list_of_ints: "MyList[int]", +): + reveal_type(list_of_ints) # revealed: list[int] +``` + +### Tuple unpacking + +```toml +[environment] +python-version = "3.11" +``` + +```py +from typing import TypeVar + +T = TypeVar("T") +U = TypeVar("U") +V = TypeVar("V") + +X = tuple[T, *tuple[U, ...], V] +Y = X[T, tuple[int, str, U], bytes] + +def g(obj: Y[bool, range]): + reveal_type(obj) # revealed: tuple[bool, *tuple[tuple[int, str, range], ...], bytes] +``` + +### Error cases + A generic alias that is already fully specialized cannot be specialized again: ```py ListOfInts = list[int] -# TODO: this should be an error +# error: [invalid-type-arguments] "Too many type arguments: expected 0, got 1" def _(doubly_specialized: ListOfInts[int]): - # TODO: this should be `Unknown` - reveal_type(doubly_specialized) # revealed: @Todo(specialized generic alias in type expression) + # TODO: This should ideally be `list[Unknown]` or `Unknown` + reveal_type(doubly_specialized) # revealed: list[int] ``` Specializing a generic implicit type alias with an incorrect number of type arguments also results in an error: ```py +from typing_extensions import TypeVar + +T = TypeVar("T") +U = TypeVar("U") + +MyList = list[T] +MyDict = dict[T, U] + def _( - # TODO: this should be an error + # error: [invalid-type-arguments] "Too many type arguments: expected 1, got 2" list_too_many_args: MyList[int, str], - # TODO: this should be an error + # error: [invalid-type-arguments] "No type argument provided for required type variable `U`" dict_too_few_args: MyDict[int], ): - # TODO: this should be `Unknown` - reveal_type(list_too_many_args) # revealed: @Todo(specialized generic alias in type expression) - # TODO: this should be `Unknown` - reveal_type(dict_too_few_args) # revealed: @Todo(specialized generic alias in type expression) + reveal_type(list_too_many_args) # revealed: list[Unknown] + reveal_type(dict_too_few_args) # revealed: dict[Unknown, Unknown] +``` + +Trying to specialize a non-name node results in an error: + +```py +from ty_extensions import TypeOf + +IntOrStr = int | str + +def this_does_not_work() -> TypeOf[IntOrStr]: + raise NotImplementedError() + +def _( + # TODO: Better error message (of kind `invalid-type-form`)? + # error: [invalid-type-arguments] "Too many type arguments: expected 0, got 1" + specialized: this_does_not_work()[int], +): + reveal_type(specialized) # revealed: int | str +``` + +Similarly, if you try to specialize a union type without a binding context, we emit an error: + +```py +# TODO: Better error message (of kind `invalid-type-form`)? +# error: [invalid-type-arguments] "Too many type arguments: expected 0, got 1" +x: (list[T] | set[T])[int] + +def _(): + # TODO: `list[Unknown] | set[Unknown]` might be better + reveal_type(x) # revealed: list[typing.TypeVar] | set[typing.TypeVar] +``` + +### Multiple definitions + +#### Shadowed definitions + +When a generic type alias shadows a definition from an outer scope, the inner definition is used: + +```py +from typing_extensions import TypeVar + +T = TypeVar("T") + +MyAlias = list[T] + +def outer(): + MyAlias = set[T] + + def _(x: MyAlias[int]): + reveal_type(x) # revealed: set[int] +``` + +#### Statically known conditions + +```py +from typing_extensions import TypeVar + +T = TypeVar("T") + +if True: + MyAlias1 = list[T] +else: + MyAlias1 = set[T] + +if False: + MyAlias2 = list[T] +else: + MyAlias2 = set[T] + +def _( + x1: MyAlias1[int], + x2: MyAlias2[int], +): + reveal_type(x1) # revealed: list[int] + reveal_type(x2) # revealed: set[int] +``` + +#### Statically unknown conditions + +If several definitions are visible, we emit an error: + +```py +from typing_extensions import TypeVar + +T = TypeVar("T") + +def flag() -> bool: + return True + +if flag(): + MyAlias = list[T] +else: + MyAlias = set[T] + +# It is questionable whether this should be supported or not. It might also be reasonable to +# emit an error here (e.g. "Invalid subscript of object of type ` | +# ` in type expression"). If we ever choose to do so, the revealed +# type should probably be `Unknown`. +def _(x: MyAlias[int]): + reveal_type(x) # revealed: list[int] | set[int] ``` ## `Literal`s @@ -642,8 +880,7 @@ Deprecated = Annotated[T, "deprecated attribute"] class C: old: Deprecated[int] -# TODO: Should be `int` -reveal_type(C().old) # revealed: @Todo(Generic specialization of typing.Annotated) +reveal_type(C().old) # revealed: int ``` If the metadata argument is missing, we emit an error (because this code fails at runtime), but @@ -1298,3 +1535,21 @@ def _( reveal_type(recursive_dict3) # revealed: dict[Divergent, int] reveal_type(recursive_dict4) # revealed: dict[Divergent, int] ``` + +### Self-referential generic implicit type aliases + +```py +from typing import TypeVar + +T = TypeVar("T") + +NestedDict = dict[str, "NestedDict[T] | T"] +NestedList = list["NestedList[T] | None"] + +def _( + nested_dict_int: NestedDict[int], + nested_list_str: NestedList[str], +): + reveal_type(nested_dict_int) # revealed: dict[str, Divergent] + reveal_type(nested_list_str) # revealed: list[Divergent] +``` diff --git a/crates/ty_python_semantic/resources/mdtest/libraries/numpy.md b/crates/ty_python_semantic/resources/mdtest/libraries/numpy.md index d1afd367ca..2b657a34f7 100644 --- a/crates/ty_python_semantic/resources/mdtest/libraries/numpy.md +++ b/crates/ty_python_semantic/resources/mdtest/libraries/numpy.md @@ -44,9 +44,6 @@ class _SupportsDType(Protocol[_DTypeT_co]): @property def dtype(self) -> _DTypeT_co: ... -# TODO: no errors here -# error: [invalid-type-arguments] "Type `typing.TypeVar` is not assignable to upper bound `generic[Any]` of type variable `_ScalarT_co@dtype`" -# error: [invalid-type-arguments] "Type `typing.TypeVar` is not assignable to upper bound `generic[Any]` of type variable `_ScalarT_co@dtype`" _DTypeLike: TypeAlias = type[_ScalarT] | dtype[_ScalarT] | _SupportsDType[dtype[_ScalarT]] DTypeLike: TypeAlias = _DTypeLike[Any] | str | None diff --git a/crates/ty_python_semantic/resources/mdtest/pep613_type_aliases.md b/crates/ty_python_semantic/resources/mdtest/pep613_type_aliases.md index 40e5d2c477..c3e63c7b8e 100644 --- a/crates/ty_python_semantic/resources/mdtest/pep613_type_aliases.md +++ b/crates/ty_python_semantic/resources/mdtest/pep613_type_aliases.md @@ -96,6 +96,45 @@ def _(x: MyAlias): reveal_type(x) # revealed: int | ((str, /) -> int) ``` +## Generic aliases + +A more comprehensive set of tests can be found in +[`implicit_type_aliases.md`](./implicit_type_aliases.md). If the implementations ever diverge, we +may need to duplicate more tests here. + +### Basic + +```py +from typing import TypeAlias, TypeVar + +T = TypeVar("T") + +MyList: TypeAlias = list[T] +ListOrSet: TypeAlias = list[T] | set[T] + +reveal_type(MyList) # revealed: +reveal_type(ListOrSet) # revealed: types.UnionType + +def _(list_of_int: MyList[int], list_or_set_of_str: ListOrSet[str]): + reveal_type(list_of_int) # revealed: list[int] + reveal_type(list_or_set_of_str) # revealed: list[str] | set[str] +``` + +### Stringified generic alias + +```py +from typing import TypeAlias, TypeVar + +T = TypeVar("T") +U = TypeVar("U") + +TotallyStringifiedPEP613: TypeAlias = "dict[T, U]" +TotallyStringifiedPartiallySpecialized: TypeAlias = "TotallyStringifiedPEP613[U, int]" + +def f(x: "TotallyStringifiedPartiallySpecialized[str]"): + reveal_type(x) # revealed: @Todo(Generic stringified PEP-613 type alias) +``` + ## Subscripted generic alias in union ```py @@ -107,8 +146,7 @@ Alias1: TypeAlias = list[T] | set[T] MyAlias: TypeAlias = int | Alias1[str] def _(x: MyAlias): - # TODO: int | list[str] | set[str] - reveal_type(x) # revealed: int | @Todo(Specialization of union type alias) + reveal_type(x) # revealed: int | list[str] | set[str] ``` ## Imported @@ -173,7 +211,7 @@ NestedDict: TypeAlias = dict[K, Union[V, "NestedDict[K, V]"]] def _(nested: NestedDict[str, int]): # TODO should be `dict[str, int | NestedDict[str, int]]` - reveal_type(nested) # revealed: @Todo(specialized generic alias in type expression) + reveal_type(nested) # revealed: dict[@Todo(specialized recursive generic type alias), Divergent] my_isinstance(1, int) my_isinstance(1, int | str) diff --git a/crates/ty_python_semantic/src/semantic_index/definition.rs b/crates/ty_python_semantic/src/semantic_index/definition.rs index 03acaa5335..2659e75493 100644 --- a/crates/ty_python_semantic/src/semantic_index/definition.rs +++ b/crates/ty_python_semantic/src/semantic_index/definition.rs @@ -90,6 +90,12 @@ impl<'db> Definition<'db> { .to_string(), ) } + DefinitionKind::Assignment(assignment) => { + let target_node = assignment.target.node(&module); + target_node + .as_name_expr() + .map(|name_expr| name_expr.id.as_str().to_string()) + } _ => None, } } diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 94ff50f161..3c701de557 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -3726,7 +3726,7 @@ impl<'db> Type<'db> { dunder_call .has_relation_to_impl( db, - CallableType::unknown(db), + Type::Callable(CallableType::unknown(db)), inferable, TypeRelation::Assignability, relation_visitor, @@ -7219,7 +7219,7 @@ impl<'db> Type<'db> { } KnownInstanceType::Literal(ty) => Ok(ty.inner(db)), KnownInstanceType::Annotated(ty) => Ok(ty.inner(db)), - KnownInstanceType::TypeGenericAlias(ty) => { + KnownInstanceType::TypeGenericAlias(instance) => { // When `type[…]` appears in a value position (e.g. in an implicit type alias), // we infer its argument as a type expression. This ensures that we can emit // diagnostics for invalid type expressions, and more importantly, that we can @@ -7228,7 +7228,7 @@ impl<'db> Type<'db> { // (`int` -> instance of `int` -> subclass of `int`) can be lossy, but it is // okay for all valid arguments to `type[…]`. - Ok(ty.inner(db).to_meta_type(db)) + Ok(instance.inner(db).to_meta_type(db)) } KnownInstanceType::Callable(callable) => Ok(Type::Callable(*callable)), KnownInstanceType::LiteralStringAlias(ty) => Ok(ty.inner(db)), @@ -7258,7 +7258,7 @@ impl<'db> Type<'db> { SpecialFormType::OrderedDict => Ok(KnownClass::OrderedDict.to_instance(db)), // TODO: Use an opt-in rule for a bare `Callable` - SpecialFormType::Callable => Ok(CallableType::unknown(db)), + SpecialFormType::Callable => Ok(Type::Callable(CallableType::unknown(db))), // Special case: `NamedTuple` in a type expression is understood to describe the type // `tuple[object, ...] & `. @@ -7578,18 +7578,71 @@ impl<'db> Type<'db> { match self { Type::TypeVar(bound_typevar) => bound_typevar.apply_type_mapping_impl(db, type_mapping, visitor), - Type::KnownInstance(KnownInstanceType::TypeVar(typevar)) => match type_mapping { - TypeMapping::BindLegacyTypevars(binding_context) => { - Type::TypeVar(BoundTypeVarInstance::new(db, typevar, *binding_context)) + Type::KnownInstance(known_instance) => match known_instance { + KnownInstanceType::TypeVar(typevar) => { + match type_mapping { + TypeMapping::BindLegacyTypevars(binding_context) => { + Type::TypeVar(BoundTypeVarInstance::new(db, typevar, *binding_context)) + } + TypeMapping::Specialization(_) | + TypeMapping::PartialSpecialization(_) | + TypeMapping::PromoteLiterals(_) | + TypeMapping::BindSelf(_) | + TypeMapping::ReplaceSelf { .. } | + TypeMapping::Materialize(_) | + TypeMapping::ReplaceParameterDefaults | + TypeMapping::EagerExpansion => self, + } } - TypeMapping::Specialization(_) | - TypeMapping::PartialSpecialization(_) | - TypeMapping::PromoteLiterals(_) | - TypeMapping::BindSelf(_) | - TypeMapping::ReplaceSelf { .. } | - TypeMapping::Materialize(_) | - TypeMapping::ReplaceParameterDefaults | - TypeMapping::EagerExpansion => self, + KnownInstanceType::UnionType(instance) => { + if let Ok(union_type) = instance.union_type(db) { + Type::KnownInstance(KnownInstanceType::UnionType( + UnionTypeInstance::new( + db, + instance._value_expr_types(db), + Ok(union_type.apply_type_mapping_impl(db, type_mapping, tcx, visitor) + ) + ))) + } else { + self + } + }, + KnownInstanceType::Annotated(ty) => { + Type::KnownInstance(KnownInstanceType::Annotated( + InternedType::new( + db, + ty.inner(db).apply_type_mapping_impl(db, type_mapping, tcx, visitor), + ) + )) + }, + KnownInstanceType::Callable(callable_type) => { + Type::KnownInstance(KnownInstanceType::Callable( + callable_type.apply_type_mapping_impl(db, type_mapping, tcx, visitor), + )) + }, + KnownInstanceType::TypeGenericAlias(ty) => { + Type::KnownInstance(KnownInstanceType::TypeGenericAlias( + InternedType::new( + db, + ty.inner(db).apply_type_mapping_impl(db, type_mapping, tcx, visitor), + ) + )) + }, + + KnownInstanceType::SubscriptedProtocol(_) | + KnownInstanceType::SubscriptedGeneric(_) | + KnownInstanceType::TypeAliasType(_) | + KnownInstanceType::Deprecated(_) | + KnownInstanceType::Field(_) | + KnownInstanceType::ConstraintSet(_) | + KnownInstanceType::GenericContext(_) | + KnownInstanceType::Specialization(_) | + KnownInstanceType::Literal(_) | + KnownInstanceType::LiteralStringAlias(_) | + KnownInstanceType::NewType(_) => { + // TODO: For some of these, we may need to apply the type mapping to inner types. + self + }, } Type::FunctionLiteral(function) => { @@ -7755,8 +7808,7 @@ impl<'db> Type<'db> { // some other generic context's specialization is applied to it. | Type::ClassLiteral(_) | Type::BoundSuper(_) - | Type::SpecialForm(_) - | Type::KnownInstance(_) => self, + | Type::SpecialForm(_) => self, } } @@ -7893,6 +7945,44 @@ impl<'db> Type<'db> { }); } + Type::KnownInstance(known_instance) => match known_instance { + KnownInstanceType::UnionType(instance) => { + if let Ok(union_type) = instance.union_type(db) { + union_type.find_legacy_typevars_impl( + db, + binding_context, + typevars, + visitor, + ); + } + } + KnownInstanceType::Annotated(ty) => { + ty.inner(db) + .find_legacy_typevars_impl(db, binding_context, typevars, visitor); + } + KnownInstanceType::Callable(callable_type) => { + callable_type.find_legacy_typevars_impl(db, binding_context, typevars, visitor); + } + KnownInstanceType::TypeGenericAlias(ty) => { + ty.inner(db) + .find_legacy_typevars_impl(db, binding_context, typevars, visitor); + } + KnownInstanceType::SubscriptedProtocol(_) + | KnownInstanceType::SubscriptedGeneric(_) + | KnownInstanceType::TypeVar(_) + | KnownInstanceType::TypeAliasType(_) + | KnownInstanceType::Deprecated(_) + | KnownInstanceType::Field(_) + | KnownInstanceType::ConstraintSet(_) + | KnownInstanceType::GenericContext(_) + | KnownInstanceType::Specialization(_) + | KnownInstanceType::Literal(_) + | KnownInstanceType::LiteralStringAlias(_) + | KnownInstanceType::NewType(_) => { + // TODO: For some of these, we may need to try to find legacy typevars in inner types. + } + }, + Type::Dynamic(_) | Type::Never | Type::AlwaysTruthy @@ -7920,7 +8010,6 @@ impl<'db> Type<'db> { | Type::EnumLiteral(_) | Type::BoundSuper(_) | Type::SpecialForm(_) - | Type::KnownInstance(_) | Type::TypedDict(_) => {} } } @@ -11595,8 +11684,8 @@ impl<'db> CallableType<'db> { } /// Create a callable type which accepts any parameters and returns an `Unknown` type. - pub(crate) fn unknown(db: &'db dyn Db) -> Type<'db> { - Type::Callable(Self::single(db, Signature::unknown())) + pub(crate) fn unknown(db: &'db dyn Db) -> CallableType<'db> { + Self::single(db, Signature::unknown()) } pub(crate) fn bind_self( diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index 71d4dfec17..df165921fe 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -4796,6 +4796,12 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { unpacked.expression_type(target) } TargetKind::Single => { + // This could be an implicit type alias (OptionalList = list[T] | None). Use the definition + // of `OptionalList` as the binding context while inferring the RHS (`list[T] | None`), in + // order to bind `T` to `OptionalList`. + let previous_typevar_binding_context = + self.typevar_binding_context.replace(definition); + let value_ty = if let Some(standalone_expression) = self.index.try_expression(value) { self.infer_standalone_expression_impl(value, standalone_expression, tcx) @@ -4834,6 +4840,8 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { self.infer_expression(value, tcx) }; + self.typevar_binding_context = previous_typevar_binding_context; + // `TYPE_CHECKING` is a special variable that should only be assigned `False` // at runtime, but is always considered `True` in type checking. // See mdtest/known_constants.md#user-defined-type_checking for details. @@ -5580,11 +5588,18 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { self.deferred_state = DeferredExpressionState::Deferred; } + // This might be a PEP-613 type alias (`OptionalList: TypeAlias = list[T] | None`). Use + // the definition of `OptionalList` as the binding context while inferring the + // RHS (`list[T] | None`), in order to bind `T` to `OptionalList`. + let previous_typevar_binding_context = self.typevar_binding_context.replace(definition); + let inferred_ty = self.infer_maybe_standalone_expression( value, TypeContext::new(Some(declared.inner_type())), ); + self.typevar_binding_context = previous_typevar_binding_context; + self.deferred_state = previous_deferred_state; self.dataclass_field_specifiers.clear(); @@ -10860,6 +10875,14 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { fn infer_subscript_load(&mut self, subscript: &ast::ExprSubscript) -> Type<'db> { let value_ty = self.infer_expression(&subscript.value, TypeContext::default()); + + // If we have an implicit type alias like `MyList = list[T]`, and if `MyList` is being + // used in another implicit type alias like `Numbers = MyList[int]`, then we infer the + // right hand side as a value expression, and need to handle the specialization here. + if value_ty.is_generic_alias() { + return self.infer_explicit_type_alias_specialization(subscript, value_ty, false); + } + self.infer_subscript_load_impl(value_ty, subscript) } @@ -10929,7 +10952,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { } Type::KnownInstance(KnownInstanceType::TypeAliasType(type_alias)) => { if let Some(generic_context) = type_alias.generic_context(self.db()) { - return self.infer_explicit_type_alias_specialization( + return self.infer_explicit_type_alias_type_specialization( subscript, value_ty, type_alias, @@ -11065,6 +11088,35 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { )); } Type::SpecialForm(SpecialFormType::Callable) => { + // TODO: Remove this once we support ParamSpec properly. This is necessary to avoid + // a lot of false positives downstream, because we can't represent the specialized + // `Callable[P, _]` type yet. + if let Some(first_arg) = subscript + .slice + .as_ref() + .as_tuple_expr() + .and_then(|args| args.elts.first()) + && first_arg.is_name_expr() + { + let first_arg_ty = self.infer_expression(first_arg, TypeContext::default()); + + if let Type::KnownInstance(KnownInstanceType::TypeVar(typevar)) = first_arg_ty + && typevar.kind(self.db()).is_paramspec() + { + return todo_type!("Callable[..] specialized with ParamSpec"); + } + + if let Some(builder) = self.context.report_lint(&INVALID_TYPE_FORM, subscript) { + builder.into_diagnostic(format_args!( + "The first argument to `Callable` must be either a list of types, \ + ParamSpec, Concatenate, or `...`", + )); + } + return Type::KnownInstance(KnownInstanceType::Callable( + CallableType::unknown(self.db()), + )); + } + let callable = self .infer_callable_type(subscript) .as_callable() @@ -11161,8 +11213,13 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { .map(Type::from) .unwrap_or_else(Type::unknown); } - Type::KnownInstance(KnownInstanceType::UnionType(_)) => { - return todo_type!("Specialization of union type alias"); + Type::KnownInstance( + KnownInstanceType::UnionType(_) + | KnownInstanceType::Annotated(_) + | KnownInstanceType::Callable(_) + | KnownInstanceType::TypeGenericAlias(_), + ) => { + return self.infer_explicit_type_alias_specialization(subscript, value_ty, false); } _ => {} } @@ -11194,7 +11251,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { ) } - fn infer_explicit_type_alias_specialization( + fn infer_explicit_type_alias_type_specialization( &mut self, subscript: &ast::ExprSubscript, value_ty: Type<'db>, diff --git a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs index af23bc646e..74f6607615 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs @@ -2,6 +2,7 @@ use itertools::Either; use ruff_python_ast as ast; use super::{DeferredExpressionState, TypeInferenceBuilder}; +use crate::FxOrderSet; use crate::types::diagnostic::{ self, INVALID_TYPE_FORM, NON_SUBSCRIPTABLE, report_invalid_argument_number_to_special_form, report_invalid_arguments_to_callable, @@ -12,9 +13,9 @@ use crate::types::string_annotation::parse_string_annotation; use crate::types::tuple::{TupleSpecBuilder, TupleType}; use crate::types::visitor::any_over_type; use crate::types::{ - CallableType, DynamicType, IntersectionBuilder, KnownClass, KnownInstanceType, - LintDiagnosticGuard, SpecialFormType, SubclassOfType, Type, TypeAliasType, TypeContext, - TypeIsType, UnionBuilder, UnionType, todo_type, + BindingContext, CallableType, DynamicType, GenericContext, IntersectionBuilder, KnownClass, + KnownInstanceType, LintDiagnosticGuard, SpecialFormType, SubclassOfType, Type, TypeAliasType, + TypeContext, TypeIsType, TypeMapping, UnionBuilder, UnionType, todo_type, }; /// Type expressions @@ -734,6 +735,84 @@ impl<'db> TypeInferenceBuilder<'db, '_> { } } + /// Infer the type of an explicitly specialized generic type alias (implicit or PEP 613). + pub(crate) fn infer_explicit_type_alias_specialization( + &mut self, + subscript: &ast::ExprSubscript, + mut value_ty: Type<'db>, + in_type_expression: bool, + ) -> Type<'db> { + let db = self.db(); + + if let Type::KnownInstance(KnownInstanceType::TypeVar(typevar)) = value_ty + && let Some(definition) = typevar.definition(db) + { + value_ty = value_ty.apply_type_mapping( + db, + &TypeMapping::BindLegacyTypevars(BindingContext::Definition(definition)), + TypeContext::default(), + ); + } + + let mut variables = FxOrderSet::default(); + value_ty.find_legacy_typevars(db, None, &mut variables); + let generic_context = GenericContext::from_typevar_instances(db, variables); + + let scope_id = self.scope(); + let current_typevar_binding_context = self.typevar_binding_context; + + // TODO + // If we explicitly specialize a recursive generic (PEP-613 or implicit) type alias, + // we currently miscount the number of type variables. For example, for a nested + // dictionary type alias `NestedDict = dict[K, "V | NestedDict[K, V]"]]`, we might + // infer ``, and therefore count just one type variable + // instead of two. So until we properly support these, specialize all remaining type + // variables with a `@Todo` type (since we don't know which of the type arguments + // belongs to the remaining type variables). + if any_over_type(self.db(), value_ty, &|ty| ty.is_divergent(), true) { + let value_ty = value_ty.apply_specialization( + db, + generic_context.specialize( + db, + std::iter::repeat_n( + todo_type!("specialized recursive generic type alias"), + generic_context.len(db), + ) + .collect(), + ), + ); + return if in_type_expression { + value_ty + .in_type_expression(db, scope_id, current_typevar_binding_context) + .unwrap_or_else(|_| Type::unknown()) + } else { + value_ty + }; + } + + let specialize = |types: &[Option>]| { + let specialized = value_ty.apply_specialization( + db, + generic_context.specialize_partial(db, types.iter().copied()), + ); + + if in_type_expression { + specialized + .in_type_expression(db, scope_id, current_typevar_binding_context) + .unwrap_or_else(|_| Type::unknown()) + } else { + specialized + } + }; + + self.infer_explicit_callable_specialization( + subscript, + value_ty, + generic_context, + specialize, + ) + } + fn infer_subscript_type_expression( &mut self, subscript: &ast::ExprSubscript, @@ -824,15 +903,11 @@ impl<'db> TypeInferenceBuilder<'db, '_> { } Type::unknown() } - KnownInstanceType::TypeVar(_) => { - self.infer_type_expression(slice); - todo_type!("TypeVar annotations") - } KnownInstanceType::TypeAliasType(type_alias @ TypeAliasType::PEP695(_)) => { match type_alias.generic_context(self.db()) { Some(generic_context) => { let specialized_type_alias = self - .infer_explicit_type_alias_specialization( + .infer_explicit_type_alias_type_specialization( subscript, value_ty, type_alias, @@ -870,11 +945,7 @@ impl<'db> TypeInferenceBuilder<'db, '_> { self.infer_type_expression(slice); todo_type!("Generic stringified PEP-613 type alias") } - KnownInstanceType::UnionType(_) => { - self.infer_type_expression(slice); - todo_type!("Generic specialization of types.UnionType") - } - KnownInstanceType::Literal(ty) | KnownInstanceType::TypeGenericAlias(ty) => { + KnownInstanceType::Literal(ty) => { self.infer_type_expression(slice); if let Some(builder) = self.context.report_lint(&INVALID_TYPE_FORM, subscript) { builder.into_diagnostic(format_args!( @@ -884,13 +955,15 @@ impl<'db> TypeInferenceBuilder<'db, '_> { } Type::unknown() } - KnownInstanceType::Callable(_) => { - self.infer_type_expression(slice); - todo_type!("Generic specialization of typing.Callable") + KnownInstanceType::TypeVar(_) => { + self.infer_explicit_type_alias_specialization(subscript, value_ty, false) } - KnownInstanceType::Annotated(_) => { - self.infer_type_expression(slice); - todo_type!("Generic specialization of typing.Annotated") + + KnownInstanceType::UnionType(_) + | KnownInstanceType::Callable(_) + | KnownInstanceType::Annotated(_) + | KnownInstanceType::TypeGenericAlias(_) => { + self.infer_explicit_type_alias_specialization(subscript, value_ty, true) } KnownInstanceType::NewType(newtype) => { self.infer_type_expression(&subscript.slice); @@ -904,7 +977,10 @@ impl<'db> TypeInferenceBuilder<'db, '_> { } }, Type::Dynamic(_) => { - self.infer_type_expression(slice); + // Infer slice as a value expression to avoid false-positive + // `invalid-type-form` diagnostics, when we have e.g. + // `MyCallable[[int, str], None]` but `MyCallable` is dynamic. + self.infer_expression(slice, TypeContext::default()); value_ty } Type::ClassLiteral(class) => { @@ -933,11 +1009,7 @@ impl<'db> TypeInferenceBuilder<'db, '_> { } } Type::GenericAlias(_) => { - self.infer_type_expression(slice); - // If the generic alias is already fully specialized, this is an error. But it - // could have been specialized with another typevar (e.g. a type alias like `MyList - // = list[T]`), in which case it's later valid to do `MyList[int]`. - todo_type!("specialized generic alias in type expression") + self.infer_explicit_type_alias_specialization(subscript, value_ty, true) } Type::StringLiteral(_) => { self.infer_type_expression(slice); @@ -1049,7 +1121,7 @@ impl<'db> TypeInferenceBuilder<'db, '_> { { Type::single_callable(db, Signature::new(parameters, Some(return_type))) } else { - CallableType::unknown(db) + Type::Callable(CallableType::unknown(db)) }; // `Signature` / `Parameters` are not a `Type` variant, so we're storing diff --git a/crates/ty_python_semantic/src/types/narrow.rs b/crates/ty_python_semantic/src/types/narrow.rs index 32ac648dc4..984f214414 100644 --- a/crates/ty_python_semantic/src/types/narrow.rs +++ b/crates/ty_python_semantic/src/types/narrow.rs @@ -238,7 +238,7 @@ impl ClassInfoConstraintFunction { Type::SpecialForm(SpecialFormType::Callable) if self == ClassInfoConstraintFunction::IsInstance => { - Some(CallableType::unknown(db).top_materialization(db)) + Some(Type::Callable(CallableType::unknown(db)).top_materialization(db)) } Type::SpecialForm(special_form) => special_form From ecab623fb2fe3846de4cafa0dfef0385a7245941 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 28 Nov 2025 14:34:27 -0600 Subject: [PATCH 24/67] Bump 0.14.7 (#21684) --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++ Cargo.lock | 6 +++--- README.md | 6 +++--- crates/ruff/Cargo.toml | 2 +- crates/ruff_linter/Cargo.toml | 2 +- crates/ruff_wasm/Cargo.toml | 2 +- docs/integrations.md | 8 +++---- docs/tutorial.md | 2 +- pyproject.toml | 2 +- scripts/benchmarks/pyproject.toml | 2 +- 10 files changed, 51 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90530e3319..d5f2dc1152 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,40 @@ # Changelog +## 0.14.7 + +Released on 2025-11-28. + +### Preview features + +- \[`flake8-bandit`\] Handle string literal bindings in suspicious-url-open-usage (`S310`) ([#21469](https://github.com/astral-sh/ruff/pull/21469)) +- \[`pylint`\] Fix `PLR1708` false positives on nested functions ([#21177](https://github.com/astral-sh/ruff/pull/21177)) +- \[`pylint`\] Fix suppression for empty dict without tuple key annotation (`PLE1141`) ([#21290](https://github.com/astral-sh/ruff/pull/21290)) +- \[`ruff`\] Add rule `RUF066` to detect unnecessary class properties ([#21535](https://github.com/astral-sh/ruff/pull/21535)) +- \[`ruff`\] Catch more dummy variable uses (`RUF052`) ([#19799](https://github.com/astral-sh/ruff/pull/19799)) + +### Bug fixes + +- [server] Set severity for non-rule diagnostics ([#21559](https://github.com/astral-sh/ruff/pull/21559)) +- \[`flake8-implicit-str-concat`\] Avoid invalid fix in (`ISC003`) ([#21517](https://github.com/astral-sh/ruff/pull/21517)) +- \[`parser`\] Fix panic when parsing IPython escape command expressions ([#21480](https://github.com/astral-sh/ruff/pull/21480)) + +### CLI + +- Show partial fixability indicator in statistics output ([#21513](https://github.com/astral-sh/ruff/pull/21513)) + +### Contributors + +- [@mikeleppane](https://github.com/mikeleppane) +- [@senekor](https://github.com/senekor) +- [@ShaharNaveh](https://github.com/ShaharNaveh) +- [@JumboBear](https://github.com/JumboBear) +- [@prakhar1144](https://github.com/prakhar1144) +- [@tsvikas](https://github.com/tsvikas) +- [@danparizher](https://github.com/danparizher) +- [@chirizxc](https://github.com/chirizxc) +- [@AlexWaygood](https://github.com/AlexWaygood) +- [@MichaReiser](https://github.com/MichaReiser) + ## 0.14.6 Released on 2025-11-21. diff --git a/Cargo.lock b/Cargo.lock index c95acc34a3..dd9f1f40f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2859,7 +2859,7 @@ dependencies = [ [[package]] name = "ruff" -version = "0.14.6" +version = "0.14.7" dependencies = [ "anyhow", "argfile", @@ -3117,7 +3117,7 @@ dependencies = [ [[package]] name = "ruff_linter" -version = "0.14.6" +version = "0.14.7" dependencies = [ "aho-corasick", "anyhow", @@ -3472,7 +3472,7 @@ dependencies = [ [[package]] name = "ruff_wasm" -version = "0.14.6" +version = "0.14.7" dependencies = [ "console_error_panic_hook", "console_log", diff --git a/README.md b/README.md index 55d1c32f3a..a95fb77768 100644 --- a/README.md +++ b/README.md @@ -147,8 +147,8 @@ curl -LsSf https://astral.sh/ruff/install.sh | sh powershell -c "irm https://astral.sh/ruff/install.ps1 | iex" # For a specific version. -curl -LsSf https://astral.sh/ruff/0.14.6/install.sh | sh -powershell -c "irm https://astral.sh/ruff/0.14.6/install.ps1 | iex" +curl -LsSf https://astral.sh/ruff/0.14.7/install.sh | sh +powershell -c "irm https://astral.sh/ruff/0.14.7/install.ps1 | iex" ``` You can also install Ruff via [Homebrew](https://formulae.brew.sh/formula/ruff), [Conda](https://anaconda.org/conda-forge/ruff), @@ -181,7 +181,7 @@ Ruff can also be used as a [pre-commit](https://pre-commit.com/) hook via [`ruff ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.14.6 + rev: v0.14.7 hooks: # Run the linter. - id: ruff-check diff --git a/crates/ruff/Cargo.toml b/crates/ruff/Cargo.toml index 07d7975a43..a811287630 100644 --- a/crates/ruff/Cargo.toml +++ b/crates/ruff/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ruff" -version = "0.14.6" +version = "0.14.7" publish = true authors = { workspace = true } edition = { workspace = true } diff --git a/crates/ruff_linter/Cargo.toml b/crates/ruff_linter/Cargo.toml index 94f1ea961b..1f5f42a524 100644 --- a/crates/ruff_linter/Cargo.toml +++ b/crates/ruff_linter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ruff_linter" -version = "0.14.6" +version = "0.14.7" publish = false authors = { workspace = true } edition = { workspace = true } diff --git a/crates/ruff_wasm/Cargo.toml b/crates/ruff_wasm/Cargo.toml index 14aae17ea0..e688039563 100644 --- a/crates/ruff_wasm/Cargo.toml +++ b/crates/ruff_wasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ruff_wasm" -version = "0.14.6" +version = "0.14.7" publish = false authors = { workspace = true } edition = { workspace = true } diff --git a/docs/integrations.md b/docs/integrations.md index e034981a6f..fc364ae8ca 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -80,7 +80,7 @@ You can add the following configuration to `.gitlab-ci.yml` to run a `ruff forma stage: build interruptible: true image: - name: ghcr.io/astral-sh/ruff:0.14.6-alpine + name: ghcr.io/astral-sh/ruff:0.14.7-alpine before_script: - cd $CI_PROJECT_DIR - ruff --version @@ -106,7 +106,7 @@ Ruff can be used as a [pre-commit](https://pre-commit.com) hook via [`ruff-pre-c ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.14.6 + rev: v0.14.7 hooks: # Run the linter. - id: ruff-check @@ -119,7 +119,7 @@ To enable lint fixes, add the `--fix` argument to the lint hook: ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.14.6 + rev: v0.14.7 hooks: # Run the linter. - id: ruff-check @@ -133,7 +133,7 @@ To avoid running on Jupyter Notebooks, remove `jupyter` from the list of allowed ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.14.6 + rev: v0.14.7 hooks: # Run the linter. - id: ruff-check diff --git a/docs/tutorial.md b/docs/tutorial.md index 8a776e8c31..322b90ed5a 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -369,7 +369,7 @@ This tutorial has focused on Ruff's command-line interface, but Ruff can also be ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.14.6 + rev: v0.14.7 hooks: # Run the linter. - id: ruff-check diff --git a/pyproject.toml b/pyproject.toml index 9647c886dc..69ae365da6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "ruff" -version = "0.14.6" +version = "0.14.7" description = "An extremely fast Python linter and code formatter, written in Rust." authors = [{ name = "Astral Software Inc.", email = "hey@astral.sh" }] readme = "README.md" diff --git a/scripts/benchmarks/pyproject.toml b/scripts/benchmarks/pyproject.toml index b3959b0e2f..4f8b71cec6 100644 --- a/scripts/benchmarks/pyproject.toml +++ b/scripts/benchmarks/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "scripts" -version = "0.14.6" +version = "0.14.7" description = "" authors = ["Charles Marsh "] From 8795d9f0cb8818aa02262a92f1baf096cbdee04c Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Sat, 29 Nov 2025 12:19:39 +0530 Subject: [PATCH 25/67] [ty] Split `ParamSpec` mdtests to separate legacy and PEP 695 tests (#21687) ## Summary This is another small refactor for https://github.com/astral-sh/ruff/pull/21445 that splits the single `paramspec.md` into `generics/legacy/paramspec.md` and `generics/pep695/paramspec.md`. ## Test Plan Make sure that all mdtests pass. --- .../mdtest/{ => generics/legacy}/paramspec.md | 58 +---------------- .../mdtest/generics/pep695/paramspec.md | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+), 57 deletions(-) rename crates/ty_python_semantic/resources/mdtest/{ => generics/legacy}/paramspec.md (67%) create mode 100644 crates/ty_python_semantic/resources/mdtest/generics/pep695/paramspec.md diff --git a/crates/ty_python_semantic/resources/mdtest/paramspec.md b/crates/ty_python_semantic/resources/mdtest/generics/legacy/paramspec.md similarity index 67% rename from crates/ty_python_semantic/resources/mdtest/paramspec.md rename to crates/ty_python_semantic/resources/mdtest/generics/legacy/paramspec.md index 254cd9d073..2ce9f14852 100644 --- a/crates/ty_python_semantic/resources/mdtest/paramspec.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/legacy/paramspec.md @@ -1,4 +1,4 @@ -# `ParamSpec` +# Legacy `ParamSpec` ## Definition @@ -115,59 +115,3 @@ P = ParamSpec("P", default=[A, B]) class A: ... class B: ... ``` - -### PEP 695 - -```toml -[environment] -python-version = "3.12" -``` - -#### Valid - -```py -def foo1[**P]() -> None: - reveal_type(P) # revealed: typing.ParamSpec - -def foo2[**P = ...]() -> None: - reveal_type(P) # revealed: typing.ParamSpec - -def foo3[**P = [int, str]]() -> None: - reveal_type(P) # revealed: typing.ParamSpec - -def foo4[**P, **Q = P](): - reveal_type(P) # revealed: typing.ParamSpec - reveal_type(Q) # revealed: typing.ParamSpec -``` - -#### Invalid - -ParamSpec, when defined using the new syntax, does not allow defining bounds or constraints. - -This results in a lot of syntax errors mainly because the AST doesn't accept them in this position. -The parser could do a better job in recovering from these errors. - - - -```py -# error: [invalid-syntax] -# error: [invalid-syntax] -# error: [invalid-syntax] -# error: [invalid-syntax] -# error: [invalid-syntax] -# error: [invalid-syntax] -def foo[**P: int]() -> None: - # error: [invalid-syntax] - # error: [invalid-syntax] - pass -``` - - - -#### Invalid default - -```py -# error: [invalid-paramspec] -def foo[**P = int]() -> None: - pass -``` diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/paramspec.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/paramspec.md new file mode 100644 index 0000000000..62b50b05ef --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/paramspec.md @@ -0,0 +1,64 @@ +# PEP 695 `ParamSpec` + +`ParamSpec` was introduced in Python 3.12 while the support for specifying defaults was added in +Python 3.13. + +```toml +[environment] +python-version = "3.13" +``` + +## Definition + +```py +def foo1[**P]() -> None: + reveal_type(P) # revealed: typing.ParamSpec +``` + +## Bounds and constraints + +`ParamSpec`, when defined using the new syntax, does not allow defining bounds or constraints. + +TODO: This results in a lot of syntax errors mainly because the AST doesn't accept them in this +position. The parser could do a better job in recovering from these errors. + + + +```py +# error: [invalid-syntax] +# error: [invalid-syntax] +# error: [invalid-syntax] +# error: [invalid-syntax] +# error: [invalid-syntax] +# error: [invalid-syntax] +def foo[**P: int]() -> None: + # error: [invalid-syntax] + # error: [invalid-syntax] + pass +``` + + + +## Default + +The default value for a `ParamSpec` can be either a list of types, `...`, or another `ParamSpec`. + +```py +def foo2[**P = ...]() -> None: + reveal_type(P) # revealed: typing.ParamSpec + +def foo3[**P = [int, str]]() -> None: + reveal_type(P) # revealed: typing.ParamSpec + +def foo4[**P, **Q = P](): + reveal_type(P) # revealed: typing.ParamSpec + reveal_type(Q) # revealed: typing.ParamSpec +``` + +Other values are invalid. + +```py +# error: [invalid-paramspec] +def foo[**P = int]() -> None: + pass +``` From b2387f4eab542203cc5cf838bb72457e50f17f16 Mon Sep 17 00:00:00 2001 From: RasmusNygren Date: Sat, 29 Nov 2025 12:13:54 +0100 Subject: [PATCH 26/67] [ty] fix typo in HasDefinition trait docstring (#21689) ## Summary Fixes a typo in the docstring for the definition method in the HasDefinition trait --- crates/ty_python_semantic/src/semantic_model.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ty_python_semantic/src/semantic_model.rs b/crates/ty_python_semantic/src/semantic_model.rs index 3f2a377c20..e2c550b0b3 100644 --- a/crates/ty_python_semantic/src/semantic_model.rs +++ b/crates/ty_python_semantic/src/semantic_model.rs @@ -397,7 +397,7 @@ pub trait HasType { } pub trait HasDefinition { - /// Returns the inferred type of `self`. + /// Returns the definition of `self`. /// /// ## Panics /// May panic if `self` is from another file than `model`. From d40590c8f963ed23c05b241ec6a574af7be24cd6 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Sat, 29 Nov 2025 15:41:54 +0100 Subject: [PATCH 27/67] [ty] Add code action to ignore diagnostic on the current line (#21595) --- .config/nextest.toml | 4 - crates/ruff_diagnostics/src/fix.rs | 4 + crates/ty_ide/src/code_action.rs | 501 +++++++++++++++++- .../mdtest/suppressions/type_ignore.md | 44 ++ crates/ty_python_semantic/src/lib.rs | 1 + crates/ty_python_semantic/src/suppression.rs | 71 +++ .../src/server/api/requests/code_action.rs | 3 +- .../e2e__code_actions__code_action.snap | 49 ++ ...action_attribute_access_on_unimported.snap | 49 +- ..._possible_missing_submodule_attribute.snap | 49 +- ...ions__code_action_undefined_decorator.snap | 46 ++ ...code_action_undefined_reference_multi.snap | 46 ++ crates/ty_test/src/assertion.rs | 9 + crates/ty_wasm/src/lib.rs | 24 +- 14 files changed, 868 insertions(+), 32 deletions(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index 3730656326..f2537ce580 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -7,10 +7,6 @@ serial = { max-threads = 1 } filter = 'binary(file_watching)' test-group = 'serial' -[[profile.default.overrides]] -filter = 'binary(e2e)' -test-group = 'serial' - [profile.ci] # Print out output for failing tests as soon as they fail, and also at the end # of the run (for easy scrollability). diff --git a/crates/ruff_diagnostics/src/fix.rs b/crates/ruff_diagnostics/src/fix.rs index 79cd3e6dff..937d4cd22c 100644 --- a/crates/ruff_diagnostics/src/fix.rs +++ b/crates/ruff_diagnostics/src/fix.rs @@ -149,6 +149,10 @@ impl Fix { &self.edits } + pub fn into_edits(self) -> Vec { + self.edits + } + /// Return the [`Applicability`] of the [`Fix`]. pub fn applicability(&self) -> Applicability { self.applicability diff --git a/crates/ty_ide/src/code_action.rs b/crates/ty_ide/src/code_action.rs index 947c7481ef..1a02389735 100644 --- a/crates/ty_ide/src/code_action.rs +++ b/crates/ty_ide/src/code_action.rs @@ -1,8 +1,10 @@ use crate::{completion, find_node::covering_node}; + use ruff_db::{files::File, parsed::parsed_module}; use ruff_diagnostics::Edit; use ruff_text_size::TextRange; use ty_project::Db; +use ty_python_semantic::create_suppression_fix; use ty_python_semantic::types::UNRESOLVED_REFERENCE; /// A `QuickFix` Code Action @@ -18,26 +20,501 @@ pub fn code_actions( file: File, diagnostic_range: TextRange, diagnostic_id: &str, -) -> Option> { +) -> Vec { let registry = db.lint_registry(); let Ok(lint_id) = registry.get(diagnostic_id) else { - return None; + return Vec::new(); }; - if lint_id.name() == UNRESOLVED_REFERENCE.name() { - let parsed = parsed_module(db, file).load(db); - let node = covering_node(parsed.syntax().into(), diagnostic_range).node(); - let symbol = &node.expr_name()?.id; - let fixes = completion::missing_imports(db, file, &parsed, symbol, node) + let mut actions = Vec::new(); + + if lint_id.name() == UNRESOLVED_REFERENCE.name() + && let Some(import_quick_fix) = create_import_symbol_quick_fix(db, file, diagnostic_range) + { + actions.extend(import_quick_fix); + } + + actions.push(QuickFix { + title: format!("Ignore '{}' for this line", lint_id.name()), + edits: create_suppression_fix(db, file, lint_id, diagnostic_range).into_edits(), + preferred: false, + }); + + actions +} + +fn create_import_symbol_quick_fix( + db: &dyn Db, + file: File, + diagnostic_range: TextRange, +) -> Option> { + let parsed = parsed_module(db, file).load(db); + let node = covering_node(parsed.syntax().into(), diagnostic_range).node(); + let symbol = &node.expr_name()?.id; + + Some( + completion::missing_imports(db, file, &parsed, symbol, node) .into_iter() .map(|import| QuickFix { title: import.label, edits: vec![import.edit], preferred: true, - }) - .collect(); - Some(fixes) - } else { - None + }), + ) +} + +#[cfg(test)] +mod tests { + + use crate::code_actions; + + use insta::assert_snapshot; + use ruff_db::{ + diagnostic::{ + Annotation, Diagnostic, DiagnosticFormat, DiagnosticId, DisplayDiagnosticConfig, + LintName, Span, SubDiagnostic, + }, + files::{File, system_path_to_file}, + system::{DbWithWritableSystem, SystemPathBuf}, + }; + use ruff_diagnostics::Fix; + use ruff_text_size::{TextRange, TextSize}; + use ty_project::ProjectMetadata; + use ty_python_semantic::{lint::LintMetadata, types::UNRESOLVED_REFERENCE}; + + #[test] + fn add_ignore() { + let test = CodeActionTest::with_source(r#"b = a / 10"#); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:1:5 + | + 1 | b = a / 10 + | ^ + | + - b = a / 10 + 1 + b = a / 10 # ty:ignore[unresolved-reference] + "); + } + + #[test] + fn add_ignore_existing_comment() { + let test = CodeActionTest::with_source(r#"b = a / 10 # fmt: off"#); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:1:5 + | + 1 | b = a / 10 # fmt: off + | ^ + | + - b = a / 10 # fmt: off + 1 + b = a / 10 # fmt: off # ty:ignore[unresolved-reference] + "); + } + + #[test] + fn add_ignore_trailing_whitespace() { + let test = CodeActionTest::with_source(r#"b = a / 10 "#); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:1:5 + | + 1 | b = a / 10 + | ^ + | + - b = a / 10 + 1 + b = a / 10 # ty:ignore[unresolved-reference] + "); + } + + #[test] + fn add_code_existing_ignore() { + let test = CodeActionTest::with_source( + r#" + b = a / 0 # ty:ignore[division-by-zero] + "#, + ); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:2:17 + | + 2 | b = a / 0 # ty:ignore[division-by-zero] + | ^ + | + 1 | + - b = a / 0 # ty:ignore[division-by-zero] + 2 + b = a / 0 # ty:ignore[division-by-zero, unresolved-reference] + 3 | + "); + } + + #[test] + fn add_code_existing_ignore_trailing_comma() { + let test = CodeActionTest::with_source( + r#" + b = a / 0 # ty:ignore[division-by-zero,] + "#, + ); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:2:17 + | + 2 | b = a / 0 # ty:ignore[division-by-zero,] + | ^ + | + 1 | + - b = a / 0 # ty:ignore[division-by-zero,] + 2 + b = a / 0 # ty:ignore[division-by-zero, unresolved-reference] + 3 | + "); + } + + #[test] + fn add_code_existing_ignore_trailing_whitespace() { + let test = CodeActionTest::with_source( + r#" + b = a / 0 # ty:ignore[division-by-zero ] + "#, + ); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:2:17 + | + 2 | b = a / 0 # ty:ignore[division-by-zero ] + | ^ + | + 1 | + - b = a / 0 # ty:ignore[division-by-zero ] + 2 + b = a / 0 # ty:ignore[division-by-zero, unresolved-reference ] + 3 | + "); + } + + #[test] + fn add_code_existing_ignore_with_reason() { + let test = CodeActionTest::with_source( + r#" + b = a / 0 # ty:ignore[division-by-zero] some explanation + "#, + ); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:2:17 + | + 2 | b = a / 0 # ty:ignore[division-by-zero] some explanation + | ^ + | + 1 | + - b = a / 0 # ty:ignore[division-by-zero] some explanation + 2 + b = a / 0 # ty:ignore[division-by-zero] some explanation # ty:ignore[unresolved-reference] + 3 | + "); + } + + #[test] + fn add_code_existing_ignore_start_line() { + let test = CodeActionTest::with_source( + r#" + b = ( + a # ty:ignore[division-by-zero] + / + 0 + ) + "#, + ); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:3:21 + | + 2 | b = ( + 3 | / a # ty:ignore[division-by-zero] + 4 | | / + 5 | | 0 + | |_____________________^ + 6 | ) + | + 1 | + 2 | b = ( + - a # ty:ignore[division-by-zero] + 3 + a # ty:ignore[division-by-zero, unresolved-reference] + 4 | / + 5 | 0 + 6 | ) + "); + } + + #[test] + fn add_code_existing_ignore_end_line() { + let test = CodeActionTest::with_source( + r#" + b = ( + a + / + 0 # ty:ignore[division-by-zero] + ) + "#, + ); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:3:21 + | + 2 | b = ( + 3 | / a + 4 | | / + 5 | | 0 # ty:ignore[division-by-zero] + | |_____________________^ + 6 | ) + | + 2 | b = ( + 3 | a + 4 | / + - 0 # ty:ignore[division-by-zero] + 5 + 0 # ty:ignore[division-by-zero, unresolved-reference] + 6 | ) + 7 | + "); + } + + #[test] + fn add_code_existing_ignores() { + let test = CodeActionTest::with_source( + r#" + b = ( + a # ty:ignore[division-by-zero] + / + 0 # ty:ignore[division-by-zero] + ) + "#, + ); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:3:21 + | + 2 | b = ( + 3 | / a # ty:ignore[division-by-zero] + 4 | | / + 5 | | 0 # ty:ignore[division-by-zero] + | |_____________________^ + 6 | ) + | + 1 | + 2 | b = ( + - a # ty:ignore[division-by-zero] + 3 + a # ty:ignore[division-by-zero, unresolved-reference] + 4 | / + 5 | 0 # ty:ignore[division-by-zero] + 6 | ) + "); + } + + #[test] + fn add_code_interpolated_string() { + let test = CodeActionTest::with_source( + r#" + b = f""" + {a} + more text + """ + "#, + ); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r#" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:3:18 + | + 2 | b = f""" + 3 | {a} + | ^ + 4 | more text + 5 | """ + | + 2 | b = f""" + 3 | {a} + 4 | more text + - """ + 5 + """ # ty:ignore[unresolved-reference] + 6 | + "#); + } + + #[test] + fn add_code_multiline_interpolation() { + let test = CodeActionTest::with_source( + r#" + b = f""" + { + a + } + more text + """ + "#, + ); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r#" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:4:17 + | + 2 | b = f""" + 3 | { + 4 | a + | ^ + 5 | } + 6 | more text + | + 1 | + 2 | b = f""" + 3 | { + - a + 4 + a # ty:ignore[unresolved-reference] + 5 | } + 6 | more text + 7 | """ + "#); + } + + #[test] + fn add_code_followed_by_multiline_string() { + let test = CodeActionTest::with_source( + r#" + b = a + """ + more text + """ + "#, + ); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r#" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:2:17 + | + 2 | b = a + """ + | ^ + 3 | more text + 4 | """ + | + 1 | + 2 | b = a + """ + 3 | more text + - """ + 4 + """ # ty:ignore[unresolved-reference] + 5 | + "#); + } + + #[test] + fn add_code_followed_by_continuation() { + let test = CodeActionTest::with_source( + r#" + b = a \ + + "test" + "#, + ); + + assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r#" + info[code-action]: Ignore 'unresolved-reference' for this line + --> main.py:2:17 + | + 2 | b = a \ + | ^ + 3 | + "test" + | + 1 | + 2 | b = a \ + - + "test" + 3 + + "test" # ty:ignore[unresolved-reference] + 4 | + "#); + } + + pub(super) struct CodeActionTest { + pub(super) db: ty_project::TestDb, + pub(super) file: File, + pub(super) diagnostic_range: TextRange, + } + + impl CodeActionTest { + pub(super) fn with_source(source: &str) -> Self { + let mut db = ty_project::TestDb::new(ProjectMetadata::new( + "test".into(), + SystemPathBuf::from("/"), + )); + + db.init_program().unwrap(); + + let mut cleansed = source.to_string(); + + let start = cleansed + .find("") + .expect("source text should contain a `` marker"); + cleansed.replace_range(start..start + "".len(), ""); + + let end = cleansed + .find("") + .expect("source text should contain a `` marker"); + + cleansed.replace_range(end..end + "".len(), ""); + + assert!(start <= end, " marker should be before marker"); + + db.write_file("main.py", cleansed) + .expect("write to memory file system to be successful"); + + let file = system_path_to_file(&db, "main.py").expect("newly written file to existing"); + + Self { + db, + file, + diagnostic_range: TextRange::new( + TextSize::try_from(start).unwrap(), + TextSize::try_from(end).unwrap(), + ), + } + } + + pub(super) fn code_actions(&self, lint: &'static LintMetadata) -> String { + use std::fmt::Write; + + let mut buf = String::new(); + + let config = DisplayDiagnosticConfig::default() + .color(false) + .show_fix_diff(true) + .format(DiagnosticFormat::Full); + + for mut action in code_actions(&self.db, self.file, self.diagnostic_range, &lint.name) { + let mut diagnostic = Diagnostic::new( + DiagnosticId::Lint(LintName::of("code-action")), + ruff_db::diagnostic::Severity::Info, + action.title, + ); + + diagnostic.annotate(Annotation::primary( + Span::from(self.file).with_range(self.diagnostic_range), + )); + + if action.preferred { + diagnostic.sub(SubDiagnostic::new( + ruff_db::diagnostic::SubDiagnosticSeverity::Help, + "This is a preferred code action", + )); + } + + let first_edit = action.edits.remove(0); + diagnostic.set_fix(Fix::safe_edits(first_edit, action.edits)); + + write!(buf, "{}", diagnostic.display(&self.db, &config)).unwrap(); + } + + buf + } } } diff --git a/crates/ty_python_semantic/resources/mdtest/suppressions/type_ignore.md b/crates/ty_python_semantic/resources/mdtest/suppressions/type_ignore.md index 60f0f349de..1368873182 100644 --- a/crates/ty_python_semantic/resources/mdtest/suppressions/type_ignore.md +++ b/crates/ty_python_semantic/resources/mdtest/suppressions/type_ignore.md @@ -85,6 +85,50 @@ a = test \ + 2 # type: ignore ``` +## Interpolated strings + +```toml +[environment] +python-version = "3.14" +``` + +Suppressions for expressions within interpolated strings can be placed after the interpolated string +if it's a single-line interpolation. + +```py +a = f""" +{test} +""" # type: ignore +``` + +For multiline-interpolation, put the ignore comment on the expression's start or end line: + +```py +a = f""" +{ + 10 / # type: ignore + 0 +} +""" + +a = f""" +{ + 10 / + 0 # type: ignore +} +""" +``` + +But not at the end of the f-string: + +```py +a = f""" +{ + 10 / 0 # error: [division-by-zero] +} +""" # error: [unused-ignore-comment] # type: ignore +``` + ## Codes Mypy supports `type: ignore[code]`. ty doesn't understand mypy's rule names. Therefore, ignore the diff --git a/crates/ty_python_semantic/src/lib.rs b/crates/ty_python_semantic/src/lib.rs index 84f755416f..be50dc9b52 100644 --- a/crates/ty_python_semantic/src/lib.rs +++ b/crates/ty_python_semantic/src/lib.rs @@ -25,6 +25,7 @@ pub use semantic_model::{ Completion, HasDefinition, HasType, MemberDefinition, NameKind, SemanticModel, }; pub use site_packages::{PythonEnvironment, SitePackagesPaths, SysPrefixPathOrigin}; +pub use suppression::create_suppression_fix; pub use types::DisplaySettings; pub use types::ide_support::{ ImportAliasResolution, ResolvedDefinition, definitions_for_attribute, definitions_for_bin_op, diff --git a/crates/ty_python_semantic/src/suppression.rs b/crates/ty_python_semantic/src/suppression.rs index ab246c1b0a..c0524728a2 100644 --- a/crates/ty_python_semantic/src/suppression.rs +++ b/crates/ty_python_semantic/src/suppression.rs @@ -375,6 +375,77 @@ fn check_unused_suppressions(context: &mut CheckSuppressionsContext) { } } +/// Creates a fix for adding a suppression comment to suppress `lint` for `range`. +/// +/// The fix prefers adding the code to an existing `ty: ignore[]` comment over +/// adding a new suppression comment. +pub fn create_suppression_fix(db: &dyn Db, file: File, id: LintId, range: TextRange) -> Fix { + let suppressions = suppressions(db, file); + let source = source_text(db, file); + + let mut existing_suppressions = suppressions.line_suppressions(range).filter(|suppression| { + matches!( + suppression.target, + SuppressionTarget::Lint(_) | SuppressionTarget::Empty, + ) + }); + + // If there's an existing `ty: ignore[]` comment, append the code to it instead of creating a new suppression comment. + if let Some(existing) = existing_suppressions.next() { + let comment_text = &source[existing.comment_range]; + // Only add to the existing ignore comment if it has no reason. + if let Some(before_closing_paren) = comment_text.trim_end().strip_suffix(']') { + let up_to_last_code = before_closing_paren.trim_end(); + + let insertion = if up_to_last_code.ends_with(',') { + format!(" {id}", id = id.name()) + } else { + format!(", {id}", id = id.name()) + }; + + let relative_offset_from_end = comment_text.text_len() - up_to_last_code.text_len(); + + return Fix::safe_edit(Edit::insertion( + insertion, + existing.comment_range.end() - relative_offset_from_end, + )); + } + } + + // Always insert a new suppression at the end of the range to avoid having to deal with multiline strings + // etc. + let parsed = parsed_module(db, file).load(db); + let tokens_after = parsed.tokens().after(range.end()); + + // Same as for `line_end` when building up the `suppressions`: Ignore newlines + // in multiline-strings, inside f-strings, or after a line continuation because we can't + // place a comment on those lines. + let line_end = tokens_after + .iter() + .find(|token| { + matches!( + token.kind(), + TokenKind::Newline | TokenKind::NonLogicalNewline + ) + }) + .map(Ranged::start) + .unwrap_or(source.text_len()); + + let up_to_line_end = &source[..line_end.to_usize()]; + let up_to_first_content = up_to_line_end.trim_end(); + let trailing_whitespace_len = up_to_line_end.text_len() - up_to_first_content.text_len(); + + let insertion = format!(" # ty:ignore[{id}]", id = id.name()); + + Fix::safe_edit(if trailing_whitespace_len == TextSize::ZERO { + Edit::insertion(insertion, line_end) + } else { + // `expr # fmt: off` + // Trim the trailing whitespace + Edit::replacement(insertion, line_end - trailing_whitespace_len, line_end) + }) +} + struct CheckSuppressionsContext<'a> { db: &'a dyn Db, file: File, diff --git a/crates/ty_server/src/server/api/requests/code_action.rs b/crates/ty_server/src/server/api/requests/code_action.rs index 6fac0d46f4..77cb9dcd1c 100644 --- a/crates/ty_server/src/server/api/requests/code_action.rs +++ b/crates/ty_server/src/server/api/requests/code_action.rs @@ -82,9 +82,8 @@ impl BackgroundDocumentRequestHandler for CodeActionRequestHandler { let encoding = snapshot.encoding(); if let Some(NumberOrString::String(diagnostic_id)) = &diagnostic.code && let Some(range) = diagnostic.range.to_text_range(db, file, url, encoding) - && let Some(fixes) = code_actions(db, file, range, diagnostic_id) { - for action in fixes { + for action in code_actions(db, file, range, diagnostic_id) { actions.push(CodeActionOrCommand::CodeAction(lsp_types::CodeAction { title: action.title, kind: Some(CodeActionKind::QUICKFIX), diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action.snap b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action.snap index af1fc0a86f..ae0da5c3ad 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action.snap @@ -51,5 +51,54 @@ expression: code_actions } }, "isPreferred": true + }, + { + "title": "Ignore 'unused-ignore-comment' for this line", + "kind": "quickfix", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 12 + }, + "end": { + "line": 0, + "character": 42 + } + }, + "severity": 2, + "code": "unused-ignore-comment", + "codeDescription": { + "href": "https://ty.dev/rules#unused-ignore-comment" + }, + "source": "ty", + "message": "Unused `ty: ignore` directive", + "relatedInformation": [], + "tags": [ + 1 + ] + } + ], + "edit": { + "changes": { + "file:///src/foo.py": [ + { + "range": { + "start": { + "line": 0, + "character": 41 + }, + "end": { + "line": 0, + "character": 41 + } + }, + "newText": ", unused-ignore-comment" + } + ] + } + }, + "isPreferred": false } ] diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_attribute_access_on_unimported.snap b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_attribute_access_on_unimported.snap index 44f60e3707..c82a14bc8e 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_attribute_access_on_unimported.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_attribute_access_on_unimported.snap @@ -2,4 +2,51 @@ source: crates/ty_server/tests/e2e/code_actions.rs expression: code_actions --- -null +[ + { + "title": "Ignore 'unresolved-reference' for this line", + "kind": "quickfix", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 3 + }, + "end": { + "line": 0, + "character": 9 + } + }, + "severity": 1, + "code": "unresolved-reference", + "codeDescription": { + "href": "https://ty.dev/rules#unresolved-reference" + }, + "source": "ty", + "message": "Name `typing` used when not defined", + "relatedInformation": [] + } + ], + "edit": { + "changes": { + "file:///src/foo.py": [ + { + "range": { + "start": { + "line": 0, + "character": 24 + }, + "end": { + "line": 0, + "character": 24 + } + }, + "newText": " # ty:ignore[unresolved-reference]" + } + ] + } + }, + "isPreferred": false + } +] diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_possible_missing_submodule_attribute.snap b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_possible_missing_submodule_attribute.snap index 44f60e3707..fe723d2fcc 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_possible_missing_submodule_attribute.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_possible_missing_submodule_attribute.snap @@ -2,4 +2,51 @@ source: crates/ty_server/tests/e2e/code_actions.rs expression: code_actions --- -null +[ + { + "title": "Ignore 'possibly-missing-attribute' for this line", + "kind": "quickfix", + "diagnostics": [ + { + "range": { + "start": { + "line": 1, + "character": 0 + }, + "end": { + "line": 1, + "character": 11 + } + }, + "severity": 2, + "code": "possibly-missing-attribute", + "codeDescription": { + "href": "https://ty.dev/rules#possibly-missing-attribute" + }, + "source": "ty", + "message": "Submodule `parser` may not be available as an attribute on module `html`", + "relatedInformation": [] + } + ], + "edit": { + "changes": { + "file:///src/foo.py": [ + { + "range": { + "start": { + "line": 1, + "character": 11 + }, + "end": { + "line": 1, + "character": 11 + } + }, + "newText": " # ty:ignore[possibly-missing-attribute]" + } + ] + } + }, + "isPreferred": false + } +] diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_decorator.snap b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_decorator.snap index c60378f1d2..576c493622 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_decorator.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_decorator.snap @@ -94,5 +94,51 @@ expression: code_actions } }, "isPreferred": true + }, + { + "title": "Ignore 'unresolved-reference' for this line", + "kind": "quickfix", + "diagnostics": [ + { + "range": { + "start": { + "line": 1, + "character": 1 + }, + "end": { + "line": 1, + "character": 11 + } + }, + "severity": 1, + "code": "unresolved-reference", + "codeDescription": { + "href": "https://ty.dev/rules#unresolved-reference" + }, + "source": "ty", + "message": "Name `deprecated` used when not defined", + "relatedInformation": [] + } + ], + "edit": { + "changes": { + "file:///src/foo.py": [ + { + "range": { + "start": { + "line": 1, + "character": 28 + }, + "end": { + "line": 1, + "character": 28 + } + }, + "newText": " # ty:ignore[unresolved-reference]" + } + ] + } + }, + "isPreferred": false } ] diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_reference_multi.snap b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_reference_multi.snap index 940dd3794f..d081e783de 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_reference_multi.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_reference_multi.snap @@ -94,5 +94,51 @@ expression: code_actions } }, "isPreferred": true + }, + { + "title": "Ignore 'unresolved-reference' for this line", + "kind": "quickfix", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 3 + }, + "end": { + "line": 0, + "character": 10 + } + }, + "severity": 1, + "code": "unresolved-reference", + "codeDescription": { + "href": "https://ty.dev/rules#unresolved-reference" + }, + "source": "ty", + "message": "Name `Literal` used when not defined", + "relatedInformation": [] + } + ], + "edit": { + "changes": { + "file:///src/foo.py": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 17 + } + }, + "newText": " # ty:ignore[unresolved-reference]" + } + ] + } + }, + "isPreferred": false } ] diff --git a/crates/ty_test/src/assertion.rs b/crates/ty_test/src/assertion.rs index e5b7baaf6d..fba6f7c899 100644 --- a/crates/ty_test/src/assertion.rs +++ b/crates/ty_test/src/assertion.rs @@ -254,6 +254,15 @@ impl<'a> UnparsedAssertion<'a> { let comment = comment.trim().strip_prefix('#')?.trim(); let (keyword, body) = comment.split_once(':')?; let keyword = keyword.trim(); + + // Support other pragma comments coming after `error` or `revealed`, e.g. + // `# error: [code] # type: ignore` (nested pragma comments) + let body = if let Some((before_nested, _)) = body.split_once('#') { + before_nested + } else { + body + }; + let body = body.trim(); match keyword { diff --git a/crates/ty_wasm/src/lib.rs b/crates/ty_wasm/src/lib.rs index daa1f63a21..1ae085581c 100644 --- a/crates/ty_wasm/src/lib.rs +++ b/crates/ty_wasm/src/lib.rs @@ -573,16 +573,16 @@ impl Workspace { // This is only for actions that are messy to compute at the time of the diagnostic. // For instance, suggesting imports requires finding symbols for the entire project, // which is dubious when you're in the middle of resolving symbols. - if let Some(range) = diagnostic.inner.range() - && let Some(fixes) = ty_ide::code_actions( - &self.db, - file_id.file, - range, - diagnostic.inner.id().as_str(), - ) - { - for action in fixes { - actions.push(CodeAction { + if let Some(range) = diagnostic.inner.range() { + actions.extend( + ty_ide::code_actions( + &self.db, + file_id.file, + range, + diagnostic.inner.id().as_str(), + ) + .into_iter() + .map(|action| CodeAction { title: action.title, preferred: action.preferred, edits: action @@ -590,8 +590,8 @@ impl Workspace { .into_iter() .map(|edit| edit_to_text_edit(self, file_id.file, &edit)) .collect(), - }); - } + }), + ); } if actions.is_empty() { From 69ace002102c7201f4514ffad87b87ce6a0d604f Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 29 Nov 2025 14:54:00 +0000 Subject: [PATCH 28/67] [ty] Rename `types::liskov` to `types::overrides` (#21694) --- crates/ty_python_semantic/src/types.rs | 2 +- crates/ty_python_semantic/src/types/diagnostic.rs | 2 +- crates/ty_python_semantic/src/types/infer/builder.rs | 7 ++++--- .../src/types/{liskov.rs => overrides.rs} | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) rename crates/ty_python_semantic/src/types/{liskov.rs => overrides.rs} (98%) diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 3c701de557..c7c370ed15 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -96,11 +96,11 @@ mod generics; pub mod ide_support; mod infer; mod instance; -mod liskov; mod member; mod mro; mod narrow; mod newtype; +mod overrides; mod protocol_class; mod signatures; mod special_form; diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index 660af238bb..782a25b98e 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -18,7 +18,7 @@ use crate::types::class::{ CodeGeneratorKind, DisjointBase, DisjointBaseKind, Field, MethodDecorator, }; use crate::types::function::{FunctionDecorators, FunctionType, KnownFunction, OverloadLiteral}; -use crate::types::liskov::MethodKind; +use crate::types::overrides::MethodKind; use crate::types::string_annotation::{ BYTE_STRING_TYPE_ANNOTATION, ESCAPE_CHARACTER_IN_FORWARD_ANNOTATION, FSTRING_TYPE_ANNOTATION, IMPLICIT_CONCATENATED_STRING_TYPE_ANNOTATION, INVALID_SYNTAX_IN_FORWARD_ANNOTATION, diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index df165921fe..4c97ad8c60 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -109,7 +109,7 @@ use crate::types::{ Truthiness, Type, TypeAliasType, TypeAndQualifiers, TypeContext, TypeQualifiers, TypeVarBoundOrConstraints, TypeVarBoundOrConstraintsEvaluation, TypeVarDefaultEvaluation, TypeVarIdentity, TypeVarInstance, TypeVarKind, TypeVarVariance, TypedDictType, UnionBuilder, - UnionType, UnionTypeInstance, binding_type, infer_scope_types, liskov, todo_type, + UnionType, UnionTypeInstance, binding_type, infer_scope_types, overrides, todo_type, }; use crate::types::{ClassBase, add_inferred_python_version_hint_to_diagnostic}; use crate::unpack::{EvaluationMode, UnpackPosition}; @@ -972,8 +972,9 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { } } - // (8) Check for Liskov violations - liskov::check_class(&self.context, class); + // (8) Check for violations of the Liskov Substitution Principle, + // and for violations of other rules relating to invalid overrides of some sort. + overrides::check_class(&self.context, class); if let Some(protocol) = class.into_protocol_class(self.db()) { protocol.validate_members(&self.context); diff --git a/crates/ty_python_semantic/src/types/liskov.rs b/crates/ty_python_semantic/src/types/overrides.rs similarity index 98% rename from crates/ty_python_semantic/src/types/liskov.rs rename to crates/ty_python_semantic/src/types/overrides.rs index 79b79889fc..0cfc8c477b 100644 --- a/crates/ty_python_semantic/src/types/liskov.rs +++ b/crates/ty_python_semantic/src/types/overrides.rs @@ -1,4 +1,5 @@ -//! Checks relating to the [Liskov Substitution Principle]. +//! Checks relating to invalid method overrides in subclasses, +//! including (but not limited to) violations of the [Liskov Substitution Principle]. //! //! [Liskov Substitution Principle]: https://en.wikipedia.org/wiki/Liskov_substitution_principle From b02e8212c99e166925b50c3be6583f53a9a5d01d Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 30 Nov 2025 13:40:33 +0000 Subject: [PATCH 29/67] [ty] Don't introduce invalid syntax when autofixing override-of-final-method (#21699) --- crates/ruff_db/src/diagnostic/mod.rs | 7 + .../resources/mdtest/final.md | 24 +- ..._possibly-undefined…_(fc7b496fd1986deb).snap | 132 ++--- ...annot_override_a_me…_(338615109711a91b).snap | 550 +++++++++--------- ...iagnostic_edge_case…_(2389d52c5ecfa2bd).snap | 2 +- ...nly_the_first_`@fin…_(9863b583f4c651c5).snap | 4 +- ...verloaded_methods_d…_(861757f48340ed92).snap | 47 +- .../src/types/diagnostic.rs | 89 ++- .../ty_python_semantic/src/types/overrides.rs | 2 +- 9 files changed, 433 insertions(+), 424 deletions(-) diff --git a/crates/ruff_db/src/diagnostic/mod.rs b/crates/ruff_db/src/diagnostic/mod.rs index a8f2d09dd8..33348ddf2e 100644 --- a/crates/ruff_db/src/diagnostic/mod.rs +++ b/crates/ruff_db/src/diagnostic/mod.rs @@ -354,6 +354,13 @@ impl Diagnostic { Arc::make_mut(&mut self.inner).fix = Some(fix); } + /// If `fix` is `Some`, set the fix for this diagnostic. + pub fn set_optional_fix(&mut self, fix: Option) { + if let Some(fix) = fix { + self.set_fix(fix); + } + } + /// Remove the fix for this diagnostic. pub fn remove_fix(&mut self) { Arc::make_mut(&mut self.inner).fix = None; diff --git a/crates/ty_python_semantic/resources/mdtest/final.md b/crates/ty_python_semantic/resources/mdtest/final.md index 1ccb647e4d..91c6f9273f 100644 --- a/crates/ty_python_semantic/resources/mdtest/final.md +++ b/crates/ty_python_semantic/resources/mdtest/final.md @@ -51,6 +51,10 @@ class Parent: @final def my_property2(self) -> int: ... + @property + @final + def my_property3(self) -> int: ... + @final @classmethod def class_method1(cls) -> int: ... @@ -86,6 +90,13 @@ class Child(Parent): @property def my_property2(self) -> int: ... # error: [override-of-final-method] + @my_property2.setter + def my_property2(self, x: int) -> None: ... + + @property + def my_property3(self) -> int: ... # error: [override-of-final-method] + @my_property3.deleter + def my_proeprty3(self) -> None: ... @classmethod def class_method1(cls) -> int: ... # error: [override-of-final-method] @@ -230,7 +241,7 @@ class ChildOfBad(Bad): def bar(self, x: str) -> str: ... @overload def bar(self, x: int) -> int: ... # error: [override-of-final-method] - + @overload def baz(self, x: str) -> str: ... @overload @@ -461,14 +472,17 @@ class B(A): def method1(self) -> None: ... # error: [override-of-final-method] def method2(self) -> None: ... # error: [override-of-final-method] def method3(self) -> None: ... # error: [override-of-final-method] - def method4(self) -> None: ... # error: [override-of-final-method] + + # check that autofixes don't introduce invalid syntax + # if there are multiple statements on one line + # + # TODO: we should emit a Liskov violation here too + # error: [override-of-final-method] + method4 = 42; unrelated = 56 # fmt: skip # Possible overrides of possibly `@final` methods... class C(A): if coinflip(): - # TODO: the autofix here introduces invalid syntax because there are now no - # statements inside the `if:` branch - # (but it might still be a useful autofix in an IDE context?) def method1(self) -> None: ... # error: [override-of-final-method] else: pass diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_A_possibly-undefined…_(fc7b496fd1986deb).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_A_possibly-undefined…_(fc7b496fd1986deb).snap index 41b39fef34..a137c44c51 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_A_possibly-undefined…_(fc7b496fd1986deb).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_A_possibly-undefined…_(fc7b496fd1986deb).snap @@ -49,26 +49,29 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/final.md 35 | def method1(self) -> None: ... # error: [override-of-final-method] 36 | def method2(self) -> None: ... # error: [override-of-final-method] 37 | def method3(self) -> None: ... # error: [override-of-final-method] -38 | def method4(self) -> None: ... # error: [override-of-final-method] -39 | -40 | # Possible overrides of possibly `@final` methods... -41 | class C(A): -42 | if coinflip(): -43 | # TODO: the autofix here introduces invalid syntax because there are now no -44 | # statements inside the `if:` branch -45 | # (but it might still be a useful autofix in an IDE context?) -46 | def method1(self) -> None: ... # error: [override-of-final-method] -47 | else: -48 | pass -49 | -50 | if coinflip(): -51 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method] -52 | else: -53 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method] -54 | -55 | if coinflip(): -56 | def method3(self) -> None: ... # error: [override-of-final-method] -57 | def method4(self) -> None: ... # error: [override-of-final-method] +38 | +39 | # check that autofixes don't introduce invalid syntax +40 | # if there are multiple statements on one line +41 | # +42 | # TODO: we should emit a Liskov violation here too +43 | # error: [override-of-final-method] +44 | method4 = 42; unrelated = 56 # fmt: skip +45 | +46 | # Possible overrides of possibly `@final` methods... +47 | class C(A): +48 | if coinflip(): +49 | def method1(self) -> None: ... # error: [override-of-final-method] +50 | else: +51 | pass +52 | +53 | if coinflip(): +54 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method] +55 | else: +56 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method] +57 | +58 | if coinflip(): +59 | def method3(self) -> None: ... # error: [override-of-final-method] +60 | def method4(self) -> None: ... # error: [override-of-final-method] ``` # Diagnostics @@ -104,7 +107,7 @@ info: rule `override-of-final-method` is enabled by default 35 + # error: [override-of-final-method] 36 | def method2(self) -> None: ... # error: [override-of-final-method] 37 | def method3(self) -> None: ... # error: [override-of-final-method] -38 | def method4(self) -> None: ... # error: [override-of-final-method] +38 | note: This is an unsafe fix and may change runtime behavior ``` @@ -118,7 +121,6 @@ error[override-of-final-method]: Cannot override `A.method2` 36 | def method2(self) -> None: ... # error: [override-of-final-method] | ^^^^^^^ Overrides a definition from superclass `A` 37 | def method3(self) -> None: ... # error: [override-of-final-method] -38 | def method4(self) -> None: ... # error: [override-of-final-method] | info: `A.method2` is decorated with `@final`, forbidding overrides --> src/mdtest_snippet.py:16:9 @@ -140,8 +142,8 @@ info: rule `override-of-final-method` is enabled by default - def method2(self) -> None: ... # error: [override-of-final-method] 36 + # error: [override-of-final-method] 37 | def method3(self) -> None: ... # error: [override-of-final-method] -38 | def method4(self) -> None: ... # error: [override-of-final-method] -39 | +38 | +39 | # check that autofixes don't introduce invalid syntax note: This is an unsafe fix and may change runtime behavior ``` @@ -154,7 +156,8 @@ error[override-of-final-method]: Cannot override `A.method3` 36 | def method2(self) -> None: ... # error: [override-of-final-method] 37 | def method3(self) -> None: ... # error: [override-of-final-method] | ^^^^^^^ Overrides a definition from superclass `A` -38 | def method4(self) -> None: ... # error: [override-of-final-method] +38 | +39 | # check that autofixes don't introduce invalid syntax | info: `A.method3` is decorated with `@final`, forbidding overrides --> src/mdtest_snippet.py:20:9 @@ -174,23 +177,23 @@ info: rule `override-of-final-method` is enabled by default 36 | def method2(self) -> None: ... # error: [override-of-final-method] - def method3(self) -> None: ... # error: [override-of-final-method] 37 + # error: [override-of-final-method] -38 | def method4(self) -> None: ... # error: [override-of-final-method] -39 | -40 | # Possible overrides of possibly `@final` methods... +38 | +39 | # check that autofixes don't introduce invalid syntax +40 | # if there are multiple statements on one line note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `A.method4` - --> src/mdtest_snippet.py:38:9 + --> src/mdtest_snippet.py:44:5 | -36 | def method2(self) -> None: ... # error: [override-of-final-method] -37 | def method3(self) -> None: ... # error: [override-of-final-method] -38 | def method4(self) -> None: ... # error: [override-of-final-method] - | ^^^^^^^ Overrides a definition from superclass `A` -39 | -40 | # Possible overrides of possibly `@final` methods... +42 | # TODO: we should emit a Liskov violation here too +43 | # error: [override-of-final-method] +44 | method4 = 42; unrelated = 56 # fmt: skip + | ^^^^^^^ Overrides a definition from superclass `A` +45 | +46 | # Possible overrides of possibly `@final` methods... | info: `A.method4` is decorated with `@final`, forbidding overrides --> src/mdtest_snippet.py:29:9 @@ -206,28 +209,19 @@ info: `A.method4` is decorated with `@final`, forbidding overrides | help: Remove the override of `method4` info: rule `override-of-final-method` is enabled by default -35 | def method1(self) -> None: ... # error: [override-of-final-method] -36 | def method2(self) -> None: ... # error: [override-of-final-method] -37 | def method3(self) -> None: ... # error: [override-of-final-method] - - def method4(self) -> None: ... # error: [override-of-final-method] -38 + # error: [override-of-final-method] -39 | -40 | # Possible overrides of possibly `@final` methods... -41 | class C(A): -note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `A.method1` - --> src/mdtest_snippet.py:46:13 + --> src/mdtest_snippet.py:49:13 | -44 | # statements inside the `if:` branch -45 | # (but it might still be a useful autofix in an IDE context?) -46 | def method1(self) -> None: ... # error: [override-of-final-method] +47 | class C(A): +48 | if coinflip(): +49 | def method1(self) -> None: ... # error: [override-of-final-method] | ^^^^^^^ Overrides a definition from superclass `A` -47 | else: -48 | pass +50 | else: +51 | pass | info: `A.method1` is decorated with `@final`, forbidding overrides --> src/mdtest_snippet.py:8:9 @@ -243,26 +237,17 @@ info: `A.method1` is decorated with `@final`, forbidding overrides | help: Remove the override of `method1` info: rule `override-of-final-method` is enabled by default -43 | # TODO: the autofix here introduces invalid syntax because there are now no -44 | # statements inside the `if:` branch -45 | # (but it might still be a useful autofix in an IDE context?) - - def method1(self) -> None: ... # error: [override-of-final-method] -46 + # error: [override-of-final-method] -47 | else: -48 | pass -49 | -note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `A.method3` - --> src/mdtest_snippet.py:56:13 + --> src/mdtest_snippet.py:59:13 | -55 | if coinflip(): -56 | def method3(self) -> None: ... # error: [override-of-final-method] +58 | if coinflip(): +59 | def method3(self) -> None: ... # error: [override-of-final-method] | ^^^^^^^ Overrides a definition from superclass `A` -57 | def method4(self) -> None: ... # error: [override-of-final-method] +60 | def method4(self) -> None: ... # error: [override-of-final-method] | info: `A.method3` is decorated with `@final`, forbidding overrides --> src/mdtest_snippet.py:20:9 @@ -277,23 +262,16 @@ info: `A.method3` is decorated with `@final`, forbidding overrides | help: Remove the override of `method3` info: rule `override-of-final-method` is enabled by default -53 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method] -54 | -55 | if coinflip(): - - def method3(self) -> None: ... # error: [override-of-final-method] -56 + # error: [override-of-final-method] -57 | def method4(self) -> None: ... # error: [override-of-final-method] -note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `A.method4` - --> src/mdtest_snippet.py:57:13 + --> src/mdtest_snippet.py:60:13 | -55 | if coinflip(): -56 | def method3(self) -> None: ... # error: [override-of-final-method] -57 | def method4(self) -> None: ... # error: [override-of-final-method] +58 | if coinflip(): +59 | def method3(self) -> None: ... # error: [override-of-final-method] +60 | def method4(self) -> None: ... # error: [override-of-final-method] | ^^^^^^^ Overrides a definition from superclass `A` | info: `A.method4` is decorated with `@final`, forbidding overrides @@ -310,11 +288,5 @@ info: `A.method4` is decorated with `@final`, forbidding overrides | help: Remove the override of `method4` info: rule `override-of-final-method` is enabled by default -54 | -55 | if coinflip(): -56 | def method3(self) -> None: ... # error: [override-of-final-method] - - def method4(self) -> None: ... # error: [override-of-final-method] -57 + # error: [override-of-final-method] -note: This is an unsafe fix and may change runtime behavior ``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Cannot_override_a_me…_(338615109711a91b).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Cannot_override_a_me…_(338615109711a91b).snap index ad51738ec5..fbb89644c6 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Cannot_override_a_me…_(338615109711a91b).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Cannot_override_a_me…_(338615109711a91b).snap @@ -28,93 +28,93 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/final.md 14 | @final 15 | def my_property2(self) -> int: ... 16 | - 17 | @final - 18 | @classmethod - 19 | def class_method1(cls) -> int: ... + 17 | @property + 18 | @final + 19 | def my_property3(self) -> int: ... 20 | - 21 | @classmethod - 22 | @final - 23 | def class_method2(cls) -> int: ... + 21 | @final + 22 | @classmethod + 23 | def class_method1(cls) -> int: ... 24 | - 25 | @final - 26 | @staticmethod - 27 | def static_method1() -> int: ... + 25 | @classmethod + 26 | @final + 27 | def class_method2(cls) -> int: ... 28 | - 29 | @staticmethod - 30 | @final - 31 | def static_method2() -> int: ... + 29 | @final + 30 | @staticmethod + 31 | def static_method1() -> int: ... 32 | - 33 | @lossy_decorator + 33 | @staticmethod 34 | @final - 35 | def decorated_1(self): ... + 35 | def static_method2() -> int: ... 36 | - 37 | @final - 38 | @lossy_decorator - 39 | def decorated_2(self): ... + 37 | @lossy_decorator + 38 | @final + 39 | def decorated_1(self): ... 40 | - 41 | class Child(Parent): - 42 | # explicitly test the concise diagnostic message, - 43 | # which is different to the verbose diagnostic summary message: - 44 | # - 45 | # error: [override-of-final-method] "Cannot override final member `foo` from superclass `Parent`" - 46 | def foo(self): ... - 47 | @property - 48 | def my_property1(self) -> int: ... # error: [override-of-final-method] - 49 | - 50 | @property - 51 | def my_property2(self) -> int: ... # error: [override-of-final-method] - 52 | - 53 | @classmethod - 54 | def class_method1(cls) -> int: ... # error: [override-of-final-method] - 55 | - 56 | @staticmethod - 57 | def static_method1() -> int: ... # error: [override-of-final-method] + 41 | @final + 42 | @lossy_decorator + 43 | def decorated_2(self): ... + 44 | + 45 | class Child(Parent): + 46 | # explicitly test the concise diagnostic message, + 47 | # which is different to the verbose diagnostic summary message: + 48 | # + 49 | # error: [override-of-final-method] "Cannot override final member `foo` from superclass `Parent`" + 50 | def foo(self): ... + 51 | @property + 52 | def my_property1(self) -> int: ... # error: [override-of-final-method] + 53 | + 54 | @property + 55 | def my_property2(self) -> int: ... # error: [override-of-final-method] + 56 | @my_property2.setter + 57 | def my_property2(self, x: int) -> None: ... 58 | - 59 | @classmethod - 60 | def class_method2(cls) -> int: ... # error: [override-of-final-method] - 61 | - 62 | @staticmethod - 63 | def static_method2() -> int: ... # error: [override-of-final-method] - 64 | - 65 | def decorated_1(self): ... # TODO: should emit [override-of-final-method] + 59 | @property + 60 | def my_property3(self) -> int: ... # error: [override-of-final-method] + 61 | @my_property3.deleter + 62 | def my_proeprty3(self) -> None: ... + 63 | + 64 | @classmethod + 65 | def class_method1(cls) -> int: ... # error: [override-of-final-method] 66 | - 67 | @lossy_decorator - 68 | def decorated_2(self): ... # TODO: should emit [override-of-final-method] + 67 | @staticmethod + 68 | def static_method1() -> int: ... # error: [override-of-final-method] 69 | - 70 | class OtherChild(Parent): ... - 71 | - 72 | class Grandchild(OtherChild): + 70 | @classmethod + 71 | def class_method2(cls) -> int: ... # error: [override-of-final-method] + 72 | 73 | @staticmethod - 74 | # TODO: we should emit a Liskov violation here too - 75 | # error: [override-of-final-method] - 76 | def foo(): ... - 77 | @property - 78 | # TODO: we should emit a Liskov violation here too - 79 | # error: [override-of-final-method] - 80 | def my_property1(self) -> str: ... - 81 | # TODO: we should emit a Liskov violation here too - 82 | # error: [override-of-final-method] - 83 | class_method1 = None - 84 | - 85 | # Diagnostic edge case: `final` is very far away from the method definition in the source code: - 86 | - 87 | T = TypeVar("T") - 88 | - 89 | def identity(x: T) -> T: ... - 90 | - 91 | class Foo: - 92 | @final - 93 | @identity - 94 | @identity - 95 | @identity - 96 | @identity - 97 | @identity - 98 | @identity - 99 | @identity -100 | @identity -101 | @identity -102 | @identity -103 | @identity + 74 | def static_method2() -> int: ... # error: [override-of-final-method] + 75 | + 76 | def decorated_1(self): ... # TODO: should emit [override-of-final-method] + 77 | + 78 | @lossy_decorator + 79 | def decorated_2(self): ... # TODO: should emit [override-of-final-method] + 80 | + 81 | class OtherChild(Parent): ... + 82 | + 83 | class Grandchild(OtherChild): + 84 | @staticmethod + 85 | # TODO: we should emit a Liskov violation here too + 86 | # error: [override-of-final-method] + 87 | def foo(): ... + 88 | @property + 89 | # TODO: we should emit a Liskov violation here too + 90 | # error: [override-of-final-method] + 91 | def my_property1(self) -> str: ... + 92 | # TODO: we should emit a Liskov violation here too + 93 | # error: [override-of-final-method] + 94 | class_method1 = None + 95 | + 96 | # Diagnostic edge case: `final` is very far away from the method definition in the source code: + 97 | + 98 | T = TypeVar("T") + 99 | +100 | def identity(x: T) -> T: ... +101 | +102 | class Foo: +103 | @final 104 | @identity 105 | @identity 106 | @identity @@ -122,24 +122,35 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/final.md 108 | @identity 109 | @identity 110 | @identity -111 | def bar(self): ... -112 | -113 | class Baz(Foo): -114 | def bar(self): ... # error: [override-of-final-method] +111 | @identity +112 | @identity +113 | @identity +114 | @identity +115 | @identity +116 | @identity +117 | @identity +118 | @identity +119 | @identity +120 | @identity +121 | @identity +122 | def bar(self): ... +123 | +124 | class Baz(Foo): +125 | def bar(self): ... # error: [override-of-final-method] ``` # Diagnostics ``` error[override-of-final-method]: Cannot override `Parent.foo` - --> src/mdtest_snippet.pyi:46:9 + --> src/mdtest_snippet.pyi:50:9 | -44 | # -45 | # error: [override-of-final-method] "Cannot override final member `foo` from superclass `Parent`" -46 | def foo(self): ... +48 | # +49 | # error: [override-of-final-method] "Cannot override final member `foo` from superclass `Parent`" +50 | def foo(self): ... | ^^^ Overrides a definition from superclass `Parent` -47 | @property -48 | def my_property1(self) -> int: ... # error: [override-of-final-method] +51 | @property +52 | def my_property1(self) -> int: ... # error: [override-of-final-method] | info: `Parent.foo` is decorated with `@final`, forbidding overrides --> src/mdtest_snippet.pyi:6:5 @@ -154,28 +165,28 @@ info: `Parent.foo` is decorated with `@final`, forbidding overrides | help: Remove the override of `foo` info: rule `override-of-final-method` is enabled by default -43 | # which is different to the verbose diagnostic summary message: -44 | # -45 | # error: [override-of-final-method] "Cannot override final member `foo` from superclass `Parent`" +47 | # which is different to the verbose diagnostic summary message: +48 | # +49 | # error: [override-of-final-method] "Cannot override final member `foo` from superclass `Parent`" - def foo(self): ... -46 + -47 | @property -48 | def my_property1(self) -> int: ... # error: [override-of-final-method] -49 | +50 + +51 | @property +52 | def my_property1(self) -> int: ... # error: [override-of-final-method] +53 | note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `Parent.my_property1` - --> src/mdtest_snippet.pyi:48:9 + --> src/mdtest_snippet.pyi:52:9 | -46 | def foo(self): ... -47 | @property -48 | def my_property1(self) -> int: ... # error: [override-of-final-method] +50 | def foo(self): ... +51 | @property +52 | def my_property1(self) -> int: ... # error: [override-of-final-method] | ^^^^^^^^^^^^ Overrides a definition from superclass `Parent` -49 | -50 | @property +53 | +54 | @property | info: `Parent.my_property1` is decorated with `@final`, forbidding overrides --> src/mdtest_snippet.pyi:9:5 @@ -192,28 +203,18 @@ info: `Parent.my_property1` is decorated with `@final`, forbidding overrides | help: Remove the override of `my_property1` info: rule `override-of-final-method` is enabled by default -44 | # -45 | # error: [override-of-final-method] "Cannot override final member `foo` from superclass `Parent`" -46 | def foo(self): ... - - @property - - def my_property1(self) -> int: ... # error: [override-of-final-method] -47 + # error: [override-of-final-method] -48 | -49 | @property -50 | def my_property2(self) -> int: ... # error: [override-of-final-method] -note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `Parent.my_property2` - --> src/mdtest_snippet.pyi:51:9 + --> src/mdtest_snippet.pyi:55:9 | -50 | @property -51 | def my_property2(self) -> int: ... # error: [override-of-final-method] +54 | @property +55 | def my_property2(self) -> int: ... # error: [override-of-final-method] | ^^^^^^^^^^^^ Overrides a definition from superclass `Parent` -52 | -53 | @classmethod +56 | @my_property2.setter +57 | def my_property2(self, x: int) -> None: ... | info: `Parent.my_property2` is decorated with `@final`, forbidding overrides --> src/mdtest_snippet.pyi:14:5 @@ -224,181 +225,197 @@ info: `Parent.my_property2` is decorated with `@final`, forbidding overrides 15 | def my_property2(self) -> int: ... | ------------ `Parent.my_property2` defined here 16 | -17 | @final +17 | @property | -help: Remove the override of `my_property2` +help: Remove the getter and setter for `my_property2` +info: rule `override-of-final-method` is enabled by default + +``` + +``` +error[override-of-final-method]: Cannot override `Parent.my_property3` + --> src/mdtest_snippet.pyi:60:9 + | +59 | @property +60 | def my_property3(self) -> int: ... # error: [override-of-final-method] + | ^^^^^^^^^^^^ Overrides a definition from superclass `Parent` +61 | @my_property3.deleter +62 | def my_proeprty3(self) -> None: ... + | +info: `Parent.my_property3` is decorated with `@final`, forbidding overrides + --> src/mdtest_snippet.pyi:18:5 + | +17 | @property +18 | @final + | ------ +19 | def my_property3(self) -> int: ... + | ------------ `Parent.my_property3` defined here +20 | +21 | @final + | +help: Remove the override of `my_property3` info: rule `override-of-final-method` is enabled by default -47 | @property -48 | def my_property1(self) -> int: ... # error: [override-of-final-method] -49 | - - @property - - def my_property2(self) -> int: ... # error: [override-of-final-method] -50 + # error: [override-of-final-method] -51 | -52 | @classmethod -53 | def class_method1(cls) -> int: ... # error: [override-of-final-method] -note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `Parent.class_method1` - --> src/mdtest_snippet.pyi:54:9 + --> src/mdtest_snippet.pyi:65:9 | -53 | @classmethod -54 | def class_method1(cls) -> int: ... # error: [override-of-final-method] +64 | @classmethod +65 | def class_method1(cls) -> int: ... # error: [override-of-final-method] | ^^^^^^^^^^^^^ Overrides a definition from superclass `Parent` -55 | -56 | @staticmethod +66 | +67 | @staticmethod | info: `Parent.class_method1` is decorated with `@final`, forbidding overrides - --> src/mdtest_snippet.pyi:17:5 + --> src/mdtest_snippet.pyi:21:5 | -15 | def my_property2(self) -> int: ... -16 | -17 | @final - | ------ -18 | @classmethod -19 | def class_method1(cls) -> int: ... - | ------------- `Parent.class_method1` defined here +19 | def my_property3(self) -> int: ... 20 | -21 | @classmethod +21 | @final + | ------ +22 | @classmethod +23 | def class_method1(cls) -> int: ... + | ------------- `Parent.class_method1` defined here +24 | +25 | @classmethod | help: Remove the override of `class_method1` info: rule `override-of-final-method` is enabled by default -50 | @property -51 | def my_property2(self) -> int: ... # error: [override-of-final-method] -52 | +61 | @my_property3.deleter +62 | def my_proeprty3(self) -> None: ... +63 | - @classmethod - def class_method1(cls) -> int: ... # error: [override-of-final-method] -53 + # error: [override-of-final-method] -54 | -55 | @staticmethod -56 | def static_method1() -> int: ... # error: [override-of-final-method] +64 + # error: [override-of-final-method] +65 | +66 | @staticmethod +67 | def static_method1() -> int: ... # error: [override-of-final-method] note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `Parent.static_method1` - --> src/mdtest_snippet.pyi:57:9 + --> src/mdtest_snippet.pyi:68:9 | -56 | @staticmethod -57 | def static_method1() -> int: ... # error: [override-of-final-method] +67 | @staticmethod +68 | def static_method1() -> int: ... # error: [override-of-final-method] | ^^^^^^^^^^^^^^ Overrides a definition from superclass `Parent` -58 | -59 | @classmethod +69 | +70 | @classmethod | info: `Parent.static_method1` is decorated with `@final`, forbidding overrides - --> src/mdtest_snippet.pyi:25:5 + --> src/mdtest_snippet.pyi:29:5 | -23 | def class_method2(cls) -> int: ... -24 | -25 | @final - | ------ -26 | @staticmethod -27 | def static_method1() -> int: ... - | -------------- `Parent.static_method1` defined here +27 | def class_method2(cls) -> int: ... 28 | -29 | @staticmethod +29 | @final + | ------ +30 | @staticmethod +31 | def static_method1() -> int: ... + | -------------- `Parent.static_method1` defined here +32 | +33 | @staticmethod | help: Remove the override of `static_method1` info: rule `override-of-final-method` is enabled by default -53 | @classmethod -54 | def class_method1(cls) -> int: ... # error: [override-of-final-method] -55 | +64 | @classmethod +65 | def class_method1(cls) -> int: ... # error: [override-of-final-method] +66 | - @staticmethod - def static_method1() -> int: ... # error: [override-of-final-method] -56 + # error: [override-of-final-method] -57 | -58 | @classmethod -59 | def class_method2(cls) -> int: ... # error: [override-of-final-method] +67 + # error: [override-of-final-method] +68 | +69 | @classmethod +70 | def class_method2(cls) -> int: ... # error: [override-of-final-method] note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `Parent.class_method2` - --> src/mdtest_snippet.pyi:60:9 + --> src/mdtest_snippet.pyi:71:9 | -59 | @classmethod -60 | def class_method2(cls) -> int: ... # error: [override-of-final-method] +70 | @classmethod +71 | def class_method2(cls) -> int: ... # error: [override-of-final-method] | ^^^^^^^^^^^^^ Overrides a definition from superclass `Parent` -61 | -62 | @staticmethod +72 | +73 | @staticmethod | info: `Parent.class_method2` is decorated with `@final`, forbidding overrides - --> src/mdtest_snippet.pyi:22:5 + --> src/mdtest_snippet.pyi:26:5 | -21 | @classmethod -22 | @final +25 | @classmethod +26 | @final | ------ -23 | def class_method2(cls) -> int: ... +27 | def class_method2(cls) -> int: ... | ------------- `Parent.class_method2` defined here -24 | -25 | @final +28 | +29 | @final | help: Remove the override of `class_method2` info: rule `override-of-final-method` is enabled by default -56 | @staticmethod -57 | def static_method1() -> int: ... # error: [override-of-final-method] -58 | +67 | @staticmethod +68 | def static_method1() -> int: ... # error: [override-of-final-method] +69 | - @classmethod - def class_method2(cls) -> int: ... # error: [override-of-final-method] -59 + # error: [override-of-final-method] -60 | -61 | @staticmethod -62 | def static_method2() -> int: ... # error: [override-of-final-method] +70 + # error: [override-of-final-method] +71 | +72 | @staticmethod +73 | def static_method2() -> int: ... # error: [override-of-final-method] note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `Parent.static_method2` - --> src/mdtest_snippet.pyi:63:9 + --> src/mdtest_snippet.pyi:74:9 | -62 | @staticmethod -63 | def static_method2() -> int: ... # error: [override-of-final-method] +73 | @staticmethod +74 | def static_method2() -> int: ... # error: [override-of-final-method] | ^^^^^^^^^^^^^^ Overrides a definition from superclass `Parent` -64 | -65 | def decorated_1(self): ... # TODO: should emit [override-of-final-method] +75 | +76 | def decorated_1(self): ... # TODO: should emit [override-of-final-method] | info: `Parent.static_method2` is decorated with `@final`, forbidding overrides - --> src/mdtest_snippet.pyi:30:5 + --> src/mdtest_snippet.pyi:34:5 | -29 | @staticmethod -30 | @final +33 | @staticmethod +34 | @final | ------ -31 | def static_method2() -> int: ... +35 | def static_method2() -> int: ... | -------------- `Parent.static_method2` defined here -32 | -33 | @lossy_decorator +36 | +37 | @lossy_decorator | help: Remove the override of `static_method2` info: rule `override-of-final-method` is enabled by default -59 | @classmethod -60 | def class_method2(cls) -> int: ... # error: [override-of-final-method] -61 | +70 | @classmethod +71 | def class_method2(cls) -> int: ... # error: [override-of-final-method] +72 | - @staticmethod - def static_method2() -> int: ... # error: [override-of-final-method] -62 + # error: [override-of-final-method] -63 | -64 | def decorated_1(self): ... # TODO: should emit [override-of-final-method] -65 | +73 + # error: [override-of-final-method] +74 | +75 | def decorated_1(self): ... # TODO: should emit [override-of-final-method] +76 | note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `Parent.foo` - --> src/mdtest_snippet.pyi:76:9 + --> src/mdtest_snippet.pyi:87:9 | -74 | # TODO: we should emit a Liskov violation here too -75 | # error: [override-of-final-method] -76 | def foo(): ... +85 | # TODO: we should emit a Liskov violation here too +86 | # error: [override-of-final-method] +87 | def foo(): ... | ^^^ Overrides a definition from superclass `Parent` -77 | @property -78 | # TODO: we should emit a Liskov violation here too +88 | @property +89 | # TODO: we should emit a Liskov violation here too | info: `Parent.foo` is decorated with `@final`, forbidding overrides --> src/mdtest_snippet.pyi:6:5 @@ -413,31 +430,31 @@ info: `Parent.foo` is decorated with `@final`, forbidding overrides | help: Remove the override of `foo` info: rule `override-of-final-method` is enabled by default -70 | class OtherChild(Parent): ... -71 | -72 | class Grandchild(OtherChild): +81 | class OtherChild(Parent): ... +82 | +83 | class Grandchild(OtherChild): - @staticmethod - # TODO: we should emit a Liskov violation here too - # error: [override-of-final-method] - def foo(): ... -73 + -74 | @property -75 | # TODO: we should emit a Liskov violation here too -76 | # error: [override-of-final-method] +84 + +85 | @property +86 | # TODO: we should emit a Liskov violation here too +87 | # error: [override-of-final-method] note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `Parent.my_property1` - --> src/mdtest_snippet.pyi:80:9 + --> src/mdtest_snippet.pyi:91:9 | -78 | # TODO: we should emit a Liskov violation here too -79 | # error: [override-of-final-method] -80 | def my_property1(self) -> str: ... +89 | # TODO: we should emit a Liskov violation here too +90 | # error: [override-of-final-method] +91 | def my_property1(self) -> str: ... | ^^^^^^^^^^^^ Overrides a definition from superclass `Parent` -81 | # TODO: we should emit a Liskov violation here too -82 | # error: [override-of-final-method] +92 | # TODO: we should emit a Liskov violation here too +93 | # error: [override-of-final-method] | info: `Parent.my_property1` is decorated with `@final`, forbidding overrides --> src/mdtest_snippet.pyi:9:5 @@ -454,92 +471,71 @@ info: `Parent.my_property1` is decorated with `@final`, forbidding overrides | help: Remove the override of `my_property1` info: rule `override-of-final-method` is enabled by default -74 | # TODO: we should emit a Liskov violation here too -75 | # error: [override-of-final-method] -76 | def foo(): ... - - @property - - # TODO: we should emit a Liskov violation here too - - # error: [override-of-final-method] - - def my_property1(self) -> str: ... -77 + -78 | # TODO: we should emit a Liskov violation here too -79 | # error: [override-of-final-method] -80 | class_method1 = None -note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `Parent.class_method1` - --> src/mdtest_snippet.pyi:83:5 + --> src/mdtest_snippet.pyi:94:5 | -81 | # TODO: we should emit a Liskov violation here too -82 | # error: [override-of-final-method] -83 | class_method1 = None +92 | # TODO: we should emit a Liskov violation here too +93 | # error: [override-of-final-method] +94 | class_method1 = None | ^^^^^^^^^^^^^ Overrides a definition from superclass `Parent` -84 | -85 | # Diagnostic edge case: `final` is very far away from the method definition in the source code: +95 | +96 | # Diagnostic edge case: `final` is very far away from the method definition in the source code: | info: `Parent.class_method1` is decorated with `@final`, forbidding overrides - --> src/mdtest_snippet.pyi:17:5 + --> src/mdtest_snippet.pyi:21:5 | -15 | def my_property2(self) -> int: ... -16 | -17 | @final - | ------ -18 | @classmethod -19 | def class_method1(cls) -> int: ... - | ------------- `Parent.class_method1` defined here +19 | def my_property3(self) -> int: ... 20 | -21 | @classmethod +21 | @final + | ------ +22 | @classmethod +23 | def class_method1(cls) -> int: ... + | ------------- `Parent.class_method1` defined here +24 | +25 | @classmethod | help: Remove the override of `class_method1` info: rule `override-of-final-method` is enabled by default -80 | def my_property1(self) -> str: ... -81 | # TODO: we should emit a Liskov violation here too -82 | # error: [override-of-final-method] - - class_method1 = None -83 + -84 | -85 | # Diagnostic edge case: `final` is very far away from the method definition in the source code: -86 | -note: This is an unsafe fix and may change runtime behavior ``` ``` error[override-of-final-method]: Cannot override `Foo.bar` - --> src/mdtest_snippet.pyi:114:9 + --> src/mdtest_snippet.pyi:125:9 | -113 | class Baz(Foo): -114 | def bar(self): ... # error: [override-of-final-method] +124 | class Baz(Foo): +125 | def bar(self): ... # error: [override-of-final-method] | ^^^ Overrides a definition from superclass `Foo` | info: `Foo.bar` is decorated with `@final`, forbidding overrides - --> src/mdtest_snippet.pyi:92:5 + --> src/mdtest_snippet.pyi:103:5 | - 91 | class Foo: - 92 | @final +102 | class Foo: +103 | @final | ------ - 93 | @identity - 94 | @identity +104 | @identity +105 | @identity | - ::: src/mdtest_snippet.pyi:111:9 + ::: src/mdtest_snippet.pyi:122:9 | -109 | @identity -110 | @identity -111 | def bar(self): ... +120 | @identity +121 | @identity +122 | def bar(self): ... | --- `Foo.bar` defined here -112 | -113 | class Baz(Foo): +123 | +124 | class Baz(Foo): | help: Remove the override of `bar` info: rule `override-of-final-method` is enabled by default -111 | def bar(self): ... -112 | -113 | class Baz(Foo): +122 | def bar(self): ... +123 | +124 | class Baz(Foo): - def bar(self): ... # error: [override-of-final-method] -114 + # error: [override-of-final-method] +125 + pass # error: [override-of-final-method] note: This is an unsafe fix and may change runtime behavior ``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Diagnostic_edge_case…_(2389d52c5ecfa2bd).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Diagnostic_edge_case…_(2389d52c5ecfa2bd).snap index 5e7f11ca02..9282af1cea 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Diagnostic_edge_case…_(2389d52c5ecfa2bd).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Diagnostic_edge_case…_(2389d52c5ecfa2bd).snap @@ -53,7 +53,7 @@ info: rule `override-of-final-method` is enabled by default 2 | 3 | class Foo(module1.Foo): - def f(self): ... # error: [override-of-final-method] -4 + # error: [override-of-final-method] +4 + pass # error: [override-of-final-method] note: This is an unsafe fix and may change runtime behavior ``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Only_the_first_`@fin…_(9863b583f4c651c5).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Only_the_first_`@fin…_(9863b583f4c651c5).snap index 342b7ec8b6..9f1c33a07d 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Only_the_first_`@fin…_(9863b583f4c651c5).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Only_the_first_`@fin…_(9863b583f4c651c5).snap @@ -59,7 +59,7 @@ info: rule `override-of-final-method` is enabled by default 7 | class B(A): - @final - def f(self): ... # error: [override-of-final-method] -8 + # error: [override-of-final-method] +8 + pass # error: [override-of-final-method] 9 | 10 | class C(B): 11 | @final @@ -95,7 +95,7 @@ info: rule `override-of-final-method` is enabled by default - @final - # we only emit one error here, not two - def f(self): ... # error: [override-of-final-method] -12 + # error: [override-of-final-method] +12 + pass # error: [override-of-final-method] note: This is an unsafe fix and may change runtime behavior ``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Overloaded_methods_d…_(861757f48340ed92).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Overloaded_methods_d…_(861757f48340ed92).snap index 38ec75b003..f49f4ac3fc 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Overloaded_methods_d…_(861757f48340ed92).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/final.md_-_Tests_for_the_`@typi…_-_Overloaded_methods_d…_(861757f48340ed92).snap @@ -58,7 +58,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/final.md 44 | def bar(self, x: str) -> str: ... 45 | @overload 46 | def bar(self, x: int) -> int: ... # error: [override-of-final-method] -47 | +47 | 48 | @overload 49 | def baz(self, x: str) -> str: ... 50 | @overload @@ -265,7 +265,7 @@ error[override-of-final-method]: Cannot override `Bad.bar` 45 | @overload 46 | def bar(self, x: int) -> int: ... # error: [override-of-final-method] | ^^^ Overrides a definition from superclass `Bad` -47 | +47 | 48 | @overload | info: `Bad.bar` is decorated with `@final`, forbidding overrides @@ -287,12 +287,11 @@ info: rule `override-of-final-method` is enabled by default - def bar(self, x: str) -> str: ... - @overload - def bar(self, x: int) -> int: ... # error: [override-of-final-method] -43 | +43 + 44 + # error: [override-of-final-method] -45 + +45 | 46 | @overload 47 | def baz(self, x: str) -> str: ... -48 | @overload note: This is an unsafe fix and may change runtime behavior ``` @@ -319,7 +318,7 @@ help: Remove all overloads for `baz` info: rule `override-of-final-method` is enabled by default 45 | @overload 46 | def bar(self, x: int) -> int: ... # error: [override-of-final-method] -47 | +47 | - @overload - def baz(self, x: str) -> str: ... - @overload @@ -360,12 +359,12 @@ info: rule `override-of-final-method` is enabled by default - def f(self, x: str) -> str: ... - @overload - def f(self, x: int) -> int: ... -13 + -14 + +13 + pass +14 + pass 15 | # error: [override-of-final-method] - def f(self, x: int | str) -> int | str: - return x -16 + +16 + pass 17 | 18 | class Bad: 19 | @overload @@ -459,15 +458,6 @@ info: `Bad.f` is decorated with `@final`, forbidding overrides | help: Remove the override of `f` info: rule `override-of-final-method` is enabled by default -57 | -58 | class ChildOfBad(Bad): -59 | # TODO: these should all cause us to emit Liskov violations as well - - f = None # error: [override-of-final-method] -60 + # error: [override-of-final-method] -61 | g = None # error: [override-of-final-method] -62 | h = None # error: [override-of-final-method] -63 | i = None # error: [override-of-final-method] -note: This is an unsafe fix and may change runtime behavior ``` @@ -493,14 +483,6 @@ info: `Bad.g` is decorated with `@final`, forbidding overrides | help: Remove the override of `g` info: rule `override-of-final-method` is enabled by default -58 | class ChildOfBad(Bad): -59 | # TODO: these should all cause us to emit Liskov violations as well -60 | f = None # error: [override-of-final-method] - - g = None # error: [override-of-final-method] -61 + # error: [override-of-final-method] -62 | h = None # error: [override-of-final-method] -63 | i = None # error: [override-of-final-method] -note: This is an unsafe fix and may change runtime behavior ``` @@ -525,13 +507,6 @@ info: `Bad.h` is decorated with `@final`, forbidding overrides | help: Remove the override of `h` info: rule `override-of-final-method` is enabled by default -59 | # TODO: these should all cause us to emit Liskov violations as well -60 | f = None # error: [override-of-final-method] -61 | g = None # error: [override-of-final-method] - - h = None # error: [override-of-final-method] -62 + # error: [override-of-final-method] -63 | i = None # error: [override-of-final-method] -note: This is an unsafe fix and may change runtime behavior ``` @@ -555,11 +530,5 @@ info: `Bad.i` is decorated with `@final`, forbidding overrides | help: Remove the override of `i` info: rule `override-of-final-method` is enabled by default -60 | f = None # error: [override-of-final-method] -61 | g = None # error: [override-of-final-method] -62 | h = None # error: [override-of-final-method] - - i = None # error: [override-of-final-method] -63 + # error: [override-of-final-method] -note: This is an unsafe fix and may change runtime behavior ``` diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index 782a25b98e..96aa876b50 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -3804,6 +3804,7 @@ pub(super) fn report_overridden_final_method<'db>( context: &InferContext<'db, '_>, member: &str, subclass_definition: Definition<'db>, + // N.B. the type of the *definition*, not the type on an instance of the subclass subclass_type: Type<'db>, superclass: ClassType<'db>, subclass: ClassType<'db>, @@ -3811,6 +3812,23 @@ pub(super) fn report_overridden_final_method<'db>( ) { let db = context.db(); + // Some hijinks so that we emit a diagnostic on the property getter rather than the property setter + let property_getter_definition = if subclass_definition.kind(db).is_function_def() + && let Type::PropertyInstance(property) = subclass_type + && let Some(Type::FunctionLiteral(getter)) = property.getter(db) + { + let getter_definition = getter.definition(db); + if getter_definition.scope(db) == subclass_definition.scope(db) { + Some(getter_definition) + } else { + None + } + } else { + None + }; + + let subclass_definition = property_getter_definition.unwrap_or(subclass_definition); + let Some(builder) = context.report_lint( &OVERRIDE_OF_FINAL_METHOD, subclass_definition.focus_range(db, context.module()), @@ -3871,37 +3889,69 @@ pub(super) fn report_overridden_final_method<'db>( diagnostic.sub(sub); - let underlying_function = match subclass_type { - Type::FunctionLiteral(function) => Some(function), - Type::BoundMethod(method) => Some(method.function(db)), - _ => None, - }; + // It's tempting to autofix properties as well, + // but you'd want to delete the `@my_property.deleter` as well as the getter and the deleter, + // and we don't model property deleters at all right now. + if let Type::FunctionLiteral(function) = subclass_type { + let class_node = subclass + .class_literal(db) + .0 + .body_scope(db) + .node(db) + .expect_class() + .node(context.module()); + + let (overloads, implementation) = function.overloads_and_implementation(db); + let overload_count = overloads.len() + usize::from(implementation.is_some()); + let is_only = overload_count >= class_node.body.len(); - if let Some(function) = underlying_function { let overload_deletion = |overload: &OverloadLiteral<'db>| { - Edit::range_deletion(overload.node(db, context.file(), context.module()).range()) + let range = overload.node(db, context.file(), context.module()).range(); + if is_only { + Edit::range_replacement("pass".to_string(), range) + } else { + Edit::range_deletion(range) + } }; + let should_fix = overloads + .iter() + .copied() + .chain(implementation) + .all(|overload| { + class_node + .body + .iter() + .filter_map(ast::Stmt::as_function_def_stmt) + .contains(overload.node(db, context.file(), context.module())) + }); + match function.overloads_and_implementation(db) { ([first_overload, rest @ ..], None) => { diagnostic.help(format_args!("Remove all overloads for `{member}`")); - diagnostic.set_fix(Fix::unsafe_edits( - overload_deletion(first_overload), - rest.iter().map(overload_deletion), - )); + diagnostic.set_optional_fix(should_fix.then(|| { + Fix::unsafe_edits( + overload_deletion(first_overload), + rest.iter().map(overload_deletion), + ) + })); } ([first_overload, rest @ ..], Some(implementation)) => { diagnostic.help(format_args!( "Remove all overloads and the implementation for `{member}`" )); - diagnostic.set_fix(Fix::unsafe_edits( - overload_deletion(first_overload), - rest.iter().chain([&implementation]).map(overload_deletion), - )); + diagnostic.set_optional_fix(should_fix.then(|| { + Fix::unsafe_edits( + overload_deletion(first_overload), + rest.iter().chain([&implementation]).map(overload_deletion), + ) + })); } ([], Some(implementation)) => { diagnostic.help(format_args!("Remove the override of `{member}`")); - diagnostic.set_fix(Fix::unsafe_edit(overload_deletion(&implementation))); + diagnostic.set_optional_fix( + should_fix.then(|| Fix::unsafe_edit(overload_deletion(&implementation))), + ); } ([], None) => { // Should be impossible to get here: how would we even infer a function as a function @@ -3911,11 +3961,12 @@ pub(super) fn report_overridden_final_method<'db>( ); } } + } else if let Type::PropertyInstance(property) = subclass_type + && property.setter(db).is_some() + { + diagnostic.help(format_args!("Remove the getter and setter for `{member}`")); } else { diagnostic.help(format_args!("Remove the override of `{member}`")); - diagnostic.set_fix(Fix::unsafe_edit(Edit::range_deletion( - subclass_definition.full_range(db, context.module()).range(), - ))); } } diff --git a/crates/ty_python_semantic/src/types/overrides.rs b/crates/ty_python_semantic/src/types/overrides.rs index 0cfc8c477b..517878202a 100644 --- a/crates/ty_python_semantic/src/types/overrides.rs +++ b/crates/ty_python_semantic/src/types/overrides.rs @@ -327,7 +327,7 @@ fn check_class_declaration<'db>( context, &member.name, *definition, - type_on_subclass_instance, + member.ty, superclass, class, &superclass_method, From e7beb7e1f4ef26f7e68ea54d3f7541d4bf24324a Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 30 Nov 2025 10:49:06 -0500 Subject: [PATCH 30/67] [ty] Forbid use of `super()` in `NamedTuple` subclasses (#21700) ## Summary The exact behavior around what's allowed vs. disallowed was partly detected through trial and error in the runtime. I was a little confused by [this comment](https://github.com/python/cpython/pull/129352) that says "`NamedTuple` subclasses cannot be inherited from" because in practice that doesn't appear to error at runtime. Closes [#1683](https://github.com/astral-sh/ty/issues/1683). --- crates/ty/docs/rules.md | 180 +++++++++++------- .../resources/mdtest/named_tuple.md | 74 +++++++ crates/ty_python_semantic/src/types/class.rs | 32 +++- .../src/types/diagnostic.rs | 28 +++ .../e2e__commands__debug_command.snap | 1 + ty.schema.json | 10 + 6 files changed, 251 insertions(+), 74 deletions(-) diff --git a/crates/ty/docs/rules.md b/crates/ty/docs/rules.md index 6923aeef6f..78f757a6bb 100644 --- a/crates/ty/docs/rules.md +++ b/crates/ty/docs/rules.md @@ -39,7 +39,7 @@ def test(): -> "int": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -63,7 +63,7 @@ Calling a non-callable object will raise a `TypeError` at runtime. Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -95,7 +95,7 @@ f(int) # error Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -126,7 +126,7 @@ a = 1 Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -158,7 +158,7 @@ class C(A, B): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -190,7 +190,7 @@ class B(A): ... Default level: error · Preview (since 1.0.0) · Related issues · -View source +View source @@ -218,7 +218,7 @@ type B = A Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -245,7 +245,7 @@ class B(A, A): ... Default level: error · Added in 0.0.1-alpha.12 · Related issues · -View source +View source @@ -357,7 +357,7 @@ def test(): -> "Literal[5]": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -387,7 +387,7 @@ class C(A, B): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -413,7 +413,7 @@ t[3] # IndexError: tuple index out of range Default level: error · Added in 0.0.1-alpha.12 · Related issues · -View source +View source @@ -502,7 +502,7 @@ an atypical memory layout. Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -529,7 +529,7 @@ func("foo") # error: [invalid-argument-type] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -557,7 +557,7 @@ a: int = '' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -591,7 +591,7 @@ C.instance_var = 3 # error: Cannot assign to instance variable Default level: error · Added in 0.0.1-alpha.19 · Related issues · -View source +View source @@ -627,7 +627,7 @@ asyncio.run(main()) Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -651,7 +651,7 @@ class A(42): ... # error: [invalid-base] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -678,7 +678,7 @@ with 1: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -707,7 +707,7 @@ a: str Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -751,7 +751,7 @@ except ZeroDivisionError: Default level: error · Added in 0.0.1-alpha.28 · Related issues · -View source +View source @@ -793,7 +793,7 @@ class D(A): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -826,7 +826,7 @@ class C[U](Generic[T]): ... Default level: error · Added in 0.0.1-alpha.17 · Related issues · -View source +View source @@ -865,7 +865,7 @@ carol = Person(name="Carol", age=25) # typo! Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -900,7 +900,7 @@ def f(t: TypeVar("U")): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -934,7 +934,7 @@ class B(metaclass=f): ... Default level: error · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -1041,7 +1041,7 @@ Correct use of `@override` is enforced by ty's `invalid-explicit-override` rule. Default level: error · Added in 0.0.1-alpha.19 · Related issues · -View source +View source @@ -1073,7 +1073,7 @@ TypeError: can only inherit from a NamedTuple type and Generic Default level: error · Preview (since 1.0.0) · Related issues · -View source +View source @@ -1103,7 +1103,7 @@ Baz = NewType("Baz", int | str) # error: invalid base for `typing.NewType` Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1153,7 +1153,7 @@ def foo(x: int) -> int: ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1179,7 +1179,7 @@ def f(a: int = ''): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1210,7 +1210,7 @@ P2 = ParamSpec("S2") # error: ParamSpec name must match the variable it's assig Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1244,7 +1244,7 @@ TypeError: Protocols can only inherit from other protocols, got Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1293,7 +1293,7 @@ def g(): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1318,7 +1318,7 @@ def func() -> int: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1376,7 +1376,7 @@ TODO #14889 Default level: error · Added in 0.0.1-alpha.6 · Related issues · -View source +View source @@ -1403,7 +1403,7 @@ NewAlias = TypeAliasType(get_name(), int) # error: TypeAliasType name mus Default level: error · Added in 0.0.1-alpha.29 · Related issues · -View source +View source @@ -1450,7 +1450,7 @@ Bar[int] # error: too few arguments Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1480,7 +1480,7 @@ TYPE_CHECKING = '' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1510,7 +1510,7 @@ b: Annotated[int] # `Annotated` expects at least two arguments Default level: error · Added in 0.0.1-alpha.11 · Related issues · -View source +View source @@ -1544,7 +1544,7 @@ f(10) # Error Default level: error · Added in 0.0.1-alpha.11 · Related issues · -View source +View source @@ -1578,7 +1578,7 @@ class C: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1613,7 +1613,7 @@ T = TypeVar('T', bound=str) # valid bound TypeVar Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1638,7 +1638,7 @@ func() # TypeError: func() missing 1 required positional argument: 'x' Default level: error · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -1671,7 +1671,7 @@ alice["age"] # KeyError Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1700,7 +1700,7 @@ func("string") # error: [no-matching-overload] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1724,7 +1724,7 @@ Subscripting an object that does not support it will raise a `TypeError` at runt Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1750,7 +1750,7 @@ for i in 34: # TypeError: 'int' object is not iterable Default level: error · Added in 0.0.1-alpha.29 · Related issues · -View source +View source @@ -1783,7 +1783,7 @@ class B(A): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1810,7 +1810,7 @@ f(1, x=2) # Error raised here Default level: error · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -1868,7 +1868,7 @@ def test(): -> "int": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1898,7 +1898,7 @@ static_assert(int(2.0 * 3.0) == 6) # error: does not have a statically known tr Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1921,13 +1921,47 @@ class A: ... class B(A): ... # Error raised here ``` +## `super-call-in-named-tuple-method` + + +Default level: error · +Preview (since 0.0.1-alpha.30) · +Related issues · +View source + + + +**What it does** + +Checks for calls to `super()` inside methods of `NamedTuple` classes. + +**Why is this bad?** + +Using `super()` in a method of a `NamedTuple` class will raise an exception at runtime. + +**Examples** + +```python +from typing import NamedTuple + +class F(NamedTuple): + x: int + + def method(self): + super() # error: super() is not supported in methods of NamedTuple classes +``` + +**References** + +- [Python documentation: super()](https://docs.python.org/3/library/functions.html#super) + ## `too-many-positional-arguments` Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1954,7 +1988,7 @@ f("foo") # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1982,7 +2016,7 @@ def _(x: int): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2028,7 +2062,7 @@ class A: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2055,7 +2089,7 @@ f(x=1, y=2) # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2083,7 +2117,7 @@ A().foo # AttributeError: 'A' object has no attribute 'foo' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2108,7 +2142,7 @@ import foo # ModuleNotFoundError: No module named 'foo' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2133,7 +2167,7 @@ print(x) # NameError: name 'x' is not defined Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2170,7 +2204,7 @@ b1 < b2 < b1 # exception raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2198,7 +2232,7 @@ A() + A() # TypeError: unsupported operand type(s) for +: 'A' and 'A' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2223,7 +2257,7 @@ l[1:10:0] # ValueError: slice step cannot be zero Default level: warn · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -2264,7 +2298,7 @@ class SubProto(BaseProto, Protocol): Default level: warn · Added in 0.0.1-alpha.16 · Related issues · -View source +View source @@ -2352,7 +2386,7 @@ a = 20 / 0 # type: ignore Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2380,7 +2414,7 @@ A.c # AttributeError: type object 'A' has no attribute 'c' Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2412,7 +2446,7 @@ A()[0] # TypeError: 'A' object is not subscriptable Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2444,7 +2478,7 @@ from module import a # ImportError: cannot import name 'a' from 'module' Default level: warn · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2471,7 +2505,7 @@ cast(int, f()) # Redundant Default level: warn · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2495,7 +2529,7 @@ reveal_type(1) # NameError: name 'reveal_type' is not defined Default level: warn · Added in 0.0.1-alpha.15 · Related issues · -View source +View source @@ -2553,7 +2587,7 @@ def g(): Default level: warn · Added in 0.0.1-alpha.7 · Related issues · -View source +View source @@ -2592,7 +2626,7 @@ class D(C): ... # error: [unsupported-base] Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2655,7 +2689,7 @@ def foo(x: int | str) -> int | str: Default level: ignore · Preview (since 0.0.1-alpha.1) · Related issues · -View source +View source @@ -2679,7 +2713,7 @@ Dividing by zero raises a `ZeroDivisionError` at runtime. Default level: ignore · Added in 0.0.1-alpha.1 · Related issues · -View source +View source diff --git a/crates/ty_python_semantic/resources/mdtest/named_tuple.md b/crates/ty_python_semantic/resources/mdtest/named_tuple.md index c49cf1708c..439cfff06b 100644 --- a/crates/ty_python_semantic/resources/mdtest/named_tuple.md +++ b/crates/ty_python_semantic/resources/mdtest/named_tuple.md @@ -408,3 +408,77 @@ class Vec2(NamedTuple): Vec2(0.0, 0.0) ``` + +## `super()` is not supported in NamedTuple methods + +Using `super()` in a method of a `NamedTuple` class will raise an exception at runtime. In Python +3.14+, a `TypeError` is raised; in earlier versions, a confusing `RuntimeError` about +`__classcell__` is raised. + +```py +from typing import NamedTuple + +class F(NamedTuple): + x: int + + def method(self): + # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple class `F`" + super() + + def method_with_args(self): + # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple class `F`" + super(F, self) + + def method_with_different_pivot(self): + # Even passing a different pivot class fails. + # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple class `F`" + super(tuple, self) + + @classmethod + def class_method(cls): + # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple class `F`" + super() + + @staticmethod + def static_method(): + # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple class `F`" + super() + + @property + def prop(self): + # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple class `F`" + return super() +``` + +However, classes that **inherit from** a `NamedTuple` class (but don't directly inherit from +`NamedTuple`) can use `super()` normally: + +```py +from typing import NamedTuple + +class Base(NamedTuple): + x: int + +class Child(Base): + def method(self): + super() +``` + +And regular classes that don't inherit from `NamedTuple` at all can use `super()` as normal: + +```py +class Regular: + def method(self): + super() # fine +``` + +Using `super()` on a `NamedTuple` class also works fine if it occurs outside the class: + +```py +from typing import NamedTuple + +class F(NamedTuple): + x: int + +super(F, F(42)) # fine +``` diff --git a/crates/ty_python_semantic/src/types/class.rs b/crates/ty_python_semantic/src/types/class.rs index 1f613fa568..3c38f6bdfc 100644 --- a/crates/ty_python_semantic/src/types/class.rs +++ b/crates/ty_python_semantic/src/types/class.rs @@ -19,7 +19,7 @@ use crate::semantic_index::{ use crate::types::bound_super::BoundSuperError; use crate::types::constraints::{ConstraintSet, IteratorConstraintsExtension}; use crate::types::context::InferContext; -use crate::types::diagnostic::INVALID_TYPE_ALIAS_TYPE; +use crate::types::diagnostic::{INVALID_TYPE_ALIAS_TYPE, SUPER_CALL_IN_NAMED_TUPLE_METHOD}; use crate::types::enums::enum_metadata; use crate::types::function::{DataclassTransformerParams, KnownFunction}; use crate::types::generics::{ @@ -5546,6 +5546,20 @@ impl KnownClass { return; }; + // Check if the enclosing class is a `NamedTuple`, which forbids the use of `super()`. + if CodeGeneratorKind::NamedTuple.matches(db, enclosing_class, None) { + if let Some(builder) = context + .report_lint(&SUPER_CALL_IN_NAMED_TUPLE_METHOD, call_expression) + { + builder.into_diagnostic(format_args!( + "Cannot use `super()` in a method of NamedTuple class `{}`", + enclosing_class.name(db) + )); + } + overload.set_return_type(Type::unknown()); + return; + } + // The type of the first parameter if the given scope is function-like (i.e. function or lambda). // `None` if the scope is not function-like, or has no parameters. let first_param = match scope.node(db) { @@ -5585,6 +5599,22 @@ impl KnownClass { overload.set_return_type(bound_super); } [Some(pivot_class_type), Some(owner_type)] => { + // Check if the enclosing class is a `NamedTuple`, which forbids the use of `super()`. + if let Some(enclosing_class) = nearest_enclosing_class(db, index, scope) { + if CodeGeneratorKind::NamedTuple.matches(db, enclosing_class, None) { + if let Some(builder) = context + .report_lint(&SUPER_CALL_IN_NAMED_TUPLE_METHOD, call_expression) + { + builder.into_diagnostic(format_args!( + "Cannot use `super()` in a method of NamedTuple class `{}`", + enclosing_class.name(db) + )); + } + overload.set_return_type(Type::unknown()); + return; + } + } + let bound_super = BoundSuperType::build(db, *pivot_class_type, *owner_type) .unwrap_or_else(|err| { err.report_diagnostic(context, call_expression.into()); diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index 96aa876b50..8e92c495cf 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -121,6 +121,7 @@ pub(crate) fn register_lints(registry: &mut LintRegistryBuilder) { registry.register_lint(&MISSING_TYPED_DICT_KEY); registry.register_lint(&INVALID_METHOD_OVERRIDE); registry.register_lint(&INVALID_EXPLICIT_OVERRIDE); + registry.register_lint(&SUPER_CALL_IN_NAMED_TUPLE_METHOD); // String annotations registry.register_lint(&BYTE_STRING_TYPE_ANNOTATION); @@ -1760,6 +1761,33 @@ declare_lint! { } } +declare_lint! { + /// ## What it does + /// Checks for calls to `super()` inside methods of `NamedTuple` classes. + /// + /// ## Why is this bad? + /// Using `super()` in a method of a `NamedTuple` class will raise an exception at runtime. + /// + /// ## Examples + /// ```python + /// from typing import NamedTuple + /// + /// class F(NamedTuple): + /// x: int + /// + /// def method(self): + /// super() # error: super() is not supported in methods of NamedTuple classes + /// ``` + /// + /// ## References + /// - [Python documentation: super()](https://docs.python.org/3/library/functions.html#super) + pub(crate) static SUPER_CALL_IN_NAMED_TUPLE_METHOD = { + summary: "detects `super()` calls in methods of `NamedTuple` classes", + status: LintStatus::preview("0.0.1-alpha.30"), + default_level: Level::Error, + } +} + declare_lint! { /// ## What it does /// Checks for calls to `reveal_type` without importing it. diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__commands__debug_command.snap b/crates/ty_server/tests/e2e/snapshots/e2e__commands__debug_command.snap index 5505fbd5f2..0daa6c768a 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__commands__debug_command.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__commands__debug_command.snap @@ -93,6 +93,7 @@ Settings: Settings { "redundant-cast": Warning (Default), "static-assert-error": Error (Default), "subclass-of-final-class": Error (Default), + "super-call-in-named-tuple-method": Error (Default), "too-many-positional-arguments": Error (Default), "type-assertion-failure": Error (Default), "unavailable-implicit-super-arguments": Error (Default), diff --git a/ty.schema.json b/ty.schema.json index 38d5fd1326..e2325d6ac4 100644 --- a/ty.schema.json +++ b/ty.schema.json @@ -973,6 +973,16 @@ } ] }, + "super-call-in-named-tuple-method": { + "title": "detects `super()` calls in methods of `NamedTuple` classes", + "description": "## What it does\nChecks for calls to `super()` inside methods of `NamedTuple` classes.\n\n## Why is this bad?\nUsing `super()` in a method of a `NamedTuple` class will raise an exception at runtime.\n\n## Examples\n```python\nfrom typing import NamedTuple\n\nclass F(NamedTuple):\n x: int\n\n def method(self):\n super() # error: super() is not supported in methods of NamedTuple classes\n```\n\n## References\n- [Python documentation: super()](https://docs.python.org/3/library/functions.html#super)", + "default": "error", + "oneOf": [ + { + "$ref": "#/definitions/Level" + } + ] + }, "too-many-positional-arguments": { "title": "detects calls passing too many positional arguments", "description": "## What it does\nChecks for calls that pass more positional arguments than the callable can accept.\n\n## Why is this bad?\nPassing too many positional arguments will raise `TypeError` at runtime.\n\n## Example\n\n```python\ndef f(): ...\n\nf(\"foo\") # Error raised here\n```", From d8d1464d9686a6bf6ee43c1526898a393e47b06a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 1 Dec 2025 01:02:48 +0000 Subject: [PATCH 31/67] Update dependency ruff to v0.14.7 (#21709) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Change | Age | Confidence | |---|---|---|---| | [ruff](https://docs.astral.sh/ruff) ([source](https://redirect.github.com/astral-sh/ruff), [changelog](https://redirect.github.com/astral-sh/ruff/blob/main/CHANGELOG.md)) | `==0.14.6` -> `==0.14.7` | [![age](https://developer.mend.io/api/mc/badges/age/pypi/ruff/0.14.7?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/ruff/0.14.6/0.14.7?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes
astral-sh/ruff (ruff) ### [`v0.14.7`](https://redirect.github.com/astral-sh/ruff/blob/HEAD/CHANGELOG.md#0147) [Compare Source](https://redirect.github.com/astral-sh/ruff/compare/0.14.6...0.14.7) Released on 2025-11-28. ##### Preview features - \[`flake8-bandit`] Handle string literal bindings in suspicious-url-open-usage (`S310`) ([#​21469](https://redirect.github.com/astral-sh/ruff/pull/21469)) - \[`pylint`] Fix `PLR1708` false positives on nested functions ([#​21177](https://redirect.github.com/astral-sh/ruff/pull/21177)) - \[`pylint`] Fix suppression for empty dict without tuple key annotation (`PLE1141`) ([#​21290](https://redirect.github.com/astral-sh/ruff/pull/21290)) - \[`ruff`] Add rule `RUF066` to detect unnecessary class properties ([#​21535](https://redirect.github.com/astral-sh/ruff/pull/21535)) - \[`ruff`] Catch more dummy variable uses (`RUF052`) ([#​19799](https://redirect.github.com/astral-sh/ruff/pull/19799)) ##### Bug fixes - \[server] Set severity for non-rule diagnostics ([#​21559](https://redirect.github.com/astral-sh/ruff/pull/21559)) - \[`flake8-implicit-str-concat`] Avoid invalid fix in (`ISC003`) ([#​21517](https://redirect.github.com/astral-sh/ruff/pull/21517)) - \[`parser`] Fix panic when parsing IPython escape command expressions ([#​21480](https://redirect.github.com/astral-sh/ruff/pull/21480)) ##### CLI - Show partial fixability indicator in statistics output ([#​21513](https://redirect.github.com/astral-sh/ruff/pull/21513)) ##### Contributors - [@​mikeleppane](https://redirect.github.com/mikeleppane) - [@​senekor](https://redirect.github.com/senekor) - [@​ShaharNaveh](https://redirect.github.com/ShaharNaveh) - [@​JumboBear](https://redirect.github.com/JumboBear) - [@​prakhar1144](https://redirect.github.com/prakhar1144) - [@​tsvikas](https://redirect.github.com/tsvikas) - [@​danparizher](https://redirect.github.com/danparizher) - [@​chirizxc](https://redirect.github.com/chirizxc) - [@​AlexWaygood](https://redirect.github.com/AlexWaygood) - [@​MichaReiser](https://redirect.github.com/MichaReiser)
--- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/astral-sh/ruff). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- docs/requirements-insiders.txt | 2 +- docs/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/requirements-insiders.txt b/docs/requirements-insiders.txt index 6d3586a58a..9726b8ab5a 100644 --- a/docs/requirements-insiders.txt +++ b/docs/requirements-insiders.txt @@ -1,5 +1,5 @@ PyYAML==6.0.3 -ruff==0.14.6 +ruff==0.14.7 mkdocs==1.6.1 mkdocs-material @ git+ssh://git@github.com/astral-sh/mkdocs-material-insiders.git@39da7a5e761410349e9a1b8abf593b0cdd5453ff mkdocs-redirects==1.2.2 diff --git a/docs/requirements.txt b/docs/requirements.txt index 73c6e31906..a9b415267f 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,5 @@ PyYAML==6.0.3 -ruff==0.14.6 +ruff==0.14.7 mkdocs==1.6.1 mkdocs-material==9.5.38 mkdocs-redirects==1.2.2 From 5b32908920fb41d0eb67a198651c11d597dc285a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 1 Dec 2025 07:58:56 +0100 Subject: [PATCH 32/67] Update CodSpeedHQ/action action to v4.4.1 (#21716) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4418e35b82..72dac5459d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -965,7 +965,7 @@ jobs: run: cargo codspeed build --features "codspeed,instrumented" --profile profiling --no-default-features -p ruff_benchmark --bench formatter --bench lexer --bench linter --bench parser - name: "Run benchmarks" - uses: CodSpeedHQ/action@6a8e2b874c338bf81cc5e8be715ada75908d3871 # v4.3.4 + uses: CodSpeedHQ/action@346a2d8a8d9d38909abd0bc3d23f773110f076ad # v4.4.1 with: mode: instrumentation run: cargo codspeed run @@ -1005,7 +1005,7 @@ jobs: run: cargo codspeed build --features "codspeed,instrumented" --profile profiling --no-default-features -p ruff_benchmark --bench ty - name: "Run benchmarks" - uses: CodSpeedHQ/action@6a8e2b874c338bf81cc5e8be715ada75908d3871 # v4.3.4 + uses: CodSpeedHQ/action@346a2d8a8d9d38909abd0bc3d23f773110f076ad # v4.4.1 with: mode: instrumentation run: cargo codspeed run @@ -1045,7 +1045,7 @@ jobs: run: cargo codspeed build --features "codspeed,walltime" --profile profiling --no-default-features -p ruff_benchmark - name: "Run benchmarks" - uses: CodSpeedHQ/action@6a8e2b874c338bf81cc5e8be715ada75908d3871 # v4.3.4 + uses: CodSpeedHQ/action@346a2d8a8d9d38909abd0bc3d23f773110f076ad # v4.4.1 env: # enabling walltime flamegraphs adds ~6 minutes to the CI time, and they don't # appear to provide much useful insight for our walltime benchmarks right now From 5265af4eee0bd298d66b7e10f75845ed2fbdd8bd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 1 Dec 2025 07:59:44 +0100 Subject: [PATCH 33/67] Update cargo-bins/cargo-binstall action to v1.16.2 (#21714) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 72dac5459d..16e8f397ef 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -448,7 +448,7 @@ jobs: - name: "Install mold" uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1 - name: "Install cargo-binstall" - uses: cargo-bins/cargo-binstall@ae04fb5e853ae6cd3ad7de4a1d554a8b646d12aa # v1.15.11 + uses: cargo-bins/cargo-binstall@3fc81674af4165a753833a94cae9f91d8849049f # v1.16.2 - name: "Install cargo-fuzz" # Download the latest version from quick install and not the github releases because github releases only has MUSL targets. run: cargo binstall cargo-fuzz --force --disable-strategies crate-meta-data --no-confirm @@ -688,7 +688,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: cargo-bins/cargo-binstall@ae04fb5e853ae6cd3ad7de4a1d554a8b646d12aa # v1.15.11 + - uses: cargo-bins/cargo-binstall@3fc81674af4165a753833a94cae9f91d8849049f # v1.16.2 - run: cargo binstall --no-confirm cargo-shear - run: cargo shear From aef056954b8f466539691180dcfb9c5976009020 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 1 Dec 2025 08:00:05 +0100 Subject: [PATCH 34/67] Update actions/setup-python action to v6.1.0 (#21713) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/build-binaries.yml | 16 ++++++++-------- .github/workflows/ci.yaml | 4 ++-- .github/workflows/publish-docs.yml | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index c26802228f..abc6b8a448 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -43,7 +43,7 @@ jobs: with: submodules: recursive persist-credentials: false - - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: "Prep README.md" @@ -72,7 +72,7 @@ jobs: with: submodules: recursive persist-credentials: false - - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 @@ -114,7 +114,7 @@ jobs: with: submodules: recursive persist-credentials: false - - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.PYTHON_VERSION }} architecture: arm64 @@ -170,7 +170,7 @@ jobs: with: submodules: recursive persist-credentials: false - - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.PYTHON_VERSION }} architecture: ${{ matrix.platform.arch }} @@ -223,7 +223,7 @@ jobs: with: submodules: recursive persist-credentials: false - - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 @@ -300,7 +300,7 @@ jobs: with: submodules: recursive persist-credentials: false - - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: "Prep README.md" @@ -365,7 +365,7 @@ jobs: with: submodules: recursive persist-credentials: false - - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 @@ -431,7 +431,7 @@ jobs: with: submodules: recursive persist-credentials: false - - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: "Prep README.md" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 16e8f397ef..5bc12c52e3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -723,7 +723,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 @@ -875,7 +875,7 @@ jobs: repository: "astral-sh/ruff-lsp" path: ruff-lsp - - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: # installation fails on 3.13 and newer python-version: "3.12" diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 8adbe4536c..529c9792ed 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -28,7 +28,7 @@ jobs: ref: ${{ inputs.ref }} persist-credentials: true - - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: 3.12 From 984480a5864fc3ac367e4665c289882f53f8c4be Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 1 Dec 2025 08:01:14 +0100 Subject: [PATCH 35/67] Update tokio-tracing monorepo (#21712) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd9f1f40f6..d8a29c0eb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1108,7 +1108,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1763,7 +1763,7 @@ dependencies = [ "portable-atomic", "portable-atomic-util", "serde_core", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3570,7 +3570,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3971,7 +3971,7 @@ dependencies = [ "getrandom 0.3.4", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4216,9 +4216,9 @@ checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647" dependencies = [ "log", "pin-project-lite", @@ -4228,9 +4228,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", @@ -4239,9 +4239,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" dependencies = [ "once_cell", "valuable", @@ -4283,9 +4283,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.20" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" dependencies = [ "chrono", "matchers", @@ -5024,7 +5024,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] From 13af584428d1640c537b2b6efbc767fb7f024852 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 1 Dec 2025 08:02:09 +0100 Subject: [PATCH 36/67] Update taiki-e/install-action action to v2.62.60 (#21711) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yaml | 14 +++++++------- .github/workflows/sync_typeshed.yaml | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5bc12c52e3..b0488644b6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -261,11 +261,11 @@ jobs: - name: "Install mold" uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1 - name: "Install cargo nextest" - uses: taiki-e/install-action@f79fe7514db78f0a7bdba3cb6dd9c1baa7d046d9 # v2.62.56 + uses: taiki-e/install-action@3575e532701a5fc614b0c842e4119af4cc5fd16d # v2.62.60 with: tool: cargo-nextest - name: "Install cargo insta" - uses: taiki-e/install-action@f79fe7514db78f0a7bdba3cb6dd9c1baa7d046d9 # v2.62.56 + uses: taiki-e/install-action@3575e532701a5fc614b0c842e4119af4cc5fd16d # v2.62.60 with: tool: cargo-insta - name: "Install uv" @@ -323,7 +323,7 @@ jobs: - name: "Install mold" uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1 - name: "Install cargo nextest" - uses: taiki-e/install-action@f79fe7514db78f0a7bdba3cb6dd9c1baa7d046d9 # v2.62.56 + uses: taiki-e/install-action@3575e532701a5fc614b0c842e4119af4cc5fd16d # v2.62.60 with: tool: cargo-nextest - name: "Install uv" @@ -356,7 +356,7 @@ jobs: - name: "Install Rust toolchain" run: rustup show - name: "Install cargo nextest" - uses: taiki-e/install-action@f79fe7514db78f0a7bdba3cb6dd9c1baa7d046d9 # v2.62.56 + uses: taiki-e/install-action@3575e532701a5fc614b0c842e4119af4cc5fd16d # v2.62.60 with: tool: cargo-nextest - name: "Install uv" @@ -957,7 +957,7 @@ jobs: run: rustup show - name: "Install codspeed" - uses: taiki-e/install-action@f79fe7514db78f0a7bdba3cb6dd9c1baa7d046d9 # v2.62.56 + uses: taiki-e/install-action@3575e532701a5fc614b0c842e4119af4cc5fd16d # v2.62.60 with: tool: cargo-codspeed @@ -997,7 +997,7 @@ jobs: run: rustup show - name: "Install codspeed" - uses: taiki-e/install-action@f79fe7514db78f0a7bdba3cb6dd9c1baa7d046d9 # v2.62.56 + uses: taiki-e/install-action@3575e532701a5fc614b0c842e4119af4cc5fd16d # v2.62.60 with: tool: cargo-codspeed @@ -1037,7 +1037,7 @@ jobs: run: rustup show - name: "Install codspeed" - uses: taiki-e/install-action@f79fe7514db78f0a7bdba3cb6dd9c1baa7d046d9 # v2.62.56 + uses: taiki-e/install-action@3575e532701a5fc614b0c842e4119af4cc5fd16d # v2.62.60 with: tool: cargo-codspeed diff --git a/.github/workflows/sync_typeshed.yaml b/.github/workflows/sync_typeshed.yaml index ef3d5e6598..5dac3a3368 100644 --- a/.github/workflows/sync_typeshed.yaml +++ b/.github/workflows/sync_typeshed.yaml @@ -207,12 +207,12 @@ jobs: uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1 - name: "Install cargo nextest" if: ${{ success() }} - uses: taiki-e/install-action@f79fe7514db78f0a7bdba3cb6dd9c1baa7d046d9 # v2.62.56 + uses: taiki-e/install-action@3575e532701a5fc614b0c842e4119af4cc5fd16d # v2.62.60 with: tool: cargo-nextest - name: "Install cargo insta" if: ${{ success() }} - uses: taiki-e/install-action@f79fe7514db78f0a7bdba3cb6dd9c1baa7d046d9 # v2.62.56 + uses: taiki-e/install-action@3575e532701a5fc614b0c842e4119af4cc5fd16d # v2.62.60 with: tool: cargo-insta - name: Update snapshots From c61e885527304d027a8b1a29e15f61d9d2449dd6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 1 Dec 2025 08:02:44 +0100 Subject: [PATCH 37/67] Update salsa digest to 59aa107 (#21708) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- fuzz/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d8a29c0eb4..fa2b9e4252 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3588,7 +3588,7 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "salsa" version = "0.24.0" -source = "git+https://github.com/salsa-rs/salsa.git?rev=17bc55d699565e5a1cb1bd42363b905af2f9f3e7#17bc55d699565e5a1cb1bd42363b905af2f9f3e7" +source = "git+https://github.com/salsa-rs/salsa.git?rev=59aa1075e837f5deb0d6ffb24b68fedc0f4bc5e0#59aa1075e837f5deb0d6ffb24b68fedc0f4bc5e0" dependencies = [ "boxcar", "compact_str", @@ -3612,12 +3612,12 @@ dependencies = [ [[package]] name = "salsa-macro-rules" version = "0.24.0" -source = "git+https://github.com/salsa-rs/salsa.git?rev=17bc55d699565e5a1cb1bd42363b905af2f9f3e7#17bc55d699565e5a1cb1bd42363b905af2f9f3e7" +source = "git+https://github.com/salsa-rs/salsa.git?rev=59aa1075e837f5deb0d6ffb24b68fedc0f4bc5e0#59aa1075e837f5deb0d6ffb24b68fedc0f4bc5e0" [[package]] name = "salsa-macros" version = "0.24.0" -source = "git+https://github.com/salsa-rs/salsa.git?rev=17bc55d699565e5a1cb1bd42363b905af2f9f3e7#17bc55d699565e5a1cb1bd42363b905af2f9f3e7" +source = "git+https://github.com/salsa-rs/salsa.git?rev=59aa1075e837f5deb0d6ffb24b68fedc0f4bc5e0#59aa1075e837f5deb0d6ffb24b68fedc0f4bc5e0" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 0b9578a245..e948f46085 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -146,7 +146,7 @@ regex-automata = { version = "0.4.9" } rustc-hash = { version = "2.0.0" } rustc-stable-hash = { version = "0.1.2" } # When updating salsa, make sure to also update the revision in `fuzz/Cargo.toml` -salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "17bc55d699565e5a1cb1bd42363b905af2f9f3e7", default-features = false, features = [ +salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "59aa1075e837f5deb0d6ffb24b68fedc0f4bc5e0", default-features = false, features = [ "compact_str", "macros", "salsa_unstable", diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index fe9a85f065..adbdcd7545 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -30,7 +30,7 @@ ty_python_semantic = { path = "../crates/ty_python_semantic" } ty_vendored = { path = "../crates/ty_vendored" } libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer", default-features = false } -salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "17bc55d699565e5a1cb1bd42363b905af2f9f3e7", default-features = false, features = [ +salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "59aa1075e837f5deb0d6ffb24b68fedc0f4bc5e0", default-features = false, features = [ "compact_str", "macros", "salsa_unstable", From 846df40a6eb75b43fff2ec99a5e770ff87011d8a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 1 Dec 2025 08:03:17 +0100 Subject: [PATCH 38/67] Update Swatinem/rust-cache action to v2.8.2 (#21710) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yaml | 42 ++++++++++---------- .github/workflows/daily_fuzz.yaml | 2 +- .github/workflows/mypy_primer.yaml | 4 +- .github/workflows/publish-docs.yml | 2 +- .github/workflows/sync_typeshed.yaml | 2 +- .github/workflows/ty-ecosystem-analyzer.yaml | 2 +- .github/workflows/ty-ecosystem-report.yaml | 2 +- .github/workflows/typing_conformance.yaml | 2 +- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b0488644b6..2685f96f94 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -230,7 +230,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - name: "Install Rust toolchain" @@ -252,7 +252,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: shared-key: ruff-linux-debug save-if: ${{ github.ref == 'refs/heads/main' }} @@ -315,7 +315,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - name: "Install Rust toolchain" @@ -350,7 +350,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - name: "Install Rust toolchain" @@ -378,7 +378,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - name: "Install Rust toolchain" @@ -415,7 +415,7 @@ jobs: with: file: "Cargo.toml" field: "workspace.package.rust-version" - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - name: "Install Rust toolchain" @@ -439,7 +439,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: workspaces: "fuzz -> target" save-if: ${{ github.ref == 'refs/heads/main' }} @@ -467,7 +467,7 @@ jobs: with: persist-credentials: false - uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: shared-key: ruff-linux-debug save-if: false @@ -498,7 +498,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 @@ -547,7 +547,7 @@ jobs: - name: "Install mold" uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1 - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: shared-key: ruff-linux-debug save-if: false @@ -643,7 +643,7 @@ jobs: fetch-depth: 0 persist-credentials: false - uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - name: "Install Rust toolchain" @@ -702,7 +702,7 @@ jobs: with: persist-credentials: false - uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - name: "Install Rust toolchain" @@ -727,7 +727,7 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - name: "Prep README.md" @@ -753,7 +753,7 @@ jobs: with: persist-credentials: false - uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 @@ -785,7 +785,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - name: "Add SSH key" @@ -829,7 +829,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - name: "Install Rust toolchain" @@ -857,7 +857,7 @@ jobs: with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: shared-key: ruff-linux-debug save-if: false @@ -908,7 +908,7 @@ jobs: persist-credentials: false - name: "Install Rust toolchain" run: rustup target add wasm32-unknown-unknown - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 @@ -948,7 +948,7 @@ jobs: with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 @@ -988,7 +988,7 @@ jobs: with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 @@ -1028,7 +1028,7 @@ jobs: with: persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 diff --git a/.github/workflows/daily_fuzz.yaml b/.github/workflows/daily_fuzz.yaml index 7b013df83f..630b79ce49 100644 --- a/.github/workflows/daily_fuzz.yaml +++ b/.github/workflows/daily_fuzz.yaml @@ -39,7 +39,7 @@ jobs: run: rustup show - name: "Install mold" uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1 - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 - name: Build ruff # A debug build means the script runs slower once it gets started, # but this is outweighed by the fact that a release build takes *much* longer to compile in CI diff --git a/.github/workflows/mypy_primer.yaml b/.github/workflows/mypy_primer.yaml index d4a480d028..b2f7f5e275 100644 --- a/.github/workflows/mypy_primer.yaml +++ b/.github/workflows/mypy_primer.yaml @@ -45,7 +45,7 @@ jobs: - name: Install the latest version of uv uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: workspaces: "ruff" @@ -83,7 +83,7 @@ jobs: - name: Install the latest version of uv uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: workspaces: "ruff" diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 529c9792ed..000b866c48 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -68,7 +68,7 @@ jobs: - name: "Install Rust toolchain" run: rustup show - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 - name: "Install Insiders dependencies" if: ${{ env.MKDOCS_INSIDERS_SSH_KEY_EXISTS == 'true' }} diff --git a/.github/workflows/sync_typeshed.yaml b/.github/workflows/sync_typeshed.yaml index 5dac3a3368..276e190c49 100644 --- a/.github/workflows/sync_typeshed.yaml +++ b/.github/workflows/sync_typeshed.yaml @@ -198,7 +198,7 @@ jobs: run: | rm "${VENDORED_TYPESHED}/pyproject.toml" git commit -am "Remove pyproject.toml file" - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 - name: "Install Rust toolchain" if: ${{ success() }} run: rustup show diff --git a/.github/workflows/ty-ecosystem-analyzer.yaml b/.github/workflows/ty-ecosystem-analyzer.yaml index 417ab77bad..6586d97845 100644 --- a/.github/workflows/ty-ecosystem-analyzer.yaml +++ b/.github/workflows/ty-ecosystem-analyzer.yaml @@ -37,7 +37,7 @@ jobs: with: enable-cache: true # zizmor: ignore[cache-poisoning] acceptable risk for CloudFlare pages artifact - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: workspaces: "ruff" lookup-only: false # zizmor: ignore[cache-poisoning] acceptable risk for CloudFlare pages artifact diff --git a/.github/workflows/ty-ecosystem-report.yaml b/.github/workflows/ty-ecosystem-report.yaml index aa07cccd04..cdfb3b1446 100644 --- a/.github/workflows/ty-ecosystem-report.yaml +++ b/.github/workflows/ty-ecosystem-report.yaml @@ -33,7 +33,7 @@ jobs: with: enable-cache: true # zizmor: ignore[cache-poisoning] acceptable risk for CloudFlare pages artifact - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: workspaces: "ruff" lookup-only: false # zizmor: ignore[cache-poisoning] acceptable risk for CloudFlare pages artifact diff --git a/.github/workflows/typing_conformance.yaml b/.github/workflows/typing_conformance.yaml index aefe0b6c40..82fac8a456 100644 --- a/.github/workflows/typing_conformance.yaml +++ b/.github/workflows/typing_conformance.yaml @@ -45,7 +45,7 @@ jobs: path: typing persist-credentials: false - - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 with: workspaces: "ruff" From a6cbc138d273b86a70ed36e13623d079bd368236 Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama <45118249+mtshiba@users.noreply.github.com> Date: Mon, 1 Dec 2025 16:48:43 +0900 Subject: [PATCH 39/67] [ty] remove the `visitor` parameter in the `recursive_type_normalized_impl` method (#21701) --- .../resources/mdtest/cycle.md | 4 + crates/ty_python_semantic/src/types.rs | 240 +++++++----------- .../src/types/bound_super.rs | 10 +- crates/ty_python_semantic/src/types/class.rs | 6 +- .../src/types/class_base.rs | 3 +- .../ty_python_semantic/src/types/function.rs | 9 +- .../ty_python_semantic/src/types/generics.rs | 7 +- .../ty_python_semantic/src/types/instance.rs | 19 +- .../src/types/protocol_class.rs | 20 +- .../src/types/signatures.rs | 31 +-- .../src/types/subclass_of.rs | 6 +- crates/ty_python_semantic/src/types/tuple.rs | 26 +- 12 files changed, 148 insertions(+), 233 deletions(-) diff --git a/crates/ty_python_semantic/resources/mdtest/cycle.md b/crates/ty_python_semantic/resources/mdtest/cycle.md index 145b7ee249..7d1686fb2d 100644 --- a/crates/ty_python_semantic/resources/mdtest/cycle.md +++ b/crates/ty_python_semantic/resources/mdtest/cycle.md @@ -52,6 +52,10 @@ def f(x: A): JSONPrimitive = Union[str, int, float, bool, None] JSONValue = TypeAliasType("JSONValue", 'Union[JSONPrimitive, Sequence["JSONValue"], Mapping[str, "JSONValue"]]') + +def _(x: JSONValue): + # TODO: should be `JSONValue` + reveal_type(x) # revealed: Divergent ``` ## Self-referential legacy type variables diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index c7c370ed15..ff41b2d06d 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -573,20 +573,19 @@ impl<'db> PropertyInstanceType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { let getter = match self.getter(db) { - Some(ty) if nested => Some(ty.recursive_type_normalized_impl(db, div, true, visitor)?), + Some(ty) if nested => Some(ty.recursive_type_normalized_impl(db, div, true)?), Some(ty) => Some( - ty.recursive_type_normalized_impl(db, div, true, visitor) + ty.recursive_type_normalized_impl(db, div, true) .unwrap_or(div), ), None => None, }; let setter = match self.setter(db) { - Some(ty) if nested => Some(ty.recursive_type_normalized_impl(db, div, true, visitor)?), + Some(ty) if nested => Some(ty.recursive_type_normalized_impl(db, div, true)?), Some(ty) => Some( - ty.recursive_type_normalized_impl(db, div, true, visitor) + ty.recursive_type_normalized_impl(db, div, true) .unwrap_or(div), ), None => None, @@ -1553,15 +1552,14 @@ impl<'db> Type<'db> { #[must_use] pub(crate) fn recursive_type_normalized(self, db: &'db dyn Db, cycle: &salsa::Cycle) -> Self { cycle.head_ids().fold(self, |ty, id| { - let visitor = NormalizedVisitor::new(Type::divergent(id)); - ty.recursive_type_normalized_impl(db, Type::divergent(id), false, &visitor) + ty.recursive_type_normalized_impl(db, Type::divergent(id), false) .unwrap_or(Type::divergent(id)) }) } /// Normalizes types including divergent types (recursive types), which is necessary for convergence of fixed-point iteration. - /// When nested is true, propagate `None`. That is, if the type contains a `Divergent` type, the return value of this method is `None`. - /// When nested is false, create a type containing `Divergent` types instead of propagating `None`. + /// When `nested` is true, propagate `None`. That is, if the type contains a `Divergent` type, the return value of this method is `None` (so we can use the `?` operator). + /// When `nested` is false, create a type containing `Divergent` types instead of propagating `None` (we should use `unwrap_or(Divergent)`). /// This is to preserve the structure of the non-divergent parts of the type instead of completely collapsing the type containing a `Divergent` type into a `Divergent` type. /// ```python /// tuple[tuple[Divergent, Literal[1]], Literal[1]].recursive_type_normalized(nested: false) @@ -1580,102 +1578,73 @@ impl<'db> Type<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { if nested && self == div { return None; } match self { - Type::Union(union) => visitor.try_visit(self, || { - union.recursive_type_normalized_impl(db, div, nested, visitor) - }), - Type::Intersection(intersection) => visitor.try_visit(self, || { - intersection - .recursive_type_normalized_impl(db, div, nested, visitor) - .map(Type::Intersection) - }), - Type::Callable(callable) => visitor.try_visit(self, || { - callable - .recursive_type_normalized_impl(db, div, nested, visitor) - .map(Type::Callable) - }), - Type::ProtocolInstance(protocol) => visitor.try_visit(self, || { - protocol - .recursive_type_normalized_impl(db, div, nested, visitor) - .map(Type::ProtocolInstance) - }), - Type::NominalInstance(instance) => visitor.try_visit(self, || { - instance - .recursive_type_normalized_impl(db, div, nested, visitor) - .map(Type::NominalInstance) - }), - Type::FunctionLiteral(function) => visitor.try_visit(self, || { - function - .recursive_type_normalized_impl(db, div, nested, visitor) - .map(Type::FunctionLiteral) - }), - Type::PropertyInstance(property) => visitor.try_visit(self, || { - property - .recursive_type_normalized_impl(db, div, nested, visitor) - .map(Type::PropertyInstance) - }), - Type::KnownBoundMethod(method_kind) => visitor.try_visit(self, || { - method_kind - .recursive_type_normalized_impl(db, div, nested, visitor) - .map(Type::KnownBoundMethod) - }), - Type::BoundMethod(method) => visitor.try_visit(self, || { - method - .recursive_type_normalized_impl(db, div, nested, visitor) - .map(Type::BoundMethod) - }), - Type::BoundSuper(bound_super) => visitor.try_visit(self, || { - bound_super - .recursive_type_normalized_impl(db, div, nested, visitor) - .map(Type::BoundSuper) - }), - Type::GenericAlias(generic) => visitor.try_visit(self, || { - generic - .recursive_type_normalized_impl(db, div, nested, visitor) - .map(Type::GenericAlias) - }), - Type::SubclassOf(subclass_of) => visitor.try_visit(self, || { - subclass_of - .recursive_type_normalized_impl(db, div, nested, visitor) - .map(Type::SubclassOf) - }), + Type::Union(union) => union.recursive_type_normalized_impl(db, div, nested), + Type::Intersection(intersection) => intersection + .recursive_type_normalized_impl(db, div, nested) + .map(Type::Intersection), + Type::Callable(callable) => callable + .recursive_type_normalized_impl(db, div, nested) + .map(Type::Callable), + Type::ProtocolInstance(protocol) => protocol + .recursive_type_normalized_impl(db, div, nested) + .map(Type::ProtocolInstance), + Type::NominalInstance(instance) => instance + .recursive_type_normalized_impl(db, div, nested) + .map(Type::NominalInstance), + Type::FunctionLiteral(function) => function + .recursive_type_normalized_impl(db, div, nested) + .map(Type::FunctionLiteral), + Type::PropertyInstance(property) => property + .recursive_type_normalized_impl(db, div, nested) + .map(Type::PropertyInstance), + Type::KnownBoundMethod(method_kind) => method_kind + .recursive_type_normalized_impl(db, div, nested) + .map(Type::KnownBoundMethod), + Type::BoundMethod(method) => method + .recursive_type_normalized_impl(db, div, nested) + .map(Type::BoundMethod), + Type::BoundSuper(bound_super) => bound_super + .recursive_type_normalized_impl(db, div, nested) + .map(Type::BoundSuper), + Type::GenericAlias(generic) => generic + .recursive_type_normalized_impl(db, div, nested) + .map(Type::GenericAlias), + Type::SubclassOf(subclass_of) => subclass_of + .recursive_type_normalized_impl(db, div, nested) + .map(Type::SubclassOf), Type::TypeVar(_) => Some(self), - Type::KnownInstance(known_instance) => visitor.try_visit(self, || { - known_instance - .recursive_type_normalized_impl(db, div, nested, visitor) - .map(Type::KnownInstance) - }), - Type::TypeIs(type_is) => visitor.try_visit(self, || { + Type::KnownInstance(known_instance) => known_instance + .recursive_type_normalized_impl(db, div, nested) + .map(Type::KnownInstance), + Type::TypeIs(type_is) => { let ty = if nested { type_is .return_type(db) - .recursive_type_normalized_impl(db, div, true, visitor)? + .recursive_type_normalized_impl(db, div, true)? } else { type_is .return_type(db) - .recursive_type_normalized_impl(db, div, true, visitor) + .recursive_type_normalized_impl(db, div, true) .unwrap_or(div) }; Some(type_is.with_type(db, ty)) - }), + } Type::Dynamic(dynamic) => Some(Type::Dynamic(dynamic.recursive_type_normalized())), Type::TypedDict(_) => { // TODO: Normalize TypedDicts Some(self) } Type::TypeAlias(_) => Some(self), - Type::NewTypeInstance(newtype) => visitor.try_visit(self, || { - newtype - .try_map_base_class_type(db, |class_type| { - class_type.recursive_type_normalized_impl(db, div, nested, visitor) - }) - .map(Type::NewTypeInstance) - }), + Type::NewTypeInstance(newtype) => newtype + .try_map_base_class_type(db, |class_type| { + class_type.recursive_type_normalized_impl(db, div, nested) + }) + .map(Type::NewTypeInstance), Type::LiteralString | Type::AlwaysFalsy | Type::AlwaysTruthy @@ -8702,7 +8671,6 @@ impl<'db> KnownInstanceType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { match self { // Nothing to normalize @@ -8712,37 +8680,37 @@ impl<'db> KnownInstanceType<'db> { Self::ConstraintSet(set) => Some(Self::ConstraintSet(set)), Self::TypeVar(typevar) => Some(Self::TypeVar(typevar)), Self::TypeAliasType(type_alias) => type_alias - .recursive_type_normalized_impl(db, div, visitor) + .recursive_type_normalized_impl(db, div) .map(Self::TypeAliasType), Self::Field(field) => field - .recursive_type_normalized_impl(db, div, nested, visitor) + .recursive_type_normalized_impl(db, div, nested) .map(Self::Field), Self::UnionType(union_type) => union_type - .recursive_type_normalized_impl(db, div, nested, visitor) + .recursive_type_normalized_impl(db, div, nested) .map(Self::UnionType), Self::Literal(ty) => ty - .recursive_type_normalized_impl(db, div, true, visitor) + .recursive_type_normalized_impl(db, div, true) .map(Self::Literal), Self::Annotated(ty) => ty - .recursive_type_normalized_impl(db, div, true, visitor) + .recursive_type_normalized_impl(db, div, true) .map(Self::Annotated), Self::TypeGenericAlias(ty) => ty - .recursive_type_normalized_impl(db, div, true, visitor) + .recursive_type_normalized_impl(db, div, true) .map(Self::TypeGenericAlias), Self::LiteralStringAlias(ty) => ty - .recursive_type_normalized_impl(db, div, true, visitor) + .recursive_type_normalized_impl(db, div, true) .map(Self::LiteralStringAlias), Self::Callable(callable) => callable - .recursive_type_normalized_impl(db, div, nested, visitor) + .recursive_type_normalized_impl(db, div, nested) .map(Self::Callable), Self::NewType(newtype) => newtype .try_map_base_class_type(db, |class_type| { - class_type.recursive_type_normalized_impl(db, div, true, visitor) + class_type.recursive_type_normalized_impl(db, div, true) }) .map(Self::NewType), Self::GenericContext(generic) => Some(Self::GenericContext(generic)), Self::Specialization(specialization) => specialization - .recursive_type_normalized_impl(db, div, true, visitor) + .recursive_type_normalized_impl(db, div, true) .map(Self::Specialization), } } @@ -9231,15 +9199,12 @@ impl<'db> FieldInstance<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { let default_type = match self.default_type(db) { - Some(default) if nested => { - Some(default.recursive_type_normalized_impl(db, div, true, visitor)?) - } + Some(default) if nested => Some(default.recursive_type_normalized_impl(db, div, true)?), Some(default) => Some( default - .recursive_type_normalized_impl(db, div, true, visitor) + .recursive_type_normalized_impl(db, div, true) .unwrap_or(div), ), None => None, @@ -10184,7 +10149,6 @@ impl<'db> UnionTypeInstance<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { // The `Divergent` elimination rules are different within union types. // See `UnionType::recursive_type_normalized_impl` for details. @@ -10192,14 +10156,14 @@ impl<'db> UnionTypeInstance<'db> { Some(types) if nested => Some( types .iter() - .map(|ty| ty.recursive_type_normalized_impl(db, div, nested, visitor)) + .map(|ty| ty.recursive_type_normalized_impl(db, div, nested)) .collect::>>()?, ), Some(types) => Some( types .iter() .map(|ty| { - ty.recursive_type_normalized_impl(db, div, nested, visitor) + ty.recursive_type_normalized_impl(db, div, nested) .unwrap_or(div) }) .collect::>(), @@ -10207,9 +10171,9 @@ impl<'db> UnionTypeInstance<'db> { None => None, }; let union_type = match self.union_type(db).clone() { - Ok(ty) if nested => Ok(ty.recursive_type_normalized_impl(db, div, nested, visitor)?), + Ok(ty) if nested => Ok(ty.recursive_type_normalized_impl(db, div, nested)?), Ok(ty) => Ok(ty - .recursive_type_normalized_impl(db, div, nested, visitor) + .recursive_type_normalized_impl(db, div, nested) .unwrap_or(div)), Err(err) => Err(err), }; @@ -10241,14 +10205,13 @@ impl<'db> InternedType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { let inner = if nested { self.inner(db) - .recursive_type_normalized_impl(db, div, nested, visitor)? + .recursive_type_normalized_impl(db, div, nested)? } else { self.inner(db) - .recursive_type_normalized_impl(db, div, nested, visitor) + .recursive_type_normalized_impl(db, div, nested) .unwrap_or(div) }; Some(InternedType::new(db, inner)) @@ -11560,14 +11523,13 @@ impl<'db> BoundMethodType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { Some(Self::new( db, self.function(db) - .recursive_type_normalized_impl(db, div, nested, visitor)?, + .recursive_type_normalized_impl(db, div, nested)?, self.self_instance(db) - .recursive_type_normalized_impl(db, div, true, visitor)?, + .recursive_type_normalized_impl(db, div, true)?, )) } @@ -11732,12 +11694,11 @@ impl<'db> CallableType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { Some(CallableType::new( db, self.signatures(db) - .recursive_type_normalized_impl(db, div, nested, visitor)?, + .recursive_type_normalized_impl(db, div, nested)?, self.is_function_like(db), )) } @@ -12175,27 +12136,26 @@ impl<'db> KnownBoundMethodType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { match self { KnownBoundMethodType::FunctionTypeDunderGet(function) => { Some(KnownBoundMethodType::FunctionTypeDunderGet( - function.recursive_type_normalized_impl(db, div, nested, visitor)?, + function.recursive_type_normalized_impl(db, div, nested)?, )) } KnownBoundMethodType::FunctionTypeDunderCall(function) => { Some(KnownBoundMethodType::FunctionTypeDunderCall( - function.recursive_type_normalized_impl(db, div, nested, visitor)?, + function.recursive_type_normalized_impl(db, div, nested)?, )) } KnownBoundMethodType::PropertyDunderGet(property) => { Some(KnownBoundMethodType::PropertyDunderGet( - property.recursive_type_normalized_impl(db, div, nested, visitor)?, + property.recursive_type_normalized_impl(db, div, nested)?, )) } KnownBoundMethodType::PropertyDunderSet(property) => { Some(KnownBoundMethodType::PropertyDunderSet( - property.recursive_type_normalized_impl(db, div, nested, visitor)?, + property.recursive_type_normalized_impl(db, div, nested)?, )) } KnownBoundMethodType::StrStartswith(_) @@ -12858,18 +12818,14 @@ impl<'db> ManualPEP695TypeAliasType<'db> { ) } - fn recursive_type_normalized_impl( - self, - db: &'db dyn Db, - div: Type<'db>, - visitor: &NormalizedVisitor<'db>, - ) -> Option { + // TODO: with full support for manual PEP-695 style type aliases, this method should become unnecessary. + fn recursive_type_normalized_impl(self, db: &'db dyn Db, div: Type<'db>) -> Option { Some(Self::new( db, self.name(db), self.definition(db), self.value(db) - .recursive_type_normalized_impl(db, div, true, visitor)?, + .recursive_type_normalized_impl(db, div, true)?, )) } } @@ -12914,16 +12870,11 @@ impl<'db> TypeAliasType<'db> { } } - fn recursive_type_normalized_impl( - self, - db: &'db dyn Db, - div: Type<'db>, - visitor: &NormalizedVisitor<'db>, - ) -> Option { + fn recursive_type_normalized_impl(self, db: &'db dyn Db, div: Type<'db>) -> Option { match self { TypeAliasType::PEP695(type_alias) => Some(TypeAliasType::PEP695(type_alias)), TypeAliasType::ManualPEP695(type_alias) => Some(TypeAliasType::ManualPEP695( - type_alias.recursive_type_normalized_impl(db, div, visitor)?, + type_alias.recursive_type_normalized_impl(db, div)?, )), } } @@ -13248,7 +13199,6 @@ impl<'db> UnionType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option> { let mut builder = UnionBuilder::new(db) .order_elements(false) @@ -13258,7 +13208,7 @@ impl<'db> UnionType<'db> { for ty in self.elements(db) { if nested { // list[T | Divergent] => list[Divergent] - let ty = ty.recursive_type_normalized_impl(db, div, nested, visitor)?; + let ty = ty.recursive_type_normalized_impl(db, div, nested)?; if ty == div { return Some(ty); } @@ -13271,7 +13221,7 @@ impl<'db> UnionType<'db> { continue; } builder = builder.add( - ty.recursive_type_normalized_impl(db, div, nested, visitor) + ty.recursive_type_normalized_impl(db, div, nested) .unwrap_or(div), ); empty = false; @@ -13389,18 +13339,16 @@ impl<'db> IntersectionType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { fn opt_normalized_set<'db>( db: &'db dyn Db, elements: &FxOrderSet>, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option>> { elements .iter() - .map(|ty| ty.recursive_type_normalized_impl(db, div, nested, visitor)) + .map(|ty| ty.recursive_type_normalized_impl(db, div, nested)) .collect() } @@ -13409,26 +13357,25 @@ impl<'db> IntersectionType<'db> { elements: &FxOrderSet>, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> FxOrderSet> { elements .iter() .map(|ty| { - ty.recursive_type_normalized_impl(db, div, nested, visitor) + ty.recursive_type_normalized_impl(db, div, nested) .unwrap_or(div) }) .collect() } let positive = if nested { - opt_normalized_set(db, self.positive(db), div, nested, visitor)? + opt_normalized_set(db, self.positive(db), div, nested)? } else { - normalized_set(db, self.positive(db), div, nested, visitor) + normalized_set(db, self.positive(db), div, nested) }; let negative = if nested { - opt_normalized_set(db, self.negative(db), div, nested, visitor)? + opt_normalized_set(db, self.negative(db), div, nested)? } else { - normalized_set(db, self.negative(db), div, nested, visitor) + normalized_set(db, self.negative(db), div, nested) }; Some(IntersectionType::new(db, positive, negative)) @@ -13911,16 +13858,15 @@ pub(crate) mod tests { nested_rec.display(&db).to_string(), "list[list[Divergent] | None]" ); - let visitor = NormalizedVisitor::default(); let normalized = nested_rec - .recursive_type_normalized_impl(&db, div, false, &visitor) + .recursive_type_normalized_impl(&db, div, false) .unwrap(); assert_eq!(normalized.display(&db).to_string(), "list[Divergent]"); let union = UnionType::from_elements(&db, [div, KnownClass::Int.to_instance(&db)]); assert_eq!(union.display(&db).to_string(), "Divergent | int"); let normalized = union - .recursive_type_normalized_impl(&db, div, false, &visitor) + .recursive_type_normalized_impl(&db, div, false) .unwrap(); assert_eq!(normalized.display(&db).to_string(), "int"); diff --git a/crates/ty_python_semantic/src/types/bound_super.rs b/crates/ty_python_semantic/src/types/bound_super.rs index e963e6a366..04cd24e40e 100644 --- a/crates/ty_python_semantic/src/types/bound_super.rs +++ b/crates/ty_python_semantic/src/types/bound_super.rs @@ -197,17 +197,16 @@ impl<'db> SuperOwnerKind<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { match self { SuperOwnerKind::Dynamic(dynamic) => { Some(SuperOwnerKind::Dynamic(dynamic.recursive_type_normalized())) } SuperOwnerKind::Class(class) => Some(SuperOwnerKind::Class( - class.recursive_type_normalized_impl(db, div, nested, visitor)?, + class.recursive_type_normalized_impl(db, div, nested)?, )), SuperOwnerKind::Instance(instance) => Some(SuperOwnerKind::Instance( - instance.recursive_type_normalized_impl(db, div, nested, visitor)?, + instance.recursive_type_normalized_impl(db, div, nested)?, )), } } @@ -620,14 +619,13 @@ impl<'db> BoundSuperType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { Some(Self::new( db, self.pivot_class(db) - .recursive_type_normalized_impl(db, div, nested, visitor)?, + .recursive_type_normalized_impl(db, div, nested)?, self.owner(db) - .recursive_type_normalized_impl(db, div, nested, visitor)?, + .recursive_type_normalized_impl(db, div, nested)?, )) } } diff --git a/crates/ty_python_semantic/src/types/class.rs b/crates/ty_python_semantic/src/types/class.rs index 3c38f6bdfc..1285fb0093 100644 --- a/crates/ty_python_semantic/src/types/class.rs +++ b/crates/ty_python_semantic/src/types/class.rs @@ -284,13 +284,12 @@ impl<'db> GenericAlias<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { Some(Self::new( db, self.origin(db), self.specialization(db) - .recursive_type_normalized_impl(db, div, nested, visitor)?, + .recursive_type_normalized_impl(db, div, nested)?, )) } @@ -443,12 +442,11 @@ impl<'db> ClassType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { match self { Self::NonGeneric(_) => Some(self), Self::Generic(generic) => Some(Self::Generic( - generic.recursive_type_normalized_impl(db, div, nested, visitor)?, + generic.recursive_type_normalized_impl(db, div, nested)?, )), } } diff --git a/crates/ty_python_semantic/src/types/class_base.rs b/crates/ty_python_semantic/src/types/class_base.rs index 74833406f5..4d85a1cc75 100644 --- a/crates/ty_python_semantic/src/types/class_base.rs +++ b/crates/ty_python_semantic/src/types/class_base.rs @@ -48,12 +48,11 @@ impl<'db> ClassBase<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { match self { Self::Dynamic(dynamic) => Some(Self::Dynamic(dynamic.recursive_type_normalized())), Self::Class(class) => Some(Self::Class( - class.recursive_type_normalized_impl(db, div, nested, visitor)?, + class.recursive_type_normalized_impl(db, div, nested)?, )), Self::Protocol | Self::Generic | Self::TypedDict => Some(self), } diff --git a/crates/ty_python_semantic/src/types/function.rs b/crates/ty_python_semantic/src/types/function.rs index 7c07a86af1..189520fa52 100644 --- a/crates/ty_python_semantic/src/types/function.rs +++ b/crates/ty_python_semantic/src/types/function.rs @@ -1112,19 +1112,14 @@ impl<'db> FunctionType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { let literal = self.literal(db); let updated_signature = match self.updated_signature(db) { - Some(signature) => { - Some(signature.recursive_type_normalized_impl(db, div, nested, visitor)?) - } + Some(signature) => Some(signature.recursive_type_normalized_impl(db, div, nested)?), None => None, }; let updated_last_definition_signature = match self.updated_last_definition_signature(db) { - Some(signature) => { - Some(signature.recursive_type_normalized_impl(db, div, nested, visitor)?) - } + Some(signature) => Some(signature.recursive_type_normalized_impl(db, div, nested)?), None => None, }; Some(Self::new( diff --git a/crates/ty_python_semantic/src/types/generics.rs b/crates/ty_python_semantic/src/types/generics.rs index cf14bc861a..de357dfbce 100644 --- a/crates/ty_python_semantic/src/types/generics.rs +++ b/crates/ty_python_semantic/src/types/generics.rs @@ -1045,24 +1045,23 @@ impl<'db> Specialization<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { let types = if nested { self.types(db) .iter() - .map(|ty| ty.recursive_type_normalized_impl(db, div, true, visitor)) + .map(|ty| ty.recursive_type_normalized_impl(db, div, true)) .collect::>>()? } else { self.types(db) .iter() .map(|ty| { - ty.recursive_type_normalized_impl(db, div, true, visitor) + ty.recursive_type_normalized_impl(db, div, true) .unwrap_or(div) }) .collect::>() }; let tuple_inner = match self.tuple_inner(db) { - Some(tuple) => Some(tuple.recursive_type_normalized_impl(db, div, nested, visitor)?), + Some(tuple) => Some(tuple.recursive_type_normalized_impl(db, div, nested)?), None => None, }; let context = self.generic_context(db); diff --git a/crates/ty_python_semantic/src/types/instance.rs b/crates/ty_python_semantic/src/types/instance.rs index 028ce648cd..fb53f10ef4 100644 --- a/crates/ty_python_semantic/src/types/instance.rs +++ b/crates/ty_python_semantic/src/types/instance.rs @@ -379,16 +379,15 @@ impl<'db> NominalInstanceType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { match self.0 { NominalInstanceInner::ExactTuple(tuple) => { Some(Self(NominalInstanceInner::ExactTuple( - tuple.recursive_type_normalized_impl(db, div, nested, visitor)?, + tuple.recursive_type_normalized_impl(db, div, nested)?, ))) } NominalInstanceInner::NonTuple(class) => Some(Self(NominalInstanceInner::NonTuple( - class.recursive_type_normalized_impl(db, div, nested, visitor)?, + class.recursive_type_normalized_impl(db, div, nested)?, ))), NominalInstanceInner::Object => Some(Self(NominalInstanceInner::Object)), } @@ -750,12 +749,9 @@ impl<'db> ProtocolInstanceType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { Some(Self { - inner: self - .inner - .recursive_type_normalized_impl(db, div, nested, visitor)?, + inner: self.inner.recursive_type_normalized_impl(db, div, nested)?, _phantom: PhantomData, }) } @@ -877,14 +873,13 @@ impl<'db> Protocol<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { match self { Self::FromClass(class) => Some(Self::FromClass( - class.recursive_type_normalized_impl(db, div, nested, visitor)?, + class.recursive_type_normalized_impl(db, div, nested)?, )), Self::Synthesized(synthesized) => Some(Self::Synthesized( - synthesized.recursive_type_normalized_impl(db, div, nested, visitor)?, + synthesized.recursive_type_normalized_impl(db, div, nested)?, )), } } @@ -963,11 +958,9 @@ mod synthesized_protocol { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { Some(Self( - self.0 - .recursive_type_normalized_impl(db, div, nested, visitor)?, + self.0.recursive_type_normalized_impl(db, div, nested)?, )) } } diff --git a/crates/ty_python_semantic/src/types/protocol_class.rs b/crates/ty_python_semantic/src/types/protocol_class.rs index 45ef664a2f..862349ea40 100644 --- a/crates/ty_python_semantic/src/types/protocol_class.rs +++ b/crates/ty_python_semantic/src/types/protocol_class.rs @@ -150,11 +150,9 @@ impl<'db> ProtocolClass<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { Some(Self( - self.0 - .recursive_type_normalized_impl(db, div, nested, visitor)?, + self.0.recursive_type_normalized_impl(db, div, nested)?, )) } } @@ -386,7 +384,6 @@ impl<'db> ProtocolInterface<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { Some(Self::new( db, @@ -395,7 +392,7 @@ impl<'db> ProtocolInterface<'db> { .map(|(name, data)| { Some(( name.clone(), - data.recursive_type_normalized_impl(db, div, nested, visitor)?, + data.recursive_type_normalized_impl(db, div, nested)?, )) }) .collect::>>()?, @@ -498,21 +495,20 @@ impl<'db> ProtocolMemberData<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { Some(Self { kind: match &self.kind { ProtocolMemberKind::Method(callable) => ProtocolMemberKind::Method( - callable.recursive_type_normalized_impl(db, div, nested, visitor)?, + callable.recursive_type_normalized_impl(db, div, nested)?, ), ProtocolMemberKind::Property(property) => ProtocolMemberKind::Property( - property.recursive_type_normalized_impl(db, div, nested, visitor)?, - ), - ProtocolMemberKind::Other(ty) if nested => ProtocolMemberKind::Other( - ty.recursive_type_normalized_impl(db, div, true, visitor)?, + property.recursive_type_normalized_impl(db, div, nested)?, ), + ProtocolMemberKind::Other(ty) if nested => { + ProtocolMemberKind::Other(ty.recursive_type_normalized_impl(db, div, true)?) + } ProtocolMemberKind::Other(ty) => ProtocolMemberKind::Other( - ty.recursive_type_normalized_impl(db, div, true, visitor) + ty.recursive_type_normalized_impl(db, div, true) .unwrap_or(div), ), }, diff --git a/crates/ty_python_semantic/src/types/signatures.rs b/crates/ty_python_semantic/src/types/signatures.rs index 612a7cf324..738fcfb971 100644 --- a/crates/ty_python_semantic/src/types/signatures.rs +++ b/crates/ty_python_semantic/src/types/signatures.rs @@ -179,13 +179,12 @@ impl<'db> CallableSignature<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { Some(Self { overloads: self .overloads .iter() - .map(|signature| signature.recursive_type_normalized_impl(db, div, nested, visitor)) + .map(|signature| signature.recursive_type_normalized_impl(db, div, nested)) .collect::>>()?, }) } @@ -575,15 +574,14 @@ impl<'db> Signature<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { let return_ty = match self.return_ty { Some(return_ty) if nested => { - Some(return_ty.recursive_type_normalized_impl(db, div, true, visitor)?) + Some(return_ty.recursive_type_normalized_impl(db, div, true)?) } Some(return_ty) => Some( return_ty - .recursive_type_normalized_impl(db, div, true, visitor) + .recursive_type_normalized_impl(db, div, true) .unwrap_or(div), ), None => None, @@ -591,7 +589,7 @@ impl<'db> Signature<'db> { let parameters = { let mut parameters = Vec::with_capacity(self.parameters.len()); for param in &self.parameters { - parameters.push(param.recursive_type_normalized_impl(db, div, nested, visitor)?); + parameters.push(param.recursive_type_normalized_impl(db, div, nested)?); } Parameters::new(db, parameters) }; @@ -1906,7 +1904,6 @@ impl<'db> Parameter<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { let Parameter { annotated_type, @@ -1916,9 +1913,9 @@ impl<'db> Parameter<'db> { } = self; let annotated_type = match annotated_type { - Some(ty) if nested => Some(ty.recursive_type_normalized_impl(db, div, true, visitor)?), + Some(ty) if nested => Some(ty.recursive_type_normalized_impl(db, div, true)?), Some(ty) => Some( - ty.recursive_type_normalized_impl(db, div, true, visitor) + ty.recursive_type_normalized_impl(db, div, true) .unwrap_or(div), ), None => None, @@ -1928,11 +1925,9 @@ impl<'db> Parameter<'db> { ParameterKind::PositionalOnly { name, default_type } => ParameterKind::PositionalOnly { name: name.clone(), default_type: match default_type { - Some(ty) if nested => { - Some(ty.recursive_type_normalized_impl(db, div, true, visitor)?) - } + Some(ty) if nested => Some(ty.recursive_type_normalized_impl(db, div, true)?), Some(ty) => Some( - ty.recursive_type_normalized_impl(db, div, true, visitor) + ty.recursive_type_normalized_impl(db, div, true) .unwrap_or(div), ), None => None, @@ -1943,10 +1938,10 @@ impl<'db> Parameter<'db> { name: name.clone(), default_type: match default_type { Some(ty) if nested => { - Some(ty.recursive_type_normalized_impl(db, div, true, visitor)?) + Some(ty.recursive_type_normalized_impl(db, div, true)?) } Some(ty) => Some( - ty.recursive_type_normalized_impl(db, div, true, visitor) + ty.recursive_type_normalized_impl(db, div, true) .unwrap_or(div), ), None => None, @@ -1956,11 +1951,9 @@ impl<'db> Parameter<'db> { ParameterKind::KeywordOnly { name, default_type } => ParameterKind::KeywordOnly { name: name.clone(), default_type: match default_type { - Some(ty) if nested => { - Some(ty.recursive_type_normalized_impl(db, div, true, visitor)?) - } + Some(ty) if nested => Some(ty.recursive_type_normalized_impl(db, div, true)?), Some(ty) => Some( - ty.recursive_type_normalized_impl(db, div, true, visitor) + ty.recursive_type_normalized_impl(db, div, true) .unwrap_or(div), ), None => None, diff --git a/crates/ty_python_semantic/src/types/subclass_of.rs b/crates/ty_python_semantic/src/types/subclass_of.rs index ed69554c8c..0e3deed233 100644 --- a/crates/ty_python_semantic/src/types/subclass_of.rs +++ b/crates/ty_python_semantic/src/types/subclass_of.rs @@ -272,12 +272,11 @@ impl<'db> SubclassOfType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { Some(Self { subclass_of: self .subclass_of - .recursive_type_normalized_impl(db, div, nested, visitor)?, + .recursive_type_normalized_impl(db, div, nested)?, }) } @@ -449,11 +448,10 @@ impl<'db> SubclassOfInner<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { match self { Self::Class(class) => Some(Self::Class( - class.recursive_type_normalized_impl(db, div, nested, visitor)?, + class.recursive_type_normalized_impl(db, div, nested)?, )), Self::Dynamic(dynamic) => Some(Self::Dynamic(dynamic.recursive_type_normalized())), Self::TypeVar(_) => Some(self), diff --git a/crates/ty_python_semantic/src/types/tuple.rs b/crates/ty_python_semantic/src/types/tuple.rs index 5fb8fc982a..d2b96f2849 100644 --- a/crates/ty_python_semantic/src/types/tuple.rs +++ b/crates/ty_python_semantic/src/types/tuple.rs @@ -234,12 +234,11 @@ impl<'db> TupleType<'db> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { Some(Self::new_internal( db, self.tuple(db) - .recursive_type_normalized_impl(db, div, nested, visitor)?, + .recursive_type_normalized_impl(db, div, nested)?, )) } @@ -411,13 +410,12 @@ impl<'db> FixedLengthTuple> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { if nested { Some(Self::from_elements( self.0 .iter() - .map(|ty| ty.recursive_type_normalized_impl(db, div, true, visitor)) + .map(|ty| ty.recursive_type_normalized_impl(db, div, true)) .collect::>>()?, )) } else { @@ -425,7 +423,7 @@ impl<'db> FixedLengthTuple> { self.0 .iter() .map(|ty| { - ty.recursive_type_normalized_impl(db, div, true, visitor) + ty.recursive_type_normalized_impl(db, div, true) .unwrap_or(div) }) .collect::>(), @@ -804,18 +802,17 @@ impl<'db> VariableLengthTuple> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { let prefix = if nested { self.prefix .iter() - .map(|ty| ty.recursive_type_normalized_impl(db, div, true, visitor)) + .map(|ty| ty.recursive_type_normalized_impl(db, div, true)) .collect::>>()? } else { self.prefix .iter() .map(|ty| { - ty.recursive_type_normalized_impl(db, div, true, visitor) + ty.recursive_type_normalized_impl(db, div, true) .unwrap_or(div) }) .collect::>() @@ -823,23 +820,23 @@ impl<'db> VariableLengthTuple> { let suffix = if nested { self.suffix .iter() - .map(|ty| ty.recursive_type_normalized_impl(db, div, true, visitor)) + .map(|ty| ty.recursive_type_normalized_impl(db, div, true)) .collect::>>()? } else { self.suffix .iter() .map(|ty| { - ty.recursive_type_normalized_impl(db, div, true, visitor) + ty.recursive_type_normalized_impl(db, div, true) .unwrap_or(div) }) .collect::>() }; let variable = if nested { self.variable - .recursive_type_normalized_impl(db, div, true, visitor)? + .recursive_type_normalized_impl(db, div, true)? } else { self.variable - .recursive_type_normalized_impl(db, div, true, visitor) + .recursive_type_normalized_impl(db, div, true) .unwrap_or(div) }; Some(Self { @@ -1250,14 +1247,13 @@ impl<'db> Tuple> { db: &'db dyn Db, div: Type<'db>, nested: bool, - visitor: &NormalizedVisitor<'db>, ) -> Option { match self { Tuple::Fixed(tuple) => Some(Tuple::Fixed( - tuple.recursive_type_normalized_impl(db, div, nested, visitor)?, + tuple.recursive_type_normalized_impl(db, div, nested)?, )), Tuple::Variable(tuple) => Some(Tuple::Variable( - tuple.recursive_type_normalized_impl(db, div, nested, visitor)?, + tuple.recursive_type_normalized_impl(db, div, nested)?, )), } } From 4686c360798f2560f298c9e7b8124995d9b14d26 Mon Sep 17 00:00:00 2001 From: Kieran Ryan Date: Mon, 1 Dec 2025 10:07:25 +0000 Subject: [PATCH 40/67] docs: Output file option with GitLab integration (#21706) Co-authored-by: Micha Reiser --- docs/integrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/integrations.md b/docs/integrations.md index fc364ae8ca..65553c6bdf 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -88,7 +88,7 @@ You can add the following configuration to `.gitlab-ci.yml` to run a `ruff forma Ruff Check: extends: .base_ruff script: - - ruff check --output-format=gitlab > code-quality-report.json + - ruff check --output-format=gitlab --output-file=code-quality-report.json artifacts: reports: codequality: $CI_PROJECT_DIR/code-quality-report.json From bc6517a80735567c829131f23d33bc82181a0f40 Mon Sep 17 00:00:00 2001 From: David Peter Date: Mon, 1 Dec 2025 11:18:41 +0100 Subject: [PATCH 41/67] [ty] Add missing projects to `good.txt` (#21721) ## Summary These projects from `mypy_primer` were missing from both `good.txt` and `bad.txt` for some reason. I thought about writing a script that would verify that `good.txt` + `bad.txt` = `mypy_primer.projects`, but that's not completely trivial since there are projects like `cpython` only appear once in `good.txt`. Given that we can hopefully soon get rid of both of these files (and always run on all projects), it's probably not worth the effort. We are usually notified of all `mypy_primer` changes. ## Test Plan CI on this PR --- crates/ty_python_semantic/resources/primer/good.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/ty_python_semantic/resources/primer/good.txt b/crates/ty_python_semantic/resources/primer/good.txt index 0271a5a46d..e62bb8f3d6 100644 --- a/crates/ty_python_semantic/resources/primer/good.txt +++ b/crates/ty_python_semantic/resources/primer/good.txt @@ -14,6 +14,7 @@ altair antidote anyio apprise +archinstall artigraph arviz async-utils @@ -25,7 +26,9 @@ bidict black bokeh boostedblob +build check-jsonschema +cibuildwheel cki-lib cloud-init colour @@ -104,6 +107,7 @@ pylox pyodide pyp pyppeteer +pyproject-metadata pytest pytest-robotframework python-chess @@ -118,6 +122,7 @@ schemathesis scikit-build-core scikit-learn scipy +scipy-stubs scrapy setuptools sockeye From c2773b4c6f3532accb99dd6d3041a3fdfc700811 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Mon, 1 Dec 2025 02:49:26 -0800 Subject: [PATCH 42/67] [ty] support `type[tuple[...]]` (#21652) Fixes https://github.com/astral-sh/ty/issues/1649 ## Summary We missed this when adding support for `type[]` of a specialized generic. ## Test Plan Added mdtests. --- .../resources/mdtest/subscript/tuple.md | 16 +++++++++++++--- .../src/types/infer/builder/type_expression.rs | 6 ++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/ty_python_semantic/resources/mdtest/subscript/tuple.md b/crates/ty_python_semantic/resources/mdtest/subscript/tuple.md index 8de82f11d6..fd909aee41 100644 --- a/crates/ty_python_semantic/resources/mdtest/subscript/tuple.md +++ b/crates/ty_python_semantic/resources/mdtest/subscript/tuple.md @@ -329,6 +329,16 @@ reveal_type(tuple[int, str]) # revealed: reveal_type(tuple[int, ...]) # revealed: ``` +```py +from typing import Any + +def _(a: type[tuple], b: type[tuple[int]], c: type[tuple[int, ...]], d: type[tuple[Any, ...]]) -> None: + reveal_type(a) # revealed: type[tuple[Unknown, ...]] + reveal_type(b) # revealed: type[tuple[int]] + reveal_type(c) # revealed: type[tuple[int, ...]] + reveal_type(d) # revealed: type[tuple[Any, ...]] +``` + ## Inheritance ```toml @@ -392,7 +402,7 @@ class C(Tuple): ... reveal_mro(C) ``` -### Union subscript access +## Union subscript access ```py def test(val: tuple[str] | tuple[int]): @@ -402,7 +412,7 @@ def test2(val: tuple[str, None] | list[int | float]): reveal_type(val[0]) # revealed: str | int | float ``` -### Union subscript access with non-indexable type +## Union subscript access with non-indexable type ```py def test3(val: tuple[str] | tuple[int] | int): @@ -410,7 +420,7 @@ def test3(val: tuple[str] | tuple[int] | int): reveal_type(val[0]) # revealed: str | int | Unknown ``` -### Intersection subscript access +## Intersection subscript access ```py from ty_extensions import Intersection diff --git a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs index 74f6607615..153f46dda3 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs @@ -691,6 +691,12 @@ impl<'db> TypeInferenceBuilder<'db, '_> { self.db(), todo_type!("type[T] for protocols").expect_dynamic(), ) + } else if class_literal.is_tuple(self.db()) { + let class_type = self + .infer_tuple_type_expression(parameters) + .map(|tuple_type| tuple_type.to_class_type(self.db())) + .unwrap_or_else(|| class_literal.default_specialization(self.db())); + SubclassOfType::from(self.db(), class_type) } else { match class_literal.generic_context(self.db()) { Some(generic_context) => { From 2e229aa8cb62edb4395dcb20b6fed0ae1e81f845 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Mon, 1 Dec 2025 12:33:53 +0100 Subject: [PATCH 43/67] [ty] LSP Benchmarks (#21625) --- scripts/ty_benchmark/README.md | 50 + scripts/ty_benchmark/pyproject.toml | 8 +- scripts/ty_benchmark/snapshots/black_ty.txt | 5 +- .../snapshots/discord.py_Pyrefly.txt | 12 +- .../ty_benchmark/snapshots/discord.py_ty.txt | 129 +- .../snapshots/homeassistant_Pyrefly.txt | 529 +--- .../snapshots/homeassistant_ty.txt | 956 +++--- scripts/ty_benchmark/snapshots/isort_ty.txt | 2 +- scripts/ty_benchmark/snapshots/jinja_ty.txt | 4 +- .../snapshots/pandas-stubs_ty.txt | 52 +- scripts/ty_benchmark/snapshots/pandas_ty.txt | 169 +- scripts/ty_benchmark/snapshots/prefect_ty.txt | 61 +- .../snapshots/pytorch_Pyrefly.txt | 33 +- scripts/ty_benchmark/snapshots/pytorch_ty.txt | 2720 ++++++++++------- .../ty_benchmark/src/benchmark/lsp_client.py | 173 ++ .../ty_benchmark/src/benchmark/projects.py | 111 + .../src/benchmark/test_lsp_diagnostics.py | 486 +++ scripts/ty_benchmark/src/benchmark/tool.py | 68 +- scripts/ty_benchmark/uv.lock | 175 +- 19 files changed, 3398 insertions(+), 2345 deletions(-) create mode 100644 scripts/ty_benchmark/src/benchmark/lsp_client.py create mode 100644 scripts/ty_benchmark/src/benchmark/test_lsp_diagnostics.py diff --git a/scripts/ty_benchmark/README.md b/scripts/ty_benchmark/README.md index f4daabd990..68654ac3b5 100644 --- a/scripts/ty_benchmark/README.md +++ b/scripts/ty_benchmark/README.md @@ -12,6 +12,56 @@ Requires hyperfine 1.20 or newer. +## Benchmarks + +### Cold check time + +Run with: + +```shell +uv run --python 3.14 benchmark +``` + +Measures how long it takes to type check a project without a pre-existing cache. + +You can run the benchmark with `--single-threaded` to measure the check time when using a single thread only. + +### Warm check time + +Run with: + +```shell +uv run --python 3.14 benchmark --warm +``` + +Measures how long it takes to recheck a project if there were no changes. + +> **Note**: Of the benchmarked type checkers, only mypy supports caching. + +### LSP: Time to first diagnostic + +Measures how long it takes for a newly started LSP to return the diagnostics for the files open in the editor. + +Run with: + +```bash +uv run --python 3.14 pytest src/benchmark/test_lsp_diagnostics.py::test_fetch_diagnostics +``` + +**Note**: Use `-v -s` to see the set of diagnostics returned by each type checker. + +### LSP: Re-check time + +Measure how long it takes to recheck all open files after making a single change in a file. + +Run with: + +```bash +uv run --python 3.14 pytest src/benchmark/test_lsp_diagnostics.py::test_incremental_edit +``` + +> **Note**: This benchmark uses [pull diagnostics](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics) for type checkers that support this operation (ty), and falls back to [publish diagnostics](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_publishDiagnostics) otherwise (Pyright, Pyrefly). + ## Known limitations The tested type checkers implement Python's type system to varying degrees and diff --git a/scripts/ty_benchmark/pyproject.toml b/scripts/ty_benchmark/pyproject.toml index 69d9276854..b77f3d6273 100644 --- a/scripts/ty_benchmark/pyproject.toml +++ b/scripts/ty_benchmark/pyproject.toml @@ -2,14 +2,18 @@ name = "ty_benchmark" version = "0.0.1" description = "Package for running end-to-end ty benchmarks" -requires-python = ">=3.12" +requires-python = ">=3.14" dependencies = [ # mypy is missing here because we need to install it into the project's virtual environment # for plugins to work. See `Venv.install`. # Pyright is missing because we install it with `npm` to avoid measuring the overhead # of the Python wrapper script (that lazily installs Pyright). "mslex>=1.3.0", - "pyrefly>=0.41.3", + "pyrefly>=0.43.1", + "pytest-benchmark>=4.0.0", + "pytest>=8.0.0", + "pygls>=2.0.0", + "lsprotocol>=2025.0.0", ] [project.scripts] diff --git a/scripts/ty_benchmark/snapshots/black_ty.txt b/scripts/ty_benchmark/snapshots/black_ty.txt index 7ad0ca8c95..64ad958a7f 100644 --- a/scripts/ty_benchmark/snapshots/black_ty.txt +++ b/scripts/ty_benchmark/snapshots/black_ty.txt @@ -18,10 +18,9 @@ src/black/linegen.py:1757:25: warning[possibly-missing-attribute] Attribute `val src/black/linegen.py:1795:13: error[invalid-assignment] Object of type `Literal[""]` is not assignable to attribute `value` on type `Node | Leaf` src/black/linegen.py:1796:13: error[invalid-assignment] Object of type `Literal[""]` is not assignable to attribute `value` on type `Node | Leaf` src/black/nodes.py:746:32: warning[possibly-missing-attribute] Attribute `value` may be missing on object of type `Leaf | Node` -src/black/rusty.py:28:23: error[invalid-argument-type] Argument to class `Err` is incorrect: Expected `Exception`, found `typing.TypeVar` +src/black/rusty.py:28:27: error[invalid-type-arguments] Type `typing.TypeVar` is not assignable to upper bound `Exception` of type variable `E@Err` src/blib2to3/pgen2/conv.py:35:6: error[unresolved-import] Cannot resolve imported module `pgen2` src/blib2to3/pgen2/conv.py:77:34: warning[possibly-missing-attribute] Attribute `groups` may be missing on object of type `Match[str] | None` -src/blib2to3/pgen2/grammar.py:151:16: error[invalid-return-type] Return type does not match returned value: expected `_P@copy`, found `Grammar` src/blib2to3/pgen2/parse.py:367:13: warning[possibly-missing-attribute] Attribute `append` may be missing on object of type `list[Node | Leaf] | None` src/blib2to3/pytree.py:149:13: error[unresolved-attribute] Unresolved attribute `parent` on type `object`. -Found 26 diagnostics +Found 25 diagnostics diff --git a/scripts/ty_benchmark/snapshots/discord.py_Pyrefly.txt b/scripts/ty_benchmark/snapshots/discord.py_Pyrefly.txt index b676ba07ef..6eeba829e1 100644 --- a/scripts/ty_benchmark/snapshots/discord.py_Pyrefly.txt +++ b/scripts/ty_benchmark/snapshots/discord.py_Pyrefly.txt @@ -6,9 +6,6 @@ ERROR discord/abc.py:1031:72-81: Argument `int` is not assignable to parameter ` ERROR discord/abc.py:1052:64-79: Argument `int` is not assignable to parameter `channel_type` with type `Literal[0, 1, 2, 3, 4, 5, 6, 10, 11, 12, 13, 15, 16]` in function `discord.http.HTTPClient.create_channel` [bad-argument-type] ERROR discord/abc.py:1224:25-37: Object of class `NoneType` has no attribute `id` [missing-attribute] ERROR discord/abc.py:1357:25-67: Argument `int | None` is not assignable to parameter `target_type` with type `Literal[1, 2] | None` in function `discord.http.HTTPClient.create_invite` [bad-argument-type] -ERROR discord/abc.py:1808:30-32: Invalid key for TypedDict `ChannelPins`, got `Literal[-1]` [bad-typed-dict-key] -ERROR discord/abc.py:1815:33-40: No matching overload found for function `reversed.__new__` called with arguments: (type[reversed[_T]], list[TypedDict[MessagePin]] | TypedDict[ChannelPins]) [no-matching-overload] -ERROR discord/abc.py:1818:39-44: Argument `list[TypedDict[MessagePin]] | reversed[Unknown] | TypedDict[ChannelPins]` is not assignable to parameter `iterable` with type `Iterable[TypedDict[MessagePin]]` in function `enumerate.__new__` [bad-argument-type] ERROR discord/abc.py:1821:23-30: Type of yielded value `Message` is not assignable to declared return type `PinnedMessage` [invalid-yield] ERROR discord/abc.py:2091:51-62: Default `type[VoiceClient]` is not assignable to parameter `cls` with type `(Client, Connectable) -> T` [bad-function-definition] ERROR discord/activity.py:286:9-16: Class member `Activity.to_dict` overrides parent class `BaseActivity` in an inconsistent manner [bad-override] @@ -196,7 +193,6 @@ ERROR discord/ext/commands/converter.py:402:47-54: Argument `(CategoryChannel & ERROR discord/ext/commands/converter.py:1119:9-26: Class member `Greedy.__class_getitem__` overrides parent class `list` in an inconsistent manner [bad-override] ERROR discord/ext/commands/converter.py:1128:31-35: Expected a type form, got instance of `tuple[()] | Any` [not-a-type] ERROR discord/ext/commands/converter.py:1280:52-59: Expected class object, got `type[Generic]` [invalid-argument] -ERROR discord/ext/commands/converter.py:1326:39-41: Cannot instantiate `Converter` because it is a protocol [bad-instantiation] ERROR discord/ext/commands/cooldowns.py:171:9-22: Class member `DynamicCooldownMapping.create_bucket` overrides parent class `CooldownMapping` in an inconsistent manner [bad-override] ERROR discord/ext/commands/core.py:462:22-46: Object of class `FunctionType` has no attribute `__commands_checks__` [missing-attribute] ERROR discord/ext/commands/core.py:470:24-50: Object of class `FunctionType` has no attribute `__commands_cooldown__` [missing-attribute] @@ -271,7 +267,6 @@ ERROR discord/ext/commands/hybrid.py:61:9-20: Class member `_HybridCommandDecora ERROR discord/ext/commands/hybrid.py:69:9-20: Class member `_HybridGroupKwargs.description` overrides parent class `_HybridCommandDecoratorKwargs` in an inconsistent manner [bad-override] ERROR discord/ext/commands/hybrid.py:73:9-20: Class member `_HybridGroupDecoratorKwargs.description` overrides parent class `_HybridGroupKwargs` in an inconsistent manner [bad-override] ERROR discord/ext/commands/hybrid.py:113:9-18: Class member `_CallableDefault.__class__` overrides parent class `object` in an inconsistent manner [bad-override] -ERROR discord/ext/commands/hybrid.py:156:43-45: Cannot instantiate `Converter` because it is a protocol [bad-instantiation] ERROR discord/ext/commands/hybrid.py:232:13-45: Object of class `FunctionType` has no attribute `__hybrid_command_flag__` [missing-attribute] ERROR discord/ext/commands/hybrid.py:273:63-100: Expected a type form, got instance of `ConverterTransformer` [not-a-type] ERROR discord/ext/commands/hybrid.py:328:9-39: Object of class `FunctionType` has no attribute `__signature__` [missing-attribute] @@ -313,7 +308,6 @@ ERROR discord/flags.py:1784:9-20: Class member `ArrayFlags._from_value` override ERROR discord/flags.py:1881:9-17: Class member `AutoModPresets.to_array` overrides parent class `ArrayFlags` in an inconsistent manner [bad-override] ERROR discord/gateway.py:137:48-57: Multiple values for argument `name` in function `threading.Thread.__init__` [bad-keyword-argument] ERROR discord/gateway.py:218:9-11: Class member `VoiceKeepAliveHandler.ws` overrides parent class `KeepAliveHandler` in an inconsistent manner [bad-override] -ERROR discord/gateway.py:336:92-94: Cannot instantiate `_DecompressionContext` because it is a protocol [bad-instantiation] ERROR discord/gateway.py:466:13-34: Cannot set item in `int` [unsupported-operation] ERROR discord/gateway.py:466:37-70: Cannot set item in `dict[str, bool | dict[str, str] | int | str | None]` [unsupported-operation] ERROR discord/gateway.py:470:13-37: Cannot set item in `int` [unsupported-operation] @@ -450,8 +444,6 @@ ERROR discord/player.py:233:92-100: Object of class `NoneType` has no attribute ERROR discord/player.py:233:102-117: Object of class `NoneType` has no attribute `returncode` [missing-attribute] ERROR discord/player.py:331:21-44: Argument `BufferedIOBase | str` is not assignable to parameter `object` with type `str` in function `list.append` [bad-argument-type] ERROR discord/player.py:443:21-44: Argument `BufferedIOBase | str` is not assignable to parameter `object` with type `str` in function `list.append` [bad-argument-type] -ERROR discord/player.py:591:63-100: Argument `() -> tuple[str | None, int | None] | Unknown` is not assignable to parameter `func` with type `(**tuple[*@_]) -> @_` in function `asyncio.events.AbstractEventLoop.run_in_executor` [bad-argument-type] -ERROR discord/player.py:601:67-103: Argument `() -> tuple[str | None, int | None]` is not assignable to parameter `func` with type `(**tuple[*@_]) -> @_` in function `asyncio.events.AbstractEventLoop.run_in_executor` [bad-argument-type] ERROR discord/player.py:768:24-75: No matching overload found for function `max` called with arguments: (Literal[0], float) [no-matching-overload] ERROR discord/poll.py:480:28-50: `int` is not assignable to TypedDict key `layout_type` with type `Literal[1]` [bad-typed-dict-key] ERROR discord/raw_models.py:247:73-102: Type `object` is not iterable [not-iterable] @@ -594,6 +586,8 @@ ERROR discord/ui/text_display.py:72:26-33: Cannot set item in `dict[str, int | s ERROR discord/ui/text_display.py:87:9-23: Class member `TextDisplay.from_component` overrides parent class `Item` in an inconsistent manner [bad-override] ERROR discord/ui/text_input.py:148:14-17: Class member `TextInput.row` overrides parent class `Item` in an inconsistent manner [bad-override] ERROR discord/ui/text_input.py:148:20-23: `int | None` is not assignable to attribute `row` with type `(self: Self@TextInput, value: int | None) -> None` [bad-assignment] + WARN discord/ui/text_input.py:190:6-11: `TextInput.label` is deprecated [deprecated] + WARN discord/ui/text_input.py:190:6-18: `TextInput.label` is deprecated [deprecated] ERROR discord/ui/text_input.py:249:9-26: Class member `TextInput.to_component_dict` overrides parent class `Item` in an inconsistent manner [bad-override] ERROR discord/ui/text_input.py:252:9-27: Class member `TextInput._refresh_component` overrides parent class `Item` in an inconsistent manner [bad-override] ERROR discord/ui/text_input.py:255:9-23: Class member `TextInput._refresh_state` overrides parent class `Item` in an inconsistent manner [bad-override] @@ -653,4 +647,4 @@ ERROR discord/welcome_screen.py:104:33-48: Object of class `_EmojiTag` has no at ERROR discord/welcome_screen.py:211:37-48: Cannot set item in `dict[str, list[Unknown]]` [unsupported-operation] ERROR discord/welcome_screen.py:214:33-40: Cannot set item in `dict[str, list[Unknown]]` [unsupported-operation] INFO Checking project configured at `/pyrefly.toml` - INFO 652 errors (521 suppressed) + INFO 644 errors (522 suppressed) diff --git a/scripts/ty_benchmark/snapshots/discord.py_ty.txt b/scripts/ty_benchmark/snapshots/discord.py_ty.txt index f4368ab777..6cd8f6120c 100644 --- a/scripts/ty_benchmark/snapshots/discord.py_ty.txt +++ b/scripts/ty_benchmark/snapshots/discord.py_ty.txt @@ -1,8 +1,10 @@ -discord/abc.py:1057:16: error[invalid-return-type] Return type does not match returned value: expected `Self@_clone_impl`, found `GuildChannel` discord/abc.py:2091:9: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `(Client, Connectable, /) -> T@connect` -discord/app_commands/checks.py:190:16: error[invalid-return-type] Return type does not match returned value: expected `Self@copy`, found `Cooldown` -discord/app_commands/commands.py:140:63: error[invalid-argument-type] Argument to class `Choice` is incorrect: Expected `str | int | float`, found `typing.TypeVar` -discord/app_commands/commands.py:141:55: error[invalid-argument-type] Argument to class `Choice` is incorrect: Expected `str | int | float`, found `typing.TypeVar` +discord/activity.py:286:9: error[invalid-method-override] Invalid override of method `to_dict`: Definition is incompatible with `BaseActivity.to_dict` +discord/activity.py:455:9: error[invalid-method-override] Invalid override of method `to_dict`: Definition is incompatible with `BaseActivity.to_dict` +discord/activity.py:566:9: error[invalid-method-override] Invalid override of method `to_dict`: Definition is incompatible with `BaseActivity.to_dict` +discord/activity.py:822:9: error[invalid-method-override] Invalid override of method `to_dict`: Definition is incompatible with `BaseActivity.to_dict` +discord/app_commands/commands.py:140:70: error[invalid-type-arguments] Type `typing.TypeVar` does not satisfy constraints `str`, `int`, `int | float`, `str | int | float` of type variable `ChoiceT@Choice` +discord/app_commands/commands.py:141:62: error[invalid-type-arguments] Type `typing.TypeVar` does not satisfy constraints `str`, `int`, `int | float`, `str | int | float` of type variable `ChoiceT@Choice` discord/app_commands/commands.py:372:37: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__qualname__` discord/app_commands/commands.py:381:102: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__qualname__` discord/app_commands/commands.py:393:29: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__discord_app_commands_param_description__` @@ -13,7 +15,6 @@ discord/app_commands/commands.py:432:38: error[unresolved-attribute] Object of t discord/app_commands/commands.py:444:58: error[unresolved-attribute] Object of type `((Interaction[Any], Member, /) -> @Todo) | ((Interaction[Any], User, /) -> @Todo) | ((Interaction[Any], Message, /) -> @Todo)` has no attribute `__qualname__` discord/app_commands/commands.py:450:57: error[unresolved-attribute] Object of type `((Interaction[Any], Member, /) -> @Todo) | ((Interaction[Any], User, /) -> @Todo) | ((Interaction[Any], Message, /) -> @Todo)` has no attribute `__globals__` discord/app_commands/commands.py:450:75: error[unresolved-attribute] Object of type `((Interaction[Any], Member, /) -> @Todo) | ((Interaction[Any], User, /) -> @Todo) | ((Interaction[Any], Message, /) -> @Todo)` has no attribute `__globals__` -discord/app_commands/commands.py:456:5: error[unresolved-attribute] Unresolved attribute `__discord_app_commands_base_function__` on type `F@mark_overrideable`. discord/app_commands/commands.py:807:19: error[missing-argument] No argument provided for required parameter `error` of function `on_error` discord/app_commands/commands.py:807:35: error[invalid-argument-type] Argument to function `on_error` is incorrect: Expected `Group`, found `Interaction[Client]` discord/app_commands/commands.py:807:48: error[invalid-argument-type] Argument to function `on_error` is incorrect: Expected `Interaction[Client]`, found `AppCommandError` @@ -30,7 +31,7 @@ discord/app_commands/transformers.py:110:67: error[invalid-argument-type] Argume discord/app_commands/transformers.py:115:67: error[invalid-argument-type] Argument to bound method `_checked_translate` is incorrect: Expected `locale_str`, found `str | locale_str` discord/app_commands/transformers.py:238:22: error[invalid-type-form] Variable of type `Self@__or__` is not allowed in a type expression discord/app_commands/transformers.py:584:13: error[invalid-assignment] Not enough values to unpack: Expected 3 -discord/app_commands/tree.py:76:10: error[invalid-argument-type] Argument to class `Interaction` is incorrect: Expected `Client`, found `typing.TypeVar` +discord/app_commands/tree.py:76:22: error[invalid-type-arguments] Type `typing.TypeVar` is not assignable to upper bound `Client` of type variable `ClientT@Interaction` discord/app_commands/tree.py:1011:27: error[unresolved-attribute] Object of type `((Interaction[Any], Member, /) -> @Todo) | ((Interaction[Any], User, /) -> @Todo) | ((Interaction[Any], Message, /) -> @Todo)` has no attribute `__name__` discord/app_commands/tree.py:1133:19: error[missing-argument] No argument provided for required parameter `error` of function `on_error` discord/app_commands/tree.py:1133:33: error[invalid-argument-type] Argument to function `on_error` is incorrect: Argument type `Interaction[ClientT@CommandTree]` does not satisfy upper bound `CommandTree[ClientT@CommandTree]` of type variable `Self` @@ -44,11 +45,8 @@ discord/app_commands/tree.py:1280:9: error[unresolved-attribute] Unresolved attr discord/app_commands/tree.py:1301:19: error[missing-argument] No argument provided for required parameter `error` of function `on_error` discord/app_commands/tree.py:1301:33: error[invalid-argument-type] Argument to function `on_error` is incorrect: Argument type `Interaction[ClientT@CommandTree]` does not satisfy upper bound `CommandTree[ClientT@CommandTree]` of type variable `Self` discord/app_commands/tree.py:1301:46: error[invalid-argument-type] Argument to function `on_error` is incorrect: Expected `Interaction[ClientT@CommandTree]`, found `AppCommandError` -discord/asset.py:462:16: error[invalid-return-type] Return type does not match returned value: expected `Self@replace`, found `Asset` discord/asset.py:462:31: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ConnectionState[Client] | _WebhookState`, found `Any | None | ConnectionState[Client] | _WebhookState` -discord/asset.py:490:16: error[invalid-return-type] Return type does not match returned value: expected `Self@with_size`, found `Asset` discord/asset.py:490:31: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ConnectionState[Client] | _WebhookState`, found `Any | None | ConnectionState[Client] | _WebhookState` -discord/asset.py:525:16: error[invalid-return-type] Return type does not match returned value: expected `Self@with_format`, found `Asset` discord/asset.py:525:31: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ConnectionState[Client] | _WebhookState`, found `Any | None | ConnectionState[Client] | _WebhookState` discord/audit_logs.py:550:56: error[invalid-argument-type] Argument to bound method `from_data` is incorrect: Expected `int`, found `None | Unknown | int` discord/audit_logs.py:551:55: error[invalid-argument-type] Argument to bound method `from_data` is incorrect: Expected `int`, found `None | Unknown | int` @@ -57,8 +55,13 @@ discord/automod.py:164:49: error[invalid-key] Unknown key "duration_seconds" for discord/automod.py:165:52: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `int | float`, found `str | int` discord/automod.py:167:47: error[invalid-key] Unknown key "channel_id" for TypedDict `_AutoModerationActionMetadataCustomMessage`: Unknown key "channel_id" discord/automod.py:167:47: error[invalid-key] Unknown key "channel_id" for TypedDict `_AutoModerationActionMetadataTimeout`: Unknown key "channel_id" -discord/automod.py:538:16: error[invalid-return-type] Return type does not match returned value: expected `Self@edit`, found `AutoModRule` discord/backoff.py:63:42: error[invalid-parameter-default] Default value of type `Literal[False]` is not assignable to annotated parameter type `T@ExponentialBackoff` +discord/channel.py:374:9: error[invalid-method-override] Invalid override of method `_update`: Definition is incompatible with `GuildChannel._update` +discord/channel.py:1098:15: error[invalid-method-override] Invalid override of method `_get_channel`: Definition is incompatible with `Messageable._get_channel` +discord/channel.py:1107:9: error[invalid-method-override] Invalid override of method `_update`: Definition is incompatible with `GuildChannel._update` +discord/channel.py:1770:9: error[invalid-method-override] Invalid override of method `_update`: Definition is incompatible with `VocalGuildChannel._update` +discord/channel.py:2065:9: error[invalid-method-override] Invalid override of method `_update`: Definition is incompatible with `GuildChannel._update` +discord/channel.py:2478:9: error[invalid-method-override] Invalid override of method `_update`: Definition is incompatible with `GuildChannel._update` discord/channel.py:3234:40: error[missing-argument] No argument provided for required parameter `data` of function `store_user` discord/channel.py:3234:57: error[invalid-argument-type] Argument to function `store_user` is incorrect: Argument type `PartialUser` does not satisfy upper bound `ConnectionState[ClientT@ConnectionState]` of type variable `Self` discord/channel.py:3409:40: error[missing-argument] No argument provided for required parameter `data` of function `store_user` @@ -69,8 +72,6 @@ discord/client.py:723:59: error[invalid-argument-type] Argument to bound method discord/client.py:723:59: error[invalid-argument-type] Argument to bound method `from_client` is incorrect: Expected `bool`, found `Unknown | int | None` discord/client.py:723:59: error[invalid-argument-type] Argument to bound method `from_client` is incorrect: Expected `str`, found `Unknown | int | None` discord/client.py:723:59: error[invalid-argument-type] Argument to bound method `from_client` is incorrect: Expected `bool`, found `Unknown | int | None` -discord/client.py:2058:23: error[unresolved-attribute] Object of type `CoroT@event` has no attribute `__name__` -discord/client.py:2059:71: error[unresolved-attribute] Object of type `CoroT@event` has no attribute `__name__` discord/components.py:86:9: error[invalid-type-form] Variable of type `Literal["TextDisplay"]` is not allowed in a type expression discord/components.py:787:29: error[invalid-type-form] Variable of type `Literal["TextDisplay"]` is not allowed in a type expression discord/components.py:1326:27: error[invalid-argument-type] Invalid argument to key "components" with declared type `list[ActionRow | TextComponent | MediaGalleryComponent | ... omitted 5 union elements]` on TypedDict `ContainerComponent`: value of type `list[ButtonComponent | SelectMenu | TextInput | ... omitted 11 union elements]` @@ -86,6 +87,7 @@ discord/components.py:1476:35: error[invalid-argument-type] Argument to bound me discord/components.py:1478:26: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ContainerComponent`, found `ButtonComponent | SelectMenu | TextInput | ... omitted 10 union elements` discord/components.py:1480:31: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `LabelComponent`, found `ButtonComponent | SelectMenu | TextInput | ... omitted 10 union elements` discord/components.py:1482:36: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `FileUploadComponent`, found `ButtonComponent | SelectMenu | TextInput | ... omitted 10 union elements` +discord/embeds.py:308:9: error[invalid-method-override] Invalid override of method `__eq__`: Definition is incompatible with `object.__eq__` discord/emoji.py:131:42: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ConnectionState[Client]`, found `Any | None | ConnectionState[Client]` discord/emoji.py:186:16: warning[possibly-missing-attribute] Attribute `_get_guild` may be missing on object of type `Any | None | ConnectionState[Client]` discord/emoji.py:225:30: warning[possibly-missing-attribute] Attribute `application_id` may be missing on object of type `Any | None | ConnectionState[Client]` @@ -101,18 +103,15 @@ discord/ext/commands/bot.py:177:9: error[invalid-parameter-default] Default valu discord/ext/commands/bot.py:655:16: error[unresolved-attribute] Object of type `(...) -> @Todo` has no attribute `__name__` discord/ext/commands/bot.py:681:16: error[unresolved-attribute] Object of type `(...) -> @Todo` has no attribute `__name__` discord/ext/commands/bot.py:1546:13: error[invalid-parameter-default] Default value of type `_DefaultRepr` is not assignable to annotated parameter type `HelpCommand | None` -discord/ext/commands/cog.py:268:5: error[unresolved-attribute] Unresolved attribute `__cog_special_method__` on type `FuncT@_cog_special_method`. -discord/ext/commands/cog.py:288:28: error[invalid-argument-type] Argument to class `Command` is incorrect: Expected `Cog | None`, found `typing.Self` -discord/ext/commands/cog.py:289:58: error[invalid-argument-type] Argument to class `Command` is incorrect: Expected `Group | Cog`, found `typing.Self` -discord/ext/commands/cog.py:497:24: error[unresolved-attribute] Object of type `FuncT@_get_overridden_method` has no attribute `__func__` -discord/ext/commands/cog.py:527:13: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `__cog_listener__` on type `(FuncT@listener & ~staticmethod[object, object]) | ((...) -> object)` -discord/ext/commands/cog.py:528:33: error[unresolved-attribute] Object of type `(FuncT@listener & ~staticmethod[object, object]) | ((...) -> object)` has no attribute `__name__` -discord/ext/commands/cog.py:530:17: error[unresolved-attribute] Object of type `(FuncT@listener & ~staticmethod[object, object]) | ((...) -> object)` has no attribute `__cog_listener_names__` -discord/ext/commands/cog.py:532:17: error[invalid-assignment] Object of type `list[Unknown | (str & ~AlwaysFalsy)]` is not assignable to attribute `__cog_listener_names__` on type `(FuncT@listener & ~staticmethod[object, object]) | ((...) -> object)` +discord/ext/commands/cog.py:288:36: error[invalid-type-arguments] Type `typing.Self` is not assignable to upper bound `Cog | None` of type variable `CogT@Command` +discord/ext/commands/cog.py:289:79: error[invalid-type-arguments] Type `typing.Self` is not assignable to upper bound `Group | Cog` of type variable `GroupT@Command` +discord/ext/commands/context.py:411:15: error[invalid-method-override] Invalid override of method `_get_channel`: Definition is incompatible with `Messageable._get_channel` +discord/ext/commands/context.py:783:9: error[invalid-method-override] Invalid override of method `typing`: Definition is incompatible with `Messageable.typing` discord/ext/commands/converter.py:402:39: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `TextChannel | VoiceChannel | StageChannel | ... omitted 4 union elements`, found `(VoiceChannel & ~AlwaysFalsy) | (StageChannel & ~AlwaysFalsy) | (ForumChannel & Messageable & ~AlwaysFalsy) | ... omitted 5 union elements` +discord/ext/commands/converter.py:1119:9: error[invalid-method-override] Invalid override of method `__class_getitem__`: Definition is incompatible with `list.__class_getitem__` discord/ext/commands/converter.py:1211:89: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Parameter | None` discord/ext/commands/converter.py:1241:13: error[invalid-assignment] Not enough values to unpack: Expected 3 -discord/ext/commands/cooldowns.py:251:16: error[invalid-return-type] Return type does not match returned value: expected `Self@copy`, found `MaxConcurrency` +discord/ext/commands/cooldowns.py:171:9: error[invalid-method-override] Invalid override of method `create_bucket`: Definition is incompatible with `CooldownMapping.create_bucket` discord/ext/commands/core.py:141:24: error[invalid-assignment] Object of type `object` is not assignable to `(...) -> Any` discord/ext/commands/core.py:433:38: error[unresolved-attribute] Object of type `(...) -> @Todo` has no attribute `__name__` discord/ext/commands/core.py:462:22: error[unresolved-attribute] Object of type `(...) -> @Todo` has no attribute `__commands_checks__` @@ -121,14 +120,6 @@ discord/ext/commands/core.py:483:31: error[unresolved-attribute] Object of type discord/ext/commands/core.py:500:29: error[unresolved-attribute] Object of type `(...) -> @Todo` has no attribute `__before_invoke__` discord/ext/commands/core.py:508:28: error[unresolved-attribute] Object of type `(...) -> @Todo` has no attribute `__after_invoke__` discord/ext/commands/core.py:544:24: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__globals__` -discord/ext/commands/core.py:653:16: error[invalid-return-type] Return type does not match returned value: expected `Self@copy`, found `Command[CogT@Command, P@Command, T@Command]` -discord/ext/commands/core.py:660:20: error[invalid-return-type] Return type does not match returned value: expected `Self@_update_copy`, found `Command[CogT@Command, P@Command, T@Command]` -discord/ext/commands/core.py:680:52: warning[possibly-missing-attribute] Attribute `cog_command_error` may be missing on object of type `CogT@Command & ~None` -discord/ext/commands/core.py:919:47: warning[possibly-missing-attribute] Attribute `cog_before_invoke` may be missing on object of type `CogT@Command & ~None` -discord/ext/commands/core.py:921:23: error[invalid-argument-type] Argument to bound method `cog_before_invoke` is incorrect: Expected `Cog`, found `CogT@Command` -discord/ext/commands/core.py:939:47: warning[possibly-missing-attribute] Attribute `cog_after_invoke` may be missing on object of type `CogT@Command & ~None` -discord/ext/commands/core.py:941:23: error[invalid-argument-type] Argument to bound method `cog_after_invoke` is incorrect: Expected `Cog`, found `CogT@Command` -discord/ext/commands/core.py:1312:58: warning[possibly-missing-attribute] Attribute `cog_check` may be missing on object of type `CogT@Command & ~None` discord/ext/commands/core.py:1552:22: error[no-matching-overload] No overload of function `command` matches arguments discord/ext/commands/core.py:1609:22: error[no-matching-overload] No overload of function `group` matches arguments discord/ext/commands/core.py:1942:17: error[invalid-assignment] Object of type `list[Unknown]` is not assignable to attribute `__commands_checks__` on type `((...) -> @Todo) & ~Top[Command[Unknown, object, Unknown]] & ~` @@ -152,18 +143,23 @@ discord/ext/commands/core.py:2547:13: error[invalid-assignment] Object of type ` discord/ext/commands/core.py:2582:13: error[invalid-assignment] Object of type `MaxConcurrency` is not assignable to attribute `__commands_max_concurrency__` on type `((...) -> @Todo) & ~Top[Command[Unknown, object, Unknown]]` discord/ext/commands/core.py:2634:13: error[invalid-assignment] Object of type `@Todo` is not assignable to attribute `__before_invoke__` on type `((...) -> @Todo) & ~Top[Command[Unknown, object, Unknown]]` discord/ext/commands/core.py:2657:13: error[invalid-assignment] Object of type `@Todo` is not assignable to attribute `__after_invoke__` on type `((...) -> @Todo) & ~Top[Command[Unknown, object, Unknown]]` -discord/ext/commands/help.py:248:5: error[unresolved-attribute] Unresolved attribute `__help_command_not_overridden__` on type `FuncT@_not_overridden`. discord/ext/commands/help.py:309:9: error[invalid-assignment] Implicit shadowing of function `get_commands` discord/ext/commands/help.py:310:9: error[invalid-assignment] Implicit shadowing of function `walk_commands` -discord/ext/commands/help.py:407:16: error[invalid-return-type] Return type does not match returned value: expected `Self@copy`, found `HelpCommand` +discord/ext/commands/help.py:1255:9: error[invalid-method-override] Invalid override of method `get_destination`: Definition is incompatible with `HelpCommand.get_destination` +discord/ext/commands/help.py:1264:15: error[invalid-method-override] Invalid override of method `prepare_help_command`: Definition is incompatible with `HelpCommand.prepare_help_command` +discord/ext/commands/help.py:1520:9: error[invalid-method-override] Invalid override of method `get_destination`: Definition is incompatible with `HelpCommand.get_destination` +discord/ext/commands/help.py:1529:15: error[invalid-method-override] Invalid override of method `prepare_help_command`: Definition is incompatible with `HelpCommand.prepare_help_command` discord/ext/commands/hybrid.py:176:49: error[unresolved-attribute] Object of type `(str, /) -> Any` has no attribute `__name__` discord/ext/commands/hybrid.py:232:13: error[unresolved-attribute] Unresolved attribute `__hybrid_command_flag__` on type `(...) -> Any`. discord/ext/commands/hybrid.py:328:9: error[unresolved-attribute] Unresolved attribute `__signature__` on type `(...) -> @Todo`. discord/ext/commands/hybrid.py:338:17: error[unresolved-attribute] Object of type `(...) -> @Todo` has no attribute `__signature__` +discord/ext/commands/hybrid.py:563:9: error[invalid-method-override] Invalid override of method `_ensure_assignment_on_copy`: Definition is incompatible with `Command._ensure_assignment_on_copy` +discord/ext/commands/hybrid.py:731:9: error[invalid-method-override] Invalid override of method `_ensure_assignment_on_copy`: Definition is incompatible with `Command._ensure_assignment_on_copy` +discord/ext/commands/hybrid.py:790:9: error[invalid-method-override] Invalid override of method `add_command`: Definition is incompatible with `GroupMixin.add_command` discord/ext/commands/parameters.py:98:9: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `str` discord/ext/commands/parameters.py:99:9: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `str` discord/ext/commands/parameters.py:100:9: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `str` -discord/ext/commands/parameters.py:151:16: error[invalid-return-type] Return type does not match returned value: expected `Self@replace`, found `Parameter` +discord/ext/commands/parameters.py:115:9: error[invalid-method-override] Invalid override of method `replace`: Definition is incompatible with `inspect.Parameter.replace` discord/ext/commands/parameters.py:219:5: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `str` discord/ext/commands/parameters.py:220:5: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `str` discord/ext/commands/parameters.py:221:5: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `str` @@ -172,14 +168,11 @@ discord/ext/commands/parameters.py:279:9: error[invalid-parameter-default] Defau discord/ext/commands/parameters.py:280:9: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `str` discord/ext/commands/view.py:151:53: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | str | None` discord/ext/commands/view.py:162:57: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | str | None` -discord/ext/tasks/__init__.py:174:49: error[unresolved-attribute] Object of type `LF@Loop` has no attribute `__qualname__` -discord/ext/tasks/__init__.py:237:29: error[unresolved-attribute] Object of type `LF@Loop` has no attribute `__qualname__` -discord/ext/tasks/__init__.py:256:25: error[unresolved-attribute] Object of type `LF@Loop` has no attribute `__qualname__` discord/ext/tasks/__init__.py:304:9: error[invalid-assignment] Implicit shadowing of function `_error` -discord/ext/tasks/__init__.py:305:22: error[unresolved-attribute] Object of type `LF@Loop` has no attribute `__name__` -discord/ext/tasks/__init__.py:552:75: error[unresolved-attribute] Object of type `LF@Loop` has no attribute `__name__` discord/file.py:106:9: error[invalid-assignment] Implicit shadowing of function `close` discord/file.py:160:9: error[invalid-assignment] Implicit shadowing of function `close` +discord/flags.py:1784:9: error[invalid-method-override] Invalid override of method `_from_value`: Definition is incompatible with `BaseFlags._from_value` +discord/flags.py:1881:9: error[invalid-method-override] Invalid override of method `to_array`: Definition is incompatible with `ArrayFlags.to_array` discord/gateway.py:137:48: error[parameter-already-assigned] Multiple values provided for parameter `name` of bound method `__init__` discord/gateway.py:466:13: error[invalid-assignment] Cannot assign to a subscript on an object of type `int` discord/gateway.py:470:13: error[invalid-assignment] Cannot assign to a subscript on an object of type `int` @@ -210,12 +203,15 @@ discord/http.py:566:53: error[invalid-argument-type] Argument to bound method `w discord/http.py:566:53: error[invalid-argument-type] Argument to bound method `ws_connect` is incorrect: Expected `int`, found `Unknown | BasicAuth | None | ... omitted 4 union elements` discord/http.py:566:53: error[invalid-argument-type] Argument to bound method `ws_connect` is incorrect: Expected `int`, found `Unknown | BasicAuth | None | ... omitted 4 union elements` discord/http.py:640:20: error[invalid-context-manager] Object of type `Ratelimit` cannot be used with `async with` because it does not correctly implement `__aexit__` +discord/integrations.py:200:9: error[invalid-method-override] Invalid override of method `_from_data`: Definition is incompatible with `Integration._from_data` +discord/integrations.py:359:9: error[invalid-method-override] Invalid override of method `_from_data`: Definition is incompatible with `Integration._from_data` discord/interactions.py:229:58: error[invalid-argument-type] Argument to bound method `_from_value` is incorrect: Expected `Sequence[Literal[0, 1, 2]]`, found `list[Unknown | int]` discord/interactions.py:250:13: error[invalid-assignment] Object of type `(Guild & ~AlwaysTruthy) | VoiceChannel | StageChannel | ... omitted 5 union elements` is not assignable to attribute `channel` of type `VoiceChannel | StageChannel | TextChannel | ... omitted 6 union elements` discord/interactions.py:256:92: error[invalid-argument-type] Argument to bound method `format_map` is incorrect: Expected `_FormatMapMapping`, found `TextChannel | NewsChannel | VoiceChannel | ... omitted 7 union elements` discord/interactions.py:307:16: error[invalid-return-type] Return type does not match returned value: expected `Guild | None`, found `(ConnectionState[ClientT@Interaction] & ~AlwaysTruthy & ~AlwaysFalsy) | (Guild & ~AlwaysFalsy) | Any | None` discord/interactions.py:744:21: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ConnectionState[Client]`, found `_InteractionMessageState` discord/interactions.py:1401:16: error[missing-argument] No argument provided for required parameter `data` of function `store_user` +discord/interactions.py:1453:15: error[invalid-method-override] Invalid override of method `edit`: Definition is incompatible with `Message.edit` discord/member.py:319:28: error[missing-argument] No argument provided for required parameter `data` of function `store_user` discord/member.py:319:45: error[invalid-argument-type] Argument to function `store_user` is incorrect: Argument type `User` does not satisfy upper bound `ConnectionState[ClientT@ConnectionState]` of type variable `Self` discord/member.py:980:91: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc) @@ -232,13 +228,13 @@ discord/message.py:2481:30: error[missing-argument] No argument provided for req discord/message.py:2481:47: error[invalid-argument-type] Argument to function `store_user` is incorrect: Argument type `UserWithMember` does not satisfy upper bound `ConnectionState[ClientT@ConnectionState]` of type variable `Self` discord/opus.py:141:48: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__` discord/opus.py:149:48: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__` -discord/poll.py:592:16: error[invalid-return-type] Return type does not match returned value: expected `Self@copy`, found `Poll` discord/presences.py:60:16: error[invalid-assignment] Object of type `(ClientStatus & ~AlwaysFalsy) | dict[Unknown, Unknown]` is not assignable to `ClientStatus` discord/role.py:450:45: error[invalid-assignment] Object of type `list[dict[Unknown | str, Unknown] | Unknown]` is not assignable to `list[RolePositionUpdate]` discord/role.py:700:45: error[invalid-assignment] Object of type `list[dict[Unknown | str, Unknown | int] | Unknown]` is not assignable to `list[RolePositionUpdate]` discord/scheduled_event.py:150:40: error[missing-argument] No argument provided for required parameter `data` of function `store_user` discord/scheduled_event.py:150:63: error[invalid-argument-type] Argument to function `store_user` is incorrect: Argument type `User & ~AlwaysFalsy` does not satisfy upper bound `ConnectionState[ClientT@ConnectionState]` of type variable `Self` discord/scheduled_event.py:663:22: error[missing-argument] No argument provided for required parameter `data` of function `store_user` +discord/soundboard.py:208:9: error[invalid-method-override] Invalid override of method `_update`: Definition is incompatible with `BaseSoundboardSound._update` discord/soundboard.py:232:20: warning[possibly-missing-attribute] Attribute `get_user` may be missing on object of type `Any | None | ConnectionState[Client]` discord/soundboard.py:233:21: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ConnectionState[Client]`, found `Any | None | ConnectionState[Client]` discord/soundboard.py:301:22: warning[possibly-missing-attribute] Attribute `http` may be missing on object of type `Any | None | ConnectionState[Client]` @@ -270,8 +266,10 @@ discord/state.py:1388:20: error[missing-argument] No argument provided for requi discord/state.py:1388:36: error[invalid-argument-type] Argument to function `store_user` is incorrect: Argument type `User` does not satisfy upper bound `ConnectionState[ClientT@ConnectionState]` of type variable `Self` discord/sticker.py:230:38: warning[possibly-missing-attribute] Attribute `http` may be missing on object of type `Any | None | ConnectionState[Client]` discord/sticker.py:232:20: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ConnectionState[Client]`, found `Any | None | ConnectionState[Client]` +discord/sticker.py:335:9: error[invalid-method-override] Invalid override of method `_from_data`: Definition is incompatible with `Sticker._from_data` discord/sticker.py:369:22: warning[possibly-missing-attribute] Attribute `http` may be missing on object of type `Any | None | ConnectionState[Client]` discord/sticker.py:370:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ConnectionState[Client]`, found `Any | None | ConnectionState[Client]` +discord/sticker.py:415:9: error[invalid-method-override] Invalid override of method `_from_data`: Definition is incompatible with `Sticker._from_data` discord/sticker.py:420:37: error[missing-argument] No argument provided for required parameter `data` of function `store_user` discord/sticker.py:420:37: warning[possibly-missing-attribute] Attribute `store_user` may be missing on object of type `Any | None | ConnectionState[Client]` discord/sticker.py:420:60: error[invalid-argument-type] Argument to function `store_user` is incorrect: Argument type `User & ~AlwaysFalsy` does not satisfy upper bound `ConnectionState[ClientT@ConnectionState]` of type variable `Self` @@ -279,10 +277,55 @@ discord/sticker.py:434:16: warning[possibly-missing-attribute] Attribute `_get_g discord/sticker.py:489:43: warning[possibly-missing-attribute] Attribute `http` may be missing on object of type `Any | None | ConnectionState[Client]` discord/sticker.py:490:29: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ConnectionState[Client]`, found `Any | None | ConnectionState[Client]` discord/sticker.py:511:15: warning[possibly-missing-attribute] Attribute `http` may be missing on object of type `Any | None | ConnectionState[Client]` -discord/ui/modal.py:109:50: error[invalid-argument-type] Argument to class `Item` is incorrect: Expected `BaseView`, found `typing.Self` +discord/ui/action_row.py:415:9: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `type[SelectT@select]` +discord/ui/action_row.py:430:9: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `type[UserSelectT@select]` +discord/ui/action_row.py:446:9: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `type[RoleSelectT@select]` +discord/ui/action_row.py:462:9: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `type[ChannelSelectT@select]` +discord/ui/action_row.py:478:9: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `type[MentionableSelectT@select]` +discord/ui/action_row.py:493:9: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `type[BaseSelectT@select]` +discord/ui/action_row.py:597:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` +discord/ui/button.py:259:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` +discord/ui/button.py:276:9: error[invalid-method-override] Invalid override of method `to_component_dict`: Definition is incompatible with `Item.to_component_dict` +discord/ui/button.py:287:9: error[invalid-method-override] Invalid override of method `_refresh_component`: Definition is incompatible with `Item._refresh_component` +discord/ui/container.py:179:9: error[invalid-method-override] Invalid override of method `_update_view`: Definition is incompatible with `Item._update_view` +discord/ui/container.py:260:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` +discord/ui/file.py:162:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` +discord/ui/file_upload.py:172:9: error[invalid-method-override] Invalid override of method `to_component_dict`: Definition is incompatible with `Item.to_component_dict` +discord/ui/file_upload.py:175:9: error[invalid-method-override] Invalid override of method `_refresh_component`: Definition is incompatible with `Item._refresh_component` +discord/ui/file_upload.py:178:9: error[invalid-method-override] Invalid override of method `_handle_submit`: Definition is incompatible with `Item._handle_submit` +discord/ui/file_upload.py:184:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` +discord/ui/label.py:112:9: error[invalid-method-override] Invalid override of method `to_component_dict`: Definition is incompatible with `Item.to_component_dict` +discord/ui/label.py:125:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` +discord/ui/media_gallery.py:259:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` +discord/ui/modal.py:109:55: error[invalid-type-arguments] Type `typing.Self` is not assignable to upper bound `BaseView` of type variable `V@Item` +discord/ui/modal.py:159:15: error[invalid-method-override] Invalid override of method `on_error`: Definition is incompatible with `BaseView.on_error` +discord/ui/modal.py:176:9: error[invalid-method-override] Invalid override of method `_refresh`: Definition is incompatible with `BaseView._refresh` +discord/ui/modal.py:202:15: error[invalid-method-override] Invalid override of method `_scheduled_task`: Definition is incompatible with `BaseView._scheduled_task` discord/ui/modal.py:273:16: error[invalid-return-type] Return type does not match returned value: expected `Self@add_item`, found `Modal` discord/ui/section.py:192:31: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `Item[V@Section]`, found `(str & Item[object]) | Item[Any]` +discord/ui/section.py:251:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` +discord/ui/select.py:363:9: error[invalid-method-override] Invalid override of method `to_component_dict`: Definition is incompatible with `Item.to_component_dict` +discord/ui/select.py:366:9: error[invalid-method-override] Invalid override of method `_refresh_component`: Definition is incompatible with `Item._refresh_component` +discord/ui/select.py:369:9: error[invalid-method-override] Invalid override of method `_handle_submit`: Definition is incompatible with `Item._handle_submit` +discord/ui/select.py:382:9: error[invalid-method-override] Invalid override of method `_refresh_state`: Definition is incompatible with `Item._refresh_state` +discord/ui/select.py:405:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` +discord/ui/select.py:1030:5: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `type[SelectT@select]` +discord/ui/select.py:1046:5: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `type[UserSelectT@select]` +discord/ui/select.py:1063:5: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `type[RoleSelectT@select]` +discord/ui/select.py:1080:5: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `type[ChannelSelectT@select]` +discord/ui/select.py:1097:5: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `type[MentionableSelectT@select]` +discord/ui/select.py:1113:5: error[invalid-parameter-default] Default value of type `` is not assignable to annotated parameter type `type[BaseSelectT@select]` +discord/ui/separator.py:129:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` +discord/ui/text_display.py:87:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` +discord/ui/text_input.py:249:9: error[invalid-method-override] Invalid override of method `to_component_dict`: Definition is incompatible with `Item.to_component_dict` +discord/ui/text_input.py:252:9: error[invalid-method-override] Invalid override of method `_refresh_component`: Definition is incompatible with `Item._refresh_component` +discord/ui/text_input.py:255:9: error[invalid-method-override] Invalid override of method `_refresh_state`: Definition is incompatible with `Item._refresh_state` +discord/ui/text_input.py:259:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` +discord/ui/thumbnail.py:138:9: error[invalid-method-override] Invalid override of method `from_component`: Definition is incompatible with `Item.from_component` discord/ui/view.py:324:16: error[invalid-return-type] Return type does not match returned value: expected `list[Item[Self@children]]`, found `list[Item[Self@__init__]]` +discord/user.py:428:9: error[invalid-method-override] Invalid override of method `_update`: Definition is incompatible with `BaseUser._update` +discord/utils.py:257:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `Sequence.__getitem__` +discord/utils.py:263:9: error[invalid-method-override] Invalid override of method `__contains__`: Definition is incompatible with `Sequence.__contains__` discord/utils.py:328:5: error[invalid-parameter-default] Default value of type `_MissingSentinel` is not assignable to annotated parameter type `Permissions` discord/utils.py:329:5: error[invalid-parameter-default] Default value of type `_MissingSentinel` is not assignable to annotated parameter type `Snowflake` discord/utils.py:330:5: error[invalid-parameter-default] Default value of type `_MissingSentinel` is not assignable to annotated parameter type `str` @@ -297,10 +340,14 @@ discord/utils.py:1349:5: error[invalid-parameter-default] Default value of type discord/utils.py:1350:5: error[invalid-parameter-default] Default value of type `_MissingSentinel` is not assignable to annotated parameter type `int` discord/webhook/async_.py:751:20: error[missing-argument] No argument provided for required parameter `data` of function `store_user` discord/webhook/async_.py:751:44: error[invalid-argument-type] Argument to function `store_user` is incorrect: Argument type `User | PartialUser` does not satisfy upper bound `ConnectionState[ClientT@ConnectionState]` of type variable `Self` +discord/webhook/async_.py:805:15: error[invalid-method-override] Invalid override of method `edit`: Definition is incompatible with `Message.edit` discord/webhook/async_.py:1042:16: error[invalid-return-type] Return type does not match returned value: expected `Guild | None`, found `(ConnectionState[Client] & ~AlwaysTruthy) | (_WebhookState & ~AlwaysTruthy) | Guild | None` discord/webhook/sync.py:81:14: error[unresolved-import] Cannot resolve imported module `requests` +discord/webhook/sync.py:410:9: error[invalid-method-override] Invalid override of method `edit`: Definition is incompatible with `Message.edit` +discord/webhook/sync.py:474:9: error[invalid-method-override] Invalid override of method `add_files`: Definition is incompatible with `Message.add_files` +discord/webhook/sync.py:498:9: error[invalid-method-override] Invalid override of method `remove_attachments`: Definition is incompatible with `Message.remove_attachments` +discord/webhook/sync.py:522:9: error[invalid-method-override] Invalid override of method `delete`: Definition is incompatible with `PartialMessage.delete` discord/webhook/sync.py:652:16: error[unresolved-import] Cannot resolve imported module `requests` discord/webhook/sync.py:695:16: error[unresolved-import] Cannot resolve imported module `requests` discord/welcome_screen.py:104:33: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `(Unknown & _EmojiTag) | PartialEmoji | Emoji | (str & _EmojiTag)` -discord/welcome_screen.py:217:16: error[invalid-return-type] Return type does not match returned value: expected `Self@edit`, found `WelcomeScreen` -Found 305 diagnostics +Found 352 diagnostics diff --git a/scripts/ty_benchmark/snapshots/homeassistant_Pyrefly.txt b/scripts/ty_benchmark/snapshots/homeassistant_Pyrefly.txt index 2024915c8b..9aaf79d318 100644 --- a/scripts/ty_benchmark/snapshots/homeassistant_Pyrefly.txt +++ b/scripts/ty_benchmark/snapshots/homeassistant_Pyrefly.txt @@ -3,9 +3,6 @@ ERROR homeassistant/auth/__init__.py:566:13-37: Argument `HassJob[[_: datetime | ERROR homeassistant/auth/auth_store.py:487:28-38: `token_type` may be uninitialized [unbound-name] ERROR homeassistant/auth/jwt_wrapper.py:36:9-14: Class member `_PyJWSWithLoadCache._load` overrides parent class `PyJWS` in an inconsistent manner [bad-override] ERROR homeassistant/auth/mfa_modules/notify.py:127:41-45: `data` may be uninitialized [unbound-name] -ERROR homeassistant/auth/mfa_modules/notify.py:238:13-50: Argument `() -> str` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/auth/mfa_modules/notify.py:298:62-78: Argument `() -> str` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/auth/mfa_modules/notify.py:299:61-77: Argument `() -> int` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/auth/mfa_modules/totp.py:105:27-31: `data` may be uninitialized [unbound-name] ERROR homeassistant/auth/mfa_modules/totp.py:207:62-209:14: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[str, datetime | None, int]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/auth/permissions/__init__.py:47:16-27: `entity_func` may be uninitialized [unbound-name] @@ -16,9 +13,7 @@ ERROR homeassistant/auth/providers/homeassistant.py:110:56-60: `data` may be uni ERROR homeassistant/auth/providers/homeassistant.py:111:22-26: `data` may be uninitialized [unbound-name] ERROR homeassistant/bootstrap.py:380:8-21: `recovery_mode` may be uninitialized [unbound-name] ERROR homeassistant/bootstrap.py:443:25-459:6: No matching overload found for function `asyncio.tasks.gather` called with arguments: (Task[None], Task[None], Task[None], Task[None], Task[None], Task[None], Task[None], Task[None], Future[None], Task[None], Task[None], Task[None], Task[dict[str, Any]], Task[None], Task[None]) [no-matching-overload] -ERROR homeassistant/bootstrap.py:452:37-74: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/bootstrap.py:518:9-519:60: String literal used as condition. It's equivalent to `False` [redundant-condition] -ERROR homeassistant/bootstrap.py:1018:42-59: Argument `BoundMethod[Self@_WatchPendingSetups, (self: Self@_WatchPendingSetups) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_later` [bad-argument-type] ERROR homeassistant/components/abode/__init__.py:83:50-81: Keyword argument `user_data` with type `Path` is not assignable to parameter `**kwargs` with type `Mapping[str, Path]` in function `jaraco.abode.config.PlatformDirs.override` [bad-argument-type] ERROR homeassistant/components/abode/alarm_control_panel.py:38:5-29: Class member `AbodeAlarm._attr_supported_features` overrides parent class `AbodeDevice` in an inconsistent manner [bad-override] ERROR homeassistant/components/abode/alarm_control_panel.py:42:5-12: Class member `AbodeAlarm._device` overrides parent class `AbodeDevice` in an inconsistent manner [bad-override] @@ -355,7 +350,6 @@ ERROR homeassistant/components/aftership/sensor.py:57:18-42: Argument `Any | Non ERROR homeassistant/components/aftership/sensor.py:88:5-37: Class member `AfterShipSensor._attr_native_unit_of_measurement` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/agent_dvr/camera.py:85:25-51: Argument `set[tuple[str, str | None]]` is not assignable to parameter `identifiers` with type `set[tuple[str, str]]` in function `homeassistant.helpers.device_registry.DeviceInfo.__init__` [bad-argument-type] ERROR homeassistant/components/ai_task/entity.py:42:16-45: Returned type `int | None` is not assignable to declared return type `AITaskEntityFeature` [bad-return] -ERROR homeassistant/components/ai_task/task.py:108:37-50: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/airgradient/button.py:34:5-8: Unexpected keyword argument `key` in function `AirGradientButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/airgradient/button.py:35:5-20: Unexpected keyword argument `translation_key` in function `AirGradientButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/airgradient/button.py:36:5-20: Unexpected keyword argument `entity_category` in function `AirGradientButtonEntityDescription.__init__` [unexpected-keyword] @@ -886,12 +880,10 @@ ERROR homeassistant/components/alarmdecoder/__init__.py:126:5-15: `controller` m ERROR homeassistant/components/alarmdecoder/__init__.py:127:5-15: `controller` may be uninitialized [unbound-name] ERROR homeassistant/components/alarmdecoder/__init__.py:134:9-19: `controller` may be uninitialized [unbound-name] ERROR homeassistant/components/alarmdecoder/__init__.py:139:11-21: `controller` may be uninitialized [unbound-name] -ERROR homeassistant/components/alarmdecoder/__init__.py:160:39-56: Argument `BoundMethod[AdExt, (self: AdExt) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/alarmdecoder/alarm_control_panel.py:77:5-29: Class member `AlarmDecoderAlarmPanel._attr_supported_features` overrides parent class `AlarmDecoderEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/alarmdecoder/binary_sensor.py:101:14-32: Class member `AlarmDecoderBinarySensor._attr_device_class` overrides parent class `AlarmDecoderEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/alarmdecoder/config_flow.py:70:9-31: Class member `AlarmDecoderFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/alarmdecoder/config_flow.py:118:32-38: `device` may be uninitialized [unbound-name] -ERROR homeassistant/components/alarmdecoder/config_flow.py:125:56-71: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/alarmdecoder/config_flow.py:127:27-32: `title` may be uninitialized [unbound-name] ERROR homeassistant/components/alarmdecoder/config_flow.py:152:25-31: `schema` may be uninitialized [unbound-name] ERROR homeassistant/components/alert/reproduce_state.py:57:17-24: `service` may be uninitialized [unbound-name] @@ -1030,7 +1022,6 @@ ERROR homeassistant/components/amberelectric/config_flow.py:68:30-64: Missing ar ERROR homeassistant/components/amberelectric/coordinator.py:55:5-17: Class member `AmberUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/amberelectric/coordinator.py:85:48-89:14: Missing argument `site_id` in function `amberelectric.api.amber_api.AmberApi.get_current_prices` [missing-argument] ERROR homeassistant/components/amberelectric/coordinator.py:86:17-29: Argument `str` is not assignable to parameter `self` with type `AmberApi` in function `amberelectric.api.amber_api.AmberApi.get_current_prices` [bad-argument-type] -ERROR homeassistant/components/amberelectric/coordinator.py:139:55-77: Argument `BoundMethod[Self@AmberUpdateCoordinator, (self: Self@AmberUpdateCoordinator) -> dict[str, dict[str, Any]]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/amberelectric/helpers.py:19:31-41: Cannot index into `dict[str, str]` [bad-index] ERROR homeassistant/components/amberelectric/sensor.py:55:14-32: Class member `AmberSensor.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/amberelectric/sensor.py:183:14-32: Class member `AmberGridSensor.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] @@ -1397,9 +1388,6 @@ ERROR homeassistant/components/ambient_station/sensor.py:659:9-24: Unexpected ke ERROR homeassistant/components/ambient_station/sensor.py:683:7-27: Field `entity_description` is declared `EntityDescription` in ancestor `class AmbientWeatherEntity: ... `, which is not assignable to the type `SensorEntityDescription` implied by multiple inheritance [inconsistent-inheritance] ERROR homeassistant/components/amcrest/__init__.py:15:1-57: Could not find import of `amcrest` [missing-import] -ERROR homeassistant/components/amcrest/__init__.py:244:50-76: Argument `BoundMethod[Self@AmcrestChecker, (self: Self@AmcrestChecker) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] -ERROR homeassistant/components/amcrest/__init__.py:268:50-76: Argument `BoundMethod[Self@AmcrestChecker, (self: Self@AmcrestChecker) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] -ERROR homeassistant/components/amcrest/__init__.py:291:50-75: Argument `BoundMethod[Self@AmcrestChecker, (self: Self@AmcrestChecker) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/components/amcrest/__init__.py:316:19-42: Object of class `AmcrestChecker` has no attribute `async_current_time` [missing-attribute] ERROR homeassistant/components/amcrest/binary_sensor.py:11:1-33: Could not find import of `amcrest` [missing-import] ERROR homeassistant/components/amcrest/binary_sensor.py:71:9-12: Unexpected keyword argument `key` in function `AmcrestSensorEntityDescription.__init__` [unexpected-keyword] @@ -1581,7 +1569,6 @@ ERROR homeassistant/components/anthropic/entity.py:431:20-31: `first_block` is u ERROR homeassistant/components/anthropic/entity.py:507:21-38: `current_tool_args` is uninitialized [unbound-name] ERROR homeassistant/components/anthropic/entity.py:529:40-57: `current_tool_args` is uninitialized [unbound-name] ERROR homeassistant/components/anthropic/entity.py:529:62-79: `current_tool_args` is uninitialized [unbound-name] -ERROR homeassistant/components/anthropic/entity.py:809:46-69: Argument `() -> Iterable[TypedDict[DocumentBlockParam] | TypedDict[ImageBlockParam]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/aosmith/coordinator.py:39:5-17: Class member `AOSmithStatusCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/aosmith/coordinator.py:72:18-33: Class member `AOSmithStatusCoordinator.update_interval` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/aosmith/coordinator.py:72:36-49: `timedelta` is not assignable to attribute `update_interval` with type `(self: Self@AOSmithStatusCoordinator, value: timedelta | None) -> None` [bad-assignment] @@ -2048,7 +2035,6 @@ ERROR homeassistant/components/assist_pipeline/select.py:155:9-24: Unexpected ke ERROR homeassistant/components/assist_pipeline/select.py:156:9-24: Unexpected keyword argument `entity_category` in function `homeassistant.components.select.SelectEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/assist_satellite/__init__.py:124:69-88: Unpacked keyword argument `Any | None` is not assignable to parameter `preannounce` with type `bool` in function `homeassistant.components.assist_satellite.entity.AssistSatelliteEntity.async_internal_ask_question` [bad-argument-type] ERROR homeassistant/components/assist_satellite/__init__.py:124:69-88: Unpacked keyword argument `Any | None` is not assignable to parameter `preannounce_media_id` with type `str` in function `homeassistant.components.assist_satellite.entity.AssistSatelliteEntity.async_internal_ask_question` [bad-argument-type] -ERROR homeassistant/components/assist_satellite/connection_test.py:41:56-77: Argument `BoundMethod[Path, (self: Path) -> bytes]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/assist_satellite/entity.py:129:5-23: Class member `AssistSatelliteEntity.entity_description` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/assist_satellite/websocket_api.py:60:38-73: Object of class `NoneType` has no attribute `async_intercept_wake_word` [missing-attribute] ERROR homeassistant/components/asuswrt/__init__.py:43:12-21: `unload_ok` may be uninitialized [unbound-name] @@ -2243,10 +2229,8 @@ ERROR homeassistant/components/august/util.py:38:12-17: Returned type `Literal[F ERROR homeassistant/components/aurora/config_flow.py:44:9-31: Class member `AuroraConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/aurora/coordinator.py:27:5-17: Class member `AuroraDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/aurora_abb_powerone/config_flow.py:53:12-33: Object of class `Serial` has no attribute `isOpen` [missing-attribute] -ERROR homeassistant/components/aurora_abb_powerone/config_flow.py:90:61-74: Argument `() -> tuple[list[str] | None, str | None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/aurora_abb_powerone/coordinator.py:24:5-17: Class member `AuroraAbbDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/aurora_abb_powerone/coordinator.py:105:20-46: Object of class `Serial` has no attribute `isOpen` [missing-attribute] -ERROR homeassistant/components/aurora_abb_powerone/coordinator.py:112:55-72: Argument `BoundMethod[Self@AuroraAbbDataUpdateCoordinator, (self: Self@AuroraAbbDataUpdateCoordinator) -> dict[str, float]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/aurora_abb_powerone/sensor.py:48:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/aurora_abb_powerone/sensor.py:50:9-24: Unexpected keyword argument `entity_category` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/aurora_abb_powerone/sensor.py:53:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -2408,9 +2392,7 @@ ERROR homeassistant/components/axis/switch.py:29:9-12: Unexpected keyword argume ERROR homeassistant/components/axis/switch.py:31:9-24: Unexpected keyword argument `entity_category` in function `AxisSwitchDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/axis/switch.py:53:5-23: Class member `AxisSwitch.entity_description` overrides parent class `AxisEventEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/axis/switch.py:53:5-23: Class member `AxisSwitch.entity_description` overrides parent class `SwitchEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/azure_data_explorer/__init__.py:144:48-76: Argument `BoundMethod[AzureDataExplorerClient, (self: AzureDataExplorerClient) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/azure_data_explorer/client.py:71:33-74: `ManagedStreamingIngestClient` is not assignable to attribute `write_client` with type `QueuedIngestClient` [bad-assignment] -ERROR homeassistant/components/azure_data_explorer/config_flow.py:56:52-74: Argument `BoundMethod[AzureDataExplorerClient, (self: AzureDataExplorerClient) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/azure_devops/config_flow.py:54:51-69: Argument `str | None` is not assignable to parameter `organization` with type `str` in function `aioazuredevops.client.DevOpsClient.authorize` [bad-argument-type] ERROR homeassistant/components/azure_devops/config_flow.py:58:53-71: Argument `str | None` is not assignable to parameter `organization` with type `str` in function `aioazuredevops.client.DevOpsClient.get_project` [bad-argument-type] ERROR homeassistant/components/azure_devops/config_flow.py:58:73-86: Argument `str | None` is not assignable to parameter `project` with type `str` in function `aioazuredevops.client.DevOpsClient.get_project` [bad-argument-type] @@ -2460,24 +2442,17 @@ ERROR homeassistant/components/azure_event_hub/config_flow.py:95:9-31: Class mem ERROR homeassistant/components/azure_service_bus/notify.py:8:1-47: Could not find import of `azure.servicebus` [missing-import] ERROR homeassistant/components/azure_service_bus/notify.py:9:1-68: Could not find import of `azure.servicebus.aio` [missing-import] ERROR homeassistant/components/azure_service_bus/notify.py:10:1-14:2: Could not find import of `azure.servicebus.exceptions` [missing-import] -ERROR homeassistant/components/azure_storage/__init__.py:55:9-32: Argument `() -> ContainerClient` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/azure_storage/backup.py:114:15-36: Class member `AzureStorageBackupAgent.async_download_backup` overrides parent class `BackupAgent` in an inconsistent manner [bad-override] -ERROR homeassistant/components/azure_storage/config_flow.py:48:55-78: Argument `() -> ContainerClient` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backblaze_b2/__init__.py:51:16-66: Returned type `b2sdk._internal.bucket.Bucket` is not assignable to declared return type `b2sdk.v2.bucket.Bucket` [bad-return] -ERROR homeassistant/components/backblaze_b2/__init__.py:54:52-82: Argument `() -> Bucket` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backblaze_b2/backup.py:193:15-36: Class member `BackblazeBackupAgent.async_download_backup` overrides parent class `BackupAgent` in an inconsistent manner [bad-override] ERROR homeassistant/components/backblaze_b2/backup.py:208:68-210:22: Unpacked argument `tuple[Iterator[Any], None]` is not assignable to parameter `*args` with type `tuple[SupportsNext[@_]]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backblaze_b2/backup.py:220:15-34: Class member `BackblazeBackupAgent.async_upload_backup` overrides parent class `BackupAgent` in an inconsistent manner [bad-override] ERROR homeassistant/components/backblaze_b2/backup.py:345:15-34: Class member `BackblazeBackupAgent.async_delete_backup` overrides parent class `BackupAgent` in an inconsistent manner [bad-override] ERROR homeassistant/components/backblaze_b2/backup.py:373:15-33: Class member `BackblazeBackupAgent.async_list_backups` overrides parent class `BackupAgent` in an inconsistent manner [bad-override] ERROR homeassistant/components/backblaze_b2/backup.py:411:15-31: Class member `BackblazeBackupAgent.async_get_backup` overrides parent class `BackupAgent` in an inconsistent manner [bad-override] -ERROR homeassistant/components/backblaze_b2/backup.py:537:17-48: Argument `BoundMethod[Self@BackblazeBackupAgent, (self: Self@BackblazeBackupAgent) -> dict[str, FileVersion]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/backblaze_b2/config_flow.py:121:52-82: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backup/agent.py:37:15-36: Abstract methods for async generators should use `def`, not `async def` [bad-function-definition] ERROR homeassistant/components/backup/agent.py:116:10-27: Function declared to return `list[BackupAgent]` but is missing an explicit `return` [bad-return] ERROR homeassistant/components/backup/agent.py:126:10-28: Function declared to return `() -> None` but is missing an explicit `return` [bad-return] -ERROR homeassistant/components/backup/backup.py:47:59-77: Argument `BoundMethod[Self@CoreLocalBackupAgent, (self: Self@CoreLocalBackupAgent) -> dict[str, tuple[AgentBackup, Path]]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/backup/backup.py:49:25-32: `Sized` is not assignable to attribute `_backups` with type `dict[str, tuple[AgentBackup, Path]]` [bad-assignment] ERROR homeassistant/components/backup/backup.py:63:15-36: Class member `CoreLocalBackupAgent.async_download_backup` overrides parent class `LocalBackupAgent` in an inconsistent manner [bad-override] ERROR homeassistant/components/backup/backup.py:100:56-74: Argument `BoundMethod[Path, (self: Path, *, follow_symlinks: bool = True) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backup/config.py:540:26-36: `cron_event` may be uninitialized [unbound-name] @@ -2487,7 +2462,6 @@ ERROR homeassistant/components/backup/http.py:119:18-62: Type `AsyncIterator[byt ERROR homeassistant/components/backup/http.py:143:26-88: `TextIOWrapper[_WrappedBuffer]` is not assignable to variable `reader` with type `IO[bytes]` [bad-assignment] ERROR homeassistant/components/backup/http.py:143:59-88: Unpacked argument `tuple[str, Literal['rb']]` is not assignable to parameter `*args` with type `tuple[PathLike[bytes] | PathLike[str] | bytes | int | str, Literal['+a', '+at', '+r', '+rt', '+ta', '+tr', '+tw', '+tx', '+w', '+wt', '+x', '+xt', 'U', 'Ur', 'Urt', 'Utr', 'a', 'a+', 'a+t', 'at', 'at+', 'r', 'r+', 'r+t', 'rU', 'rUt', 'rt', 'rt+', 'rtU', 't+a', 't+r', 't+w', 't+x', 'tUr', 'ta', 'ta+', 'tr', 'tr+', 'trU', 'tw', 'tw+', 'tx', 'tx+', 'w', 'w+', 'w+t', 'wt', 'wt+', 'x', 'x+', 'x+t', 'xt', 'xt+'], int, str | None, str | None, str | None, bool, ((str, int) -> int) | None]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backup/http.py:147:22-66: Type `AsyncIterator[bytes]` is not awaitable [not-async] -ERROR homeassistant/components/backup/http.py:154:44-65: Argument `BoundMethod[Event, (self: Event) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/components/backup/manager.py:586:29-45: `open_stream_func` may be uninitialized [unbound-name] ERROR homeassistant/components/backup/manager.py:587:24-31: `_backup` may be uninitialized [unbound-name] ERROR homeassistant/components/backup/manager.py:675:25-34: `backup_id` may be uninitialized [unbound-name] @@ -2497,20 +2471,14 @@ ERROR homeassistant/components/backup/manager.py:1525:60-89: Unpacked argument ` ERROR homeassistant/components/backup/manager.py:1527:29-73: Type `AsyncIterator[bytes]` is not awaitable [not-async] ERROR homeassistant/components/backup/manager.py:1778:53-79: Unpacked argument `tuple[Literal['rb']]` is not assignable to parameter `*args` with type `tuple[Literal['+a', '+at', '+r', '+rt', '+ta', '+tr', '+tw', '+tx', '+w', '+wt', '+x', '+xt', 'U', 'Ur', 'Urt', 'Utr', 'a', 'a+', 'a+t', 'at', 'at+', 'r', 'r+', 'r+t', 'rU', 'rUt', 'rt', 'rt+', 'rtU', 't+a', 't+r', 't+w', 't+x', 'tUr', 'ta', 'ta+', 'tr', 'tr+', 'trU', 'tw', 'tw+', 'tx', 'tx+', 'w', 'w+', 'w+t', 'wt', 'wt+', 'x', 'x+', 'x+t', 'xt', 'xt+'], int, str | None, str | None, str | None]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backup/manager.py:1781:35-40: Type of yielded value `str` is not assignable to declared return type `bytes` [invalid-yield] -ERROR homeassistant/components/backup/manager.py:1783:54-61: Argument `BoundMethod[TextIOWrapper[_WrappedBuffer], (self: TextIOWrapper[_WrappedBuffer]) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backup/manager.py:1823:21-41: Argument `list[BaseException | Exception | None]` is not assignable to parameter `exceptions` with type `Sequence[Exception]` in function `ExceptionGroup.__new__` [bad-argument-type] ERROR homeassistant/components/backup/manager.py:1903:41-63: Unpacked argument `tuple[Literal['wb']]` is not assignable to parameter `*args` with type `tuple[Literal['+a', '+at', '+r', '+rt', '+ta', '+tr', '+tw', '+tx', '+w', '+wt', '+x', '+xt', 'U', 'Ur', 'Urt', 'Utr', 'a', 'a+', 'a+t', 'at', 'at+', 'r', 'r+', 'r+t', 'rU', 'rUt', 'rt', 'rt+', 'rtU', 't+a', 't+r', 't+w', 't+x', 'tUr', 'ta', 'ta+', 'tr', 'tr+', 'trU', 'tw', 'tw+', 'tx', 'tx+', 'w', 'w+', 'w+t', 'wt', 'wt+', 'x', 'x+', 'x+t', 'xt', 'xt+'], int, str | None, str | None, str | None]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backup/manager.py:1906:45-61: Unpacked argument `tuple[bytes]` is not assignable to parameter `*args` with type `tuple[str]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/backup/manager.py:1908:42-49: Argument `BoundMethod[TextIOWrapper[_WrappedBuffer], (self: TextIOWrapper[_WrappedBuffer]) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backup/manager.py:1921:41-80: Unpacked argument `tuple[Path, Path]` is not assignable to parameter `*args` with type `tuple[PathLike[str] | str, @_, ((PathLike[str] | str, PathLike[str] | str) -> object) | ((str, str) -> object)]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backup/manager.py:1926:45-71: Unpacked argument `tuple[Literal['rb']]` is not assignable to parameter `*args` with type `tuple[Literal['+a', '+at', '+r', '+rt', '+ta', '+tr', '+tw', '+tx', '+w', '+wt', '+x', '+xt', 'U', 'Ur', 'Urt', 'Utr', 'a', 'a+', 'a+t', 'at', 'at+', 'r', 'r+', 'r+t', 'rU', 'rUt', 'rt', 'rt+', 'rtU', 't+a', 't+r', 't+w', 't+x', 'tUr', 'ta', 'ta+', 'tr', 'tr+', 'trU', 'tw', 'tw+', 'tx', 'tx+', 'w', 'w+', 'w+t', 'wt', 'wt+', 'x', 'x+', 'x+t', 'xt', 'xt+'], int, str | None, str | None, str | None]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backup/manager.py:1929:27-32: Type of yielded value `str` is not assignable to declared return type `bytes` [invalid-yield] -ERROR homeassistant/components/backup/manager.py:1931:46-53: Argument `BoundMethod[TextIOWrapper[_WrappedBuffer], (self: TextIOWrapper[_WrappedBuffer]) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backup/manager.py:1987:45-62: Unpacked argument `tuple[Literal['wb']]` is not assignable to parameter `*args` with type `tuple[Literal['+a', '+at', '+r', '+rt', '+ta', '+tr', '+tw', '+tx', '+w', '+wt', '+x', '+xt', 'U', 'Ur', 'Urt', 'Utr', 'a', 'a+', 'a+t', 'at', 'at+', 'r', 'r+', 'r+t', 'rU', 'rUt', 'rt', 'rt+', 'rtU', 't+a', 't+r', 't+w', 't+x', 'tUr', 'ta', 'ta+', 'tr', 'tr+', 'trU', 'tw', 'tw+', 'tx', 'tx+', 'w', 'w+', 'w+t', 'wt', 'wt+', 'x', 'x+', 'x+t', 'xt', 'xt+'], int, str | None, str | None, str | None]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backup/manager.py:1990:49-65: Unpacked argument `tuple[bytes]` is not assignable to parameter `*args` with type `tuple[str]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/backup/manager.py:1992:46-53: Argument `BoundMethod[TextIOWrapper[_WrappedBuffer], (self: TextIOWrapper[_WrappedBuffer]) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/backup/manager.py:2017:49-68: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/backup/manager.py:2054:66-84: Argument `() -> dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None] | None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/backup/sensor.py:31:9-12: Unexpected keyword argument `key` in function `BackupSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/backup/sensor.py:32:9-24: Unexpected keyword argument `translation_key` in function `BackupSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/backup/sensor.py:38:9-12: Unexpected keyword argument `key` in function `BackupSensorEntityDescription.__init__` [unexpected-keyword] @@ -2524,8 +2492,6 @@ ERROR homeassistant/components/backup/sensor.py:76:5-23: Class member `BackupMan ERROR homeassistant/components/backup/util.py:186:20-56: Object of class `NoneType` has no attribute `plaintext_size` [missing-attribute] ERROR homeassistant/components/backup/util.py:289:35-71: Object of class `NoneType` has no attribute `plaintext_size` [missing-attribute] ERROR homeassistant/components/backup/util.py:381:34-58: Object of class `BinaryIO` has no attribute `encrypted_size` [missing-attribute] -ERROR homeassistant/components/backup/util.py:455:50-72: Argument `BoundMethod[Event, (self: Event) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] -ERROR homeassistant/components/backup/util.py:525:43-63: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> None` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/baf/binary_sensor.py:34:9-12: Unexpected keyword argument `key` in function `BAFBinarySensorDescription.__init__` [unexpected-keyword] WARN homeassistant/components/baf/binary_sensor.py:36:37-81: Redundant cast: `bool | None` is the same type as `bool | None` [redundant-cast] ERROR homeassistant/components/baf/binary_sensor.py:57:5-23: Class member `BAFBinarySensor.entity_description` overrides parent class `BAFDescriptionEntity` in an inconsistent manner [bad-override] @@ -2919,8 +2885,6 @@ ERROR homeassistant/components/bluemaestro/sensor.py:132:7-39: Field `entity_des `, which is not assignable to the type `SensorEntityDescription` implied by multiple inheritance [inconsistent-inheritance] ERROR homeassistant/components/blueprint/importer.py:140:48-61: `block_content` may be uninitialized [unbound-name] ERROR homeassistant/components/blueprint/importer.py:226:54-61: `content` may be uninitialized [unbound-name] -ERROR homeassistant/components/blueprint/models.py:275:59-80: Argument `BoundMethod[Self@DomainBlueprints, (self: Self@DomainBlueprints) -> dict[str, Blueprint | BlueprintException | None]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/blueprint/models.py:386:48-56: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/bluesound/button.py:70:9-12: Unexpected keyword argument `key` in function `BluesoundButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/bluesound/button.py:71:9-24: Unexpected keyword argument `translation_key` in function `BluesoundButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/bluesound/button.py:72:9-40: Unexpected keyword argument `entity_registry_enabled_default` in function `BluesoundButtonEntityDescription.__init__` [unexpected-keyword] @@ -2934,7 +2898,6 @@ ERROR homeassistant/components/bluesound/media_player.py:628:25-40: No matching ERROR homeassistant/components/bluesound/media_player.py:637:25-40: No matching overload found for function `max` called with arguments: (Literal[0], float) [no-matching-overload] ERROR homeassistant/components/bluesound/media_player.py:646:41-47: Argument `float` is not assignable to parameter `level` with type `int | None` in function `pyblu.player.Player.volume` [bad-argument-type] ERROR homeassistant/components/bluetooth/__init__.py:199:13-31: Argument `HassJob[[now: datetime], Coroutine[Unknown, Unknown, None]]` is not assignable to parameter `action` with type `((datetime) -> Coroutine[Any, Any, None] | None) | HassJob[[datetime], Coroutine[Any, Any, None] | None]` in function `homeassistant.helpers.event.async_call_later` [bad-argument-type] -ERROR homeassistant/components/bluetooth/__init__.py:355:21-358:22: Argument `() -> Task[dict[str, Any]]` is not assignable to parameter `func` with type `(**tuple[*@_]) -> object` in function `homeassistant.core.callback` [bad-argument-type] ERROR homeassistant/components/bluetooth/config_flow.py:222:9-31: Class member `BluetoothConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/bluetooth/manager.py:215:36-45: No matching overload found for function `homeassistant.components.bluetooth.match.BluetoothCallbackMatcherWithCallback.update` called with arguments: (TypedDict[BluetoothCallbackMatcher]) [no-matching-overload] ERROR homeassistant/components/bluetooth/match.py:202:54-73: `_T` is not subscriptable [unsupported-operation] @@ -3188,9 +3151,6 @@ ERROR homeassistant/components/bosch_alarm/switch.py:47:9-12: Unexpected keyword ERROR homeassistant/components/bosch_alarm/switch.py:48:9-24: Unexpected keyword argument `translation_key` in function `BoschAlarmSwitchEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/bosch_alarm/switch.py:91:5-23: Class member `PanelDoorEntity.entity_description` overrides parent class `BoschAlarmDoorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/bosch_alarm/switch.py:91:5-23: Class member `PanelDoorEntity.entity_description` overrides parent class `SwitchEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/bosch_shc/__init__.py:70:43-63: Argument `BoundMethod[SHCSession, (self: SHCSession) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/bosch_shc/__init__.py:72:39-60: Argument `BoundMethod[SHCSession, (self: SHCSession) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/bosch_shc/__init__.py:82:39-70: Argument `BoundMethod[SHCSession, (self: SHCSession) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/bosch_shc/binary_sensor.py:34:13-35:54: `+` is not supported between `Sequence[SHCShutterContact]` and `Sequence[SHCShutterContact2]` [unsupported-operation] ERROR homeassistant/components/bosch_shc/binary_sensor.py:46:13-47:53: `+` is not supported between `Sequence[SHCMotionDetector]` and `Sequence[SHCShutterContact]` [unsupported-operation] ERROR homeassistant/components/bosch_shc/binary_sensor.py:75:14-32: Class member `ShutterContactSensor._attr_device_class` overrides parent class `SHCEntity` in an inconsistent manner [bad-override] @@ -3310,10 +3270,7 @@ ERROR homeassistant/components/bring/sensor.py:120:5-16: Class member `BringSens ERROR homeassistant/components/bring/todo.py:91:5-16: Class member `BringTodoListEntity.coordinator` overrides parent class `BringBaseEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/broadlink/climate.py:48:5-29: Class member `BroadlinkThermostat._attr_supported_features` overrides parent class `BroadlinkEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/broadlink/config_flow.py:77:60-77: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[str, int, int]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/broadlink/config_flow.py:163:52-63: Argument `BoundMethod[Device, (self: Device) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/broadlink/device.py:109:20-23: `Device` is not assignable to attribute `api` with type `_ApiT` [bad-assignment] -ERROR homeassistant/components/broadlink/device.py:113:17-43: Argument `BoundMethod[Self@BroadlinkDevice, (self: Self@BroadlinkDevice) -> int | None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/broadlink/device.py:161:52-65: Argument `BoundMethod[_ApiT, (self: _ApiT) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/broadlink/light.py:82:35-68: `list[Unknown]` is not assignable to attribute `_attr_hs_color` with type `tuple[float, float] | None` [bad-assignment] ERROR homeassistant/components/broadlink/remote.py:124:14-38: Class member `BroadlinkRemote._attr_supported_features` overrides parent class `BroadlinkEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/broadlink/remote.py:124:14-38: Class member `BroadlinkRemote._attr_supported_features` overrides parent class `RestoreEntity` in an inconsistent manner [bad-override] @@ -3828,11 +3785,8 @@ ERROR homeassistant/components/button/__init__.py:79:5-17: Class member `ButtonE ERROR homeassistant/components/button/__init__.py:90:5-23: Class member `ButtonEntity.entity_description` overrides parent class `RestoreEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/button/__init__.py:92:5-23: Class member `ButtonEntity._attr_device_class` overrides parent class `RestoreEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/button/__init__.py:93:5-16: Class member `ButtonEntity._attr_state` overrides parent class `RestoreEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/button/__init__.py:147:48-58: Argument `BoundMethod[Self@ButtonEntity, (self: Self@ButtonEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/caldav/__init__.py:38:43-59: Argument `BoundMethod[DAVClient, (self: DAVClient, *, url: ParseResult | SplitResult | URL | str | None = None) -> Principal]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/caldav/api.py:20:46-60: Argument `() -> list[Calendar]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/caldav/config_flow.py:70:52-68: Argument `BoundMethod[DAVClient, (self: DAVClient, *, url: ParseResult | SplitResult | URL | str | None = None) -> Principal]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/caldav/todo.py:199:56-67: Argument `BoundMethod[CalendarObjectResource, (self: CalendarObjectResource) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/calendar/__init__.py:513:5-23: Class member `CalendarEntity.entity_description` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/cambridge_audio/__init__.py:69:12-21: `unload_ok` may be uninitialized [unbound-name] ERROR homeassistant/components/cambridge_audio/media_player.py:81:5-23: Class member `CambridgeAudioDevice._attr_device_class` overrides parent class `CambridgeAudioEntity` in an inconsistent manner [bad-override] @@ -3857,16 +3811,9 @@ ERROR homeassistant/components/cambridge_audio/switch.py:61:5-23: Class member ` ERROR homeassistant/components/cambridge_audio/switch.py:61:5-23: Class member `CambridgeAudioSwitch.entity_description` overrides parent class `SwitchEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/camera/__init__.py:458:5-16: Class member `Camera._attr_state` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/camera/__init__.py:459:5-29: Class member `Camera._attr_supported_features` overrides parent class `Entity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/camera/__init__.py:637:48-61: Argument `BoundMethod[Self@Camera, (self: Self@Camera) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/camera/__init__.py:645:48-60: Argument `BoundMethod[Self@Camera, (self: Self@Camera) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/camera/__init__.py:653:48-76: Argument `BoundMethod[Self@Camera, (self: Self@Camera) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/camera/__init__.py:661:48-77: Argument `BoundMethod[Self@Camera, (self: Self@Camera) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/camera/media_source.py:52:5-9: Class member `CameraMediaSource.name` overrides parent class `MediaSource` in an inconsistent manner [bad-override] ERROR homeassistant/components/canary/alarm_control_panel.py:42:5-29: Class member `CanaryAlarm._attr_supported_features` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/canary/camera.py:130:52-82: Argument `BoundMethod[Self@CanaryCamera, (self: Self@CanaryCamera) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/canary/camera.py:150:52-84: Argument `BoundMethod[LiveStreamSession, (self: LiveStreamSession) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/canary/camera.py:173:17-30: Argument `asyncio.streams.StreamReader` is not assignable to parameter `stream` with type `aiohttp.streams.StreamReader` in function `homeassistant.helpers.aiohttp_client.async_aiohttp_proxy_stream` [bad-argument-type] -ERROR homeassistant/components/canary/coordinator.py:70:63-80: Argument `BoundMethod[Self@CanaryDataUpdateCoordinator, (self: Self@CanaryDataUpdateCoordinator) -> TypedDict[CanaryData]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/canary/sensor.py:126:14-32: Class member `CanarySensor._attr_device_class` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/cast/__init__.py:39:10-27: Function declared to return `list[BrowseMedia]` but is missing an explicit `return` [bad-return] ERROR homeassistant/components/cast/__init__.py:62:10-14: Function declared to return `bool` but is missing an explicit `return` [bad-return] @@ -3910,9 +3857,6 @@ ERROR homeassistant/components/citybikes/sensor.py:184:44-63: `<` is not support ERROR homeassistant/components/clementine/media_player.py:8:1-46: Could not find import of `clementineremote` [missing-import] ERROR homeassistant/components/climate/__init__.py:257:5-23: Class member `ClimateEntity.entity_description` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/climate/__init__.py:272:5-29: Class member `ClimateEntity._attr_supported_features` overrides parent class `Entity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/climate/__init__.py:643:52-64: Argument `BoundMethod[Self@ClimateEntity, (self: Self@ClimateEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/climate/__init__.py:671:52-65: Argument `BoundMethod[Self@ClimateEntity, (self: Self@ClimateEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/climate/__init__.py:689:52-63: Argument `BoundMethod[Self@ClimateEntity, (self: Self@ClimateEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/climate/device_action.py:98:17-24: `service` may be uninitialized [unbound-name] ERROR homeassistant/components/cloud/__init__.py:281:51-61: Argument `str | Unknown` is not assignable to parameter `alexa_user_config` with type `dict[str, Any]` in function `homeassistant.components.cloud.client.CloudClient.__init__` [bad-argument-type] ERROR homeassistant/components/cloud/__init__.py:281:63-74: Argument `str | Unknown` is not assignable to parameter `google_user_config` with type `dict[str, Any]` in function `homeassistant.components.cloud.client.CloudClient.__init__` [bad-argument-type] @@ -3921,7 +3865,6 @@ ERROR homeassistant/components/cloud/__init__.py:282:51-59: Unpacked keyword arg ERROR homeassistant/components/cloud/backup.py:83:15-36: Class member `CloudBackupAgent.async_download_backup` overrides parent class `BackupAgent` in an inconsistent manner [bad-override] ERROR homeassistant/components/cloud/client.py:96:33-44: Module `aiohttp.web` exists, but was not imported explicitly. You are relying on other modules to load it. [implicit-import] ERROR homeassistant/components/cloud/client.py:183:50-66: Argument `HassJob[[_: Any], Coroutine[Unknown, Unknown, None]]` is not assignable to parameter `action` with type `((datetime) -> Coroutine[Any, Any, None] | None) | HassJob[[datetime], Coroutine[Any, Any, None] | None]` in function `homeassistant.helpers.event.async_call_later` [bad-argument-type] -ERROR homeassistant/components/cloud/helpers.py:31:50-59: Argument `() -> list[str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/cloud/http_api.py:490:46-59: `documentation` may be uninitialized [unbound-name] ERROR homeassistant/components/cloud/http_api.py:711:18-31: `language_info` is uninitialized [unbound-name] ERROR homeassistant/components/cloud/prefs.py:131:23-28: `prefs` may be uninitialized [unbound-name] @@ -4083,7 +4026,6 @@ ERROR homeassistant/components/conversation/chat_log.py:208:30-88: `list[SystemC ERROR homeassistant/components/conversation/chat_log.py:317:29-40: Argument `dict[str, str] | Unknown` is not assignable to parameter `tool_result` with type `dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None]` in function `ToolResultContent.__init__` [bad-argument-type] ERROR homeassistant/components/conversation/chat_log.py:594:36-55: `extra_system_prompt` may be uninitialized [unbound-name] ERROR homeassistant/components/conversation/default_agent.py:1026:16-22: Returned type `str | None` is not assignable to declared return type `str` [bad-return] -ERROR homeassistant/components/conversation/default_agent.py:1351:52-77: Argument `BoundMethod[Self@DefaultAgent, (self: Self@DefaultAgent) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/cookidoo/button.py:28:5-8: Unexpected keyword argument `key` in function `CookidooButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/cookidoo/button.py:29:5-20: Unexpected keyword argument `translation_key` in function `CookidooButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/cookidoo/button.py:31:5-36: Unexpected keyword argument `entity_registry_enabled_default` in function `CookidooButtonEntityDescription.__init__` [unexpected-keyword] @@ -4127,8 +4069,6 @@ ERROR homeassistant/components/cppm_tracker/device_tracker.py:8:1-34: Could not ERROR homeassistant/components/cppm_tracker/device_tracker.py:65:45-57: Type `None` is not iterable [not-iterable] ERROR homeassistant/components/cppm_tracker/device_tracker.py:70:43-55: Type `None` is not iterable [not-iterable] ERROR homeassistant/components/cppm_tracker/device_tracker.py:84:24-31: `list[Unknown]` is not assignable to attribute `results` with type `None` [bad-assignment] -ERROR homeassistant/components/cpuspeed/__init__.py:13:46-66: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/cpuspeed/config_flow.py:30:55-75: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/crownstone/config_flow.py:142:9-31: Class member `CrownstoneConfigFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/crownstone/config_flow.py:238:60-70: Cannot index into `dict[str, Sphere]` [bad-index] ERROR homeassistant/components/crownstone/entry_manager.py:110:20-30: Cannot use `CrownstoneSSEAsync` as a context manager [bad-context-manager] @@ -4187,7 +4127,6 @@ ERROR homeassistant/components/datetime/__init__.py:84:5-23: Class member `DateT ERROR homeassistant/components/datetime/__init__.py:85:5-16: Class member `DateTimeEntity._attr_state` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/ddwrt/device_tracker.py:125:29-31: `list[@_]` is not assignable to attribute `last_results` with type `dict[Unknown, Unknown]` [bad-assignment] ERROR homeassistant/components/ddwrt/device_tracker.py:140:9-33: Object of class `dict` has no attribute `extend` [missing-attribute] -ERROR homeassistant/components/debugpy/__init__.py:64:48-57: Argument `BoundMethod[Event, (self: Event) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/components/deconz/alarm_control_panel.py:77:5-29: Class member `DeconzAlarmControlPanel._attr_supported_features` overrides parent class `DeconzDevice` in an inconsistent manner [bad-override] ERROR homeassistant/components/deconz/alarm_control_panel.py:103:42-60: Cannot index into `dict[AncillaryControlPanel, AlarmControlPanelState]` [bad-index] ERROR homeassistant/components/deconz/binary_sensor.py:76:9-12: Unexpected keyword argument `key` in function `DeconzBinarySensorDescription.__init__` [unexpected-keyword] @@ -4278,10 +4217,7 @@ ERROR homeassistant/components/delijn/sensor.py:9:1-42: Could not find import of ERROR homeassistant/components/delijn/sensor.py:117:17-30: `first_passage` may be uninitialized [unbound-name] ERROR homeassistant/components/deluge/__init__.py:34:44-36:6: Unpacked argument `tuple[Any, Any, Any, Any]` is not assignable to parameter `*args` with type `tuple[Unknown, Unknown, Unknown, Unknown, bool | Unknown, bool | Unknown, int | Unknown]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/deluge/__init__.py:37:5-17: Object of class `DelugeRPCClient` has no attribute `web_port` [missing-attribute] -ERROR homeassistant/components/deluge/__init__.py:39:43-54: Argument `BoundMethod[DelugeRPCClient, (self: DelugeRPCClient) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/deluge/config_flow.py:89:52-63: Argument `BoundMethod[DelugeRPCClient, (self: DelugeRPCClient) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/deluge/coordinator.py:39:5-17: Class member `DelugeDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/deluge/coordinator.py:90:62-83: Argument `BoundMethod[Self@DelugeDataUpdateCoordinator, (self: Self@DelugeDataUpdateCoordinator) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/deluge/sensor.py:67:9-12: Unexpected keyword argument `key` in function `DelugeSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/deluge/sensor.py:68:9-24: Unexpected keyword argument `translation_key` in function `DelugeSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/deluge/sensor.py:76:9-12: Unexpected keyword argument `key` in function `DelugeSensorEntityDescription.__init__` [unexpected-keyword] @@ -4298,7 +4234,6 @@ ERROR homeassistant/components/deluge/sensor.py:120:9-12: Unexpected keyword arg ERROR homeassistant/components/deluge/sensor.py:121:9-24: Unexpected keyword argument `translation_key` in function `DelugeSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/deluge/sensor.py:142:5-23: Class member `DelugeSensor.entity_description` overrides parent class `DelugeEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/deluge/sensor.py:142:5-23: Class member `DelugeSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/demo/camera.py:50:55-76: Argument `BoundMethod[Path, (self: Path) -> bytes]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/demo/config_flow.py:34:9-31: Class member `DemoConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/demo/media_player.py:290:14-33: Class member `DemoMusicPlayer._attr_group_members` overrides parent class `AbstractDemoPlayer` in an inconsistent manner [bad-override] ERROR homeassistant/components/demo/sensor.py:182:5-23: Class member `DemoSumSensor._attr_native_value` overrides parent class `RestoreSensor` in an inconsistent manner [bad-override] @@ -4353,11 +4288,9 @@ ERROR homeassistant/components/device_tracker/legacy.py:655:12-18: `device` may ERROR homeassistant/components/device_tracker/legacy.py:656:19-25: `device` may be uninitialized [unbound-name] ERROR homeassistant/components/device_tracker/legacy.py:666:16-22: `device` may be uninitialized [unbound-name] ERROR homeassistant/components/device_tracker/legacy.py:667:17-23: `device` may be uninitialized [unbound-name] -ERROR homeassistant/components/device_tracker/legacy.py:984:55-72: Argument `BoundMethod[Self@DeviceScanner, (self: Self@DeviceScanner) -> list[str]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/device_tracker/legacy.py:1033:52-81: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[str, Secrets | None]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/devolo_home_control/binary_sensor.py:79:14-32: Class member `DevoloBinaryDeviceEntity._attr_device_class` overrides parent class `DevoloDeviceEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/devolo_home_control/climate.py:53:5-29: Class member `DevoloClimateDeviceEntity._attr_supported_features` overrides parent class `DevoloMultiLevelSwitchDeviceEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/devolo_home_control/config_flow.py:104:13-39: Argument `BoundMethod[Mydevolo, (self: Mydevolo) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/devolo_home_control/cover.py:42:5-29: Class member `DevoloCoverDeviceEntity._attr_supported_features` overrides parent class `DevoloMultiLevelSwitchDeviceEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/devolo_home_control/cover.py:47:5-23: Class member `DevoloCoverDeviceEntity._attr_device_class` overrides parent class `DevoloMultiLevelSwitchDeviceEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/devolo_home_control/sensor.py:192:60-80: Cannot index into `dict[str, ConsumptionProperty]` [bad-index] @@ -4408,7 +4341,6 @@ ERROR homeassistant/components/devolo_home_network/update.py:41:9-12: Unexpected ERROR homeassistant/components/devolo_home_network/update.py:72:5-29: Class member `DevoloUpdateEntity._attr_supported_features` overrides parent class `DevoloCoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/devolo_home_network/update.py:76:5-23: Class member `DevoloUpdateEntity.entity_description` overrides parent class `DevoloCoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/devolo_home_network/update.py:76:5-23: Class member `DevoloUpdateEntity.entity_description` overrides parent class `UpdateEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/dexcom/coordinator.py:43:13-52: Argument `BoundMethod[Dexcom, (self: Dexcom) -> GlucoseReading]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/diagnostics/__init__.py:96:10-27: Function declared to return `Mapping[str, Any]` but is missing an explicit `return` [bad-return] ERROR homeassistant/components/diagnostics/__init__.py:101:10-27: Function declared to return `Mapping[str, Any]` but is missing an explicit `return` [bad-return] ERROR homeassistant/components/diagnostics/__init__.py:219:29-40: Cannot set item in `dict[str, Mapping[str | None, dict[SetupPhases, float]] | Mapping[str, Any] | dict[str, Any] | dict[Unknown, Unknown] | TypedDict[Manifest]]` [unsupported-operation] @@ -4564,7 +4496,6 @@ ERROR homeassistant/components/dremel_3d_printer/camera.py:15:5-9: Unexpected ke ERROR homeassistant/components/dremel_3d_printer/config_flow.py:56:40-43: `api` may be uninitialized [unbound-name] ERROR homeassistant/components/dremel_3d_printer/config_flow.py:58:46-49: `api` may be uninitialized [unbound-name] ERROR homeassistant/components/dremel_3d_printer/coordinator.py:19:5-17: Class member `Dremel3DPrinterDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/dremel_3d_printer/coordinator.py:37:52-68: Argument `BoundMethod[Dremel3DPrinter, (self: Dremel3DPrinter) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/dremel_3d_printer/sensor.py:45:9-12: Unexpected keyword argument `key` in function `Dremel3DPrinterSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/dremel_3d_printer/sensor.py:46:9-24: Unexpected keyword argument `translation_key` in function `Dremel3DPrinterSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/dremel_3d_printer/sensor.py:50:9-12: Unexpected keyword argument `key` in function `Dremel3DPrinterSensorEntityDescription.__init__` [unexpected-keyword] @@ -5091,7 +5022,6 @@ ERROR homeassistant/components/dsmr_reader/definitions.py:545:9-40: Unexpected k ERROR homeassistant/components/dsmr_reader/sensor.py:31:5-23: Class member `DSMRSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/duckdns/__init__.py:141:46-67: Argument `HassJob[[now: datetime], Coroutine[Unknown, Unknown, None]]` is not assignable to parameter `action` with type `((datetime) -> Coroutine[Any, Any, None] | None) | HassJob[[datetime], Coroutine[Any, Any, None] | None]` in function `homeassistant.helpers.event.async_call_later` [bad-argument-type] ERROR homeassistant/components/duke_energy/coordinator.py:41:5-17: Class member `DukeEnergyCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/dunehd/config_flow.py:26:56-75: Argument `BoundMethod[DuneHDPlayer, (self: DuneHDPlayer) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/dunehd/media_player.py:109:23-45: Object of class `DuneHDPlayer` has no attribute `volume_up` [missing-attribute] ERROR homeassistant/components/dunehd/media_player.py:113:23-47: Object of class `DuneHDPlayer` has no attribute `volume_down` [missing-attribute] ERROR homeassistant/components/duotecno/binary_sensor.py:30:5-10: Class member `DuotecnoBinarySensor._unit` overrides parent class `DuotecnoEntity` in an inconsistent manner [bad-override] @@ -5105,9 +5035,7 @@ ERROR homeassistant/components/dwd_weather_warnings/config_flow.py:75:35-43: `po ERROR homeassistant/components/dwd_weather_warnings/coordinator.py:28:5-17: Class member `DwdWeatherWarningsCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/dwd_weather_warnings/coordinator.py:70:21-32: `None` is not subscriptable [unsupported-operation] ERROR homeassistant/components/dwd_weather_warnings/coordinator.py:71:21-32: `None` is not subscriptable [unsupported-operation] -ERROR homeassistant/components/dwd_weather_warnings/coordinator.py:84:56-71: Argument `BoundMethod[DwdWeatherWarningsAPI, (self: DwdWeatherWarningsAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/dwd_weather_warnings/coordinator.py:86:39-47: `tuple[float, float] | None` is not assignable to attribute `_previous_position` with type `None` [bad-assignment] -ERROR homeassistant/components/dwd_weather_warnings/coordinator.py:88:52-67: Argument `BoundMethod[DwdWeatherWarningsAPI, (self: DwdWeatherWarningsAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/dwd_weather_warnings/sensor.py:45:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/dwd_weather_warnings/sensor.py:46:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/dwd_weather_warnings/sensor.py:49:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -5209,8 +5137,6 @@ ERROR homeassistant/components/ebox/sensor.py:136:9-13: Unexpected keyword argum ERROR homeassistant/components/ebusd/__init__.py:5:8-15: Could not find import of `ebusdpy` [missing-import] ERROR homeassistant/components/ebusd/sensor.py:94:41-59: Cannot set item in `dict[str, None]` [unsupported-operation] ERROR homeassistant/components/ecoal_boiler/__init__.py:5:1-46: Could not find import of `ecoaliface.simple` [missing-import] -ERROR homeassistant/components/ecobee/__init__.py:62:53-71: Argument `BoundMethod[Ecobee, (self: Ecobee) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/ecobee/__init__.py:71:52-78: Argument `BoundMethod[Ecobee, (self: Ecobee) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ecobee/binary_sensor.py:25:28-51: Argument `None` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type] ERROR homeassistant/components/ecobee/binary_sensor.py:27:25-45: Cannot index into `str` [bad-index] ERROR homeassistant/components/ecobee/binary_sensor.py:31:53-67: Cannot index into `str` [bad-index] @@ -5231,8 +5157,6 @@ ERROR homeassistant/components/ecobee/climate.py:908:36-47: Argument `str | None ERROR homeassistant/components/ecobee/climate.py:925:16-932:10: Returned type `list[str | None]` is not assignable to declared return type `list[str]` [bad-return] ERROR homeassistant/components/ecobee/climate.py:1040:36-45: Argument `Unknown | None` is not assignable to parameter `auto_away` with type `bool` in function `pyecobee.Ecobee.set_occupancy_modes` [bad-argument-type] ERROR homeassistant/components/ecobee/climate.py:1040:47-56: Argument `Unknown | None` is not assignable to parameter `follow_me` with type `bool` in function `pyecobee.Ecobee.set_occupancy_modes` [bad-argument-type] -ERROR homeassistant/components/ecobee/config_flow.py:33:55-79: Argument `BoundMethod[Ecobee, (self: Ecobee) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/ecobee/config_flow.py:52:55-82: Argument `BoundMethod[Ecobee, (self: Ecobee) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ecobee/config_flow.py:64:38-67:14: Argument `dict[str, str | None]` is not assignable to parameter `description_placeholders` with type `Mapping[str, str] | None` in function `homeassistant.config_entries.ConfigFlow.async_show_form` [bad-argument-type] ERROR homeassistant/components/ecobee/entity.py:36:16-70: Returned type `str` is not assignable to declared return type `dict[str, Any]` [bad-return] ERROR homeassistant/components/ecobee/humidifier.py:38:28-51: Argument `None` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type] @@ -5317,7 +5241,6 @@ ERROR homeassistant/components/ecoforest/switch.py:30:9-12: Unexpected keyword a ERROR homeassistant/components/ecoforest/switch.py:31:9-13: Unexpected keyword argument `name` in function `EcoforestSwitchEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/ecoforest/switch.py:56:5-23: Class member `EcoforestSwitchEntity.entity_description` overrides parent class `EcoforestEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/ecoforest/switch.py:56:5-23: Class member `EcoforestSwitchEntity.entity_description` overrides parent class `SwitchEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/econet/__init__.py:84:43-58: Argument `BoundMethod[EcoNetApiInterface, (self: EcoNetApiInterface) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/econet/binary_sensor.py:20:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/econet/binary_sensor.py:21:9-13: Unexpected keyword argument `name` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/econet/binary_sensor.py:25:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -5352,7 +5275,6 @@ ERROR homeassistant/components/econet/sensor.py:114:14-32: Class member `EcoNetS ERROR homeassistant/components/econet/sensor.py:125:16-40: Object of class `Equipment` has no attribute `energy_type` [missing-attribute] ERROR homeassistant/components/econet/switch.py:29:33-43: Argument `Equipment` is not assignable to parameter `thermostat` with type `Thermostat` in function `EcoNetSwitchAuxHeatOnly.__init__` [bad-argument-type] ERROR homeassistant/components/econet/water_heater.py:57:31-43: Argument `Equipment` is not assignable to parameter `water_heater` with type `WaterHeater` in function `EcoNetWaterHeater.__init__` [bad-argument-type] -ERROR homeassistant/components/ecovacs/__init__.py:38:43-78: Argument `BoundMethod[VacBot, (self: VacBot) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ecovacs/binary_sensor.py:43:9-12: Unexpected keyword argument `key` in function `EcovacsBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/ecovacs/binary_sensor.py:44:9-24: Unexpected keyword argument `translation_key` in function `EcovacsBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/ecovacs/binary_sensor.py:45:9-24: Unexpected keyword argument `entity_category` in function `EcovacsBinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -5952,7 +5874,6 @@ ERROR homeassistant/components/enigma2/coordinator.py:42:5-17: Class member `Eni ERROR homeassistant/components/enigma2/media_player.py:47:5-29: Class member `Enigma2Device._attr_supported_features` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/enigma2/media_player.py:170:18-29: Class member `Enigma2Device._attr_state` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/enocean/binary_sensor.py:65:14-32: Class member `EnOceanBinarySensor._attr_device_class` overrides parent class `EnOceanEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/enocean/config_flow.py:60:58-71: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/enocean/dongle.py:39:45-41:10: `() -> None` is not assignable to attribute `dispatcher_disconnect_handle` with type `None` [bad-assignment] ERROR homeassistant/components/enocean/light.py:72:27-56: `/` is not supported between `None` and `float` [unsupported-operation] ERROR homeassistant/components/enocean/sensor.py:56:5-8: Unexpected keyword argument `key` in function `EnOceanSensorEntityDescription.__init__` [unexpected-keyword] @@ -6254,8 +6175,6 @@ ERROR homeassistant/components/ephember/climate.py:10:1-19:2: Could not find imp ERROR homeassistant/components/ephember/climate.py:85:17-22: `ember` may be uninitialized [unbound-name] ERROR homeassistant/components/ephember/climate.py:91:28-33: `ember` may be uninitialized [unbound-name] ERROR homeassistant/components/ephember/climate.py:196:23-76: No matching overload found for function `getattr` called with arguments: (Unknown, str | None, None) [no-matching-overload] -ERROR homeassistant/components/epion/config_flow.py:32:67-82: Argument `BoundMethod[Epion, (self: Epion) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/epion/coordinator.py:40:17-43: Argument `BoundMethod[Epion, (self: Epion) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/epion/sensor.py:32:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/epion/sensor.py:39:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/epion/sensor.py:46:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -6395,7 +6314,6 @@ ERROR homeassistant/components/ezviz/button.py:93:5-23: Class member `EzvizButto ERROR homeassistant/components/ezviz/camera.py:142:18-42: Class member `EzvizCamera._attr_supported_features` overrides parent class `EzvizEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/ezviz/config_flow.py:132:47-134:10: Unpacked argument `tuple[Unknown]` is not assignable to parameter `*args` with type `tuple[str, str, int]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ezviz/config_flow.py:151:9-31: Class member `EzvizConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] -ERROR homeassistant/components/ezviz/coordinator.py:57:21-51: Argument `BoundMethod[EzvizClient, (self: EzvizClient) -> dict[Any, Any]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ezviz/image.py:25:5-8: Unexpected keyword argument `key` in function `homeassistant.components.image.ImageEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/ezviz/image.py:26:5-20: Unexpected keyword argument `translation_key` in function `homeassistant.components.image.ImageEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/ezviz/light.py:78:58-82:18: Unpacked argument `tuple[str, int]` is not assignable to parameter `*args` with type `tuple[str, int, int, int]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] @@ -6498,7 +6416,6 @@ ERROR homeassistant/components/fastdotcom/sensor.py:33:5-23: Class member `Speed ERROR homeassistant/components/feedreader/config_flow.py:35:45-68: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[Unknown, Unknown | None, Unknown | None, Unknown | None, Unknown | None, Unknown | None, Unknown | None, Unknown | None, Unknown | None, Unknown | None]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/feedreader/config_flow.py:45:9-31: Class member `FeedReaderConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/feedreader/coordinator.py:39:5-17: Class member `FeedReaderCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/feedreader/coordinator.py:81:55-66: Argument `() -> FeedParserDict` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/feedreader/coordinator.py:161:13-31: Object of class `FeedParserDict` has no attribute `entries` [missing-attribute] ERROR homeassistant/components/feedreader/event.py:88:35-46: `description` may be uninitialized [unbound-name] ERROR homeassistant/components/feedreader/event.py:89:29-34: `title` may be uninitialized [unbound-name] @@ -6620,15 +6537,10 @@ ERROR homeassistant/components/fido/sensor.py:167:9-13: Unexpected keyword argum ERROR homeassistant/components/fido/sensor.py:169:9-13: Unexpected keyword argument `icon` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/file/config_flow.py:76:9-31: Class member `FileConfigFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/file/sensor.py:76:24-28: `data` may be uninitialized [unbound-name] -ERROR homeassistant/components/file_upload/__init__.py:86:54-70: Argument `() -> Path` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/file_upload/__init__.py:147:39-47: `filename` is uninitialized [unbound-name] ERROR homeassistant/components/file_upload/__init__.py:165:19-38: `/` is not supported between `Path` and `None` [unsupported-operation] -ERROR homeassistant/components/file_upload/__init__.py:176:47-67: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> None` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/file_upload/__init__.py:198:43-51: `filename` is uninitialized [unbound-name] -ERROR homeassistant/components/file_upload/__init__.py:217:13-70: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/filesize/coordinator.py:26:5-17: Class member `FileSizeCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/filesize/coordinator.py:62:60-79: Argument `BoundMethod[Self@FileSizeCoordinator, (self: Self@FileSizeCoordinator) -> Path]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/filesize/coordinator.py:66:59-71: Argument `BoundMethod[Self@FileSizeCoordinator, (self: Self@FileSizeCoordinator) -> stat_result]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/filesize/sensor.py:27:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/filesize/sensor.py:28:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/filesize/sensor.py:34:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -6657,11 +6569,6 @@ ERROR homeassistant/components/fireservicerota/config_flow.py:73:65-88: Object o ERROR homeassistant/components/fireservicerota/config_flow.py:93:53-58: Argument `ConfigEntry[Any] | None` is not assignable to parameter `entry` with type `ConfigEntry[Any]` in function `homeassistant.config_entries.ConfigEntries.async_update_entry` [bad-argument-type] ERROR homeassistant/components/fireservicerota/config_flow.py:94:53-67: Object of class `NoneType` has no attribute `entry_id` [missing-attribute] ERROR homeassistant/components/fireservicerota/coordinator.py:37:5-17: Class member `FireServiceUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/fireservicerota/coordinator.py:81:17-41: Argument `BoundMethod[FireServiceRota, (self: FireServiceRota) -> dict[Unknown, Unknown]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fireservicerota/coordinator.py:167:49-78: Argument `BoundMethod[FireServiceRotaWebSocket, (self: FireServiceRotaWebSocket) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fireservicerota/coordinator.py:177:53-81: Argument `BoundMethod[FireServiceRotaWebSocket, (self: FireServiceRotaWebSocket) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fireservicerota/coordinator.py:182:57-86: Argument `BoundMethod[FireServiceRotaWebSocket, (self: FireServiceRotaWebSocket) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fireservicerota/coordinator.py:226:49-77: Argument `BoundMethod[FireServiceRotaWebSocket, (self: FireServiceRotaWebSocket) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/firmata/__init__.py:142:25-31: `DOMAIN` may be uninitialized [unbound-name] ERROR homeassistant/components/firmata/__init__.py:145:56-62: `DOMAIN` may be uninitialized [unbound-name] ERROR homeassistant/components/firmata/__init__.py:154:21-27: `DOMAIN` may be uninitialized [unbound-name] @@ -6673,7 +6580,6 @@ ERROR homeassistant/components/firmata/pin.py:100:5-11: Class member `FirmataPWM ERROR homeassistant/components/firmata/pin.py:149:5-11: Class member `FirmataBinaryDigitalInput._state` overrides parent class `FirmataBoardPin` in an inconsistent manner [bad-override] ERROR homeassistant/components/firmata/pin.py:218:5-16: Class member `FirmataAnalogInput._analog_pin` overrides parent class `FirmataBoardPin` in an inconsistent manner [bad-override] ERROR homeassistant/components/firmata/pin.py:219:5-11: Class member `FirmataAnalogInput._state` overrides parent class `FirmataBoardPin` in an inconsistent manner [bad-override] -ERROR homeassistant/components/fitbit/api.py:132:60-64: Argument `() -> _T` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/fitbit/application_credentials.py:64:40-44: `resp` is uninitialized [unbound-name] ERROR homeassistant/components/fitbit/coordinator.py:29:5-17: Class member `FitbitDeviceCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/fitbit/sensor.py:152:9-12: Unexpected keyword argument `key` in function `FitbitSensorEntityDescription.__init__` [unexpected-keyword] @@ -6938,18 +6844,12 @@ ERROR homeassistant/components/flexit_bacnet/switch.py:80:5-23: Class member `Fl ERROR homeassistant/components/flexit_bacnet/switch.py:80:5-23: Class member `FlexitSwitch.entity_description` overrides parent class `SwitchEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/flic/binary_sensor.py:85:37-56: `(address: Unknown) -> Unknown` is not assignable to attribute `on_new_verified_button` with type `(bd_addr: Unknown) -> None` [bad-assignment] ERROR homeassistant/components/flic/binary_sensor.py:120:32-55: `(scan_wizard: Unknown, result: Unknown, address: Unknown, name: Unknown) -> Unknown` is not assignable to attribute `on_completed` with type `(scan_wizard: Unknown, result: Unknown, bd_addr: Unknown, name: Unknown) -> None` [bad-assignment] -ERROR homeassistant/components/flipr/__init__.py:33:45-66: Argument `BoundMethod[FliprAPIRestClient, (self: FliprAPIRestClient) -> dict[str, list[str]]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/flipr/__init__.py:38:21-33: Cannot index into `object` [bad-index] -ERROR homeassistant/components/flipr/__init__.py:44:19-29: Cannot index into `object` [bad-index] ERROR homeassistant/components/flipr/binary_sensor.py:18:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/flipr/binary_sensor.py:19:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/flipr/binary_sensor.py:23:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/flipr/binary_sensor.py:24:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/flipr/binary_sensor.py:46:7-24: Field `entity_description` is declared `EntityDescription` in ancestor `class FliprEntity: ... `, which is not assignable to the type `BinarySensorEntityDescription` implied by multiple inheritance [inconsistent-inheritance] -ERROR homeassistant/components/flipr/config_flow.py:45:62-83: Argument `BoundMethod[FliprAPIRestClient, (self: FliprAPIRestClient) -> dict[str, list[str]]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/flipr/config_flow.py:57:24-36: Cannot index into `object` [bad-index] -ERROR homeassistant/components/flipr/config_flow.py:57:49-59: Cannot index into `object` [bad-index] ERROR homeassistant/components/flipr/coordinator.py:34:5-17: Class member `BaseDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/flipr/select.py:16:9-12: Unexpected keyword argument `key` in function `homeassistant.components.select.SelectEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/flipr/select.py:17:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.select.SelectEntityDescription.__init__` [unexpected-keyword] @@ -7002,11 +6902,8 @@ ERROR homeassistant/components/flume/binary_sensor.py:145:5-23: Class member `Fl ERROR homeassistant/components/flume/binary_sensor.py:145:5-23: Class member `FlumeConnectionBinarySensor.entity_description` overrides parent class `BinarySensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/flume/binary_sensor.py:147:5-23: Class member `FlumeConnectionBinarySensor._attr_device_class` overrides parent class `FlumeEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/flume/coordinator.py:41:5-17: Class member `FlumeDeviceDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/flume/coordinator.py:63:52-82: Argument `BoundMethod[FlumeData, (self: FlumeData) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/flume/coordinator.py:76:5-17: Class member `FlumeDeviceConnectionUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/flume/coordinator.py:107:52-77: Argument `BoundMethod[Self@FlumeDeviceConnectionUpdateCoordinator, (self: Self@FlumeDeviceConnectionUpdateCoordinator) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/flume/coordinator.py:115:5-17: Class member `FlumeNotificationDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/flume/coordinator.py:161:52-70: Argument `BoundMethod[Self@FlumeNotificationDataUpdateCoordinator, (self: Self@FlumeNotificationDataUpdateCoordinator) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/flume/sensor.py:34:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/flume/sensor.py:35:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/flume/sensor.py:41:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -7152,7 +7049,6 @@ ERROR homeassistant/components/forked_daapd/media_player.py:876:19-29: Object of ERROR homeassistant/components/fortios/device_tracker.py:12:1-34: Could not find import of `fortiosapi` [missing-import] ERROR homeassistant/components/foscam/camera.py:112:18-42: Class member `HassFoscamCamera._attr_supported_features` overrides parent class `FoscamEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/foscam/coordinator.py:54:5-17: Class member `FoscamCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/foscam/coordinator.py:212:59-82: Argument `BoundMethod[Self@FoscamCoordinator, (self: Self@FoscamCoordinator) -> FoscamDeviceInfo]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/foscam/number.py:30:9-12: Unexpected keyword argument `key` in function `FoscamNumberEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/foscam/number.py:31:9-24: Unexpected keyword argument `translation_key` in function `FoscamNumberEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/foscam/number.py:39:9-12: Unexpected keyword argument `key` in function `FoscamNumberEntityDescription.__init__` [unexpected-keyword] @@ -7245,7 +7141,6 @@ ERROR homeassistant/components/fritz/button.py:63:9-24: Unexpected keyword argum ERROR homeassistant/components/fritz/button.py:64:9-24: Unexpected keyword argument `entity_category` in function `FritzButtonDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/fritz/button.py:107:5-23: Class member `FritzButton.entity_description` overrides parent class `ButtonEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/fritz/config_flow.py:71:9-31: Class member `FritzBoxToolsFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] -ERROR homeassistant/components/fritz/config_flow.py:89:55-76: Argument `BoundMethod[Self@FritzBoxToolsFlowHandler, (self: Self@FritzBoxToolsFlowHandler) -> str | None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/fritz/config_flow.py:186:16-20: `uuid` may be uninitialized [unbound-name] ERROR homeassistant/components/fritz/config_flow.py:187:78-82: `uuid` may be uninitialized [unbound-name] ERROR homeassistant/components/fritz/config_flow.py:295:12-17: `error` may be uninitialized [unbound-name] @@ -7256,20 +7151,11 @@ ERROR homeassistant/components/fritz/coordinator.py:122:49-53: `None` is not ass ERROR homeassistant/components/fritz/coordinator.py:123:40-44: `None` is not assignable to attribute `fritz_hosts` with type `FritzHosts` [bad-assignment] ERROR homeassistant/components/fritz/coordinator.py:124:42-46: `None` is not assignable to attribute `fritz_status` with type `FritzStatus` [bad-assignment] ERROR homeassistant/components/fritz/coordinator.py:125:38-42: `None` is not assignable to attribute `fritz_call` with type `FritzCall` [bad-assignment] -ERROR homeassistant/components/fritz/coordinator.py:149:48-58: Argument `BoundMethod[Self@FritzBoxTools, (self: Self@FritzBoxTools) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fritz/coordinator.py:273:17-43: Argument `BoundMethod[Self@FritzBoxTools, (self: Self@FritzBoxTools) -> dict[Unknown, Unknown]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fritz/coordinator.py:378:21-58: Argument `BoundMethod[FritzHosts, (self: FritzHosts) -> list[dict[Unknown, Unknown]]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fritz/coordinator.py:382:21-52: Argument `BoundMethod[FritzHosts, (self: FritzHosts) -> list[dict[Unknown, Unknown]]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fritz/coordinator.py:441:55-79: Argument `BoundMethod[Self@FritzBoxTools, (self: Self@FritzBoxTools) -> tuple[bool, str | None, str | None]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] +ERROR homeassistant/components/fritz/coordinator.py:377:36-379:18: `list[dict[Unknown, Unknown]]` is not assignable to variable `hosts_attributes` with type `list[TypedDict[HostAttributes]]` [bad-assignment] +ERROR homeassistant/components/fritz/coordinator.py:381:30-383:18: `list[dict[Unknown, Unknown]]` is not assignable to variable `hosts_info` with type `list[TypedDict[HostInfo]]` [bad-assignment] ERROR homeassistant/components/fritz/coordinator.py:548:21-33: Object of class `str` has no attribute `get` [missing-attribute] ERROR homeassistant/components/fritz/coordinator.py:571:21-33: Object of class `str` has no attribute `get` [missing-attribute] -ERROR homeassistant/components/fritz/coordinator.py:610:48-70: Argument `BoundMethod[FritzConnection, (self: FritzConnection) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fritz/coordinator.py:614:48-73: Argument `BoundMethod[FritzConnection, (self: FritzConnection) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fritz/coordinator.py:630:52-74: Argument `BoundMethod[FritzCall, (self: FritzCall) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fritz/coordinator.py:739:60-78: Argument `() -> str` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fritz/diagnostics.py:51:17-62: Argument `BoundMethod[FritzStatus, (self: FritzStatus) -> list[int]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/fritz/entity.py:96:5-23: Class member `FritzBoxBaseCoordinatorEntity.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/fritz/image.py:34:9-46: Argument `BoundMethod[FritzGuestWLAN, (self: FritzGuestWLAN) -> dict[Unknown, Unknown]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/fritz/image.py:71:13-64: Object of class `FritzGuestWLAN` has no attribute `get_wifi_qr_code` [missing-attribute] ERROR homeassistant/components/fritz/sensor.py:162:9-12: Unexpected keyword argument `key` in function `FritzSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/fritz/sensor.py:163:9-24: Unexpected keyword argument `translation_key` in function `FritzSensorEntityDescription.__init__` [unexpected-keyword] @@ -7330,7 +7216,6 @@ ERROR homeassistant/components/fritz/update.py:52:5-23: Class member `FritzBoxUp ERROR homeassistant/components/fritz/update.py:52:5-23: Class member `FritzBoxUpdateEntity.entity_description` overrides parent class `UpdateEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/fritz/update.py:61:13-16: Unexpected keyword argument `key` in function `FritzUpdateEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/fritz/update.py:61:27-31: Unexpected keyword argument `name` in function `FritzUpdateEntityDescription.__init__` [unexpected-keyword] -ERROR homeassistant/components/fritzbox/__init__.py:60:39-70: Argument `BoundMethod[Fritzhome, (self: Fritzhome) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/fritzbox/binary_sensor.py:39:9-12: Unexpected keyword argument `key` in function `FritzBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/fritzbox/binary_sensor.py:40:9-24: Unexpected keyword argument `translation_key` in function `FritzBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/fritzbox/binary_sensor.py:46:9-12: Unexpected keyword argument `key` in function `FritzBinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -7352,15 +7237,10 @@ ERROR homeassistant/components/fritzbox/binary_sensor.py:120:5-23: Class member ERROR homeassistant/components/fritzbox/binary_sensor.py:120:5-23: Class member `FritzboxBinarySensor.entity_description` overrides parent class `BinarySensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/fritzbox/button.py:40:7-23: Field `entity_description` is declared `EntityDescription` in ancestor `class FritzBoxEntity: ... `, which is not assignable to the type `ButtonEntityDescription` implied by multiple inheritance [inconsistent-inheritance] -ERROR homeassistant/components/fritzbox/button.py:61:48-67: Argument `BoundMethod[Self@FritzBoxTemplate, (self: Self@FritzBoxTemplate) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/fritzbox/climate.py:94:14-38: Class member `FritzboxThermostat._attr_supported_features` overrides parent class `FritzBoxDeviceEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/fritzbox/config_flow.py:70:55-72: Argument `BoundMethod[Self@FritzboxConfigFlow, (self: Self@FritzboxConfigFlow) -> str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/fritzbox/config_flow.py:140:20-24: `uuid` may be uninitialized [unbound-name] ERROR homeassistant/components/fritzbox/config_flow.py:141:82-86: `uuid` may be uninitialized [unbound-name] ERROR homeassistant/components/fritzbox/coordinator.py:36:5-17: Class member `FritzboxDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/fritzbox/coordinator.py:66:52-68: Argument `BoundMethod[Fritzhome, (self: Fritzhome) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fritzbox/coordinator.py:73:13-37: Argument `BoundMethod[Fritzhome, (self: Fritzhome) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fritzbox/coordinator.py:170:59-85: Argument `BoundMethod[Self@FritzboxDataUpdateCoordinator, (self: Self@FritzboxDataUpdateCoordinator) -> FritzboxCoordinatorData]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/fritzbox/cover.py:52:5-23: Class member `FritzboxCover._attr_device_class` overrides parent class `FritzBoxDeviceEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/fritzbox/cover.py:53:5-29: Class member `FritzboxCover._attr_supported_features` overrides parent class `FritzBoxDeviceEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/fritzbox/diagnostics.py:27:33-30:6: `dict[str, FritzhomeDevice | FritzhomeTemplate]` is not assignable to `dict[str, dict[Unknown, Unknown]]` [bad-assignment] @@ -7395,13 +7275,9 @@ ERROR homeassistant/components/fritzbox/sensor.py:219:9-24: Unexpected keyword a ERROR homeassistant/components/fritzbox/sensor.py:220:9-24: Unexpected keyword argument `entity_category` in function `FritzSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/fritzbox/sensor.py:257:5-23: Class member `FritzBoxSensor.entity_description` overrides parent class `FritzBoxDeviceEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/fritzbox/sensor.py:257:5-23: Class member `FritzBoxSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/fritzbox_callmonitor/__init__.py:34:43-76: Argument `BoundMethod[FritzBoxPhonebook, (self: FritzBoxPhonebook) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/fritzbox_callmonitor/base.py:84:22-49: Object of class `NoneType` has no attribute `contacts` [missing-attribute] ERROR homeassistant/components/fritzbox_callmonitor/base.py:103:23-36: Type `None` is not iterable [not-iterable] ERROR homeassistant/components/fritzbox_callmonitor/config_flow.py:133:9-31: Class member `FritzBoxCallMonitorConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] -ERROR homeassistant/components/fritzbox_callmonitor/config_flow.py:154:57-74: Argument `BoundMethod[Self@FritzBoxCallMonitorConfigFlow, (self: Self@FritzBoxCallMonitorConfigFlow) -> ConnectResult]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fritzbox_callmonitor/config_flow.py:245:61-78: Argument `BoundMethod[Self@FritzBoxCallMonitorConfigFlow, (self: Self@FritzBoxCallMonitorConfigFlow) -> ConnectResult]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/fritzbox_callmonitor/sensor.py:116:48-72: Argument `BoundMethod[Self@FritzBoxCallSensor, (self: Self@FritzBoxCallSensor) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/fronius/coordinator.py:70:26-41: Class member `FroniusCoordinatorBase.update_interval` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/fronius/coordinator.py:70:44-63: `timedelta` is not assignable to attribute `update_interval` with type `(self: Self@FroniusCoordinatorBase, value: timedelta | None) -> None` [bad-assignment] ERROR homeassistant/components/fronius/coordinator.py:79:40-61: `timedelta` is not assignable to attribute `update_interval` with type `(self: Self@FroniusCoordinatorBase, value: timedelta | None) -> None` [bad-assignment] @@ -7576,7 +7452,6 @@ ERROR homeassistant/components/fronius/sensor.py:868:35-44: `meter_uid` may be u ERROR homeassistant/components/frontend/__init__.py:541:18-28: `theme_data` may be uninitialized [unbound-name] ERROR homeassistant/components/frontend/__init__.py:542:23-33: `theme_data` may be uninitialized [unbound-name] ERROR homeassistant/components/frontend/__init__.py:717:16-19: `tpl` may be uninitialized [unbound-name] -ERROR homeassistant/components/frontend/__init__.py:727:13-30: Argument `BoundMethod[Self@IndexView, (self: Self@IndexView) -> Template]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/frontend/storage.py:35:12-17: `store` may be uninitialized [unbound-name] ERROR homeassistant/components/frontier_silicon/browse_media.py:36:15-26: Argument `str | None` is not assignable to parameter `title` with type `str` in function `homeassistant.components.media_player.browse_media.BrowseMedia.__init__` [bad-argument-type] ERROR homeassistant/components/frontier_silicon/browse_media.py:138:36-40: Argument `dict[str, int | str | None]` is not assignable to parameter `item` with type `dict[str, str]` in function `_item_payload` [bad-argument-type] @@ -8175,14 +8050,12 @@ ERROR homeassistant/components/google/api.py:57:44-62: Object of class `Credenti ERROR homeassistant/components/google/api.py:60:29-47: Object of class `Credentials` has no attribute `access_token` [missing-attribute] ERROR homeassistant/components/google/api.py:61:30-49: Object of class `Credentials` has no attribute `refresh_token` [missing-attribute] ERROR homeassistant/components/google/api.py:62:31-43: Object of class `Credentials` has no attribute `scopes` [missing-attribute] -ERROR homeassistant/components/google/api.py:134:67-81: Argument `BoundMethod[Self@DeviceFlow, (self: Self@DeviceFlow) -> Credentials]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/google/calendar.py:96:5-9: Class member `GoogleCalendarEntityDescription.name` overrides parent class `CalendarEntityDescription` in an inconsistent manner [bad-override] ERROR homeassistant/components/google/calendar.py:152:13-16: Unexpected keyword argument `key` in function `GoogleCalendarEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/google/calendar.py:160:20-26: `search` may be uninitialized [unbound-name] ERROR homeassistant/components/google/calendar.py:162:13-44: Unexpected keyword argument `entity_registry_enabled_default` in function `GoogleCalendarEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/google/calendar.py:169:13-19: `search` may be uninitialized [unbound-name] ERROR homeassistant/components/google/calendar.py:284:53-287:18: Missing argument `calendarId` in function `gcal_sync.api.SyncEventsRequest.__init__` [missing-argument] -ERROR homeassistant/components/google/calendar.py:319:43-69: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/google/calendar.py:340:5-23: Class member `GoogleCalendarEntity.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/google/calendar.py:340:5-23: Class member `GoogleCalendarEntity.entity_description` overrides parent class `CalendarEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/google/calendar.py:449:27-39: `offset_value` may be uninitialized [unbound-name] @@ -8246,7 +8119,6 @@ ERROR homeassistant/components/google_assistant/trait.py:2645:9-18: Class member ERROR homeassistant/components/google_assistant/trait.py:2672:9-18: Class member `ChannelTrait.supported` overrides parent class `_Trait` in an inconsistent manner [bad-param-name-override] ERROR homeassistant/components/google_assistant/trait.py:2771:9-18: Class member `SensorStateTrait.supported` overrides parent class `_Trait` in an inconsistent manner [bad-param-name-override] ERROR homeassistant/components/google_assistant_sdk/helpers.py:109:29-67: Object of class `NoneType` has no attribute `format` [missing-attribute] -ERROR homeassistant/components/google_cloud/config_flow.py:115:71-85: Argument `() -> dict[str, Any]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/google_cloud/config_flow.py:134:9-31: Class member `GoogleCloudConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/google_cloud/tts.py:63:8-16: `key_file` may be uninitialized [unbound-name] ERROR homeassistant/components/google_cloud/tts.py:65:13-21: `key_file` may be uninitialized [unbound-name] @@ -8258,9 +8130,6 @@ ERROR homeassistant/components/google_generative_ai_conversation/entity.py:395:2 ERROR homeassistant/components/google_generative_ai_conversation/entity.py:402:43-56: `content_index` may be uninitialized [unbound-name] ERROR homeassistant/components/google_generative_ai_conversation/entity.py:409:25-38: `content_index` may be uninitialized [unbound-name] ERROR homeassistant/components/google_generative_ai_conversation/entity.py:422:39-54: `tool_call_index` may be uninitialized [unbound-name] -ERROR homeassistant/components/google_generative_ai_conversation/entity.py:728:54-66: Argument `() -> list[File]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/google_mail/config_flow.py:64:56-68: Argument `() -> str` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/google_mail/config_flow.py:70:50-55: Argument `str | None` is not assignable to parameter `title` with type `str` in function `homeassistant.config_entries.ConfigFlow.async_create_entry` [bad-argument-type] ERROR homeassistant/components/google_mail/notify.py:58:17-55: Object of class `Resource` has no attribute `users` [missing-attribute] ERROR homeassistant/components/google_mail/notify.py:62:20-28: `to_addrs` may be uninitialized [unbound-name] ERROR homeassistant/components/google_mail/sensor.py:23:5-8: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -8341,8 +8210,6 @@ ERROR homeassistant/components/govee_light_local/light.py:216:72-78: Argument `i ERROR homeassistant/components/govee_light_local/light.py:216:72-78: Argument `int | None` is not assignable to parameter `green` with type `int` in function `homeassistant.components.govee_light_local.coordinator.GoveeLocalApiCoordinator.set_rgb_color` [bad-argument-type] ERROR homeassistant/components/govee_light_local/light.py:216:72-78: Argument `int | None` is not assignable to parameter `blue` with type `int` in function `homeassistant.components.govee_light_local.coordinator.GoveeLocalApiCoordinator.set_rgb_color` [bad-argument-type] ERROR homeassistant/components/govee_light_local/light.py:218:74-80: Argument `int | None` is not assignable to parameter `temperature` with type `int` in function `homeassistant.components.govee_light_local.coordinator.GoveeLocalApiCoordinator.set_temperature` [bad-argument-type] -ERROR homeassistant/components/gpsd/__init__.py:27:39-49: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/gpsd/__init__.py:39:13-43:14: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/gpsd/__init__.py:46:12-21: `unload_ok` may be uninitialized [unbound-name] ERROR homeassistant/components/gpsd/sensor.py:51:18-52: Object of class `DataStream` has no attribute `satellites` [missing-attribute] ERROR homeassistant/components/gpsd/sensor.py:57:18-52: Object of class `DataStream` has no attribute `satellites` [missing-attribute] @@ -8434,9 +8301,7 @@ ERROR homeassistant/components/group/sensor.py:365:14-32: Class member `SensorGr ERROR homeassistant/components/group/valve.py:262:14-38: Class member `ValveGroup._attr_supported_features` overrides parent class `GroupEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/growatt_server/__init__.py:40:53-67: `login_response` is uninitialized [unbound-name] ERROR homeassistant/components/growatt_server/config_flow.py:76:68-78:14: Unpacked argument `tuple[Any, Any]` is not assignable to parameter `*args` with type `tuple[Unknown, Unknown, bool | Unknown]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/growatt_server/config_flow.py:112:69-88: Argument `BoundMethod[OpenApiV1, (self: OpenApiV1) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/growatt_server/coordinator.py:61:24-63:14: `GrowattApi` is not assignable to attribute `api` with type `OpenApiV1` [bad-assignment] -ERROR homeassistant/components/growatt_server/coordinator.py:181:59-81: Argument `BoundMethod[Self@GrowattCoordinator, (self: Self@GrowattCoordinator) -> dict[str, Any]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/growatt_server/number.py:41:9-12: Unexpected keyword argument `key` in function `GrowattNumberEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/growatt_server/number.py:42:9-24: Unexpected keyword argument `translation_key` in function `GrowattNumberEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/growatt_server/number.py:51:9-12: Unexpected keyword argument `key` in function `GrowattNumberEntityDescription.__init__` [unexpected-keyword] @@ -8984,7 +8849,6 @@ ERROR homeassistant/components/hardkernel/hardware.py:40:33-38: `board` is unini ERROR homeassistant/components/hardkernel/hardware.py:42:23-28: `board` is uninitialized [unbound-name] ERROR homeassistant/components/hardkernel/hardware.py:47:34-39: `board` is uninitialized [unbound-name] ERROR homeassistant/components/hardkernel/hardware.py:47:77-82: `board` is uninitialized [unbound-name] -ERROR homeassistant/components/hardware/__init__.py:30:57-80: Argument `type[PsutilWrapper]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/hardware/models.py:26:16-25: Expected a type form, got instance of `Module[psutil_home_assistant]` [not-a-type] ERROR homeassistant/components/hardware/models.py:67:50-68: Function declared to return `list[HardwareInfo]` but is missing an explicit `return` [bad-return] ERROR homeassistant/components/harman_kardon_avr/media_player.py:5:8-13: Could not find import of `hkavr` [missing-import] @@ -9000,8 +8864,6 @@ ERROR homeassistant/components/harmony/data.py:113:68-79: Unpacked keyword argum ERROR homeassistant/components/harmony/data.py:234:28-37: Argument `str` is not assignable to parameter `device` with type `int` in function `aioharmony.const.SendCommandDevice.__new__` [bad-argument-type] ERROR homeassistant/components/harmony/remote.py:88:5-29: Class member `HarmonyRemote._attr_supported_features` overrides parent class `HarmonyEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/harmony/remote.py:88:5-29: Class member `HarmonyRemote._attr_supported_features` overrides parent class `RestoreEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/harmony/remote.py:213:48-70: Argument `BoundMethod[Self@HarmonyRemote, (self: Self@HarmonyRemote) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/harmony/remote.py:259:52-74: Argument `BoundMethod[Self@HarmonyRemote, (self: Self@HarmonyRemote) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/harmony/select.py:70:39-58: Argument `HassJob[[activity_info: tuple[Unknown, ...]], None]` is not assignable to parameter `activity_starting` with type `HassJob[[tuple[Unknown, ...]], Any] | None` in function `homeassistant.components.harmony.subscriber.HarmonyCallback.__new__` [bad-argument-type] ERROR homeassistant/components/harmony/select.py:71:38-57: Argument `HassJob[[activity_info: tuple[Unknown, ...]], None]` is not assignable to parameter `activity_started` with type `HassJob[[tuple[Unknown, ...]], Any] | None` in function `homeassistant.components.harmony.subscriber.HarmonyCallback.__new__` [bad-argument-type] ERROR homeassistant/components/hassio/__init__.py:500:12-16: `user` may be uninitialized [unbound-name] @@ -9568,7 +9430,6 @@ ERROR homeassistant/components/homeassistant_hardware/update.py:88:5-23: Class m ERROR homeassistant/components/homeassistant_hardware/update.py:92:5-29: Class member `BaseFirmwareUpdateEntity._attr_supported_features` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/homeassistant_hardware/update.py:233:22-52: Object of class `NoneType` has no attribute `metadata` [missing-attribute] ERROR homeassistant/components/homeassistant_hardware/update.py:236:42-77: Object of class `NoneType` has no attribute `release_notes` [missing-attribute] -ERROR homeassistant/components/homeassistant_sky_connect/__init__.py:166:66-83: Argument `() -> Sequence[USBDevice]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/homeassistant_sky_connect/update.py:43:9-12: Unexpected keyword argument `key` in function `homeassistant.components.homeassistant_hardware.update.FirmwareUpdateEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/homeassistant_sky_connect/update.py:54:9-12: Unexpected keyword argument `key` in function `homeassistant.components.homeassistant_hardware.update.FirmwareUpdateEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/homeassistant_sky_connect/update.py:65:9-12: Unexpected keyword argument `key` in function `homeassistant.components.homeassistant_hardware.update.FirmwareUpdateEntityDescription.__init__` [unexpected-keyword] @@ -9770,8 +9631,6 @@ ERROR homeassistant/components/homee/switch.py:103:5-23: Class member `HomeeSwit ERROR homeassistant/components/homee/switch.py:103:5-23: Class member `HomeeSwitch.entity_description` overrides parent class `SwitchEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/homee/valve.py:23:9-12: Unexpected keyword argument `key` in function `homeassistant.components.valve.ValveEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/homee/valve.py:66:14-32: Class member `HomeeValve.entity_description` overrides parent class `HomeeEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/homekit/__init__.py:294:39-49: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/homekit/__init__.py:898:56-75: Argument `BoundMethod[HomeDriver, (self: HomeDriver) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/homekit/__init__.py:913:56-77: Argument `Accessory | None` is not assignable to parameter `accessory` with type `Accessory` in function `homeassistant.components.homekit.util.accessory_friendly_name` [bad-argument-type] ERROR homeassistant/components/homekit/__init__.py:915:13-42: Object of class `NoneType` has no attribute `xhm_uri` [missing-attribute] ERROR homeassistant/components/homekit/__init__.py:964:61-82: Argument `Accessory | None` is not assignable to parameter `accessory` with type `Accessory` in function `homeassistant.components.homekit.util.accessory_friendly_name` [bad-argument-type] @@ -10505,8 +10364,6 @@ ERROR homeassistant/components/homewizard/switch.py:59:9-24: Unexpected keyword ERROR homeassistant/components/homewizard/switch.py:60:9-24: Unexpected keyword argument `entity_category` in function `HomeWizardSwitchEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/homewizard/switch.py:85:5-23: Class member `HomeWizardSwitchEntity.entity_description` overrides parent class `HomeWizardEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/homewizard/switch.py:85:5-23: Class member `HomeWizardSwitchEntity.entity_description` overrides parent class `SwitchEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/homeworks/__init__.py:159:43-61: Argument `BoundMethod[Homeworks, (self: Homeworks) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/homeworks/__init__.py:190:43-77: Argument `BoundMethod[Homeworks, (self: Homeworks) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/homeworks/__init__.py:192:12-21: `unload_ok` may be uninitialized [unbound-name] ERROR homeassistant/components/homeworks/config_flow.py:662:9-31: Class member `HomeworksConfigFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/honeywell/__init__.py:61:12-33: Module `aiosomecomfort.device` exists, but was not imported explicitly. You are relying on other modules to load it. [implicit-import] @@ -10539,7 +10396,6 @@ ERROR homeassistant/components/hp_ilo/sensor.py:8:8-13: Could not find import of ERROR homeassistant/components/html5/notify.py:481:13-35: Object of class `str` has no attribute `get` [missing-attribute] ERROR homeassistant/components/html5/notify.py:484:13-41: Cannot set item in `str` [unsupported-operation] ERROR homeassistant/components/html5/notify.py:501:28-35: `targets` may be uninitialized [unbound-name] -ERROR homeassistant/components/http/__init__.py:428:17-41: Argument `BoundMethod[Self@HomeAssistantHTTP, (self: Self@HomeAssistantHTTP) -> SSLContext | None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/http/auth.py:82:44-50: `secret` may be uninitialized [unbound-name] ERROR homeassistant/components/http/auth.py:130:26-30: `data` may be uninitialized [unbound-name] ERROR homeassistant/components/http/auth.py:131:47-51: `data` may be uninitialized [unbound-name] @@ -10551,9 +10407,6 @@ ERROR homeassistant/components/http/ban.py:218:59-220:14: Unpacked argument `tup ERROR homeassistant/components/http/security_filter.py:53:16-24: `unquoted` may be uninitialized [unbound-name] ERROR homeassistant/components/http/static.py:42:37-84: `str` is not assignable to attribute `content_type` with type `(self: FileResponse, value: str) -> None` [bad-assignment] ERROR homeassistant/components/http/web_runner.py:58:15-28: Method `start` inherited from class `BaseSite` has no implementation and cannot be accessed via `super()` [missing-attribute] -ERROR homeassistant/components/huawei_lte/__init__.py:309:56-64: Argument `() -> Connection` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/huawei_lte/__init__.py:319:39-52: Argument `BoundMethod[Router, (self: Router) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/huawei_lte/__init__.py:364:13-52: Argument `BoundMethod[WLan, (self: WLan) -> dict[str, Any]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/huawei_lte/__init__.py:485:73-76: `url` may be uninitialized [unbound-name] ERROR homeassistant/components/huawei_lte/binary_sensor.py:137:17-32: Cannot index into `dict[str, str]` [bad-index] ERROR homeassistant/components/huawei_lte/binary_sensor.py:161:5-26: Class member `HuaweiLteWifiStatusBinarySensor._attr_translation_key` overrides parent class `HuaweiLteBaseWifiStatusBinarySensor` in an inconsistent manner [bad-override] @@ -10566,9 +10419,7 @@ ERROR homeassistant/components/huawei_lte/button.py:74:9-24: Unexpected keyword ERROR homeassistant/components/huawei_lte/button.py:89:9-12: Unexpected keyword argument `key` in function `homeassistant.components.button.ButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/huawei_lte/button.py:91:9-24: Unexpected keyword argument `entity_category` in function `homeassistant.components.button.ButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/huawei_lte/config_flow.py:78:9-31: Class member `HuaweiLteConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] -ERROR homeassistant/components/huawei_lte/config_flow.py:169:59-74: Argument `() -> Connection` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/huawei_lte/config_flow.py:309:37-40: Argument `str | None` is not assignable to parameter `url` with type `str` in function `huawei_lte_api.Connection.Connection.__init__` [bad-argument-type] -ERROR homeassistant/components/huawei_lte/config_flow.py:317:55-75: Argument `() -> bool` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/huawei_lte/select.py:47:9-12: Unexpected keyword argument `key` in function `HuaweiSelectEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/huawei_lte/select.py:48:9-24: Unexpected keyword argument `entity_category` in function `HuaweiSelectEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/huawei_lte/select.py:49:9-24: Unexpected keyword argument `translation_key` in function `HuaweiSelectEntityDescription.__init__` [unexpected-keyword] @@ -11603,11 +11454,8 @@ ERROR homeassistant/components/hyperion/config_flow.py:427:9-31: Class member `H ERROR homeassistant/components/hyperion/sensor.py:47:5-8: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/hyperion/sensor.py:48:5-20: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/hyperion/sensor.py:49:5-9: Unexpected keyword argument `icon` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] -ERROR homeassistant/components/ialarm/__init__.py:26:53-67: Argument `BoundMethod[IAlarm, (self: IAlarm) -> str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ialarm/alarm_control_panel.py:35:5-29: Class member `IAlarmPanel._attr_supported_features` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/ialarm/config_flow.py:27:46-60: Argument `BoundMethod[IAlarm, (self: IAlarm) -> str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ialarm/coordinator.py:28:5-17: Class member `IAlarmDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/ialarm/coordinator.py:62:56-73: Argument `BoundMethod[Self@IAlarmDataUpdateCoordinator, (self: Self@IAlarmDataUpdateCoordinator) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/iammeter/sensor.py:11:1-37: Could not find import of `iammeter.client` [missing-import] ERROR homeassistant/components/iammeter/sensor.py:164:5-23: Class member `IammeterSensor.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/iammeter/sensor.py:164:5-23: Class member `IammeterSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] @@ -11754,7 +11602,6 @@ ERROR homeassistant/components/ibeacon/sensor.py:62:9-24: Unexpected keyword arg ERROR homeassistant/components/ibeacon/sensor.py:63:9-40: Unexpected keyword argument `entity_registry_enabled_default` in function `IBeaconSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/ibeacon/sensor.py:103:5-23: Class member `IBeaconSensorEntity.entity_description` overrides parent class `IBeaconEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/ibeacon/sensor.py:103:5-23: Class member `IBeaconSensorEntity.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/icloud/__init__.py:61:39-52: Argument `BoundMethod[IcloudAccount, (self: IcloudAccount) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/icloud/account.py:148:35-69: Object of class `NoneType` has no attribute `items` [missing-attribute] ERROR homeassistant/components/icloud/account.py:223:26-76: Unpacked argument `tuple[HomeAssistant]` is not assignable to parameter `*args` with type `tuple[HomeAssistant, TypedDict[ConfigFlowContext] | None, dict[str, Any] | None]` in function `homeassistant.core.HomeAssistant.add_job` [bad-argument-type] ERROR homeassistant/components/icloud/account.py:450:54-58: Argument `None` is not assignable to parameter `newpasscode` with type `str` in function `pyicloud.services.findmyiphone.AppleDevice.lost_device` [bad-argument-type] @@ -11810,8 +11657,6 @@ ERROR homeassistant/components/ihc/sensor.py:57:18-36: Class member `IHCSensor._ ERROR homeassistant/components/ihc/switch.py:7:1-47: Could not find import of `ihcsdk.ihccontroller` [missing-import] ERROR homeassistant/components/ihc/util.py:5:1-47: Could not find import of `ihcsdk.ihccontroller` [missing-import] ERROR homeassistant/components/image/__init__.py:187:5-16: Class member `ImageEntity._attr_state` overrides parent class `Entity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/image/__init__.py:272:55-65: Argument `BoundMethod[Self@ImageEntity, (self: Self@ImageEntity) -> bytes | None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/image/__init__.py:428:50-72: Argument `() -> None` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_later` [bad-argument-type] ERROR homeassistant/components/image/media_source.py:29:5-9: Class member `ImageMediaSource.name` overrides parent class `MediaSource` in an inconsistent manner [bad-override] ERROR homeassistant/components/image_processing/__init__.py:125:5-17: Class member `ImageProcessingEntityDescription.device_class` overrides parent class `EntityDescription` in an inconsistent manner [bad-override] ERROR homeassistant/components/image_processing/__init__.py:133:5-23: Class member `ImageProcessingEntity.entity_description` overrides parent class `Entity` in an inconsistent manner [bad-override] @@ -12108,7 +11953,6 @@ ERROR homeassistant/components/insteon/services.py:188:39-43: Argument `None` is ERROR homeassistant/components/insteon/services.py:188:45-49: Argument `None` is not assignable to parameter `firmware` with type `int` in function `pyinsteon.managers.device_manager.DeviceManager.set_id` [bad-argument-type] ERROR homeassistant/components/insteon/switch.py:32:13-27: Argument `Unknown | None` is not assignable to parameter `discovery_info` with type `dict[str, Any]` in function `homeassistant.components.insteon.utils.async_add_insteon_entities` [bad-argument-type] ERROR homeassistant/components/insteon/utils.py:66:41-50: Cannot set item in `dict[str, Address | int]` [unsupported-operation] -ERROR homeassistant/components/insteon/utils.py:201:46-59: Argument `() -> dict[str, str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/integration/sensor.py:268:21-32: `unit_prefix` may be uninitialized [unbound-name] ERROR homeassistant/components/integration/sensor.py:601:60-72: Argument `State | None` is not assignable to parameter `source_state` with type `State` in function `IntegrationSensor._derive_and_set_attributes_from_state` [bad-argument-type] ERROR homeassistant/components/integration/sensor.py:603:38-54: Argument `Decimal | None` is not assignable to parameter `constant_state` with type `Decimal` in function `_IntegrationMethod.calculate_area_with_one_state` [bad-argument-type] @@ -12680,10 +12524,7 @@ ERROR homeassistant/components/ista_ecotrend/__init__.py:26:9-16: Argument `Logg ERROR homeassistant/components/ista_ecotrend/config_flow.py:54:17-24: Argument `Logger` is not assignable to parameter `totp` with type `str | None` in function `pyecotrend_ista.pyecotrend_ista.PyEcotrendIsta.__init__` [bad-argument-type] ERROR homeassistant/components/ista_ecotrend/config_flow.py:57:56-66: Argument `BoundMethod[PyEcotrendIsta, (self: PyEcotrendIsta, **kwargs: Unknown) -> str | None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ista_ecotrend/config_flow.py:105:17-24: Argument `Logger` is not assignable to parameter `totp` with type `str | None` in function `pyecotrend_ista.pyecotrend_ista.PyEcotrendIsta.__init__` [bad-argument-type] -ERROR homeassistant/components/ista_ecotrend/config_flow.py:117:21-42: Argument `() -> set[str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ista_ecotrend/coordinator.py:27:5-17: Class member `IstaCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/ista_ecotrend/coordinator.py:47:67-83: Argument `BoundMethod[Self@IstaCoordinator, (self: Self@IstaCoordinator) -> dict[str, Any]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/ista_ecotrend/coordinator.py:66:59-84: Argument `BoundMethod[Self@IstaCoordinator, (self: Self@IstaCoordinator) -> dict[str, Any]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ista_ecotrend/sensor.py:74:9-12: Unexpected keyword argument `key` in function `IstaSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/ista_ecotrend/sensor.py:75:9-24: Unexpected keyword argument `translation_key` in function `IstaSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/ista_ecotrend/sensor.py:81:9-12: Unexpected keyword argument `key` in function `IstaSensorEntityDescription.__init__` [unexpected-keyword] @@ -13035,7 +12876,6 @@ ERROR homeassistant/components/jewish_calendar/binary_sensor.py:46:9-24: Unexpec ERROR homeassistant/components/jewish_calendar/binary_sensor.py:48:9-40: Unexpected keyword argument `entity_registry_enabled_default` in function `JewishCalendarBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/jewish_calendar/binary_sensor.py:70:5-23: Class member `JewishCalendarBinarySensor.entity_description` overrides parent class `JewishCalendarEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/jewish_calendar/binary_sensor.py:70:5-23: Class member `JewishCalendarBinarySensor.entity_description` overrides parent class `BinarySensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/jewish_calendar/config_flow.py:67:43-71: Argument `() -> set[str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/jewish_calendar/config_flow.py:91:9-31: Class member `JewishCalendarConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/jewish_calendar/sensor.py:62:9-12: Unexpected keyword argument `key` in function `JewishCalendarSensorDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/jewish_calendar/sensor.py:63:9-24: Unexpected keyword argument `translation_key` in function `JewishCalendarSensorDescription.__init__` [unexpected-keyword] @@ -13105,9 +12945,7 @@ ERROR homeassistant/components/jewish_calendar/sensor.py:265:5-23: Class member ERROR homeassistant/components/jewish_calendar/sensor.py:295:5-23: Class member `JewishCalendarTimeSensor.entity_description` overrides parent class `JewishCalendarBaseSensor` in an inconsistent manner [bad-override] ERROR homeassistant/components/joaoapps_join/__init__.py:5:1-13:2: Could not find import of `pyjoin` [missing-import] ERROR homeassistant/components/joaoapps_join/notify.py:7:1-50: Could not find import of `pyjoin` [missing-import] -ERROR homeassistant/components/justnimbus/config_flow.py:53:52-67: Argument `BoundMethod[JustNimbusClient, (self: JustNimbusClient) -> JustNimbusModel]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/justnimbus/coordinator.py:25:5-17: Class member `JustNimbusCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/justnimbus/coordinator.py:45:55-76: Argument `BoundMethod[JustNimbusClient, (self: JustNimbusClient) -> JustNimbusModel]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/justnimbus/sensor.py:39:9-12: Unexpected keyword argument `key` in function `JustNimbusEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/justnimbus/sensor.py:40:9-24: Unexpected keyword argument `translation_key` in function `JustNimbusEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/justnimbus/sensor.py:44:9-24: Unexpected keyword argument `entity_category` in function `JustNimbusEntityDescription.__init__` [unexpected-keyword] @@ -13227,15 +13065,12 @@ ERROR homeassistant/components/keba/sensor.py:77:17-20: Unexpected keyword argum ERROR homeassistant/components/keba/sensor.py:78:17-21: Unexpected keyword argument `name` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/keenetic_ndms2/config_flow.py:57:9-31: Class member `KeeneticFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/keenetic_ndms2/config_flow.py:75:21-25: Argument `bytes | str | Any` is not assignable to parameter `host` with type `str` in function `ndms2_client.connection.TelnetConnection.__init__` [bad-argument-type] -ERROR homeassistant/components/keenetic_ndms2/config_flow.py:85:21-44: Argument `BoundMethod[Client, (self: Client) -> RouterInfo]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/keenetic_ndms2/config_flow.py:187:16-36: Object of class `NoneType` has no attribute `lower` [missing-attribute] ERROR homeassistant/components/keenetic_ndms2/device_tracker.py:56:34-60: Argument `str | None` is not assignable to parameter `name` with type `str` in function `ndms2_client.client.Device.__new__` [bad-argument-type] ERROR homeassistant/components/keenetic_ndms2/device_tracker.py:57:32-36: Argument `None` is not assignable to parameter `ip` with type `str` in function `ndms2_client.client.Device.__new__` [bad-argument-type] ERROR homeassistant/components/keenetic_ndms2/device_tracker.py:58:39-43: Argument `None` is not assignable to parameter `interface` with type `str` in function `ndms2_client.client.Device.__new__` [bad-argument-type] ERROR homeassistant/components/keenetic_ndms2/router.py:129:26-74: `Task[Unknown]` is not assignable to attribute `_progress` with type `None` [bad-assignment] ERROR homeassistant/components/keenetic_ndms2/router.py:130:9-29: Type `None` is not awaitable [not-async] -ERROR homeassistant/components/keenetic_ndms2/router.py:136:48-68: Argument `BoundMethod[Self@KeeneticRouter, (self: Self@KeeneticRouter) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/keenetic_ndms2/router.py:150:52-76: Argument `BoundMethod[Self@KeeneticRouter, (self: Self@KeeneticRouter) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/keenetic_ndms2/router.py:168:9-36: Object of class `NoneType` has no attribute `disconnect` [missing-attribute] ERROR homeassistant/components/keenetic_ndms2/router.py:172:33-61: Object of class `NoneType` has no attribute `get_router_info` [missing-attribute] ERROR homeassistant/components/keenetic_ndms2/router.py:183:25-49: Object of class `NoneType` has no attribute `get_devices` [missing-attribute] @@ -13284,7 +13119,6 @@ ERROR homeassistant/components/keymitt_ble/config_flow.py:105:46-66: Argument `M ERROR homeassistant/components/keymitt_ble/config_flow.py:133:20-36: Argument `BLEDevice | None` is not assignable to parameter `device` with type `BLEDevice` in function `microbot.MicroBotApiClient.__init__` [bad-argument-type] ERROR homeassistant/components/kitchen_sink/backup.py:77:15-36: Class member `KitchenSinkBackupAgent.async_download_backup` overrides parent class `BackupAgent` in an inconsistent manner [bad-override] ERROR homeassistant/components/kitchen_sink/config_flow.py:35:9-31: Class member `KitchenSinkConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] -ERROR homeassistant/components/kitchen_sink/image.py:72:55-76: Argument `BoundMethod[Path, (self: Path) -> bytes]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/kiwi/lock.py:8:1-45: Could not find import of `kiwiki` [missing-import] ERROR homeassistant/components/kmtronic/config_flow.py:50:12-37: Module `aiohttp.client_exceptions` exists, but was not imported explicitly. You are relying on other modules to load it. [implicit-import] ERROR homeassistant/components/kmtronic/config_flow.py:52:12-37: Module `aiohttp.client_exceptions` exists, but was not imported explicitly. You are relying on other modules to load it. [implicit-import] @@ -13342,7 +13176,6 @@ ERROR homeassistant/components/knx/light.py:557:5-12: Class member `KnxYamlLight ERROR homeassistant/components/knx/light.py:585:5-12: Class member `KnxUiLight._device` overrides parent class `KnxUiEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/knx/notify.py:45:5-12: Class member `KNXNotify._device` overrides parent class `KnxYamlEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/knx/number.py:58:5-12: Class member `KNXNumber._device` overrides parent class `KnxYamlEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/knx/project.py:126:58-72: Argument `() -> TypedDict[KNXProject]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/knx/scene.py:37:5-12: Class member `KNXScene._device` overrides parent class `KnxYamlEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/knx/select.py:64:5-12: Class member `KNXSelect._device` overrides parent class `KnxYamlEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/knx/sensor.py:51:5-20: Class member `KNXSystemEntityDescription.entity_category` overrides parent class `SensorEntityDescription` in an inconsistent manner [bad-override] @@ -13364,7 +13197,6 @@ ERROR homeassistant/components/knx/sensor.py:105:9-21: Unexpected keyword argume ERROR homeassistant/components/knx/sensor.py:149:5-12: Class member `KNXSensor._device` overrides parent class `KnxYamlEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/knx/sensor.py:158:18-36: Class member `KNXSensor._attr_device_class` overrides parent class `KnxYamlEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/knx/sensor.py:206:14-32: Class member `KNXSystemSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/knx/storage/keyring.py:48:46-61: Argument `() -> Keyring` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/knx/switch.py:106:5-12: Class member `KnxYamlSwitch._device` overrides parent class `KnxYamlEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/knx/switch.py:122:14-32: Class member `KnxYamlSwitch._attr_device_class` overrides parent class `KnxYamlEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/knx/switch.py:129:5-12: Class member `KnxUiSwitch._device` overrides parent class `KnxUiEntity` in an inconsistent manner [bad-override] @@ -13652,7 +13484,6 @@ ERROR homeassistant/components/kostal_plenticore/switch.py:258:5-23: Class membe ERROR homeassistant/components/kostal_plenticore/switch.py:285:13-16: Unexpected keyword argument `key` in function `homeassistant.components.switch.SwitchEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/kostal_plenticore/switch.py:286:13-17: Unexpected keyword argument `name` in function `homeassistant.components.switch.SwitchEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/kostal_plenticore/switch.py:287:13-44: Unexpected keyword argument `entity_registry_enabled_default` in function `homeassistant.components.switch.SwitchEntityDescription.__init__` [unexpected-keyword] -ERROR homeassistant/components/kraken/__init__.py:77:64-85: Argument `BoundMethod[Self@KrakenData, (self: Self@KrakenData) -> dict[str, TypedDict[KrakenResponseEntry]]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/kraken/config_flow.py:32:9-31: Class member `KrakenConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/kraken/sensor.py:45:9-12: Unexpected keyword argument `key` in function `KrakenSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/kraken/sensor.py:46:9-24: Unexpected keyword argument `translation_key` in function `KrakenSensorEntityDescription.__init__` [unexpected-keyword] @@ -13864,11 +13695,7 @@ ERROR homeassistant/components/lametric/switch.py:35:9-24: Unexpected keyword ar ERROR homeassistant/components/lametric/switch.py:66:5-23: Class member `LaMetricSwitchEntity.entity_description` overrides parent class `LaMetricEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/lametric/switch.py:66:5-23: Class member `LaMetricSwitchEntity.entity_description` overrides parent class `SwitchEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/lametric/update.py:29:5-23: Class member `LaMetricUpdate._attr_device_class` overrides parent class `LaMetricEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/landisgyr_heat_meter/config_flow.py:109:63-78: Argument `BoundMethod[HeatMeterService, (self: HeatMeterService) -> HeatMeterResponse]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/landisgyr_heat_meter/config_flow.py:116:16-26: Object of class `object` has no attribute `model` [missing-attribute] -ERROR homeassistant/components/landisgyr_heat_meter/config_flow.py:116:28-46: Object of class `object` has no attribute `device_number` [missing-attribute] ERROR homeassistant/components/landisgyr_heat_meter/coordinator.py:24:5-17: Class member `UltraheatCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/landisgyr_heat_meter/coordinator.py:46:63-76: Argument `BoundMethod[HeatMeterService, (self: HeatMeterService) -> HeatMeterResponse]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/landisgyr_heat_meter/sensor.py:49:9-12: Unexpected keyword argument `key` in function `HeatMeterSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/landisgyr_heat_meter/sensor.py:50:9-13: Unexpected keyword argument `icon` in function `HeatMeterSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/landisgyr_heat_meter/sensor.py:51:9-13: Unexpected keyword argument `name` in function `HeatMeterSensorEntityDescription.__init__` [unexpected-keyword] @@ -13964,7 +13791,6 @@ ERROR homeassistant/components/landisgyr_heat_meter/sensor.py:261:9-13: Unexpect ERROR homeassistant/components/landisgyr_heat_meter/sensor.py:262:9-24: Unexpected keyword argument `entity_category` in function `HeatMeterSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/landisgyr_heat_meter/sensor.py:298:5-23: Class member `HeatMeterSensor.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/landisgyr_heat_meter/sensor.py:298:5-23: Class member `HeatMeterSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/lannouncer/notify.py:59:18-37: Argument `() -> None` is not assignable to parameter `target` with type `((**tuple[*@_]) -> Any) | Coroutine[Any, Any, Any]` in function `homeassistant.core.HomeAssistant.add_job` [bad-argument-type] ERROR homeassistant/components/lastfm/config_flow.py:83:9-31: Class member `LastFmConfigFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/lastfm/coordinator.py:41:5-17: Class member `LastFMDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/launch_library/__init__.py:44:29-73: Argument `dict[str, int | str]` is not assignable to parameter `filters` with type `Mapping[str, str] | None` in function `pylaunches.api.PyLaunches.launch_upcoming` [bad-argument-type] @@ -14036,9 +13862,6 @@ ERROR homeassistant/components/laundrify/sensor.py:97:40-55: Object of class `La ERROR homeassistant/components/laundrify/sensor.py:98:22-40: Object of class `LaundrifyDevice` has no attribute `totalEnergy` [missing-attribute] ERROR homeassistant/components/lawn_mower/__init__.py:83:5-23: Class member `LawnMowerEntity.entity_description` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/lawn_mower/__init__.py:85:5-29: Class member `LawnMowerEntity._attr_supported_features` overrides parent class `Entity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/lawn_mower/__init__.py:109:48-65: Argument `BoundMethod[Self@LawnMowerEntity, (self: Self@LawnMowerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/lawn_mower/__init__.py:117:48-57: Argument `BoundMethod[Self@LawnMowerEntity, (self: Self@LawnMowerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/lawn_mower/__init__.py:125:48-58: Argument `BoundMethod[Self@LawnMowerEntity, (self: Self@LawnMowerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/lcn/__init__.py:279:65-68: Argument `ModStatusAccessControl` is not assignable to parameter `inp` with type `type[Input]` in function `_async_fire_access_control_event` [bad-argument-type] ERROR homeassistant/components/lcn/__init__.py:281:60-63: Argument `ModSendKeysHost` is not assignable to parameter `inp` with type `type[Input]` in function `_async_fire_send_keys_event` [bad-argument-type] ERROR homeassistant/components/lcn/__init__.py:294:17-25: Class `Input` has no class attribute `code` [missing-attribute] @@ -14329,11 +14152,7 @@ ERROR homeassistant/components/letpot/time.py:46:9-24: Unexpected keyword argume ERROR homeassistant/components/letpot/time.py:53:9-24: Unexpected keyword argument `entity_category` in function `LetPotTimeEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/letpot/time.py:75:5-23: Class member `LetPotTimeEntity.entity_description` overrides parent class `LetPotEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/letpot/time.py:75:5-23: Class member `LetPotTimeEntity.entity_description` overrides parent class `TimeEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/lg_netcast/config_flow.py:114:17-44: Argument `BoundMethod[LgNetCastClient, (self: LgNetCastClient) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/lg_netcast/config_flow.py:146:17-44: Argument `BoundMethod[LgNetCastClient, (self: LgNetCastClient) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/lg_netcast/helpers.py:33:50-74: Argument `BoundMethod[LgNetCastClient, (self: LgNetCastClient) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/lg_netcast/media_player.py:130:44-64: `int` is not assignable to attribute `_channel_id` with type `None` [bad-assignment] -ERROR homeassistant/components/lg_soundbar/media_player.py:85:48-61: Argument `BoundMethod[Self@LGDevice, (self: Self@LGDevice) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/lg_soundbar/media_player.py:89:24-91:10: `temescal` is not assignable to attribute `_device` with type `None` [bad-assignment] ERROR homeassistant/components/lg_soundbar/media_player.py:92:9-38: Object of class `NoneType` has no attribute `get_product_info` [missing-attribute] ERROR homeassistant/components/lg_soundbar/media_player.py:93:9-34: Object of class `NoneType` has no attribute `get_mac_info` [missing-attribute] @@ -14843,7 +14662,6 @@ ERROR homeassistant/components/lifx/sensor.py:54:14-32: Class member `LIFXRssiSe ERROR homeassistant/components/lifx/util.py:82:34-48: No matching overload found for function `dict.get` called with arguments: (None) [no-matching-overload] ERROR homeassistant/components/light/__init__.py:503:21-48: Expected 7 positional arguments, got 9 in function `homeassistant.util.color.color_rgbww_to_rgb` [bad-argument-count] ERROR homeassistant/components/light/__init__.py:806:25-28: `rec` is uninitialized [unbound-name] -ERROR homeassistant/components/light/__init__.py:815:60-83: Argument `BoundMethod[Self@Profiles, (self: Self@Profiles) -> dict[str, Profile]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/light/__init__.py:903:5-23: Class member `LightEntity.entity_description` overrides parent class `ToggleEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/light/__init__.py:919:5-29: Class member `LightEntity._attr_supported_features` overrides parent class `ToggleEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/light/reproduce_state.py:154:51-64: `cm_attr_state` may be uninitialized [unbound-name] @@ -14918,8 +14736,6 @@ ERROR homeassistant/components/linux_battery/sensor.py:123:38-75: Object of clas ERROR homeassistant/components/linux_battery/sensor.py:124:31-61: Object of class `NoneType` has no attribute `voltage_now` [missing-attribute] ERROR homeassistant/components/litejet/config_flow.py:79:9-31: Class member `LiteJetConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/litejet/light.py:110:73-85: No matching overload found for function `int.__new__` called with arguments: (type[int], Any | None) [no-matching-overload] -ERROR homeassistant/components/litejet/trigger.py:88:26-37: Argument `() -> None` is not assignable to parameter `target` with type `((**tuple[*@_]) -> Any) | Coroutine[Any, Any, Any]` in function `homeassistant.core.HomeAssistant.add_job` [bad-argument-type] -ERROR homeassistant/components/litejet/trigger.py:110:26-37: Argument `() -> None` is not assignable to parameter `target` with type `((**tuple[*@_]) -> Any) | Coroutine[Any, Any, Any]` in function `homeassistant.core.HomeAssistant.add_job` [bad-argument-type] ERROR homeassistant/components/litterrobot/binary_sensor.py:36:13-16: Unexpected keyword argument `key` in function `RobotBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/litterrobot/binary_sensor.py:37:13-28: Unexpected keyword argument `translation_key` in function `RobotBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/litterrobot/binary_sensor.py:38:13-28: Unexpected keyword argument `entity_category` in function `RobotBinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -15030,12 +14846,7 @@ ERROR homeassistant/components/livisi/coordinator.py:35:5-17: Class member `Livi ERROR homeassistant/components/livisi/coordinator.py:89:32-47: `controller_type` may be uninitialized [unbound-name] ERROR homeassistant/components/livisi/coordinator.py:98:36-100:10: `dict[str, Any] | None` is not assignable to `dict[str, Any]` [bad-assignment] ERROR homeassistant/components/livisi/coordinator.py:107:42-84: `dict[str, Any]` is not assignable to `list[dict[str, Any]]` [bad-assignment] -ERROR homeassistant/components/local_calendar/calendar.py:100:55-70: Argument `() -> list[CalendarEvent]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/local_calendar/calendar.py:112:62-72: Argument `() -> CalendarEvent | None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/local_calendar/calendar.py:175:56-66: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/local_calendar/calendar.py:220:13-24: `-` is not supported between `datetime` and `date` [unsupported-operation] -ERROR homeassistant/components/local_calendar/store.py:23:60-70: Argument `BoundMethod[Self@LocalCalendarStore, (self: Self@LocalCalendarStore) -> str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/local_todo/store.py:21:60-70: Argument `BoundMethod[Self@LocalTodoListStore, (self: Self@LocalTodoListStore) -> str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/local_todo/todo.py:155:25-28: `due` may be uninitialized [unbound-name] ERROR homeassistant/components/local_todo/todo.py:176:51-84: Unpacked argument `tuple[str, Todo]` is not assignable to parameter `*args` with type `tuple[str, Todo, str | None, Range]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/locative/device_tracker.py:52:34-54:10: `() -> None` is not assignable to attribute `_unsub_dispatcher` with type `None` [bad-assignment] @@ -15159,7 +14970,6 @@ ERROR homeassistant/components/lutron_caseta/binary_sensor.py:50:14-24: Class me ERROR homeassistant/components/lutron_caseta/binary_sensor.py:55:18-27: Argument `UndefinedType | str | None` is not assignable to parameter `name` with type `str | None` in function `homeassistant.helpers.device_registry.DeviceInfo.__init__` [bad-argument-type] ERROR homeassistant/components/lutron_caseta/button.py:56:57-68: `device_name` may be uninitialized [unbound-name] ERROR homeassistant/components/lutron_caseta/button.py:82:14-24: Class member `LutronCasetaButton._attr_name` overrides parent class `LutronCasetaEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/lutron_caseta/config_flow.py:111:56-78: Argument `BoundMethod[Self@LutronCasetaFlowHandler, (self: Self@LutronCasetaFlowHandler) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/lutron_caseta/cover.py:32:5-29: Class member `LutronCasetaShade._attr_supported_features` overrides parent class `LutronCasetaUpdatableEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/lutron_caseta/cover.py:38:5-23: Class member `LutronCasetaShade._attr_device_class` overrides parent class `LutronCasetaUpdatableEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/lutron_caseta/cover.py:107:5-29: Class member `LutronCasetaTiltOnlyBlind._attr_supported_features` overrides parent class `LutronCasetaUpdatableEntity` in an inconsistent manner [bad-override] @@ -15800,8 +15610,6 @@ ERROR homeassistant/components/matter/water_heater.py:146:73-83: Argument `type[ ERROR homeassistant/components/matter/water_heater.py:212:13-16: Unexpected keyword argument `key` in function `MatterWaterHeaterEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/matter/water_heater.py:213:13-17: Unexpected keyword argument `name` in function `MatterWaterHeaterEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/mcp/coordinator.py:102:5-17: Class member `ModelContextProtocolCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/mcp_server/http.py:180:31-41: Argument `() -> Coroutine[Unknown, Unknown, None]` is not assignable to parameter `func` with type `(**tuple[*@_]) -> Awaitable[Any]` in function `anyio.abc._tasks.TaskGroup.start_soon` [bad-argument-type] -ERROR homeassistant/components/mcp_server/http.py:272:27-37: Argument `() -> Coroutine[Unknown, Unknown, None]` is not assignable to parameter `func` with type `(**tuple[*@_]) -> Awaitable[Any]` in function `anyio.abc._tasks.TaskGroup.start_soon` [bad-argument-type] ERROR homeassistant/components/mealie/coordinator.py:47:5-17: Class member `MealieDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/mealie/coordinator.py:49:5-21: Class member `MealieDataUpdateCoordinator._update_interval` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/mealie/sensor.py:32:9-12: Unexpected keyword argument `key` in function `MealieStatisticsSensorEntityDescription.__init__` [unexpected-keyword] @@ -15840,7 +15648,6 @@ ERROR homeassistant/components/medcom_ble/sensor.py:25:9-12: Unexpected keyword ERROR homeassistant/components/medcom_ble/sensor.py:26:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/medcom_ble/sensor.py:71:14-32: Class member `MedcomSensor.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/medcom_ble/sensor.py:96:16-74: Returned type `float | str | None` is not assignable to declared return type `float` [bad-return] -ERROR homeassistant/components/media_extractor/__init__.py:74:52-64: Argument `() -> dict[str, Any]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/media_extractor/__init__.py:168:30-38: `entities` may be uninitialized [unbound-name] ERROR homeassistant/components/media_extractor/__init__.py:178:40-57: Cannot set item in `dict[str, Logger | bool]` [unsupported-operation] ERROR homeassistant/components/media_player/__init__.py:493:5-17: Class member `MediaPlayerEntityDescription.device_class` overrides parent class `EntityDescription` in an inconsistent manner [bad-override] @@ -15848,19 +15655,8 @@ ERROR homeassistant/components/media_player/__init__.py:553:5-23: Class member ` ERROR homeassistant/components/media_player/__init__.py:558:5-23: Class member `MediaPlayerEntity._attr_device_class` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/media_player/__init__.py:585:5-16: Class member `MediaPlayerEntity._attr_state` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/media_player/__init__.py:586:5-29: Class member `MediaPlayerEntity._attr_supported_features` overrides parent class `Entity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/media_player/__init__.py:808:48-60: Argument `BoundMethod[Self@MediaPlayerEntity, (self: Self@MediaPlayerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/media_player/__init__.py:816:48-61: Argument `BoundMethod[Self@MediaPlayerEntity, (self: Self@MediaPlayerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/media_player/__init__.py:840:48-63: Argument `BoundMethod[Self@MediaPlayerEntity, (self: Self@MediaPlayerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/media_player/__init__.py:848:48-64: Argument `BoundMethod[Self@MediaPlayerEntity, (self: Self@MediaPlayerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/media_player/__init__.py:856:48-63: Argument `BoundMethod[Self@MediaPlayerEntity, (self: Self@MediaPlayerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/media_player/__init__.py:864:48-73: Argument `BoundMethod[Self@MediaPlayerEntity, (self: Self@MediaPlayerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/media_player/__init__.py:872:48-69: Argument `BoundMethod[Self@MediaPlayerEntity, (self: Self@MediaPlayerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/media_player/__init__.py:918:48-67: Argument `BoundMethod[Self@MediaPlayerEntity, (self: Self@MediaPlayerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/media_player/__init__.py:1194:48-66: Argument `BoundMethod[Self@MediaPlayerEntity, (self: Self@MediaPlayerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/media_source/__init__.py:51:68-79: Function declared to return `MediaSource` but is missing an explicit `return` [bad-return] ERROR homeassistant/components/media_source/__init__.py:74:56-68: Argument `Module[homeassistant.components.media_source.local_source]` is not assignable to parameter `platform` with type `MediaSourceProtocol` in function `_process_media_source_platform` [bad-argument-type] -ERROR homeassistant/components/media_source/local_source.py:112:48-58: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/media_source/local_source.py:150:13-21: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/media_source/local_source.py:305:49-67: Argument `BoundMethod[Path, (self: Path, *, follow_symlinks: bool = True) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/mediaroom/media_player.py:8:1-14:2: Could not find import of `pymediaroom` [missing-import] ERROR homeassistant/components/mediaroom/media_player.py:79:9-20: `known_hosts` may be uninitialized [unbound-name] @@ -16225,10 +16021,8 @@ ERROR homeassistant/components/miele/vacuum.py:119:13-28: Unexpected keyword arg ERROR homeassistant/components/miele/vacuum.py:163:5-23: Class member `MieleVacuum.entity_description` overrides parent class `MieleEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/miele/vacuum.py:163:5-23: Class member `MieleVacuum.entity_description` overrides parent class `StateVacuumEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/miele/vacuum.py:164:5-29: Class member `MieleVacuum._attr_supported_features` overrides parent class `MieleEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/mikrotik/__init__.py:27:39-70: Argument `BoundMethod[MikrotikData, (self: MikrotikData) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/mikrotik/config_flow.py:45:9-31: Class member `MikrotikFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/mikrotik/coordinator.py:251:5-17: Class member `MikrotikDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/mikrotik/coordinator.py:310:48-76: Argument `BoundMethod[MikrotikData, (self: MikrotikData) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/mikrotik/coordinator.py:345:12-15: Returned type `type[Api]` is not assignable to declared return type `Api` [bad-return] ERROR homeassistant/components/mill/climate.py:98:5-29: Class member `MillHeater._attr_supported_features` overrides parent class `MillBaseEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/mill/climate.py:117:15-68: Object of class `Mill` has no attribute `set_heater_temp` [missing-attribute] @@ -16283,7 +16077,6 @@ ERROR homeassistant/components/mill/sensor.py:221:19-63: Object of class `Mill` ERROR homeassistant/components/mill/sensor.py:225:35-76: Object of class `Mill` has no attribute `url` [missing-attribute] ERROR homeassistant/components/mill/sensor.py:228:22-59: Object of class `Mill` has no attribute `name` [missing-attribute] ERROR homeassistant/components/mill/sensor.py:229:28-68: Object of class `Mill` has no attribute `version` [missing-attribute] -ERROR homeassistant/components/minecraft_server/__init__.py:42:39-76: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/minecraft_server/api.py:80:71-82:18: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[str, float]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/minecraft_server/binary_sensor.py:19:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/minecraft_server/binary_sensor.py:20:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -16458,10 +16251,7 @@ ERROR homeassistant/components/mopeka/sensor.py:131:7-34: Field `entity_descript ERROR homeassistant/components/motion_blinds/button.py:57:52-84: Object of class `MotionGateway` has no attribute `Go_favorite_position` [missing-attribute] ERROR homeassistant/components/motion_blinds/button.py:77:52-85: Object of class `MotionGateway` has no attribute `Set_favorite_position` [missing-attribute] ERROR homeassistant/components/motion_blinds/config_flow.py:81:9-31: Class member `MotionBlindsFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] -ERROR homeassistant/components/motion_blinds/config_flow.py:98:52-73: Argument `BoundMethod[MotionGateway, (self: MotionGateway) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/motion_blinds/config_flow.py:128:63-86: Argument `BoundMethod[MotionDiscovery, (self: MotionDiscovery) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/motion_blinds/coordinator.py:29:5-17: Class member `DataUpdateCoordinatorMotionBlinds.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/motion_blinds/coordinator.py:82:17-36: Argument `BoundMethod[Self@DataUpdateCoordinatorMotionBlinds, (self: Self@DataUpdateCoordinatorMotionBlinds) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/motion_blinds/coordinator.py:94:18-33: Class member `DataUpdateCoordinatorMotionBlinds.update_interval` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/motion_blinds/coordinator.py:94:36-70: `timedelta` is not assignable to attribute `update_interval` with type `(self: Self@DataUpdateCoordinatorMotionBlinds, value: timedelta | None) -> None` [bad-assignment] ERROR homeassistant/components/motion_blinds/coordinator.py:96:36-75: `timedelta` is not assignable to attribute `update_interval` with type `(self: Self@DataUpdateCoordinatorMotionBlinds, value: timedelta | None) -> None` [bad-assignment] @@ -16668,7 +16458,6 @@ ERROR homeassistant/components/mpd/media_player.py:515:19-36: Object of class `M ERROR homeassistant/components/mpd/media_player.py:520:19-36: Object of class `MPDClient` has no attribute `play` [missing-attribute] ERROR homeassistant/components/mpd/media_player.py:526:19-37: Object of class `MPDClient` has no attribute `clear` [missing-attribute] ERROR homeassistant/components/mpd/media_player.py:531:19-39: Object of class `MPDClient` has no attribute `seekcur` [missing-attribute] -ERROR homeassistant/components/mqtt/__init__.py:359:47-57: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/mqtt/alarm_control_panel.py:134:9-22: Class member `MqttAlarm.config_schema` overrides parent class `MqttEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/mqtt/binary_sensor.py:140:9-22: Class member `MqttBinarySensor.config_schema` overrides parent class `MqttEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/mqtt/binary_sensor.py:152:14-32: Class member `MqttBinarySensor._attr_device_class` overrides parent class `MqttEntity` in an inconsistent manner [bad-override] @@ -16676,14 +16465,9 @@ ERROR homeassistant/components/mqtt/binary_sensor.py:152:14-32: Class member `Mq ERROR homeassistant/components/mqtt/button.py:71:9-22: Class member `MqttButton.config_schema` overrides parent class `MqttEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/mqtt/button.py:80:14-32: Class member `MqttButton._attr_device_class` overrides parent class `MqttEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/mqtt/camera.py:97:9-22: Class member `MqttCamera.config_schema` overrides parent class `MqttEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/mqtt/client.py:258:40-52: Argument `() -> None` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/components/mqtt/client.py:319:23-32: `client_id` may be uninitialized [unbound-name] ERROR homeassistant/components/mqtt/client.py:359:12-23: `certificate` may be uninitialized [unbound-name] ERROR homeassistant/components/mqtt/client.py:361:17-28: `certificate` may be uninitialized [unbound-name] -ERROR homeassistant/components/mqtt/client.py:486:48-65: Argument `BoundMethod[MqttClientSetup, (self: MqttClientSetup) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/mqtt/client.py:534:76-87: Argument `() -> None` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_at` [bad-argument-type] -ERROR homeassistant/components/mqtt/client.py:536:68-79: Argument `() -> None` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_at` [bad-argument-type] -ERROR homeassistant/components/mqtt/client.py:730:64-85: Argument `BoundMethod[AsyncMQTTClient, (self: AsyncMQTTClient) -> MQTTErrorCode]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/mqtt/client.py:822:50-57: `max_qos` may be uninitialized [unbound-name] ERROR homeassistant/components/mqtt/climate.py:667:14-38: Class member `MqttClimate._attr_supported_features` overrides parent class `MqttTemperatureControlEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/mqtt/climate.py:807:15-44: Method `async_set_temperature` inherited from class `MqttTemperatureControlEntity` has no implementation and cannot be accessed via `super()` [missing-attribute] @@ -16702,8 +16486,6 @@ ERROR homeassistant/components/mqtt/config_flow.py:3854:21-38: `reconfigure_entr ERROR homeassistant/components/mqtt/config_flow.py:3863:20-34: `is_reconfigure` may be uninitialized [unbound-name] ERROR homeassistant/components/mqtt/config_flow.py:3865:25-42: `reconfigure_entry` may be uninitialized [unbound-name] ERROR homeassistant/components/mqtt/config_flow.py:4219:76-84: `reconfig` may be uninitialized [unbound-name] -ERROR homeassistant/components/mqtt/config_flow.py:4737:46-67: Argument `() -> bytes` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/mqtt/config_flow.py:4869:13-34: Argument `() -> str | None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/mqtt/config_flow.py:4890:17-40: Expected a type form, got instance of `*Unknown` [not-a-type] ERROR homeassistant/components/mqtt/config_flow.py:4890:18-40: Expected a type form, got instance of `tuple[type[JSONDecodeError]]` [not-a-type] ERROR homeassistant/components/mqtt/config_flow.py:5129:8-26: `client_certificate` may be uninitialized [unbound-name] @@ -16767,9 +16549,6 @@ ERROR homeassistant/components/mqtt/tag.py:184:60-74: Cannot index into `dict[st ERROR homeassistant/components/mqtt/tag.py:185:22-36: Cannot index into `dict[str, dict[str, MQTTTagScanner]]` [bad-index] ERROR homeassistant/components/mqtt/update.py:117:14-32: Class member `MqttUpdate._attr_device_class` overrides parent class `MqttEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/mqtt/update.py:117:14-32: Class member `MqttUpdate._attr_device_class` overrides parent class `RestoreEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/mqtt/util.py:113:57-82: Argument `BoundMethod[Self@EnsureJobAfterCooldown, (self: Self@EnsureJobAfterCooldown) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_at` [bad-argument-type] -ERROR homeassistant/components/mqtt/util.py:131:38-63: Argument `BoundMethod[Self@EnsureJobAfterCooldown, (self: Self@EnsureJobAfterCooldown) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_at` [bad-argument-type] -ERROR homeassistant/components/mqtt/util.py:371:39-65: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/mqtt/vacuum.py:235:14-38: Class member `MqttStateVacuum._attr_supported_features` overrides parent class `MqttEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/mqtt/valve.py:199:14-32: Class member `MqttValve._attr_device_class` overrides parent class `MqttEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/mqtt/valve.py:213:14-38: Class member `MqttValve._attr_supported_features` overrides parent class `MqttEntity` in an inconsistent manner [bad-override] @@ -16777,11 +16556,9 @@ ERROR homeassistant/components/mqtt/water_heater.py:260:14-38: Class member `Mqt ERROR homeassistant/components/mqtt/water_heater.py:303:15-44: Method `async_set_temperature` inherited from class `MqttTemperatureControlEntity` has no implementation and cannot be accessed via `super()` [missing-attribute] ERROR homeassistant/components/mqtt_room/sensor.py:138:29-45: `datetime` is not assignable to attribute `_updated` with type `None` [bad-assignment] ERROR homeassistant/components/msteams/notify.py:7:8-17: Could not find import of `pymsteams` [missing-import] -ERROR homeassistant/components/mullvad/__init__.py:24:53-63: Argument `type[MullvadAPI]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/mullvad/binary_sensor.py:21:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/mullvad/binary_sensor.py:22:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/mullvad/binary_sensor.py:55:14-32: Class member `MullvadBinarySensor.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/mullvad/config_flow.py:27:56-66: Argument `type[MullvadAPI]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/music_assistant/button.py:39:5-23: Class member `MusicAssistantFavoriteButton.entity_description` overrides parent class `MusicAssistantEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/music_assistant/button.py:40:9-12: Unexpected keyword argument `key` in function `homeassistant.components.button.ButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/music_assistant/button.py:41:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.button.ButtonEntityDescription.__init__` [unexpected-keyword] @@ -17030,18 +16807,13 @@ ERROR homeassistant/components/nasweb/sensor.py:143:14-32: Class member `InputSt ERROR homeassistant/components/nasweb/switch.py:115:53-71: Cannot index into `dict[str | None, bool | None]` [bad-index] ERROR homeassistant/components/neato/__init__.py:58:43-60: Argument `BoundMethod[NeatoHub, (...) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/neato/api.py:31:9-23: Class member `ConfigEntryAuth.refresh_tokens` overrides parent class `OAuthSession` in an inconsistent manner [bad-override] -ERROR homeassistant/components/neato/button.py:44:48-80: Argument `BoundMethod[Robot, (self: Robot) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/neato/camera.py:94:26-34: `map_data` may be uninitialized [unbound-name] ERROR homeassistant/components/neato/camera.py:114:30-38: `map_data` may be uninitialized [unbound-name] ERROR homeassistant/components/neato/entity.py:21:14-31: Class member `NeatoEntity._attr_device_info` overrides parent class `Entity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/neato/hub.py:42:49-79: Argument `BoundMethod[Account, (self: Account) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/neato/sensor.py:48:5-23: Class member `NeatoSensor._attr_device_class` overrides parent class `NeatoEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/neato/vacuum.py:98:5-29: Class member `NeatoConnectedVacuum._attr_supported_features` overrides parent class `NeatoEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/neato/vacuum.py:125:14-29: Class member `NeatoConnectedVacuum._attr_unique_id` overrides parent class `NeatoEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/neato/vacuum.py:125:14-29: Class member `NeatoConnectedVacuum._attr_unique_id` overrides parent class `StateVacuumEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/nederlandse_spoorwegen/config_flow.py:60:52-71: Argument `BoundMethod[NSAPI, (self: NSAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/nederlandse_spoorwegen/config_flow.py:142:63-82: Argument `BoundMethod[NSAPI, (self: NSAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/nederlandse_spoorwegen/config_flow.py:205:25-44: Argument `BoundMethod[NSAPI, (self: NSAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/nederlandse_spoorwegen/sensor.py:132:5-23: Class member `NSDepartureSensor._attr_device_class` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/ness_alarm/alarm_control_panel.py:74:35-39: Argument `str | None` is not assignable to parameter `code` with type `str` in function `nessclient.client.Client.disarm` [bad-argument-type] ERROR homeassistant/components/ness_alarm/alarm_control_panel.py:86:34-38: Argument `str | None` is not assignable to parameter `code` with type `str` in function `nessclient.client.Client.panic` [bad-argument-type] @@ -17060,7 +16832,6 @@ ERROR homeassistant/components/nest/event.py:43:9-24: Unexpected keyword argumen ERROR homeassistant/components/nest/event.py:50:9-12: Unexpected keyword argument `key` in function `NestEventEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/nest/event.py:51:9-24: Unexpected keyword argument `translation_key` in function `NestEventEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/nest/event.py:85:5-23: Class member `NestTraitEventEntity.entity_description` overrides parent class `EventEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/nest/media_source.py:91:39-44: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/nest/media_source.py:384:5-9: Class member `NestMediaSource.name` overrides parent class `MediaSource` in an inconsistent manner [bad-override] ERROR homeassistant/components/netatmo/binary_sensor.py:19:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/netatmo/binary_sensor.py:55:14-32: Class member `NetatmoWeatherBinarySensor.entity_description` overrides parent class `NetatmoWeatherModuleEntity` in an inconsistent manner [bad-override] @@ -17162,16 +16933,6 @@ ERROR homeassistant/components/netgear/router.py:84:29-33: `None` is not assigna ERROR homeassistant/components/netgear/router.py:115:30-83: `bool | Unknown` is not assignable to attribute `track_devices` with type `Never` [bad-assignment] ERROR homeassistant/components/netgear/router.py:124:39-40: `Literal[2]` is not assignable to attribute `method_version` with type `Never` [bad-assignment] ERROR homeassistant/components/netgear/router.py:135:39-40: `Literal[1]` is not assignable to attribute `method_version` with type `Never` [bad-assignment] -ERROR homeassistant/components/netgear/router.py:142:59-70: Argument `BoundMethod[Self@NetgearRouter, (self: Self@NetgearRouter) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/netgear/router.py:181:21-50: Argument `BoundMethod[Netgear, (self: Netgear) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/netgear/router.py:186:17-48: Argument `BoundMethod[Netgear, (self: Netgear) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/netgear/router.py:232:59-85: Argument `BoundMethod[Netgear, (self: Netgear) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/netgear/router.py:238:17-51: Argument `BoundMethod[Netgear, (self: Netgear) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/netgear/router.py:244:59-87: Argument `BoundMethod[Netgear, (self: Netgear) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/netgear/router.py:256:59-83: Argument `BoundMethod[Netgear, (self: Netgear) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/netgear/router.py:261:52-67: Argument `BoundMethod[Netgear, (self: Netgear) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/netgear/router.py:266:59-86: Argument `BoundMethod[Netgear, (self: Netgear) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/netgear/router.py:271:52-80: Argument `BoundMethod[Netgear, (self: Netgear) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/netgear/sensor.py:47:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/netgear/sensor.py:48:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/netgear/sensor.py:49:9-24: Unexpected keyword argument `entity_category` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -17287,7 +17048,6 @@ ERROR homeassistant/components/netgear/switch.py:94:9-24: Unexpected keyword arg ERROR homeassistant/components/netgear/switch.py:159:14-32: Class member `NetgearAllowBlock.entity_description` overrides parent class `NetgearDeviceEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/netgear/switch.py:188:5-23: Class member `NetgearRouterSwitchEntity.entity_description` overrides parent class `NetgearRouterEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/netgear/switch.py:188:5-23: Class member `NetgearRouterSwitchEntity.entity_description` overrides parent class `SwitchEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/netgear/switch.py:212:17-61: Argument `() -> bool | None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/netgear/update.py:41:5-23: Class member `NetgearUpdateEntity._attr_device_class` overrides parent class `NetgearRouterCoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/netgear/update.py:42:5-29: Class member `NetgearUpdateEntity._attr_supported_features` overrides parent class `NetgearRouterCoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/netgear_lte/__init__.py:76:32-40: Unexpected keyword argument `hostname` in function `eternalegypt.eternalegypt.LB2120.__init__` [unexpected-keyword] @@ -17367,7 +17127,6 @@ ERROR homeassistant/components/netgear_lte/services.py:71:15-20: `modem` is unin ERROR homeassistant/components/netgear_lte/services.py:73:15-20: `modem` is uninitialized [unbound-name] ERROR homeassistant/components/netio/switch.py:10:1-26: Could not find import of `pynetio` [missing-import] ERROR homeassistant/components/network/__init__.py:90:12-65: Returned type `str | Unknown | None` is not assignable to declared return type `str` [bad-return] -ERROR homeassistant/components/network/__init__.py:182:46-83: Argument `() -> bool` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/neurio_energy/sensor.py:8:8-14: Could not find import of `neurio` [missing-import] ERROR homeassistant/components/neurio_energy/sensor.py:135:29-42: `int` is not assignable to attribute `_daily_usage` with type `None` [bad-assignment] ERROR homeassistant/components/neurio_energy/sensor.py:156:41-68: `Literal[UnitOfEnergy.KILO_WATT_HOUR]` is not assignable to attribute `_unit_of_measurement` with type `UnitOfPower` [bad-assignment] @@ -17388,9 +17147,7 @@ ERROR homeassistant/components/nexia/switch.py:74:45-52: Argument `int | str` is ERROR homeassistant/components/nexia/switch.py:112:46-58: Cannot index into `dict[int, NexiaRoomIQHarmonizer]` [bad-index] ERROR homeassistant/components/nexia/switch.py:117:27-39: Cannot set item in `dict[int, NexiaRoomIQHarmonizer]` [unsupported-operation] ERROR homeassistant/components/nextbus/coordinator.py:118:55-72: Cannot set item in `dict[RouteStop, dict[str, Any]]` [unsupported-operation] -ERROR homeassistant/components/nextbus/coordinator.py:129:55-67: Argument `() -> dict[RouteStop, dict[str, Any]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/nextbus/sensor.py:63:5-23: Class member `NextBusDepartureSensor._attr_device_class` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/nextcloud/__init__.py:57:49-60: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/nextcloud/binary_sensor.py:20:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/nextcloud/binary_sensor.py:21:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/nextcloud/binary_sensor.py:22:9-24: Unexpected keyword argument `entity_category` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -17414,7 +17171,6 @@ ERROR homeassistant/components/nextcloud/binary_sensor.py:49:9-24: Unexpected ke ERROR homeassistant/components/nextcloud/binary_sensor.py:68:7-28: Field `entity_description` is declared `EntityDescription` in ancestor `class NextcloudEntity: ... `, which is not assignable to the type `BinarySensorEntityDescription` implied by multiple inheritance [inconsistent-inheritance] ERROR homeassistant/components/nextcloud/coordinator.py:23:5-17: Class member `NextcloudDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/nextcloud/coordinator.py:81:48-60: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/nextcloud/sensor.py:43:9-12: Unexpected keyword argument `key` in function `NextcloudSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/nextcloud/sensor.py:44:9-24: Unexpected keyword argument `translation_key` in function `NextcloudSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/nextcloud/sensor.py:46:9-24: Unexpected keyword argument `entity_category` in function `NextcloudSensorEntityDescription.__init__` [unexpected-keyword] @@ -18202,7 +17958,6 @@ ERROR homeassistant/components/nmap_tracker/__init__.py:326:29-42: `PortScanner` ERROR homeassistant/components/nmap_tracker/__init__.py:330:26-44: Object of class `NoneType` has no attribute `scan` [missing-attribute] ERROR homeassistant/components/nmap_tracker/__init__.py:331:35-48: No matching overload found for function `str.join` called with arguments: (None) [no-matching-overload] ERROR homeassistant/components/nmap_tracker/__init__.py:348:16-22: `result` may be uninitialized [unbound-name] -ERROR homeassistant/components/nmap_tracker/__init__.py:392:58-77: Argument `BoundMethod[Self@NmapDeviceScanner, (self: Self@NmapDeviceScanner) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/nmap_tracker/__init__.py:418:16-50: `in` is not supported between `str` and `None` [not-iterable] ERROR homeassistant/components/nmap_tracker/__init__.py:430:50-56: Argument `str | Unknown | None` is not assignable to parameter `vendor` with type `str` in function `human_readable_name` [bad-argument-type] ERROR homeassistant/components/nmap_tracker/__init__.py:432:54-60: Argument `str | Unknown | None` is not assignable to parameter `manufacturer` with type `str` in function `NmapDevice.__init__` [bad-argument-type] @@ -18398,7 +18153,6 @@ ERROR homeassistant/components/ntfy/sensor.py:246:5-23: Class member `NtfySensor ERROR homeassistant/components/nuheat/climate.py:76:5-29: Class member `NuHeatThermostat._attr_supported_features` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/nuheat/climate.py:159:52-85: No matching overload found for function `dict.get` called with arguments: (None, Literal['Run Schedule']) [no-matching-overload] ERROR homeassistant/components/nuheat/climate.py:210:31-51: `int` is not assignable to attribute `_schedule_mode` with type `None` [bad-assignment] -ERROR homeassistant/components/nuheat/config_flow.py:37:43-59: Argument `BoundMethod[NuHeat, (self: NuHeat) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/nuheat/config_flow.py:87:48-52: `info` may be uninitialized [unbound-name] ERROR homeassistant/components/nuheat/config_flow.py:89:54-58: `info` may be uninitialized [unbound-name] ERROR homeassistant/components/nuki/binary_sensor.py:50:5-23: Class member `NukiDoorsensorEntity._attr_device_class` overrides parent class `NukiEntity` in an inconsistent manner [bad-override] @@ -18409,7 +18163,6 @@ ERROR homeassistant/components/nuki/binary_sensor.py:92:16-51: Object of class ` ERROR homeassistant/components/nuki/binary_sensor.py:99:5-23: Class member `NukiBatteryCriticalEntity._attr_device_class` overrides parent class `NukiEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/nuki/binary_sensor.py:117:5-23: Class member `NukiBatteryChargingEntity._attr_device_class` overrides parent class `NukiEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/nuki/binary_sensor.py:129:16-50: Object of class `NukiDevice` has no attribute `battery_charging` [missing-attribute] -ERROR homeassistant/components/nuki/config_flow.py:54:50-61: Argument `BoundMethod[NukiBridge, (self: NukiBridge) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/nuki/config_flow.py:132:26-30: `info` may be uninitialized [unbound-name] ERROR homeassistant/components/nuki/config_flow.py:171:38-42: `info` may be uninitialized [unbound-name] ERROR homeassistant/components/nuki/coordinator.py:32:5-17: Class member `NukiCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] @@ -18970,7 +18723,6 @@ ERROR homeassistant/components/nws/sensor.py:176:5-23: Class member `NWSSensor.e ERROR homeassistant/components/nws/weather.py:230:38-42: `time` may be uninitialized [unbound-name] ERROR homeassistant/components/nws/weather.py:323:31-55: Argument `list[dict[str, Any]] | None` is not assignable to parameter `nws_forecast` with type `list[dict[str, Any]]` in function `NWSWeather._forecast` [bad-argument-type] ERROR homeassistant/components/nws/weather.py:328:31-48: Argument `list[dict[str, Any]] | None` is not assignable to parameter `nws_forecast` with type `list[dict[str, Any]]` in function `NWSWeather._forecast` [bad-argument-type] -ERROR homeassistant/components/nx584/alarm_control_panel.py:61:43-66: Argument `BoundMethod[Client, (self: Client) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/nx584/alarm_control_panel.py:130:16-20: `part` may be uninitialized [unbound-name] ERROR homeassistant/components/nx584/alarm_control_panel.py:137:21-25: `part` may be uninitialized [unbound-name] ERROR homeassistant/components/nyt_games/coordinator.py:32:5-17: Class member `NYTGamesCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] @@ -19007,7 +18759,6 @@ ERROR homeassistant/components/nyt_games/sensor.py:198:5-23: Class member `NYTGa ERROR homeassistant/components/nyt_games/sensor.py:222:5-23: Class member `NYTGamesConnectionsSensor.entity_description` overrides parent class `ConnectionsEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/nyt_games/sensor.py:222:5-23: Class member `NYTGamesConnectionsSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/nzbget/coordinator.py:29:5-17: Class member `NZBGetDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/nzbget/coordinator.py:98:63-75: Argument `() -> dict[Unknown, Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/nzbget/sensor.py:28:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/nzbget/sensor.py:29:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/nzbget/sensor.py:34:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -19031,17 +18782,12 @@ ERROR homeassistant/components/nzbget/sensor.py:80:9-24: Unexpected keyword argu ERROR homeassistant/components/nzbget/sensor.py:84:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/nzbget/sensor.py:85:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/nzbget/sensor.py:127:14-32: Class member `NZBGetSensor.entity_description` overrides parent class `NZBGetEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/nzbget/switch.py:66:48-86: Argument `BoundMethod[NZBGetAPI, (self: NZBGetAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/nzbget/switch.py:71:48-85: Argument `BoundMethod[NZBGetAPI, (self: NZBGetAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/oasa_telematics/sensor.py:9:8-22: Could not find import of `oasatelematics` [missing-import] ERROR homeassistant/components/oasa_telematics/sensor.py:120:34-66: `None` is not subscriptable [unsupported-operation] ERROR homeassistant/components/oasa_telematics/sensor.py:121:33-64: `None` is not subscriptable [unsupported-operation] -ERROR homeassistant/components/obihai/__init__.py:20:39-55: Argument `BoundMethod[ObihaiConnection, (self: ObihaiConnection) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/obihai/__init__.py:37:13-46: Argument `BoundMethod[PyObihai, (self: PyObihai) -> str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/obihai/button.py:20:5-8: Unexpected keyword argument `key` in function `homeassistant.components.button.ButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/obihai/button.py:21:5-9: Unexpected keyword argument `name` in function `homeassistant.components.button.ButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/obihai/button.py:23:5-20: Unexpected keyword argument `entity_category` in function `homeassistant.components.button.ButtonEntityDescription.__init__` [unexpected-keyword] -ERROR homeassistant/components/obihai/config_flow.py:78:25-48: Argument `BoundMethod[PyObihai, (self: PyObihai) -> str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/obihai/connectivity.py:55:35-39: `None` is not assignable to attribute `pyobihai` with type `PyObihai` [bad-assignment] ERROR homeassistant/components/obihai/connectivity.py:62:29-83: `PyObihai | None` is not assignable to attribute `pyobihai` with type `PyObihai` [bad-assignment] ERROR homeassistant/components/obihai/connectivity.py:68:25-50: `dict[str, Any]` is not assignable to attribute `services` with type `list[Unknown]` [bad-assignment] @@ -19146,11 +18892,6 @@ ERROR homeassistant/components/onboarding/__init__.py:122:12-16: `data` may be u ERROR homeassistant/components/onboarding/__init__.py:125:51-55: `data` may be uninitialized [unbound-name] ERROR homeassistant/components/onboarding/__init__.py:127:35-39: `data` may be uninitialized [unbound-name] ERROR homeassistant/components/ondilo_ico/coordinator.py:47:5-17: Class member `OndiloIcoPoolsCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/ondilo_ico/coordinator.py:69:63-80: Argument `BoundMethod[Self@OndiloIcoPoolsCoordinator, (self: Self@OndiloIcoPoolsCoordinator) -> dict[str, OndiloIcoPoolData]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/ondilo_ico/coordinator.py:77:25-38: Cannot index into `Iterable[Unknown]` [bad-index] -ERROR homeassistant/components/ondilo_ico/coordinator.py:104:25-38: Cannot index into `Iterable[Unknown]` [bad-index] -ERROR homeassistant/components/ondilo_ico/coordinator.py:110:16-20: Returned type `Iterable[Unknown]` is not assignable to declared return type `dict[str, OndiloIcoPoolData]` [bad-return] -ERROR homeassistant/components/ondilo_ico/coordinator.py:168:59-76: Argument `BoundMethod[Self@OndiloIcoMeasuresCoordinator, (self: Self@OndiloIcoMeasuresCoordinator) -> OndiloIcoMeasurementData]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ondilo_ico/coordinator.py:174:18-33: Class member `OndiloIcoMeasuresCoordinator.update_interval` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/ondilo_ico/coordinator.py:174:36-54: `timedelta` is not assignable to attribute `update_interval` with type `(self: Self@OndiloIcoMeasuresCoordinator, value: timedelta | None) -> None` [bad-assignment] ERROR homeassistant/components/ondilo_ico/coordinator.py:181:55-68: Argument `str` is not assignable to parameter `pool_id` with type `int` in function `ondilo.ondilo.Ondilo.get_last_pool_measures` [bad-argument-type] @@ -19335,7 +19076,6 @@ ERROR homeassistant/components/onvif/binary_sensor.py:87:18-36: Class member `ON ERROR homeassistant/components/onvif/button.py:27:5-23: Class member `RebootButton._attr_device_class` overrides parent class `ONVIFBaseEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/onvif/camera.py:98:5-29: Class member `ONVIFCameraEntity._attr_supported_features` overrides parent class `ONVIFBaseEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/onvif/camera.py:182:17-30: Argument `asyncio.streams.StreamReader` is not assignable to parameter `stream` with type `aiohttp.streams.StreamReader` in function `homeassistant.helpers.aiohttp_client.async_aiohttp_proxy_stream` [bad-argument-type] -ERROR homeassistant/components/onvif/config_flow.py:83:50-61: Argument `() -> list[Service]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/onvif/config_flow.py:115:9-31: Class member `OnvifFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/onvif/device.py:189:20-43: Expected a callable, got `None` [not-callable] ERROR homeassistant/components/onvif/device.py:480:15-40: Expected a callable, got `None` [not-callable] @@ -19358,18 +19098,14 @@ ERROR homeassistant/components/onvif/switch.py:56:9-24: Unexpected keyword argum ERROR homeassistant/components/onvif/switch.py:84:5-23: Class member `ONVIFSwitch.entity_description` overrides parent class `ONVIFBaseEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/onvif/switch.py:84:5-23: Class member `ONVIFSwitch.entity_description` overrides parent class `SwitchEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/open_meteo/coordinator.py:30:5-17: Class member `OpenMeteoDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/open_router/__init__.py:29:43-66: Argument `BoundMethod[AsyncOpenAI, (self: AsyncOpenAI) -> dict[str, str]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/open_router/ai_task.py:61:16-44: Object of class `ToolResultContent` has no attribute `content` [missing-attribute] -ERROR homeassistant/components/open_router/entity.py:207:46-69: Argument `() -> list[TypedDict[ChatCompletionContentPartImageParam]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/open_router/entity.py:293:62-76: No matching overload found for function `openai.resources.chat.completions.completions.AsyncCompletions.create` called with arguments: (**dict[str, dict[str, bool] | dict[str, str] | str | Any]) [no-matching-overload] ERROR homeassistant/components/openai_conversation/__init__.py:181:63-77: No matching overload found for function `openai.resources.responses.responses.AsyncResponses.create` called with arguments: (**dict[str, bool | list[TypedDict[ApplyPatchCall] | TypedDict[ApplyPatchCallOutput] | TypedDict[ComputerCallOutput] | TypedDict[EasyInputMessageParam] | TypedDict[FunctionCallOutput] | TypedDict[ImageGenerationCall] | TypedDict[ItemReference] | TypedDict[LocalShellCall] | TypedDict[LocalShellCallOutput] | TypedDict[McpApprovalRequest] | TypedDict[McpApprovalResponse] | TypedDict[McpCall] | TypedDict[McpListTools] | TypedDict[Message] | TypedDict[ResponseCodeInterpreterToolCallParam] | TypedDict[ResponseComputerToolCallParam] | TypedDict[ResponseCustomToolCallOutputParam] | TypedDict[ResponseCustomToolCallParam] | TypedDict[ResponseFileSearchToolCallParam] | TypedDict[ResponseFunctionToolCallParam] | TypedDict[ResponseFunctionWebSearchParam] | TypedDict[ResponseOutputMessageParam] | TypedDict[ResponseReasoningItemParam] | TypedDict[ShellCall] | TypedDict[ShellCallOutput]] | str | Any | None]) [no-matching-overload] -ERROR homeassistant/components/openai_conversation/__init__.py:243:43-66: Argument `BoundMethod[AsyncOpenAI, (self: AsyncOpenAI) -> dict[str, str]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/openai_conversation/__init__.py:246:43-88: Argument `BoundMethod[AsyncModels, (self: AsyncModels, *, extra_headers: Mapping[str, Omit | str] | None = None, extra_query: Mapping[str, object] | None = None, extra_body: object | None = None, timeout: NotGiven | Timeout | float | None = ...) -> AsyncPaginator[Model, AsyncPage[Model]]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/openai_conversation/ai_task.py:82:16-44: Object of class `ToolResultContent` has no attribute `content` [missing-attribute] ERROR homeassistant/components/openai_conversation/config_flow.py:101:39-84: Argument `BoundMethod[AsyncModels, (self: AsyncModels, *, extra_headers: Mapping[str, Omit | str] | None = None, extra_query: Mapping[str, object] | None = None, extra_body: object | None = None, timeout: NotGiven | Timeout | float | None = ...) -> AsyncPaginator[Model, AsyncPage[Model]]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/openai_conversation/entity.py:390:13-30: `current_tool_call` is uninitialized [unbound-name] ERROR homeassistant/components/openai_conversation/entity.py:392:13-30: `current_tool_call` is uninitialized [unbound-name] -ERROR homeassistant/components/openai_conversation/entity.py:712:46-69: Argument `() -> list[TypedDict[ResponseInputFileParam] | TypedDict[ResponseInputImageParam] | TypedDict[ResponseInputTextParam]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/openevse/sensor.py:7:8-20: Could not find import of `openevsewifi` [missing-import] ERROR homeassistant/components/openevse/sensor.py:34:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/openevse/sensor.py:35:9-13: Unexpected keyword argument `name` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -19409,8 +19145,6 @@ ERROR homeassistant/components/opengarage/sensor.py:53:9-12: Unexpected keyword ERROR homeassistant/components/opengarage/sensor.py:81:7-23: Field `entity_description` is declared `EntityDescription` in ancestor `class OpenGarageEntity: ... `, which is not assignable to the type `SensorEntityDescription` implied by multiple inheritance [inconsistent-inheritance] ERROR homeassistant/components/openrgb/coordinator.py:56:65-61:14: Unpacked argument `tuple[Any, Any, Literal['Home Assistant']]` is not assignable to parameter `*args` with type `tuple[str, int, str, int | None]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/openrgb/coordinator.py:76:56-75: Argument `BoundMethod[Self@OpenRGBCoordinator, (self: Self@OpenRGBCoordinator) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/openrgb/coordinator.py:123:52-74: Argument `BoundMethod[OpenRGBClient, (self: OpenRGBClient) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/openrgb/light.py:141:18-42: Class member `OpenRGBLight._attr_supported_features` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/openrgb/light.py:293:55-83: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[ModeData | int | str, bool, bool]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/opensensemap/air_quality.py:8:1-42: Could not find import of `opensensemap_api` [missing-import] @@ -19840,8 +19574,6 @@ ERROR homeassistant/components/opentherm_gw/sensor.py:868:9-12: Unexpected keywo ERROR homeassistant/components/opentherm_gw/sensor.py:869:9-24: Unexpected keyword argument `translation_key` in function `OpenThermSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/opentherm_gw/sensor.py:896:5-23: Class member `OpenThermSensor.entity_description` overrides parent class `OpenThermStatusEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/opentherm_gw/sensor.py:896:5-23: Class member `OpenThermSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/opentherm_gw/services.py:123:43-51: Argument `Literal['ABCDEF']` is not assignable to parameter `container` with type `Container[Unknown]` in function `voluptuous.validators.In.__init__` [bad-argument-type] -ERROR homeassistant/components/opentherm_gw/services.py:124:45-59: Argument `Literal['RXTBOFHWCEMP']` is not assignable to parameter `container` with type `Container[Unknown]` in function `voluptuous.validators.In.__init__` [bad-argument-type] ERROR homeassistant/components/opentherm_gw/switch.py:30:9-12: Unexpected keyword argument `key` in function `OpenThermSwitchEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/opentherm_gw/switch.py:31:9-24: Unexpected keyword argument `translation_key` in function `OpenThermSwitchEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/opentherm_gw/switch.py:32:9-33: Unexpected keyword argument `translation_placeholders` in function `OpenThermSwitchEntityDescription.__init__` [unexpected-keyword] @@ -20086,7 +19818,6 @@ ERROR homeassistant/components/otbr/config_flow.py:210:20-29: `unique_id` may be ERROR homeassistant/components/otbr/config_flow.py:230:31-40: `unique_id` may be uninitialized [unbound-name] ERROR homeassistant/components/otbr/websocket_api.py:230:28-50: `thread_dataset_channel` may be uninitialized [unbound-name] ERROR homeassistant/components/otbr/websocket_api.py:234:52-74: `thread_dataset_channel` may be uninitialized [unbound-name] -ERROR homeassistant/components/otp/config_flow.py:54:25-63: Argument `BoundMethod[TOTP, (self: TOTP) -> str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/otp/config_flow.py:93:54-95:14: Unpacked argument `tuple[Any]` is not assignable to parameter `*args` with type `tuple[str, datetime | None, int]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/otp/config_flow.py:106:66-110:10: Unpacked argument `tuple[Any, Literal['Home Assistant']]` is not assignable to parameter `*args` with type `tuple[str | None, str | None, str | None]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/otp/sensor.py:41:5-23: Class member `TOTPSensor._attr_native_value` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] @@ -20595,11 +20326,8 @@ ERROR homeassistant/components/palazzetti/sensor.py:99:5-23: Class member `Palaz ERROR homeassistant/components/palazzetti/sensor.py:99:5-23: Class member `PalazzettiSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/panasonic_bluray/media_player.py:7:1-34: Could not find import of `panacotta` [missing-import] ERROR homeassistant/components/panasonic_viera/__init__.py:88:39-48: `on_action` may be uninitialized [unbound-name] -ERROR homeassistant/components/panasonic_viera/__init__.py:187:35-47: Argument `BoundMethod[Self@Remote, (self: Self@Remote) -> None]` is not assignable to parameter `func` with type `(**tuple[*@_]) -> @_` in function `Remote._handle_errors` [bad-argument-type] ERROR homeassistant/components/panasonic_viera/__init__.py:198:33-42: Object of class `Keys` has no attribute `upper` [missing-attribute] -ERROR homeassistant/components/panasonic_viera/__init__.py:242:49-78: Argument `BoundMethod[RemoteControl, (self: RemoteControl) -> Unknown]` is not assignable to parameter `func` with type `(**tuple[*@_]) -> @_` in function `Remote._handle_errors` [bad-argument-type] ERROR homeassistant/components/panasonic_viera/__init__.py:251:62-66: Argument `(**tuple[*_Ts]) -> _R` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/panasonic_viera/config_flow.py:61:21-49: Argument `BoundMethod[RemoteControl, (self: RemoteControl) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/paperless_ngx/coordinator.py:42:5-17: Class member `PaperlessCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/paperless_ngx/sensor.py:43:9-12: Unexpected keyword argument `key` in function `PaperlessEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/paperless_ngx/sensor.py:44:9-24: Unexpected keyword argument `translation_key` in function `PaperlessEntityDescription.__init__` [unexpected-keyword] @@ -20926,7 +20654,6 @@ ERROR homeassistant/components/pi_hole/update.py:94:14-18: Expected a type form, ERROR homeassistant/components/picnic/__init__.py:30:20-53: Argument `Any | None` is not assignable to parameter `auth_token` with type `str` in function `python_picnic_api2.client.PicnicAPI.__init__` [bad-argument-type] ERROR homeassistant/components/picnic/__init__.py:31:22-55: Argument `Any | None` is not assignable to parameter `country_code` with type `str` in function `python_picnic_api2.client.PicnicAPI.__init__` [bad-argument-type] ERROR homeassistant/components/picnic/coordinator.py:24:5-17: Class member `PicnicUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/picnic/coordinator.py:51:63-78: Argument `BoundMethod[Self@PicnicUpdateCoordinator, (self: Self@PicnicUpdateCoordinator) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/picnic/coordinator.py:85:17-86:74: `str` is not assignable to attribute `_user_address` with type `None` [bad-assignment] WARN homeassistant/components/picnic/coordinator.py:110:22-59: `python_picnic_api2.client.PicnicAPI.get_deliveries` is deprecated [deprecated] ERROR homeassistant/components/picnic/coordinator.py:148:37-48: Cannot set item in `dict[str, list[Unknown]]` [unsupported-operation] @@ -21021,15 +20748,8 @@ ERROR homeassistant/components/playstation_network/binary_sensor.py:70:5-16: Cla ERROR homeassistant/components/playstation_network/coordinator.py:56:5-17: Class member `PlayStationNetworkBaseCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/playstation_network/coordinator.py:101:5-21: Class member `PlaystationNetworkUserDataCoordinator._update_interval` overrides parent class `PlayStationNetworkBaseCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/playstation_network/coordinator.py:129:5-21: Class member `PlaystationNetworkTrophyTitlesCoordinator._update_interval` overrides parent class `PlayStationNetworkBaseCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/playstation_network/coordinator.py:134:13-69: Argument `() -> list[TrophyTitle]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/playstation_network/coordinator.py:145:5-21: Class member `PlaystationNetworkFriendlistCoordinator._update_interval` overrides parent class `PlayStationNetworkBaseCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/playstation_network/coordinator.py:151:13-153:14: Argument `() -> dict[str, User]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/playstation_network/coordinator.py:164:5-21: Class member `PlaystationNetworkGroupsUpdateCoordinator._update_interval` overrides parent class `PlayStationNetworkBaseCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/playstation_network/coordinator.py:170:17-174:18: Argument `() -> dict[str, TypedDict[GroupDetails]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/playstation_network/coordinator.py:230:52-63: Argument `BoundMethod[Self@PlaystationNetworkFriendDataCoordinator, (self: Self@PlaystationNetworkFriendDataCoordinator) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/playstation_network/coordinator.py:272:55-72: Argument `BoundMethod[Self@PlaystationNetworkFriendDataCoordinator, (self: Self@PlaystationNetworkFriendDataCoordinator) -> PlaystationNetworkData]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/playstation_network/helpers.py:77:48-59: Argument `BoundMethod[Self@PlaystationNetwork, (self: Self@PlaystationNetwork) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/playstation_network/helpers.py:108:55-77: Argument `BoundMethod[Self@PlaystationNetwork, (self: Self@PlaystationNetwork) -> PlaystationNetworkData]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/playstation_network/image.py:46:9-12: Unexpected keyword argument `key` in function `PlaystationNetworkImageEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/playstation_network/image.py:47:9-24: Unexpected keyword argument `translation_key` in function `PlaystationNetworkImageEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/playstation_network/image.py:53:9-12: Unexpected keyword argument `key` in function `PlaystationNetworkImageEntityDescription.__init__` [unexpected-keyword] @@ -21078,9 +20798,7 @@ ERROR homeassistant/components/playstation_network/sensor.py:179:5-23: Class mem ERROR homeassistant/components/playstation_network/sensor.py:179:5-23: Class member `PlaystationNetworkSensorBaseEntity.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/playstation_network/sensor.py:214:5-16: Class member `PlaystationNetworkSensorEntity.coordinator` overrides parent class `PlaystationNetworkSensorBaseEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/playstation_network/sensor.py:220:5-16: Class member `PlaystationNetworkFriendSensorEntity.coordinator` overrides parent class `PlaystationNetworkSensorBaseEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/plex/__init__.py:137:43-62: Argument `BoundMethod[PlexServer, (self: PlexServer) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/plex/config_flow.py:103:9-31: Class member `PlexFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] -ERROR homeassistant/components/plex/config_flow.py:214:52-71: Argument `BoundMethod[PlexServer, (self: PlexServer) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/plex/config_flow.py:361:26-57: `str` is not assignable to attribute `client_id` with type `None` [bad-assignment] ERROR homeassistant/components/plex/media_browser.py:46:45-54: Argument `str | None` is not assignable to parameter `server_id` with type `str` in function `homeassistant.components.plex.helpers.get_plex_server` [bad-argument-type] ERROR homeassistant/components/plex/media_browser.py:74:13-40: Object of class `NoneType` has no attribute `thumbnail_cache` [missing-attribute] @@ -21197,8 +20915,6 @@ ERROR homeassistant/components/plex/models.py:110:39-54: `Literal[MediaType.MUSI ERROR homeassistant/components/plex/models.py:116:17-86: `str` is not assignable to attribute `sensor_title` with type `None` [bad-assignment] ERROR homeassistant/components/plex/models.py:119:39-54: `Literal[MediaType.VIDEO]` is not assignable to attribute `media_content_type` with type `None` [bad-assignment] ERROR homeassistant/components/plex/models.py:122:33-42: `Literal['Unknown']` is not assignable to attribute `sensor_title` with type `None` [bad-assignment] -ERROR homeassistant/components/plex/sensor.py:69:39-61: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/plex/sensor.py:166:52-80: Argument `BoundMethod[Self@PlexLibrarySectionSensor, (self: Self@PlexLibrarySectionSensor) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/plex/server.py:116:38-85: `MyPlexAccount` is not assignable to attribute `_plex_account` with type `None` [bad-assignment] ERROR homeassistant/components/plex/server.py:130:45-48: `float` is not assignable to attribute `_plextv_client_timestamp` with type `int` [bad-assignment] ERROR homeassistant/components/plex/server.py:131:36-135:14: `list[Unknown]` is not assignable to attribute `_plextv_clients` with type `None` [bad-assignment] @@ -21674,8 +21390,6 @@ ERROR homeassistant/components/proximity/sensor.py:59:9-24: Unexpected keyword a ERROR homeassistant/components/proximity/sensor.py:144:14-32: Class member `ProximitySensor.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/proximity/sensor.py:175:14-32: Class member `ProximityTrackedEntitySensor.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/proxmoxve/__init__.py:8:1-54: Could not find import of `proxmoxer` [missing-import] -ERROR homeassistant/components/proxmoxve/__init__.py:136:39-51: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/proxmoxve/__init__.py:205:55-63: Argument `() -> dict[str, Any] | None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/proxmoxve/binary_sensor.py:78:5-23: Class member `ProxmoxBinarySensor._attr_device_class` overrides parent class `ProxmoxEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/proxmoxve/common.py:7:1-33: Could not find import of `proxmoxer` [missing-import] ERROR homeassistant/components/proxmoxve/common.py:8:1-45: Could not find import of `proxmoxer.core` [missing-import] @@ -21754,14 +21468,11 @@ ERROR homeassistant/components/prusalink/sensor.py:230:5-23: Class member `Prusa ERROR homeassistant/components/prusalink/sensor.py:230:5-23: Class member `PrusaLinkSensorEntity.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/ps4/config_flow.py:67:56-86: Unpacked argument `tuple[dict_keys[int, str]]` is not assignable to parameter `*args` with type `tuple[list[Unknown]]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ps4/config_flow.py:173:72-180:14: Unpacked argument `tuple[Any, str | None, str, Literal['Home-Assistant'], Literal[1988]]` is not assignable to parameter `*args` with type `tuple[str, str, str, Unknown | None, int | Unknown]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/ps4/media_player.py:152:52-72: Argument `BoundMethod[Ps4Async, (self: Ps4Async) -> dict[Unknown, Unknown]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ps4/media_player.py:156:38-71: `DDPProtocol` is not assignable to attribute `ddp_protocol` with type `None` [bad-assignment] -ERROR homeassistant/components/ps4/media_player.py:159:48-66: Argument `BoundMethod[Self@PS4Device, (self: Self@PS4Device) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ps4/media_player.py:205:54-75: Cannot index into `dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None]` [bad-index] -ERROR homeassistant/components/ps4/media_player.py:283:52-68: Argument `BoundMethod[Self@PS4Device, (self: Self@PS4Device) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ps4/media_player.py:289:54-75: Cannot index into `dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None]` [bad-index] ERROR homeassistant/components/ps4/media_player.py:295:32-55: No matching overload found for function `dict.pop` called with arguments: (str | None) [no-matching-overload] -ERROR homeassistant/components/pterodactyl/api.py:77:67-88: Argument `BoundMethod[Self@PterodactylAPI, (self: Self@PterodactylAPI) -> list[str]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] +ERROR homeassistant/components/pterodactyl/api.py:92:41-66: Cannot index into `str` [bad-index] ERROR homeassistant/components/pterodactyl/binary_sensor.py:19:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/pterodactyl/binary_sensor.py:20:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/pterodactyl/binary_sensor.py:58:14-32: Class member `PterodactylBinarySensorEntity.entity_description` overrides parent class `PterodactylEntity` in an inconsistent manner [bad-override] @@ -21968,7 +21679,6 @@ No attribute `__class__` in module `homeassistant.util.dt` [missing-attribute] ERROR homeassistant/components/qbittorrent/__init__.py:145:12-21: `unload_ok` may be uninitialized [unbound-name] ERROR homeassistant/components/qbittorrent/coordinator.py:31:5-17: Class member `QBittorrentDataCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/qbittorrent/coordinator.py:60:21-59: Argument `BoundMethod[Client, (self: Client, **kwargs: Any) -> str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/qbittorrent/coordinator.py:90:17-66: Argument `() -> TorrentInfoList` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/qbittorrent/sensor.py:117:9-12: Unexpected keyword argument `key` in function `QBittorrentSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/qbittorrent/sensor.py:118:9-24: Unexpected keyword argument `translation_key` in function `QBittorrentSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/qbittorrent/sensor.py:124:9-12: Unexpected keyword argument `key` in function `QBittorrentSensorEntityDescription.__init__` [unexpected-keyword] @@ -22091,8 +21801,6 @@ ERROR homeassistant/components/qld_bushfire/geo_location.py:219:34-54: `datetime ERROR homeassistant/components/qld_bushfire/geo_location.py:220:30-48: `datetime | None` is not assignable to attribute `_updated_date` with type `None` [bad-assignment] ERROR homeassistant/components/qld_bushfire/geo_location.py:221:24-41: `str` is not assignable to attribute `_status` with type `None` [bad-assignment] ERROR homeassistant/components/qnap/__init__.py:34:12-21: `unload_ok` may be uninitialized [unbound-name] -ERROR homeassistant/components/qnap/config_flow.py:68:64-84: Argument `BoundMethod[QNAPStats, (self: QNAPStats) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/qnap/coordinator.py:88:55-72: Argument `BoundMethod[Self@QnapCoordinator, (self: Self@QnapCoordinator) -> dict[str, dict[str, Any]]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/qnap/sensor.py:47:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/qnap/sensor.py:48:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/qnap/sensor.py:49:9-24: Unexpected keyword argument `entity_category` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -22294,9 +22002,6 @@ ERROR homeassistant/components/rachio/binary_sensor.py:141:5-23: Class member `R ERROR homeassistant/components/rachio/binary_sensor.py:141:5-23: Class member `RachioControllerBinarySensor.entity_description` overrides parent class `BinarySensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/rachio/binary_sensor.py:192:5-23: Class member `RachioHoseTimerBinarySensor.entity_description` overrides parent class `RachioHoseTimerEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/rachio/binary_sensor.py:192:5-23: Class member `RachioHoseTimerBinarySensor.entity_description` overrides parent class `BinarySensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/rachio/config_flow.py:49:50-68: Argument `BoundMethod[Person, (self: Person) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/rachio/config_flow.py:51:16-23: Cannot index into `object` [bad-index] -ERROR homeassistant/components/rachio/config_flow.py:54:21-28: Cannot index into `object` [bad-index] ERROR homeassistant/components/rachio/config_flow.py:113:9-31: Class member `RachioConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/rachio/device.py:285:15-38: Object of class `Rachio` has no attribute `webhook_url` [missing-attribute] ERROR homeassistant/components/rachio/device.py:286:35-59: Object of class `Rachio` has no attribute `webhook_auth` [missing-attribute] @@ -22331,7 +22036,6 @@ ERROR homeassistant/components/radarr/sensor.py:98:9-24: Unexpected keyword argu ERROR homeassistant/components/radarr/sensor.py:99:9-40: Unexpected keyword argument `entity_registry_enabled_default` in function `RadarrSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/radarr/sensor.py:138:5-23: Class member `RadarrSensor.entity_description` overrides parent class `RadarrEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/radarr/sensor.py:138:5-23: Class member `RadarrSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/radio_browser/media_source.py:152:52-84: Argument `() -> int` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/radiotherm/__init__.py:74:12-21: `unload_ok` may be uninitialized [unbound-name] ERROR homeassistant/components/radiotherm/climate.py:116:14-38: Class member `RadioThermostat._attr_supported_features` overrides parent class `RadioThermostatEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/radiotherm/coordinator.py:25:5-17: Class member `RadioThermUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] @@ -22360,7 +22064,6 @@ ERROR homeassistant/components/rainforest_eagle/coordinator.py:32:5-17: Class me ERROR homeassistant/components/rainforest_eagle/coordinator.py:89:26-40: `eagle200_meter` may be uninitialized [unbound-name] ERROR homeassistant/components/rainforest_eagle/coordinator.py:92:35-49: `eagle200_meter` may be uninitialized [unbound-name] ERROR homeassistant/components/rainforest_eagle/coordinator.py:93:35-49: `eagle200_meter` may be uninitialized [unbound-name] -ERROR homeassistant/components/rainforest_eagle/coordinator.py:102:59-79: Argument `BoundMethod[Self@EagleDataCoordinator, (self: Self@EagleDataCoordinator) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/rainforest_eagle/sensor.py:24:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/rainforest_eagle/sensor.py:25:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/rainforest_eagle/sensor.py:31:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -22528,10 +22231,6 @@ ERROR homeassistant/components/recollect_waste/sensor.py:77:14-32: Class member ERROR homeassistant/components/recollect_waste/sensor.py:93:65-70: `event` may be uninitialized [unbound-name] ERROR homeassistant/components/recollect_waste/sensor.py:95:58-63: `event` may be uninitialized [unbound-name] ERROR homeassistant/components/recollect_waste/sensor.py:97:39-44: `event` may be uninitialized [unbound-name] -ERROR homeassistant/components/recorder/core.py:742:27-56: Argument `BoundMethod[Self@Recorder, (self: Self@Recorder) -> None]` is not assignable to parameter `target` with type `((**tuple[*@_]) -> Any) | Coroutine[Any, Any, Any]` in function `homeassistant.core.HomeAssistant.add_job` [bad-argument-type] -ERROR homeassistant/components/recorder/core.py:781:39-60: Argument `BoundMethod[Self@Recorder, (self: Self@Recorder) -> None]` is not assignable to parameter `target` with type `((**tuple[*@_]) -> Any) | Coroutine[Any, Any, Any]` in function `homeassistant.core.HomeAssistant.add_job` [bad-argument-type] -ERROR homeassistant/components/recorder/core.py:802:27-72: Argument `BoundMethod[Self@Recorder, (self: Self@Recorder) -> None]` is not assignable to parameter `target` with type `((**tuple[*@_]) -> Any) | Coroutine[Any, Any, Any]` in function `homeassistant.core.HomeAssistant.add_job` [bad-argument-type] -ERROR homeassistant/components/recorder/core.py:821:27-50: Argument `BoundMethod[Self@Recorder, (self: Self@Recorder) -> None]` is not assignable to parameter `target` with type `((**tuple[*@_]) -> Any) | Coroutine[Any, Any, Any]` in function `homeassistant.core.HomeAssistant.add_job` [bad-argument-type] ERROR homeassistant/components/recorder/core.py:1419:54-74: Cannot set item in `dict[str, str]` [unsupported-operation] ERROR homeassistant/components/recorder/db_schema.py:646:13-24: Unexpected keyword argument `metadata_id` in function `object.__init__` [unexpected-keyword] ERROR homeassistant/components/recorder/db_schema.py:647:13-20: Unexpected keyword argument `created` in function `object.__init__` [unexpected-keyword] @@ -22575,11 +22274,8 @@ ERROR homeassistant/components/recorder/table_managers/event_types.py:85:35-48: ERROR homeassistant/components/recorder/table_managers/recorder_runs.py:90:27-30: `run` may be uninitialized [unbound-name] ERROR homeassistant/components/recorder/table_managers/state_attributes.py:92:37-50: `attributes_id` may be uninitialized [unbound-name] ERROR homeassistant/components/recorder/table_managers/states_meta.py:96:34-45: `metadata_id` may be uninitialized [unbound-name] -ERROR homeassistant/components/recorder/tasks.py:328:49-77: Argument `BoundMethod[Self@SynchronizeTask, (self: Self@SynchronizeTask) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/components/recorder/util.py:126:49-60: `timer_start` may be uninitialized [unbound-name] ERROR homeassistant/components/recorder/websocket_api.py:245:13-18: `types` may be uninitialized [unbound-name] -ERROR homeassistant/components/recorder/websocket_api.py:369:40-54: Argument `BoundMethod[Event, (self: Event) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] -ERROR homeassistant/components/recorder/websocket_api.py:425:40-54: Argument `BoundMethod[Event, (self: Event) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/components/recswitch/switch.py:8:1-50: Could not find import of `pyrecswitch` [missing-import] ERROR homeassistant/components/reddit/sensor.py:88:12-27: Module `praw.exceptions` exists, but was not imported explicitly. You are relying on other modules to load it. [implicit-import] ERROR homeassistant/components/reddit/sensor.py:156:16-31: Module `praw.exceptions` exists, but was not imported explicitly. You are relying on other modules to load it. [implicit-import] @@ -22690,8 +22386,6 @@ ERROR homeassistant/components/remember_the_milk/__init__.py:135:13-18: Argument ERROR homeassistant/components/remote/__init__.py:163:5-23: Class member `RemoteEntity.entity_description` overrides parent class `ToggleEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/remote/__init__.py:166:5-29: Class member `RemoteEntity._attr_supported_features` overrides parent class `ToggleEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/remote/reproduce_state.py:56:17-24: `service` may be uninitialized [unbound-name] -ERROR homeassistant/components/remote_calendar/calendar.py:78:55-70: Argument `() -> list[CalendarEvent]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/remote_calendar/calendar.py:94:65-78: Argument `() -> SortableItemTimeline[Event] | None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/remote_calendar/coordinator.py:28:5-17: Class member `RemoteCalendarDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/remote_rpi_gpio/__init__.py:39:21-33: `pull_gpio_up` may be uninitialized [unbound-name] ERROR homeassistant/components/renault/binary_sensor.py:69:5-23: Class member `RenaultBinarySensor.entity_description` overrides parent class `RenaultDataEntity` in an inconsistent manner [bad-override] @@ -22778,7 +22472,6 @@ ERROR homeassistant/components/renault/sensor.py:363:9-12: Unexpected keyword ar ERROR homeassistant/components/renault/sensor.py:370:9-24: Unexpected keyword argument `translation_key` in function `RenaultSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/renault/sensor.py:373:9-12: Unexpected keyword argument `key` in function `RenaultSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/renault/sensor.py:380:9-24: Unexpected keyword argument `translation_key` in function `RenaultSensorEntityDescription.__init__` [unexpected-keyword] -ERROR homeassistant/components/renson/__init__.py:42:46-57: Argument `BoundMethod[RensonVentilation, (self: RensonVentilation) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/renson/__init__.py:62:12-21: `unload_ok` may be uninitialized [unbound-name] ERROR homeassistant/components/renson/binary_sensor.py:43:9-24: Unexpected keyword argument `translation_key` in function `RensonBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/renson/binary_sensor.py:44:9-12: Unexpected keyword argument `key` in function `RensonBinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -22811,9 +22504,7 @@ ERROR homeassistant/components/renson/button.py:47:9-24: Unexpected keyword argu ERROR homeassistant/components/renson/button.py:48:9-24: Unexpected keyword argument `entity_category` in function `RensonButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/renson/button.py:75:5-23: Class member `RensonButton.entity_description` overrides parent class `RensonEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/renson/button.py:75:5-23: Class member `RensonButton.entity_description` overrides parent class `ButtonEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/renson/config_flow.py:38:55-66: Argument `BoundMethod[RensonVentilation, (self: RensonVentilation) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/renson/coordinator.py:24:5-17: Class member `RensonCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/renson/coordinator.py:47:59-80: Argument `BoundMethod[RensonVentilation, (self: RensonVentilation) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/renson/fan.py:124:5-29: Class member `RensonFan._attr_supported_features` overrides parent class `RensonEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/renson/fan.py:197:62-86: Argument `FieldEnum` is not assignable to parameter `fieldname` with type `str` in function `renson_endura_delta.renson.RensonVentilation.get_field_value` [bad-argument-type] ERROR homeassistant/components/renson/fan.py:198:51-200:14: Unpacked argument `tuple[Level, str, Literal[True]]` is not assignable to parameter `*args` with type `tuple[Level, int, bool]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] @@ -23736,8 +23427,6 @@ ERROR homeassistant/components/ring/camera.py:68:9-40: Unexpected keyword argume ERROR homeassistant/components/ring/camera.py:169:16-21: `image` may be uninitialized [unbound-name] ERROR homeassistant/components/ring/camera.py:186:17-30: Argument `asyncio.streams.StreamReader` is not assignable to parameter `stream` with type `aiohttp.streams.StreamReader` in function `homeassistant.helpers.aiohttp_client.async_aiohttp_proxy_stream` [bad-argument-type] ERROR homeassistant/components/ring/coordinator.py:51:5-17: Class member `RingDataCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/ring/coordinator.py:76:32-39: Unpacked argument `tuple[object, ...]` is not assignable to varargs type `tuple[*_Ts]` [bad-argument-type] -ERROR homeassistant/components/ring/coordinator.py:119:33-64: Argument `BoundMethod[RingGeneric, (self: RingGeneric) -> Coroutine[Unknown, Unknown, None]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> Coroutine[Any, Any, @_]` in function `RingDataCoordinator._call_api` [bad-argument-type] ERROR homeassistant/components/ring/entity.py:145:34-49: `deprecated_info` may be uninitialized [unbound-name] ERROR homeassistant/components/ring/entity.py:154:33-48: `deprecated_info` may be uninitialized [unbound-name] ERROR homeassistant/components/ring/event.py:34:9-12: Unexpected keyword argument `key` in function `RingEventEntityDescription.__init__` [unexpected-keyword] @@ -23920,7 +23609,6 @@ ERROR homeassistant/components/roborock/number.py:41:9-24: Unexpected keyword ar ERROR homeassistant/components/roborock/number.py:46:9-24: Unexpected keyword argument `entity_category` in function `RoborockNumberDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/roborock/number.py:93:5-23: Class member `RoborockNumberEntity.entity_description` overrides parent class `RoborockEntityV1` in an inconsistent manner [bad-override] ERROR homeassistant/components/roborock/number.py:93:5-23: Class member `RoborockNumberEntity.entity_description` overrides parent class `NumberEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/roborock/roborock_storage.py:66:49-59: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/roborock/select.py:43:9-12: Unexpected keyword argument `key` in function `RoborockSelectDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/roborock/select.py:44:9-24: Unexpected keyword argument `translation_key` in function `RoborockSelectDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/roborock/select.py:47:9-24: Unexpected keyword argument `entity_category` in function `RoborockSelectDescription.__init__` [unexpected-keyword] @@ -24127,12 +23815,8 @@ ERROR homeassistant/components/romy/sensor.py:69:9-24: Unexpected keyword argume ERROR homeassistant/components/romy/sensor.py:72:9-24: Unexpected keyword argument `entity_category` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/romy/sensor.py:96:5-23: Class member `RomySensor.entity_description` overrides parent class `RomyEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/romy/vacuum.py:65:5-29: Class member `RomyVacuumEntity._attr_supported_features` overrides parent class `RomyEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/roomba/__init__.py:84:47-61: Argument `BoundMethod[Roomba, (self: Roomba) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/roomba/__init__.py:108:47-64: Argument `BoundMethod[Roomba, (self: Roomba) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/roomba/config_flow.py:92:9-31: Class member `RoombaConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/roomba/config_flow.py:134:30-53: Object of class `object` has no attribute `get` [missing-attribute] -ERROR homeassistant/components/roomba/config_flow.py:252:63-85: Argument `BoundMethod[RoombaPassword, (self: RoombaPassword) -> str | None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/roomba/config_flow.py:364:68-85: Argument `BoundMethod[RoombaDiscovery, (self: RoombaDiscovery) -> set[RoombaInfo]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/roomba/sensor.py:34:9-12: Unexpected keyword argument `key` in function `RoombaSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/roomba/sensor.py:35:9-24: Unexpected keyword argument `translation_key` in function `RoombaSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/roomba/sensor.py:37:9-24: Unexpected keyword argument `entity_category` in function `RoombaSensorEntityDescription.__init__` [unexpected-keyword] @@ -24203,9 +23887,6 @@ ERROR homeassistant/components/roon/server.py:124:31-49: Object of class `NoneTy ERROR homeassistant/components/roon/server.py:127:20-38: Object of class `NoneType` has no attribute `zones` [missing-attribute] ERROR homeassistant/components/roon/server.py:144:20-38: Object of class `NoneType` has no attribute `zones` [missing-attribute] ERROR homeassistant/components/roon/server.py:149:21-39: Object of class `NoneType` has no attribute `zones` [missing-attribute] -ERROR homeassistant/components/route_b_smart_meter/__init__.py:27:39-67: Argument `BoundMethod[Momonga, (self: Momonga) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/route_b_smart_meter/coordinator.py:57:13-26: Argument `BoundMethod[Momonga, (self: Momonga) -> Momonga]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/route_b_smart_meter/coordinator.py:73:59-73: Argument `BoundMethod[Self@BRouteUpdateCoordinator, (self: Self@BRouteUpdateCoordinator) -> BRouteData]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/route_b_smart_meter/sensor.py:39:9-12: Unexpected keyword argument `key` in function `SensorEntityDescriptionWithValueAccessor.__init__` [unexpected-keyword] ERROR homeassistant/components/route_b_smart_meter/sensor.py:40:9-24: Unexpected keyword argument `translation_key` in function `SensorEntityDescriptionWithValueAccessor.__init__` [unexpected-keyword] ERROR homeassistant/components/route_b_smart_meter/sensor.py:47:9-12: Unexpected keyword argument `key` in function `SensorEntityDescriptionWithValueAccessor.__init__` [unexpected-keyword] @@ -24216,9 +23897,7 @@ ERROR homeassistant/components/route_b_smart_meter/sensor.py:63:9-12: Unexpected ERROR homeassistant/components/route_b_smart_meter/sensor.py:64:9-24: Unexpected keyword argument `translation_key` in function `SensorEntityDescriptionWithValueAccessor.__init__` [unexpected-keyword] ERROR homeassistant/components/route_b_smart_meter/sensor.py:99:14-32: Class member `SmartMeterBRouteSensor.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/route_b_smart_meter/sensor.py:99:14-32: Class member `SmartMeterBRouteSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/rova/__init__.py:30:55-71: Argument `BoundMethod[Rova, (self: Rova) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/rova/__init__.py:64:12-21: `unload_ok` may be uninitialized [unbound-name] -ERROR homeassistant/components/rova/config_flow.py:37:63-79: Argument `BoundMethod[Rova, (self: Rova) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/rova/coordinator.py:20:5-17: Class member `RovaCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/rova/sensor.py:25:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/rova/sensor.py:26:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -24230,8 +23909,7 @@ ERROR homeassistant/components/rova/sensor.py:37:9-12: Unexpected keyword argume ERROR homeassistant/components/rova/sensor.py:38:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/rova/sensor.py:62:5-23: Class member `RovaSensor._attr_device_class` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/rova/sensor.py:73:14-32: Class member `RovaSensor.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/rpi_power/binary_sensor.py:34:55-72: Argument `() -> UnderVoltage | None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/rpi_power/config_flow.py:19:55-72: Argument `() -> UnderVoltage | None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] +ERROR homeassistant/components/rpi_power/binary_sensor.py:35:54-67: Argument `UnderVoltage | None` is not assignable to parameter `under_voltage` with type `UnderVoltage` in function `RaspberryChargerBinarySensor.__init__` [bad-argument-type] ERROR homeassistant/components/rtorrent/sensor.py:45:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/rtorrent/sensor.py:46:9-13: Unexpected keyword argument `name` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/rtorrent/sensor.py:49:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -24358,23 +24036,16 @@ ERROR homeassistant/components/sabnzbd/sensor.py:129:5-23: Class member `Sabnzbd ERROR homeassistant/components/sabnzbd/sensor.py:129:5-23: Class member `SabnzbdSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/saj/sensor.py:10:8-13: Could not find import of `pysaj` [missing-import] ERROR homeassistant/components/saj/sensor.py:145:9-31: Expected a callable, got `None` [not-callable] -ERROR homeassistant/components/samsungtv/bridge.py:281:55-66: Argument `BoundMethod[Self@SamsungTVLegacyBridge, (self: Self@SamsungTVLegacyBridge) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/samsungtv/bridge.py:296:55-72: Argument `BoundMethod[Self@SamsungTVLegacyBridge, (self: Self@SamsungTVLegacyBridge) -> str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/samsungtv/bridge.py:333:49-70: Argument `() -> None` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/components/samsungtv/bridge.py:351:16-28: Returned type `Remote | None` is not assignable to declared return type `Remote` [bad-return] -ERROR homeassistant/components/samsungtv/bridge.py:393:48-66: Argument `BoundMethod[Self@SamsungTVLegacyBridge, (self: Self@SamsungTVLegacyBridge) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/samsungtv/bridge.py:520:18-22: Class member `SamsungTVWSBridge.port` overrides parent class `SamsungTVWSBaseBridge` in an inconsistent manner [bad-override] ERROR homeassistant/components/samsungtv/coordinator.py:24:5-17: Class member `SamsungTVDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/samsungtv/entity.py:101:52-69: Argument `BoundMethod[Self@SamsungTVEntity, (self: Self@SamsungTVEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/samsungtv/media_player.py:80:5-22: Class member `SamsungTVDevice._attr_source_list` overrides parent class `MediaPlayerEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/samsungtv/media_player.py:82:5-23: Class member `SamsungTVDevice._attr_device_class` overrides parent class `SamsungTVEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/samsungtv/media_player.py:93:14-35: Class member `SamsungTVDevice._attr_is_volume_muted` overrides parent class `MediaPlayerEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/samsungtv/media_player.py:98:14-38: Class member `SamsungTVDevice._attr_supported_features` overrides parent class `SamsungTVEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/samsungtv/media_player.py:138:18-29: Class member `SamsungTVDevice._attr_state` overrides parent class `SamsungTVEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/sanix/__init__.py:37:12-21: `unload_ok` may be uninitialized [unbound-name] -ERROR homeassistant/components/sanix/config_flow.py:44:56-76: Argument `BoundMethod[Sanix, (self: Sanix) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sanix/coordinator.py:22:5-17: Class member `SanixCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/sanix/coordinator.py:40:59-85: Argument `BoundMethod[Sanix, (self: Sanix) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sanix/sensor.py:43:9-12: Unexpected keyword argument `key` in function `SanixSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/sanix/sensor.py:50:9-12: Unexpected keyword argument `key` in function `SanixSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/sanix/sensor.py:57:9-12: Unexpected keyword argument `key` in function `SanixSensorEntityDescription.__init__` [unexpected-keyword] @@ -24396,7 +24067,6 @@ ERROR homeassistant/components/satel_integra/config_flow.py:98:9-31: Class membe ERROR homeassistant/components/saunum/__init__.py:50:12-21: `unload_ok` may be uninitialized [unbound-name] ERROR homeassistant/components/saunum/climate.py:46:5-29: Class member `LeilSaunaClimate._attr_supported_features` overrides parent class `LeilSaunaEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/saunum/coordinator.py:24:5-17: Class member `LeilSaunaCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/scene/__init__.py:113:49-78: Argument `BoundMethod[Self@BaseScene, (self: Self@BaseScene) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> @_` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] ERROR homeassistant/components/schedule/__init__.py:251:16-20: `data` may be uninitialized [unbound-name] ERROR homeassistant/components/schedule/__init__.py:263:5-16: Class member `Schedule._attr_state` overrides parent class `CollectionEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/schlage/binary_sensor.py:30:9-12: Unexpected keyword argument `key` in function `SchlageBinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -24405,8 +24075,6 @@ ERROR homeassistant/components/schlage/binary_sensor.py:33:9-24: Unexpected keyw ERROR homeassistant/components/schlage/binary_sensor.py:65:5-23: Class member `SchlageBinarySensor.entity_description` overrides parent class `SchlageEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/schlage/binary_sensor.py:65:5-23: Class member `SchlageBinarySensor.entity_description` overrides parent class `BinarySensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/schlage/coordinator.py:43:5-17: Class member `SchlageDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/schlage/lock.py:60:48-63: Argument `BoundMethod[Lock, (self: Lock) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/schlage/lock.py:65:48-65: Argument `BoundMethod[Lock, (self: Lock) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/schlage/select.py:17:9-12: Unexpected keyword argument `key` in function `homeassistant.components.select.SelectEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/schlage/select.py:18:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.select.SelectEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/schlage/select.py:19:9-24: Unexpected keyword argument `entity_category` in function `homeassistant.components.select.SelectEntityDescription.__init__` [unexpected-keyword] @@ -24844,7 +24512,6 @@ ERROR homeassistant/components/sensoterra/sensor.py:73:9-12: Unexpected keyword ERROR homeassistant/components/sensoterra/sensor.py:78:9-24: Unexpected keyword argument `entity_category` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/sensoterra/sensor.py:79:9-40: Unexpected keyword argument `entity_registry_enabled_default` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/sensoterra/sensor.py:137:14-32: Class member `SensoterraEntity.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/sentry/__init__.py:107:50-59: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_import_executor_job` [bad-argument-type] ERROR homeassistant/components/sentry/config_flow.py:48:9-31: Class member `SentryConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/senz/climate.py:45:5-29: Class member `SENZClimate._attr_supported_features` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/senz/sensor.py:35:9-12: Unexpected keyword argument `key` in function `SenzSensorDescription.__init__` [unexpected-keyword] @@ -24935,7 +24602,6 @@ ERROR homeassistant/components/sfr_box/sensor.py:199:9-24: Unexpected keyword ar ERROR homeassistant/components/sfr_box/sensor.py:248:5-23: Class member `SFRBoxSensor.entity_description` overrides parent class `SFRCoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/sfr_box/sensor.py:248:5-23: Class member `SFRBoxSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/sftp_storage/backup.py:64:15-36: Class member `SFTPBackupAgent.async_download_backup` overrides parent class `BackupAgent` in an inconsistent manner [bad-override] -ERROR homeassistant/components/sftp_storage/config_flow.py:236:46-61: Argument `() -> str` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sharkiq/coordinator.py:27:5-17: Class member `SharkIqUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/sharkiq/coordinator.py:73:20-74:73: `>` is not supported between `datetime` and `timedelta` [unsupported-operation] ERROR homeassistant/components/sharkiq/coordinator.py:74:19-73: `-` is not supported between `None` and `timedelta` [unsupported-operation] @@ -25612,16 +25278,6 @@ ERROR homeassistant/components/shelly/valve.py:228:5-23: Class member `BlockShel ERROR homeassistant/components/shelly/valve.py:229:5-23: Class member `BlockShellyValve._attr_device_class` overrides parent class `ShellyBlockAttributeEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/shelly/valve.py:230:5-29: Class member `BlockShellyValve._attr_supported_features` overrides parent class `ShellyBlockAttributeEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/shodan/sensor.py:8:8-14: Could not find import of `shodan` [missing-import] -ERROR homeassistant/components/shopping_list/__init__.py:211:48-57: Argument `BoundMethod[Self@ShoppingData, (self: Self@ShoppingData) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/shopping_list/__init__.py:248:48-57: Argument `BoundMethod[Self@ShoppingData, (self: Self@ShoppingData) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/shopping_list/__init__.py:272:48-57: Argument `BoundMethod[Self@ShoppingData, (self: Self@ShoppingData) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/shopping_list/__init__.py:293:48-57: Argument `BoundMethod[Self@ShoppingData, (self: Self@ShoppingData) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/shopping_list/__init__.py:305:48-57: Argument `BoundMethod[Self@ShoppingData, (self: Self@ShoppingData) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/shopping_list/__init__.py:319:48-57: Argument `BoundMethod[Self@ShoppingData, (self: Self@ShoppingData) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/shopping_list/__init__.py:354:42-51: Argument `BoundMethod[Self@ShoppingData, (self: Self@ShoppingData) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/shopping_list/__init__.py:379:48-57: Argument `BoundMethod[Self@ShoppingData, (self: Self@ShoppingData) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/shopping_list/__init__.py:391:42-51: Argument `BoundMethod[Self@ShoppingData, (self: Self@ShoppingData) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/shopping_list/__init__.py:409:61-65: Argument `() -> list[dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sia/alarm_control_panel.py:36:5-8: Unexpected keyword argument `key` in function `SIAAlarmControlPanelEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/sia/alarm_control_panel.py:90:5-23: Class member `SIAAlarmControlPanel.entity_description` overrides parent class `SIABaseEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/sia/alarm_control_panel.py:90:5-23: Class member `SIAAlarmControlPanel.entity_description` overrides parent class `AlarmControlPanelEntity` in an inconsistent manner [bad-override] @@ -26104,16 +25760,6 @@ ERROR homeassistant/components/sma/sensor.py:827:9-12: Unexpected keyword argume ERROR homeassistant/components/sma/sensor.py:828:9-13: Unexpected keyword argument `name` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/sma/sensor.py:868:18-36: Class member `SMAsensor.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/sma/sensor.py:904:19-30: `name_prefix` may be uninitialized [unbound-name] -ERROR homeassistant/components/smappee/__init__.py:85:47-85: Argument `BoundMethod[SmappeeLocalMqtt, (self: SmappeeLocalMqtt) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/smappee/__init__.py:95:43-78: Argument `BoundMethod[Smappee, (self: Smappee) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/smappee/__init__.py:132:13-60: Argument `BoundMethod[Smappee, (self: Smappee) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/smappee/config_flow.py:92:62-88: Argument `BoundMethod[SmappeeLocalMqtt, (self: SmappeeLocalMqtt) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/smappee/config_flow.py:98:60-77: Argument `BoundMethod[SmappeeLocalApi, (self: SmappeeLocalApi) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/smappee/config_flow.py:165:56-73: Argument `BoundMethod[SmappeeLocalApi, (self: SmappeeLocalApi) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/smappee/config_flow.py:168:17-49: Argument `BoundMethod[SmappeeLocalApi, (self: SmappeeLocalApi) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/smappee/config_flow.py:176:62-88: Argument `BoundMethod[SmappeeLocalMqtt, (self: SmappeeLocalMqtt) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/smappee/config_flow.py:181:17-55: Argument `BoundMethod[SmappeeLocalMqtt, (self: SmappeeLocalMqtt) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/smappee/config_flow.py:183:52-69: Argument `BoundMethod[SmappeeLocalMqtt, (self: SmappeeLocalMqtt) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/smappee/sensor.py:45:9-12: Unexpected keyword argument `key` in function `SmappeePollingSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/smappee/sensor.py:46:9-13: Unexpected keyword argument `name` in function `SmappeePollingSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/smappee/sensor.py:54:9-12: Unexpected keyword argument `key` in function `SmappeePollingSensorEntityDescription.__init__` [unexpected-keyword] @@ -26484,8 +26130,6 @@ ERROR homeassistant/components/smarty/button.py:32:9-24: Unexpected keyword argu ERROR homeassistant/components/smarty/button.py:55:5-23: Class member `SmartyButton.entity_description` overrides parent class `SmartyEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/smarty/button.py:55:5-23: Class member `SmartyButton.entity_description` overrides parent class `ButtonEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/smarty/coordinator.py:21:5-17: Class member `SmartyCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/smarty/coordinator.py:37:55-73: Argument `BoundMethod[Smarty, (self: Smarty) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/smarty/coordinator.py:44:55-73: Argument `BoundMethod[Smarty, (self: Smarty) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/smarty/fan.py:46:5-29: Class member `SmartyFan._attr_supported_features` overrides parent class `SmartyEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/smarty/sensor.py:44:9-12: Unexpected keyword argument `key` in function `SmartySensorDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/smarty/sensor.py:45:9-24: Unexpected keyword argument `translation_key` in function `SmartySensorDescription.__init__` [unexpected-keyword] @@ -26663,7 +26307,6 @@ ERROR homeassistant/components/snmp/sensor.py:141:56-79: Multiple values for arg ERROR homeassistant/components/snmp/sensor.py:220:56-61: `value` may be uninitialized [unbound-name] ERROR homeassistant/components/snmp/sensor.py:246:17-38: Object of class `int` has no attribute `prettyPrint` [missing-attribute] ERROR homeassistant/components/snmp/switch.py:273:17-38: Object of class `int` has no attribute `prettyPrint` [missing-attribute] -ERROR homeassistant/components/snmp/util.py:78:48-64: Argument `() -> SnmpEngine` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/snoo/binary_sensor.py:32:9-12: Unexpected keyword argument `key` in function `SnooBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/snoo/binary_sensor.py:33:9-24: Unexpected keyword argument `translation_key` in function `SnooBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/snoo/binary_sensor.py:34:18-52: Argument `(data: SnooData) -> int` is not assignable to parameter `value_fn` with type `(SnooData) -> bool` in function `SnooBinarySensorEntityDescription.__init__` [bad-argument-type] @@ -26900,8 +26543,6 @@ ERROR homeassistant/components/solax/sensor.py:78:9-12: Unexpected keyword argum ERROR homeassistant/components/solax/sensor.py:84:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/solax/sensor.py:144:14-32: Class member `InverterSensorEntity._attr_device_class` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/solax/sensor.py:156:16-42: Object of class `dict` has no attribute `data` [missing-attribute] -ERROR homeassistant/components/soma/__init__.py:52:49-65: Argument `BoundMethod[SomaApi, (self: SomaApi) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/soma/config_flow.py:52:61-77: Argument `BoundMethod[SomaApi, (self: SomaApi) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/soma/cover.py:49:5-23: Class member `SomaTilt._attr_device_class` overrides parent class `SomaEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/soma/cover.py:50:5-29: Class member `SomaTilt._attr_supported_features` overrides parent class `SomaEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/soma/cover.py:123:37-69: `float` is not assignable to attribute `current_position` with type `int` [bad-assignment] @@ -26946,13 +26587,8 @@ ERROR homeassistant/components/songpal/media_player.py:431:22-51: Object of clas ERROR homeassistant/components/sonos/__init__.py:115:33-47: `Module[soco.events_asyncio]` is not assignable to attribute `EVENTS_MODULE` with type `None` [bad-assignment] ERROR homeassistant/components/sonos/__init__.py:117:38-43: `Literal[False]` is not assignable to attribute `ZGT_EVENT_FALLBACK` with type `Literal[True]` [bad-assignment] ERROR homeassistant/components/sonos/__init__.py:118:5-39: No attribute `EVENT_CACHE_TIMEOUT` in module `soco.zonegroupstate` [missing-attribute] -ERROR homeassistant/components/sonos/__init__.py:349:52-65: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/sonos/__init__.py:456:60-78: Argument `BoundMethod[SonosSpeaker, (SonosSpeaker) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sonos/binary_sensor.py:62:5-23: Class member `SonosPowerEntity._attr_device_class` overrides parent class `SonosEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/sonos/binary_sensor.py:104:48-63: Argument `BoundMethod[Self@SonosMicrophoneSensorEntity, (Self@SonosMicrophoneSensorEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/sonos/diagnostics.py:106:9-32: Argument `() -> dict[str, Any] | str` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sonos/diagnostics.py:129:20-30: Returned type `MappingProxyType[str, Any]` is not assignable to declared return type `dict[str, Any] | float | int | str` [bad-return] -ERROR homeassistant/components/sonos/household_coordinator.py:41:27-44: Argument `BoundMethod[Self@SonosHouseholdCoordinator, (self: Self@SonosHouseholdCoordinator) -> None]` is not assignable to parameter `target` with type `((**tuple[*@_]) -> Any) | Coroutine[Any, Any, Any]` in function `homeassistant.core.HomeAssistant.add_job` [bad-argument-type] ERROR homeassistant/components/sonos/media.py:176:16-21: `ct_md` may be uninitialized [unbound-name] ERROR homeassistant/components/sonos/media.py:176:34-39: `ct_md` may be uninitialized [unbound-name] ERROR homeassistant/components/sonos/media.py:176:59-64: `ct_md` may be uninitialized [unbound-name] @@ -26964,7 +26600,6 @@ ERROR homeassistant/components/sonos/media_browser.py:304:21-38: Expected a call ERROR homeassistant/components/sonos/media_browser.py:497:26-34: Argument `DidlFavorite` is not assignable to parameter `item` with type `MusicServiceItem | None` in function `get_thumbnail_url_full` [bad-argument-type] ERROR homeassistant/components/sonos/media_player.py:116:5-29: Class member `SonosMediaPlayerEntity._attr_supported_features` overrides parent class `SonosEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/sonos/media_player.py:136:5-23: Class member `SonosMediaPlayerEntity._attr_device_class` overrides parent class `SonosEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/sonos/media_player.py:208:48-60: Argument `BoundMethod[Self@SonosMediaPlayerEntity, (self: Self@SonosMediaPlayerEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sonos/media_player.py:230:27-47: Cannot index into `dict[str, tuple[bool, bool] | tuple[bool, str]]` [bad-index] ERROR homeassistant/components/sonos/media_player.py:235:35-55: Cannot index into `dict[str, tuple[bool, bool] | tuple[bool, str]]` [bad-index] ERROR homeassistant/components/sonos/media_player.py:317:35-55: Cannot index into `dict[str, tuple[bool, bool] | tuple[bool, str]]` [bad-index] @@ -26975,21 +26610,14 @@ ERROR homeassistant/components/sonos/media_player.py:381:22-49: Object of class ERROR homeassistant/components/sonos/media_player.py:487:46-490:22: Argument `dict[str, dict[str, Any] | str]` is not assignable to parameter `translation_placeholders` with type `dict[str, str] | None` in function `homeassistant.exceptions.HomeAssistantError.__init__` [bad-argument-type] ERROR homeassistant/components/sonos/number.py:122:14-36: Class member `SonosLevelEntity._attr_native_min_value` overrides parent class `NumberEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/sonos/number.py:122:43-65: Class member `SonosLevelEntity._attr_native_max_value` overrides parent class `NumberEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/sonos/number.py:126:48-63: Argument `BoundMethod[Self@SonosLevelEntity, (Self@SonosLevelEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sonos/select.py:36:9-12: Unexpected keyword argument `key` in function `SonosSelectEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/sonos/select.py:37:9-24: Unexpected keyword argument `translation_key` in function `SonosSelectEntityDescription.__init__` [unexpected-keyword] -ERROR homeassistant/components/sonos/select.py:104:48-63: Argument `BoundMethod[Self@SonosSelectEntity, (Self@SonosSelectEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sonos/sensor.py:100:5-23: Class member `SonosBatteryEntity._attr_device_class` overrides parent class `SonosEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/sonos/sensor.py:127:5-23: Class member `SonosPowerSourceEntity._attr_device_class` overrides parent class `SonosEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/sonos/speaker.py:131:13-42: Object of class `SubscriptionBase` has no attribute `callback` [missing-attribute] ERROR homeassistant/components/sonos/speaker.py:337:22-59: Object of class `SubscriptionBase` has no attribute `event_listener` [missing-attribute] -ERROR homeassistant/components/sonos/speaker.py:683:52-61: Argument `BoundMethod[Self@SonosSpeaker, (Self@SonosSpeaker) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/sonos/speaker.py:795:21-44: Argument `BoundMethod[Self@SonosSpeaker, (Self@SonosSpeaker) -> dict[str, Any]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/sonos/speaker.py:830:17-40: Argument `BoundMethod[Self@SonosSpeaker, (Self@SonosSpeaker) -> dict[str, Any]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/sonos/speaker.py:909:59-74: Argument `() -> list[str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sonos/statistics.py:75:44-73: Cannot set item in `dict[str, dict[str, float | int]]` [unsupported-operation] ERROR homeassistant/components/sonos/statistics.py:76:43-71: Cannot set item in `dict[str, dict[str, float | int]]` [unsupported-operation] -ERROR homeassistant/components/sonos/switch.py:180:52-67: Argument `BoundMethod[Self@SonosSwitchEntity, (Self@SonosSwitchEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sonos/switch.py:257:16-259:10: Returned type `Alarm | None` is not assignable to declared return type `Alarm` [bad-return] ERROR homeassistant/components/sony_projector/switch.py:8:8-14: Could not find import of `pysdcp` [missing-import] ERROR homeassistant/components/sony_projector/switch.py:100:27-35: `Literal['on']` is not assignable to attribute `_state` with type `None` [bad-assignment] @@ -27012,7 +26640,6 @@ ERROR homeassistant/components/spaceapi/__init__.py:305:32-308:14: Cannot set it ERROR homeassistant/components/spaceapi/__init__.py:348:21-48: Object of class `float` has no attribute `append` [missing-attribute] ERROR homeassistant/components/speedtestdotnet/config_flow.py:33:9-31: Class member `SpeedTestFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/speedtestdotnet/coordinator.py:23:5-17: Class member `SpeedTestDataCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/speedtestdotnet/coordinator.py:80:59-75: Argument `BoundMethod[Self@SpeedTestDataCoordinator, (self: Self@SpeedTestDataCoordinator) -> dict[str, Any]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/speedtestdotnet/sensor.py:44:9-12: Unexpected keyword argument `key` in function `SpeedtestSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/speedtestdotnet/sensor.py:45:9-24: Unexpected keyword argument `translation_key` in function `SpeedtestSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/speedtestdotnet/sensor.py:51:9-12: Unexpected keyword argument `key` in function `SpeedtestSensorEntityDescription.__init__` [unexpected-keyword] @@ -27028,12 +26655,10 @@ ERROR homeassistant/components/spotify/coordinator.py:85:32-47: `timedelta` is n ERROR homeassistant/components/spotify/coordinator.py:139:40-72: `timedelta` is not assignable to attribute `update_interval` with type `(self: Self@SpotifyCoordinator, value: timedelta | None) -> None` [bad-assignment] ERROR homeassistant/components/sql/config_flow.py:173:9-31: Class member `SQLConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/sql/config_flow.py:198:31-52: `db_url_for_validation` may be uninitialized [unbound-name] -ERROR homeassistant/components/sql/sensor.py:261:52-64: Argument `BoundMethod[Self@SQLSensor, (self: Self@SQLSensor) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sql/sensor.py:284:17-31: `rendered_query` is uninitialized [unbound-name] ERROR homeassistant/components/sql/sensor.py:295:51-54: Cannot set item in `dict[str, Any]` [unsupported-operation] ERROR homeassistant/components/sql/services.py:78:25-34: Expected a callable, got `None` [not-callable] ERROR homeassistant/components/sql/services.py:95:35-38: Cannot set item in `dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None]` [unsupported-operation] -ERROR homeassistant/components/sql/services.py:107:61-87: Argument `() -> list[bool | dict[str, Unknown] | float | int | list[Unknown] | str | None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/sql/util.py:92:29-37: `instance` may be uninitialized [unbound-name] ERROR homeassistant/components/sql/util.py:94:16-24: `instance` may be uninitialized [unbound-name] ERROR homeassistant/components/sql/util.py:95:54-62: `instance` may be uninitialized [unbound-name] @@ -27126,16 +26751,12 @@ ERROR homeassistant/components/squeezebox/update.py:37:5-8: Unexpected keyword a ERROR homeassistant/components/squeezebox/update.py:63:7-25: Field `entity_description` is declared `EntityDescription` in ancestor `class LMSStatusEntity: ... `, which is not assignable to the type `UpdateEntityDescription` implied by multiple inheritance [inconsistent-inheritance] ERROR homeassistant/components/srp_energy/__init__.py:46:12-21: `unload_ok` may be uninitialized [unbound-name] -ERROR homeassistant/components/srp_energy/config_flow.py:29:50-69: Argument `BoundMethod[SrpEnergyClient, (self: SrpEnergyClient) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/srp_energy/config_flow.py:35:12-20: Returned type `object` is not assignable to declared return type `dict[str, Any]` [bad-return] ERROR homeassistant/components/srp_energy/coordinator.py:30:5-17: Class member `SRPEnergyDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/srp_energy/sensor.py:38:5-23: Class member `SrpEntity._attr_device_class` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/ssdp/__init__.py:166:9-169:10: Argument `((**tuple[SsdpServiceInfo, SsdpChange]) -> Coroutine[Any, Any, None]) | ((**tuple[SsdpServiceInfo, SsdpChange]) -> None)` is not assignable to parameter `target` with type `(**tuple[SsdpServiceInfo, SsdpChange]) -> Coroutine[Any, Any, None]` in function `homeassistant.core.HassJob.__init__` [bad-argument-type] ERROR homeassistant/components/ssdp/server.py:86:5-21: Class member `HassUpnpServiceDevice.EMBEDDED_DEVICES` overrides parent class `UpnpServerDevice` in an inconsistent manner [bad-override] ERROR homeassistant/components/ssdp/server.py:87:5-13: Class member `HassUpnpServiceDevice.SERVICES` overrides parent class `UpnpServerDevice` in an inconsistent manner [bad-override] ERROR homeassistant/components/ssdp/websocket_api.py:69:78-81: Argument `HassJob[[info: SsdpServiceInfo, change: SsdpChange], None]` is not assignable to parameter `callback` with type `HassJob[[SsdpServiceInfo, SsdpChange], Coroutine[Any, Any, None] | None]` in function `homeassistant.components.ssdp.scanner.Scanner.async_register_callback` [bad-argument-type] -ERROR homeassistant/components/starline/account.py:104:49-66: Argument `BoundMethod[Self@StarlineAccount, (self: Self@StarlineAccount) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/starline/account.py:108:49-70: Argument `BoundMethod[Self@StarlineAccount, (self: Self@StarlineAccount) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/starline/binary_sensor.py:21:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/starline/binary_sensor.py:22:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/starline/binary_sensor.py:25:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -27242,7 +26863,6 @@ ERROR homeassistant/components/starlink/button.py:52:9-12: Unexpected keyword ar ERROR homeassistant/components/starlink/button.py:54:9-24: Unexpected keyword argument `entity_category` in function `StarlinkButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/starlink/coordinator.py:56:5-17: Class member `StarlinkUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/starlink/coordinator.py:84:36-56: `int` is not assignable to attribute `history_stats_start` with type `None` [bad-assignment] -ERROR homeassistant/components/starlink/coordinator.py:92:63-86: Argument `BoundMethod[Self@StarlinkUpdateCoordinator, (self: Self@StarlinkUpdateCoordinator) -> StarlinkData]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/starlink/device_tracker.py:42:9-12: Unexpected keyword argument `key` in function `StarlinkDeviceTrackerEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/starlink/device_tracker.py:43:9-24: Unexpected keyword argument `translation_key` in function `StarlinkDeviceTrackerEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/starlink/device_tracker.py:44:9-40: Unexpected keyword argument `entity_registry_enabled_default` in function `StarlinkDeviceTrackerEntityDescription.__init__` [unexpected-keyword] @@ -27335,14 +26955,12 @@ ERROR homeassistant/components/statistics/sensor.py:674:14-24: Class member `Sta ERROR homeassistant/components/steam_online/config_flow.py:41:9-31: Class member `SteamFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/steam_online/config_flow.py:76:27-31: `name` may be uninitialized [unbound-name] ERROR homeassistant/components/steam_online/config_flow.py:78:72-76: `name` may be uninitialized [unbound-name] -ERROR homeassistant/components/steam_online/config_flow.py:154:68-85: Argument `BoundMethod[Self@SteamOptionsFlowHandler, (self: Self@SteamOptionsFlowHandler) -> list[dict[str, int | str]]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/steam_online/coordinator.py:26:5-17: Class member `SteamDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/steam_online/coordinator.py:38:44-48: `None` is not assignable to attribute `player_interface` with type `_interface_method` [bad-assignment] ERROR homeassistant/components/steam_online/coordinator.py:39:42-46: `None` is not assignable to attribute `user_interface` with type `_interface_method` [bad-assignment] ERROR homeassistant/components/steam_online/coordinator.py:51:23-58: Object of class `_interface_method` has no attribute `GetOwnedGames` [missing-attribute] ERROR homeassistant/components/steam_online/coordinator.py:57:20-58: Object of class `_interface_method` has no attribute `GetPlayerSummaries` [missing-attribute] ERROR homeassistant/components/steam_online/coordinator.py:64:20-55: Object of class `_interface_method` has no attribute `GetSteamLevel` [missing-attribute] -ERROR homeassistant/components/steam_online/coordinator.py:71:59-71: Argument `BoundMethod[Self@SteamDataUpdateCoordinator, (self: Self@SteamDataUpdateCoordinator) -> dict[str, dict[str, int | str]]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/steam_online/sensor.py:47:14-32: Class member `SteamSensor.entity_description` overrides parent class `SteamEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/steam_online/sensor.py:48:13-16: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/steam_online/sensor.py:49:13-17: Unexpected keyword argument `name` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -27359,11 +26977,8 @@ ERROR homeassistant/components/steamist/switch.py:17:5-8: Unexpected keyword arg ERROR homeassistant/components/steamist/switch.py:18:5-20: Unexpected keyword argument `translation_key` in function `homeassistant.components.switch.SwitchEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/steamist/switch.py:34:7-27: Field `entity_description` is declared `EntityDescription` in ancestor `class SteamistEntity: ... `, which is not assignable to the type `SwitchEntityDescription` implied by multiple inheritance [inconsistent-inheritance] -ERROR homeassistant/components/stiebel_eltron/__init__.py:131:49-62: Argument `BoundMethod[StiebelEltronAPI, (self: StiebelEltronAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/stiebel_eltron/climate.py:169:36-44: Argument `str | None` is not assignable to parameter `mode` with type `str` in function `pystiebeleltron.pystiebeleltron.StiebelEltronAPI.set_operation` [bad-argument-type] ERROR homeassistant/components/stiebel_eltron/climate.py:182:36-44: Argument `str | None` is not assignable to parameter `mode` with type `str` in function `pystiebeleltron.pystiebeleltron.StiebelEltronAPI.set_operation` [bad-argument-type] -ERROR homeassistant/components/stiebel_eltron/config_flow.py:38:66-79: Argument `BoundMethod[StiebelEltronAPI, (self: StiebelEltronAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/stiebel_eltron/config_flow.py:68:62-75: Argument `BoundMethod[StiebelEltronAPI, (self: StiebelEltronAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/stookwijzer/coordinator.py:23:5-17: Class member `StookwijzerCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/stookwijzer/sensor.py:35:9-12: Unexpected keyword argument `key` in function `StookwijzerSensorDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/stookwijzer/sensor.py:44:9-12: Unexpected keyword argument `key` in function `StookwijzerSensorDescription.__init__` [unexpected-keyword] @@ -27374,18 +26989,14 @@ ERROR homeassistant/components/stookwijzer/sensor.py:73:5-23: Class member `Stoo ERROR homeassistant/components/stream/__init__.py:392:16-24: `provider` may be uninitialized [unbound-name] ERROR homeassistant/components/stream/__init__.py:397:27-40: Cannot index into `dict[str, StreamOutput]` [bad-index] ERROR homeassistant/components/stream/__init__.py:398:31-44: Cannot delete item in `dict[str, StreamOutput]` [unsupported-operation] -ERROR homeassistant/components/stream/core.py:462:46-61: Argument `BoundMethod[Event, (self: Event) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/components/stream/fmp4utils.py:28:11-12: Integer literal used as condition. It's equivalent to `True` [redundant-condition] ERROR homeassistant/components/stream/fmp4utils.py:144:23-28: Argument `str` is not assignable to parameter `object` with type `LiteralString` in function `list.append` [bad-argument-type] ERROR homeassistant/components/stream/fmp4utils.py:153:11-12: Integer literal used as condition. It's equivalent to `True` [redundant-condition] -ERROR homeassistant/components/stream/hls.py:99:46-71: Argument `BoundMethod[Self@HlsStreamOutput, (self: Self@HlsStreamOutput) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/components/stream/worker.py:334:27-338:10: No matching overload found for function `min` called with arguments: (int, float) [no-matching-overload] ERROR homeassistant/components/stream/worker.py:382:60-76: `segment_duration` may be uninitialized [unbound-name] ERROR homeassistant/components/streamlabswater/__init__.py:49:45-54: Argument `Any | None` is not assignable to parameter `home_or_away` with type `str` in function `streamlabswater.streamlabswater.StreamlabsClient.update_location` [bad-argument-type] ERROR homeassistant/components/streamlabswater/__init__.py:63:12-21: `unload_ok` may be uninitialized [unbound-name] -ERROR homeassistant/components/streamlabswater/config_flow.py:21:50-70: Argument `BoundMethod[StreamlabsClient, (self: StreamlabsClient) -> dict[Unknown, Unknown]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/streamlabswater/coordinator.py:29:5-17: Class member `StreamlabsCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/streamlabswater/coordinator.py:48:55-72: Argument `BoundMethod[Self@StreamlabsCoordinator, (self: Self@StreamlabsCoordinator) -> dict[str, StreamlabsData]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/streamlabswater/sensor.py:34:9-12: Unexpected keyword argument `key` in function `StreamlabsWaterSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/streamlabswater/sensor.py:35:9-24: Unexpected keyword argument `translation_key` in function `StreamlabsWaterSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/streamlabswater/sensor.py:42:9-12: Unexpected keyword argument `key` in function `StreamlabsWaterSensorEntityDescription.__init__` [unexpected-keyword] @@ -28026,7 +27637,6 @@ ERROR homeassistant/components/system_bridge/sensor.py:645:5-23: Class member `S ERROR homeassistant/components/system_bridge/sensor.py:645:5-23: Class member `SystemBridgeSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/system_log/__init__.py:304:15-19: `conf` may be uninitialized [unbound-name] ERROR homeassistant/components/system_log/__init__.py:304:39-43: `conf` may be uninitialized [unbound-name] -ERROR homeassistant/components/systemmonitor/__init__.py:36:56-79: Argument `type[PsutilWrapper]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/systemmonitor/binary_sensor.py:75:9-12: Unexpected keyword argument `key` in function `SysMonitorBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/systemmonitor/binary_sensor.py:76:9-24: Unexpected keyword argument `translation_key` in function `SysMonitorBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/systemmonitor/binary_sensor.py:77:9-13: Unexpected keyword argument `icon` in function `SysMonitorBinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -28037,7 +27647,6 @@ ERROR homeassistant/components/systemmonitor/binary_sensor.py:140:5-23: Class me ERROR homeassistant/components/systemmonitor/binary_sensor.py:153:14-29: Class member `SystemMonitorSensor._attr_unique_id` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/systemmonitor/binary_sensor.py:153:14-29: Class member `SystemMonitorSensor._attr_unique_id` overrides parent class `BinarySensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/systemmonitor/coordinator.py:100:5-17: Class member `SystemMonitorCoordinator.config_entry` overrides parent class `TimestampDataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/systemmonitor/coordinator.py:153:56-72: Argument `BoundMethod[Self@SystemMonitorCoordinator, (self: Self@SystemMonitorCoordinator) -> dict[str, Any]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/systemmonitor/sensor.py:174:9-12: Unexpected keyword argument `key` in function `SysMonitorSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/systemmonitor/sensor.py:187:9-12: Unexpected keyword argument `key` in function `SysMonitorSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/systemmonitor/sensor.py:188:9-24: Unexpected keyword argument `translation_key` in function `SysMonitorSensorEntityDescription.__init__` [unexpected-keyword] @@ -28096,12 +27705,10 @@ ERROR homeassistant/components/systemmonitor/sensor.py:441:9-12: Unexpected keyw ERROR homeassistant/components/systemmonitor/sensor.py:442:9-24: Unexpected keyword argument `translation_key` in function `SysMonitorSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/systemmonitor/sensor.py:452:9-12: Unexpected keyword argument `key` in function `SysMonitorSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/systemmonitor/sensor.py:453:9-24: Unexpected keyword argument `translation_key` in function `SysMonitorSensorEntityDescription.__init__` [unexpected-keyword] -ERROR homeassistant/components/systemmonitor/sensor.py:515:59-72: Argument `() -> dict[str, Any]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/systemmonitor/sensor.py:630:5-23: Class member `SystemMonitorSensor.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/systemmonitor/sensor.py:630:5-23: Class member `SystemMonitorSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/systemmonitor/sensor.py:648:14-29: Class member `SystemMonitorSensor._attr_unique_id` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/systemmonitor/sensor.py:648:14-29: Class member `SystemMonitorSensor._attr_unique_id` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/tado/__init__.py:90:65-85: Argument `() -> tuple[Tado, str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tado/binary_sensor.py:43:5-8: Unexpected keyword argument `key` in function `TadoBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/tado/binary_sensor.py:48:5-8: Unexpected keyword argument `key` in function `TadoBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/tado/binary_sensor.py:49:5-20: Unexpected keyword argument `translation_key` in function `TadoBinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -28120,14 +27727,11 @@ ERROR homeassistant/components/tado/climate.py:313:14-38: Class member `TadoClim ERROR homeassistant/components/tado/climate.py:340:31-46: No attribute `TadoZone` in module `PyTado` [missing-attribute] ERROR homeassistant/components/tado/climate.py:813:20-33: `in` is not supported between `None` and `str` [unsupported-operation] ERROR homeassistant/components/tado/config_flow.py:75:29-44: Argument `str | None` is not assignable to parameter `val` with type `SplitResult | URL | UndefinedType | str` in function `yarl._url.URL.__new__` [bad-argument-type] -ERROR homeassistant/components/tado/config_flow.py:82:56-83: Argument `BoundMethod[Tado, (self: Tado) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/tado/config_flow.py:103:17-44: Argument `BoundMethod[Tado, (self: Tado) -> str | None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tado/config_flow.py:110:38-113:14: Argument `dict[str, str | None]` is not assignable to parameter `description_placeholders` with type `Mapping[str, str] | None` in function `homeassistant.data_entry_flow.FlowHandler.async_show_progress` [bad-argument-type] ERROR homeassistant/components/tado/config_flow.py:111:24-39: `tado_device_url` may be uninitialized [unbound-name] ERROR homeassistant/components/tado/config_flow.py:112:25-34: `user_code` may be uninitialized [unbound-name] ERROR homeassistant/components/tado/config_flow.py:178:9-31: Class member `TadoConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/tado/coordinator.py:43:5-17: Class member `TadoDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/tado/coordinator.py:111:13-41: Argument `BoundMethod[Tado, (self: Tado) -> str | None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tado/coordinator.py:200:16-20: Returned type `object` is not assignable to declared return type `dict[str, str]` [bad-return] ERROR homeassistant/components/tado/coordinator.py:218:16-58: Returned type `dict[str, object]` is not assignable to declared return type `dict[str, dict[Unknown, Unknown]]` [bad-return] ERROR homeassistant/components/tado/coordinator.py:315:33-40: Argument `Unknown | None` is not assignable to parameter `zone_id` with type `int` in function `TadoDataUpdateCoordinator._update_zone` [bad-argument-type] @@ -28219,7 +27823,6 @@ ERROR homeassistant/components/tami4/__init__.py:23:48-77: Unpacked argument `tu ERROR homeassistant/components/tami4/__init__.py:47:12-21: `unload_ok` may be uninitialized [unbound-name] ERROR homeassistant/components/tami4/button.py:37:5-8: Unexpected keyword argument `key` in function `Tami4EdgeButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/tami4/button.py:38:5-20: Unexpected keyword argument `translation_key` in function `Tami4EdgeButtonEntityDescription.__init__` [unexpected-keyword] -ERROR homeassistant/components/tami4/button.py:53:48-62: Argument `BoundMethod[Tami4EdgeAPI, (self: Tami4EdgeAPI) -> Device]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tami4/button.py:60:17-20: Unexpected keyword argument `key` in function `Tami4EdgeDrinkButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/tami4/button.py:61:17-32: Unexpected keyword argument `translation_key` in function `Tami4EdgeDrinkButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/tami4/button.py:62:17-41: Unexpected keyword argument `translation_placeholders` in function `Tami4EdgeDrinkButtonEntityDescription.__init__` [unexpected-keyword] @@ -28228,7 +27831,6 @@ ERROR homeassistant/components/tami4/button.py:76:5-23: Class member `Tami4EdgeB ERROR homeassistant/components/tami4/button.py:86:5-23: Class member `Tami4EdgeDrinkButton.entity_description` overrides parent class `Tami4EdgeBaseEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/tami4/button.py:86:5-23: Class member `Tami4EdgeDrinkButton.entity_description` overrides parent class `ButtonEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/tami4/coordinator.py:40:5-17: Class member `Tami4EdgeCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/tami4/coordinator.py:58:61-81: Argument `BoundMethod[Tami4EdgeAPI, (self: Tami4EdgeAPI) -> Device]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tami4/sensor.py:27:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/tami4/sensor.py:28:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/tami4/sensor.py:32:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -28448,8 +28050,6 @@ ERROR homeassistant/components/telegram_bot/notify.py:33:7-30: Field `entity_des `, which is not assignable to the type `NotifyEntityDescription` implied by multiple inheritance [inconsistent-inheritance] ERROR homeassistant/components/telegram_bot/notify.py:36:5-29: Class member `TelegramBotNotifyEntity._attr_supported_features` overrides parent class `TelegramBotEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/telegram_bot/notify.py:45:51-54: Unexpected keyword argument `key` in function `homeassistant.components.notify.NotifyEntityDescription.__init__` [unexpected-keyword] -ERROR homeassistant/components/tellduslive/config_flow.py:80:55-78: Argument `BoundMethod[Session, (self: Session) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/tellduslive/config_flow.py:101:67-85: Argument `BoundMethod[Self@FlowHandler, (self: Self@FlowHandler) -> str | None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tellduslive/config_flow.py:120:15-35: Class member `FlowHandler.async_step_discovery` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/tellduslive/config_flow.py:148:54-150:10: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[PathLike[str] | str, dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None]]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tellduslive/sensor.py:46:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -29725,7 +29325,6 @@ ERROR homeassistant/components/thread/dataset_store.py:181:16-20: `data` may be ERROR homeassistant/components/thread/diagnostics.py:73:10-13: Expected a type form, got instance of `Module[pyroute2.NDB]` [not-a-type] ERROR homeassistant/components/thread/diagnostics.py:104:26-29: Expected a type form, got instance of `Module[pyroute2.NDB]` [not-a-type] ERROR homeassistant/components/thread/diagnostics.py:122:10-13: Expected a callable, got `Module[pyroute2.NDB]` [not-callable] -ERROR homeassistant/components/thread/diagnostics.py:158:9-34: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/thread/diagnostics.py:179:18-49: Cannot set item in `dict[str, TypedDict[Router]]` [unsupported-operation] ERROR homeassistant/components/thread/diagnostics.py:195:21-44: Object of class `NoneType` has no attribute `update` Object of class `list` has no attribute `update` @@ -29857,7 +29456,6 @@ ERROR homeassistant/components/tolo/binary_sensor.py:35:5-23: Class member `Tolo ERROR homeassistant/components/tolo/binary_sensor.py:56:5-23: Class member `ToloFlowOutBinarySensor._attr_device_class` overrides parent class `ToloSaunaCoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/tolo/climate.py:52:5-29: Class member `SaunaClimate._attr_supported_features` overrides parent class `ToloSaunaCoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/tolo/coordinator.py:33:5-17: Class member `ToloSaunaUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/tolo/coordinator.py:51:55-80: Argument `BoundMethod[Self@ToloSaunaUpdateCoordinator, (self: Self@ToloSaunaUpdateCoordinator) -> ToloSaunaData]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tolo/fan.py:29:5-29: Class member `ToloFan._attr_supported_features` overrides parent class `ToloSaunaCoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/tolo/number.py:40:9-12: Unexpected keyword argument `key` in function `ToloNumberEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/tolo/number.py:41:9-24: Unexpected keyword argument `translation_key` in function `ToloNumberEntityDescription.__init__` [unexpected-keyword] @@ -30094,17 +29692,11 @@ ERROR homeassistant/components/toon/switch.py:123:9-13: Unexpected keyword argum ERROR homeassistant/components/toon/switch.py:126:9-13: Unexpected keyword argument `icon` in function `ToonSwitchEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/totalconnect/__init__.py:33:51-35:10: Unpacked argument `tuple[Any, Any, dict[int, Unknown], Any]` is not assignable to parameter `*args` with type `tuple[str, str, dict[str, str] | None, bool, int, bool]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/totalconnect/alarm_control_panel.py:62:5-29: Class member `TotalConnectAlarm._attr_supported_features` overrides parent class `TotalConnectLocationEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/totalconnect/alarm_control_panel.py:128:52-64: Argument `BoundMethod[Self@TotalConnectAlarm, (self: Self@TotalConnectAlarm) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/totalconnect/alarm_control_panel.py:139:42-70: Argument `dict[str, Any | None]` is not assignable to parameter `translation_placeholders` with type `dict[str, str] | None` in function `homeassistant.exceptions.HomeAssistantError.__init__` [bad-argument-type] -ERROR homeassistant/components/totalconnect/alarm_control_panel.py:151:52-66: Argument `BoundMethod[Self@TotalConnectAlarm, (self: Self@TotalConnectAlarm) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/totalconnect/alarm_control_panel.py:162:42-70: Argument `dict[str, Any | None]` is not assignable to parameter `translation_placeholders` with type `dict[str, str] | None` in function `homeassistant.exceptions.HomeAssistantError.__init__` [bad-argument-type] -ERROR homeassistant/components/totalconnect/alarm_control_panel.py:174:52-66: Argument `BoundMethod[Self@TotalConnectAlarm, (self: Self@TotalConnectAlarm) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/totalconnect/alarm_control_panel.py:185:42-70: Argument `dict[str, Any | None]` is not assignable to parameter `translation_placeholders` with type `dict[str, str] | None` in function `homeassistant.exceptions.HomeAssistantError.__init__` [bad-argument-type] -ERROR homeassistant/components/totalconnect/alarm_control_panel.py:197:52-67: Argument `BoundMethod[Self@TotalConnectAlarm, (self: Self@TotalConnectAlarm) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/totalconnect/alarm_control_panel.py:208:42-70: Argument `dict[str, Any | None]` is not assignable to parameter `translation_placeholders` with type `dict[str, str] | None` in function `homeassistant.exceptions.HomeAssistantError.__init__` [bad-argument-type] -ERROR homeassistant/components/totalconnect/alarm_control_panel.py:219:52-74: Argument `BoundMethod[Self@TotalConnectAlarm, (self: Self@TotalConnectAlarm) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/totalconnect/alarm_control_panel.py:230:42-70: Argument `dict[str, Any | None]` is not assignable to parameter `translation_placeholders` with type `dict[str, str] | None` in function `homeassistant.exceptions.HomeAssistantError.__init__` [bad-argument-type] -ERROR homeassistant/components/totalconnect/alarm_control_panel.py:241:52-74: Argument `BoundMethod[Self@TotalConnectAlarm, (self: Self@TotalConnectAlarm) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/totalconnect/alarm_control_panel.py:252:42-70: Argument `dict[str, Any | None]` is not assignable to parameter `translation_placeholders` with type `dict[str, str] | None` in function `homeassistant.exceptions.HomeAssistantError.__init__` [bad-argument-type] ERROR homeassistant/components/totalconnect/alarm_control_panel.py:264:51-77: Cannot index into `dict[str, str]` [bad-index] ERROR homeassistant/components/totalconnect/binary_sensor.py:54:5-8: Unexpected keyword argument `key` in function `TotalConnectZoneBinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -30140,7 +29732,6 @@ ERROR homeassistant/components/totalconnect/config_flow.py:55:64-57:18: Unpacked ERROR homeassistant/components/totalconnect/config_flow.py:156:51-161:14: Unpacked argument `tuple[str | None, str, dict[int, str | None]]` is not assignable to parameter `*args` with type `tuple[str, str, dict[str, str] | None, bool, int, bool]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/totalconnect/config_flow.py:188:9-31: Class member `TotalConnectConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/totalconnect/coordinator.py:29:5-17: Class member `TotalConnectDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/totalconnect/coordinator.py:49:48-69: Argument `BoundMethod[Self@TotalConnectDataUpdateCoordinator, (self: Self@TotalConnectDataUpdateCoordinator) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/totalconnect/diagnostics.py:40:19-44: Object of class `NoneType` has no attribute `_master_user` [missing-attribute] ERROR homeassistant/components/totalconnect/diagnostics.py:41:23-47: Object of class `NoneType` has no attribute `_user_admin` [missing-attribute] ERROR homeassistant/components/totalconnect/diagnostics.py:42:25-51: Object of class `NoneType` has no attribute `_config_admin` [missing-attribute] @@ -30581,11 +30172,9 @@ ERROR homeassistant/components/trafikverket_weatherstation/sensor.py:197:9-24: U ERROR homeassistant/components/trafikverket_weatherstation/sensor.py:199:9-40: Unexpected keyword argument `entity_registry_enabled_default` in function `TrafikverketSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/trafikverket_weatherstation/sensor.py:227:5-23: Class member `TrafikverketWeatherStation.entity_description` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/trafikverket_weatherstation/sensor.py:227:5-23: Class member `TrafikverketWeatherStation.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/transmission/__init__.py:97:39-68: Argument `BoundMethod[TransmissionDataUpdateCoordinator, (self: TransmissionDataUpdateCoordinator) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/transmission/__init__.py:133:32-35: `new` may be uninitialized [unbound-name] ERROR homeassistant/components/transmission/config_flow.py:62:9-31: Class member `TransmissionFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/transmission/coordinator.py:36:5-17: Class member `TransmissionDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/transmission/coordinator.py:72:55-66: Argument `BoundMethod[Self@TransmissionDataUpdateCoordinator, (self: Self@TransmissionDataUpdateCoordinator) -> SessionStats]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/transmission/coordinator.py:118:36-62: `list[Never]` is not assignable to attribute `_completed_torrents` with type `list[Torrent]` [bad-assignment] ERROR homeassistant/components/transmission/coordinator.py:139:34-58: `list[Never]` is not assignable to attribute `_started_torrents` with type `list[Torrent]` [bad-assignment] ERROR homeassistant/components/transmission/sensor.py:54:9-12: Unexpected keyword argument `key` in function `TransmissionSensorEntityDescription.__init__` [unexpected-keyword] @@ -30644,7 +30233,6 @@ ERROR homeassistant/components/travisci/sensor.py:66:9-12: Unexpected keyword ar ERROR homeassistant/components/travisci/sensor.py:67:9-13: Unexpected keyword argument `name` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/travisci/sensor.py:68:9-13: Unexpected keyword argument `icon` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/trend/binary_sensor.py:197:14-32: Class member `SensorTrend._attr_device_class` overrides parent class `RestoreEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/trend/binary_sensor.py:278:48-72: Argument `BoundMethod[Self@SensorTrend, (self: Self@SensorTrend) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tts/__init__.py:292:53-72: Unpacked keyword argument `object` is not assignable to parameter `engine` with type `str` in function `SpeechManager.async_create_result_stream` [bad-argument-type] ERROR homeassistant/components/tts/__init__.py:292:53-72: Unpacked keyword argument `object` is not assignable to parameter `use_file_cache` with type `bool | None` in function `SpeechManager.async_create_result_stream` [bad-argument-type] ERROR homeassistant/components/tts/__init__.py:292:53-72: Unpacked keyword argument `object` is not assignable to parameter `language` with type `str | None` in function `SpeechManager.async_create_result_stream` [bad-argument-type] @@ -30653,12 +30241,8 @@ ERROR homeassistant/components/tts/__init__.py:292:62-71: TypedDict `ParsedMedia ERROR homeassistant/components/tts/__init__.py:293:41-50: TypedDict `ParsedMediaSourceStreamId` does not have key `message` [bad-typed-dict-key] ERROR homeassistant/components/tts/__init__.py:370:36-47: Type `AsyncGenerator[bytes, None] | Path | str` is not an async iterable [not-iterable] ERROR homeassistant/components/tts/__init__.py:414:22-65: `bool | str | Unknown` is not assignable to `str` [bad-assignment] -ERROR homeassistant/components/tts/__init__.py:594:17-53: Argument `BoundMethod[Path, (self: Path) -> bytes]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tts/__init__.py:659:13-29: Argument `HassJob[[_now: datetime], None]` is not assignable to parameter `action` with type `((datetime) -> Coroutine[Any, Any, None] | None) | HassJob[[datetime], Coroutine[Any, Any, None] | None]` in function `homeassistant.helpers.event.async_call_later` [bad-argument-type] -ERROR homeassistant/components/tts/__init__.py:726:71-87: Argument `BoundMethod[Self@SpeechManager, (self: Self@SpeechManager) -> dict[str, str]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/tts/__init__.py:989:52-63: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tts/__init__.py:1074:27-44: Type of yielded value `AsyncGenerator[str, None] | str` is not assignable to declared return type `str` [invalid-yield] -ERROR homeassistant/components/tts/__init__.py:1124:59-70: Argument `() -> bytes` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tts/entity.py:184:19-23: Type of yielded value `bytes | None` is not assignable to declared return type `bytes` [invalid-yield] ERROR homeassistant/components/tts/legacy.py:106:54-108:6: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[PathLike[str] | str, Secrets | None]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tts/media_source.py:128:5-9: Class member `TTSMediaSource.name` overrides parent class `MediaSource` in an inconsistent manner [bad-override] @@ -30668,11 +30252,7 @@ ERROR homeassistant/components/tts/media_source.py:145:61-80: Unpacked keyword a ERROR homeassistant/components/tts/media_source.py:145:61-80: Unpacked keyword argument `object` is not assignable to parameter `options` with type `dict[Unknown, Unknown] | None` in function `homeassistant.components.tts.SpeechManager.async_create_result_stream` [bad-argument-type] ERROR homeassistant/components/tts/media_source.py:145:70-79: TypedDict `ParsedMediaSourceStreamId` does not have key `options` [bad-typed-dict-key] ERROR homeassistant/components/tts/media_source.py:146:49-58: TypedDict `ParsedMediaSourceStreamId` does not have key `message` [bad-typed-dict-key] -ERROR homeassistant/components/tuya/__init__.py:68:43-70: Argument `BoundMethod[Manager, (self: Manager) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/tuya/__init__.py:109:39-57: Argument `BoundMethod[Manager, (self: Manager) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tuya/__init__.py:130:12-21: `unload_ok` may be uninitialized [unbound-name] -ERROR homeassistant/components/tuya/__init__.py:145:39-53: Argument `BoundMethod[Manager, (self: Manager) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/tuya/__init__.py:245:27-45: Argument `() -> None` is not assignable to parameter `target` with type `((**tuple[*@_]) -> Any) | Coroutine[Any, Any, Any]` in function `homeassistant.core.HomeAssistant.add_job` [bad-argument-type] ERROR homeassistant/components/tuya/alarm_control_panel.py:28:13-16: Unexpected keyword argument `key` in function `homeassistant.components.alarm_control_panel.AlarmControlPanelEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/tuya/alarm_control_panel.py:29:13-17: Unexpected keyword argument `name` in function `homeassistant.components.alarm_control_panel.AlarmControlPanelEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/tuya/alarm_control_panel.py:120:41-58: No matching overload found for function `dict.get` called with arguments: (str) [no-matching-overload] @@ -31177,7 +30757,6 @@ ERROR homeassistant/components/tuya/number.py:439:13-28: Unexpected keyword argu ERROR homeassistant/components/tuya/number.py:463:43-60: No matching overload found for function `dict.get` called with arguments: (str) [no-matching-overload] ERROR homeassistant/components/tuya/number.py:497:14-32: Class member `TuyaNumberEntity.entity_description` overrides parent class `TuyaEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/tuya/number.py:534:22-40: Class member `TuyaNumberEntity._attr_device_class` overrides parent class `TuyaEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/tuya/scene.py:25:48-68: Argument `BoundMethod[Manager, (self: Manager) -> list[Unknown]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/tuya/scene.py:61:41-59: Argument `int` is not assignable to parameter `home_id` with type `str` in function `tuya_sharing.manager.Manager.trigger_scene` [bad-argument-type] ERROR homeassistant/components/tuya/select.py:23:13-16: Unexpected keyword argument `key` in function `homeassistant.components.select.SelectEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/tuya/select.py:24:13-28: Unexpected keyword argument `entity_category` in function `homeassistant.components.select.SelectEntityDescription.__init__` [unexpected-keyword] @@ -33308,9 +32887,7 @@ ERROR homeassistant/components/upb/config_flow.py:109:36-40: `info` may be unini ERROR homeassistant/components/upb/light.py:61:14-30: Class member `UpbLight._attr_brightness` overrides parent class `LightEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/upc_connect/device_tracker.py:7:1-35: Could not find import of `connect_box` [missing-import] ERROR homeassistant/components/upc_connect/device_tracker.py:8:1-73: Could not find import of `connect_box.exceptions` [missing-import] -ERROR homeassistant/components/upcloud/__init__.py:54:43-63: Argument `BoundMethod[CloudManager, (self: CloudManager) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/upcloud/binary_sensor.py:28:5-23: Class member `UpCloudBinarySensor._attr_device_class` overrides parent class `UpCloudServerEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/upcloud/config_flow.py:45:52-72: Argument `BoundMethod[CloudManager, (self: CloudManager) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/upcloud/config_flow.py:90:9-31: Class member `UpCloudConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/upcloud/coordinator.py:47:14-29: Class member `UpCloudDataUpdateCoordinator.update_interval` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/upcloud/coordinator.py:47:32-49:10: `timedelta` is not assignable to attribute `update_interval` with type `(self: Self@UpCloudDataUpdateCoordinator, value: timedelta | None) -> None` [bad-assignment] @@ -33322,7 +32899,6 @@ ERROR homeassistant/components/update/__init__.py:224:5-23: Class member `Update ERROR homeassistant/components/update/__init__.py:227:5-23: Class member `UpdateEntity._attr_device_class` overrides parent class `RestoreEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/update/__init__.py:233:5-16: Class member `UpdateEntity._attr_state` overrides parent class `RestoreEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/update/__init__.py:234:5-29: Class member `UpdateEntity._attr_supported_features` overrides parent class `RestoreEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/update/__init__.py:396:55-73: Argument `BoundMethod[Self@UpdateEntity, (self: Self@UpdateEntity) -> str | None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/update/__init__.py:468:35-50: `release_summary` may be uninitialized [unbound-name] ERROR homeassistant/components/upnp/binary_sensor.py:30:9-12: Unexpected keyword argument `key` in function `UpnpBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/upnp/binary_sensor.py:31:9-24: Unexpected keyword argument `translation_key` in function `UpnpBinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -33413,7 +32989,6 @@ ERROR homeassistant/components/uptimerobot/sensor.py:68:7-24: Field `entity_desc ERROR homeassistant/components/uptimerobot/switch.py:45:21-24: Unexpected keyword argument `key` in function `homeassistant.components.switch.SwitchEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/uptimerobot/switch.py:58:7-24: Field `entity_description` is declared `EntityDescription` in ancestor `class UptimeRobotEntity: ... `, which is not assignable to the type `SwitchEntityDescription` implied by multiple inheritance [inconsistent-inheritance] -ERROR homeassistant/components/usb/__init__.py:489:56-73: Argument `() -> Sequence[USBDevice]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/usgs_earthquakes_feed/geo_location.py:264:31-56: `None` is not subscriptable [unsupported-operation] ERROR homeassistant/components/usgs_earthquakes_feed/geo_location.py:265:32-57: `None` is not subscriptable [unsupported-operation] ERROR homeassistant/components/usgs_earthquakes_feed/geo_location.py:267:23-39: `str` is not assignable to attribute `_place` with type `None` [bad-assignment] @@ -33504,8 +33079,6 @@ ERROR homeassistant/components/v2c/switch.py:96:5-23: Class member `V2CSwitchEnt ERROR homeassistant/components/v2c/switch.py:96:5-23: Class member `V2CSwitchEntity.entity_description` overrides parent class `SwitchEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/vacuum/__init__.py:208:5-23: Class member `StateVacuumEntity.entity_description` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/vacuum/__init__.py:217:5-29: Class member `StateVacuumEntity._attr_supported_features` overrides parent class `Entity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/vacuum/__init__.py:502:48-58: Argument `BoundMethod[Self@StateVacuumEntity, (self: Self@StateVacuumEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/vacuum/__init__.py:513:48-58: Argument `BoundMethod[Self@StateVacuumEntity, (self: Self@StateVacuumEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/vacuum/device_action.py:77:17-24: `service` may be uninitialized [unbound-name] ERROR homeassistant/components/vacuum/reproduce_state.py:84:21-28: `service` may be uninitialized [unbound-name] ERROR homeassistant/components/vallox/__init__.py:149:12-21: `unload_ok` may be uninitialized [unbound-name] @@ -33568,9 +33141,6 @@ ERROR homeassistant/components/valve/__init__.py:126:5-17: Class member `ValveEn ERROR homeassistant/components/valve/__init__.py:133:5-23: Class member `ValveEntity.entity_description` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/valve/__init__.py:135:5-23: Class member `ValveEntity._attr_device_class` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/valve/__init__.py:140:5-29: Class member `ValveEntity._attr_supported_features` overrides parent class `Entity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/valve/__init__.py:224:48-63: Argument `BoundMethod[Self@ValveEntity, (self: Self@ValveEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/valve/__init__.py:240:48-64: Argument `BoundMethod[Self@ValveEntity, (self: Self@ValveEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/valve/__init__.py:276:48-63: Argument `BoundMethod[Self@ValveEntity, (self: Self@ValveEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/vasttrafik/sensor.py:8:8-18: Could not find import of `vasttrafik` [missing-import] ERROR homeassistant/components/vasttrafik/sensor.py:149:32-34: `dict[@_, @_]` is not assignable to attribute `_attributes` with type `None` [bad-assignment] ERROR homeassistant/components/vasttrafik/sensor.py:160:43-162:48: `str` is not assignable to attribute `_state` with type `None` [bad-assignment] @@ -33621,13 +33191,8 @@ ERROR homeassistant/components/velux/cover.py:67:14-32: Class member `VeluxCover ERROR homeassistant/components/velux/light.py:40:5-9: Class member `VeluxLight.node` overrides parent class `VeluxEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/venstar/binary_sensor.py:34:5-23: Class member `VenstarBinarySensor._attr_device_class` overrides parent class `VenstarEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/venstar/binary_sensor.py:46:22-41: Type `None` is not iterable [not-iterable] -ERROR homeassistant/components/venstar/config_flow.py:42:54-72: Argument `BoundMethod[VenstarColorTouch, (self: VenstarColorTouch) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/venstar/config_flow.py:46:12-23: Returned type `None` is not assignable to declared return type `str` [bad-return] ERROR homeassistant/components/venstar/coordinator.py:21:5-17: Class member `VenstarDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/venstar/coordinator.py:43:52-75: Argument `BoundMethod[VenstarColorTouch, (self: VenstarColorTouch) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/venstar/coordinator.py:53:52-78: Argument `BoundMethod[VenstarColorTouch, (self: VenstarColorTouch) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/venstar/coordinator.py:63:52-77: Argument `BoundMethod[VenstarColorTouch, (self: VenstarColorTouch) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/venstar/coordinator.py:74:17-41: Argument `BoundMethod[VenstarColorTouch, (self: VenstarColorTouch) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/venstar/sensor.py:140:5-23: Class member `VenstarSensor.entity_description` overrides parent class `VenstarEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/venstar/sensor.py:140:5-23: Class member `VenstarSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/venstar/sensor.py:175:9-12: Unexpected keyword argument `key` in function `VenstarSensorEntityDescription.__init__` [unexpected-keyword] @@ -33644,16 +33209,12 @@ ERROR homeassistant/components/venstar/sensor.py:257:9-12: Unexpected keyword ar ERROR homeassistant/components/venstar/sensor.py:260:9-24: Unexpected keyword argument `translation_key` in function `VenstarSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/venstar/sensor.py:268:9-12: Unexpected keyword argument `key` in function `VenstarSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/venstar/sensor.py:271:9-24: Unexpected keyword argument `translation_key` in function `VenstarSensorEntityDescription.__init__` [unexpected-keyword] -ERROR homeassistant/components/vera/__init__.py:108:56-77: Argument `BoundMethod[VeraController, (self: VeraController) -> list[VeraScene]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/vera/__init__.py:141:39-55: Argument `BoundMethod[VeraController, (self: VeraController) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/vera/__init__.py:157:41-72: Argument `BoundMethod[VeraController, (self: VeraController) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/vera/binary_sensor.py:26:30-36: Argument `VeraDevice` is not assignable to parameter `vera_device` with type `VeraBinarySensor` in function `VeraBinarySensor.__init__` [bad-argument-type] ERROR homeassistant/components/vera/climate.py:39:28-34: Argument `VeraDevice` is not assignable to parameter `vera_device` with type `VeraThermostat` in function `VeraThermostat.__init__` [bad-argument-type] ERROR homeassistant/components/vera/climate.py:51:5-29: Class member `VeraThermostat._attr_supported_features` overrides parent class `VeraEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/vera/climate.py:114:16-48: Returned type `str | None` is not assignable to declared return type `str` [bad-return] ERROR homeassistant/components/vera/climate.py:124:46-74: Argument `Any | None` is not assignable to parameter `temp` with type `float` in function `pyvera.VeraThermostat.set_temperature` [bad-argument-type] ERROR homeassistant/components/vera/config_flow.py:105:9-31: Class member `VeraFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] -ERROR homeassistant/components/vera/config_flow.py:166:52-75: Argument `BoundMethod[VeraController, (self: VeraController) -> dict[int, VeraDevice]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/vera/cover.py:28:23-29: Argument `VeraDevice` is not assignable to parameter `vera_device` with type `VeraCurtain` in function `VeraCover.__init__` [bad-argument-type] ERROR homeassistant/components/vera/cover.py:60:36-61: Argument `Any | None` is not assignable to parameter `level` with type `int` in function `pyvera.VeraCurtain.set_level` [bad-argument-type] ERROR homeassistant/components/vera/entity.py:49:52-73: Argument `BoundMethod[Self@VeraEntity, (self: Self@VeraEntity, _device: _DeviceTypeT) -> None]` is not assignable to parameter `callback` with type `(VeraDevice) -> None` in function `pyvera.VeraController.register` [bad-argument-type] @@ -33673,16 +33234,7 @@ ERROR homeassistant/components/verisure/alarm_control_panel.py:40:5-29: Class me ERROR homeassistant/components/verisure/binary_sensor.py:45:5-23: Class member `VerisureDoorWindowSensor._attr_device_class` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/verisure/binary_sensor.py:99:5-23: Class member `VerisureEthernetStatus._attr_device_class` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/verisure/config_flow.py:46:9-31: Class member `VerisureConfigFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] -ERROR homeassistant/components/verisure/config_flow.py:70:56-75: Argument `BoundMethod[Session, (self: Session) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/verisure/config_flow.py:75:29-54: Argument `BoundMethod[Session, (self: Session) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/verisure/config_flow.py:146:13-44: Argument `BoundMethod[Session, (self: Session) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/verisure/config_flow.py:204:56-75: Argument `BoundMethod[Session, (self: Session) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/verisure/config_flow.py:209:29-54: Argument `BoundMethod[Session, (self: Session) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/verisure/config_flow.py:262:56-75: Argument `BoundMethod[Session, (self: Session) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/verisure/coordinator.py:28:5-17: Class member `VerisureDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/verisure/coordinator.py:54:52-78: Argument `BoundMethod[Session, (self: Session) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/verisure/coordinator.py:71:52-79: Argument `BoundMethod[Session, (self: Session) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/verisure/coordinator.py:75:56-82: Argument `BoundMethod[Session, (self: Session) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/verisure/sensor.py:50:5-23: Class member `VerisureThermometer._attr_device_class` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/verisure/sensor.py:100:5-23: Class member `VerisureHygrometer._attr_device_class` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/versasense/__init__.py:5:8-27: Could not find import of `pyversasense` [missing-import] @@ -33925,7 +33477,6 @@ ERROR homeassistant/components/vicare/climate.py:344:9-26: Object of class `Devi Object of class `HeatingDeviceWithComponent` has no attribute `setMode` [missing-attribute] ERROR homeassistant/components/vicare/config_flow.py:66:55-85: Unpacked argument `tuple[HomeAssistant, dict[str, Any]]` is not assignable to parameter `*args` with type `tuple[HomeAssistant, Mapping[str, Any], int | Unknown]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/vicare/config_flow.py:101:55-79: Unpacked argument `tuple[HomeAssistant, dict[str, Any]]` is not assignable to parameter `*args` with type `tuple[HomeAssistant, Mapping[str, Any], int | Unknown]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/vicare/diagnostics.py:31:51-63: Argument `() -> list[dict[str, Any]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/vicare/fan.py:140:13-39: Argument `str | None` is not assignable to parameter `unique_id_suffix` with type `str` in function `homeassistant.components.vicare.entity.ViCareEntity.__init__` [bad-argument-type] ERROR homeassistant/components/vicare/fan.py:143:37-66: Object of class `Device` has no attribute `getVentilationModes` Object of class `HeatingDeviceWithComponent` has no attribute `getVentilationModes` [missing-attribute] @@ -34735,7 +34286,6 @@ ERROR homeassistant/components/vizio/media_player.py:251:41-73: `int | str` is n ERROR homeassistant/components/vizio/media_player.py:253:50-257:22: `dict[str, int | str] | list[str] | None` is not assignable to attribute `_attr_sound_mode_list` with type `list[str] | None` [bad-assignment] ERROR homeassistant/components/vizio/media_player.py:454:25-39: Argument `list[dict[str, Any]] | None` is not assignable to parameter `apps_list` with type `list[dict[str, list[dict[str, Any] | str] | str]]` in function `pyvizio.VizioAsync.launch_app` [bad-argument-type] ERROR homeassistant/components/vlc/media_player.py:8:8-11: Could not find import of `vlc` [missing-import] -ERROR homeassistant/components/vlc/media_player.py:146:48-52: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/vodafone_station/__init__.py:80:12-21: `unload_ok` may be uninitialized [unbound-name] ERROR homeassistant/components/vodafone_station/button.py:45:9-12: Unexpected keyword argument `key` in function `VodafoneStationEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/vodafone_station/button.py:47:9-24: Unexpected keyword argument `entity_category` in function `VodafoneStationEntityDescription.__init__` [unexpected-keyword] @@ -34813,7 +34363,6 @@ ERROR homeassistant/components/voip/voip.py:72:8-27: Object of class `VoipDatagr ERROR homeassistant/components/voip/voip.py:74:9-41: Object of class `object` has no attribute `bye_callback` [missing-attribute] ERROR homeassistant/components/voip/voip.py:91:36-93:14: Argument `(call_info: CallInfo, rtcp_state: RtcpState) -> VoipDatagramProtocol` is not assignable to parameter `valid_protocol_factory` with type `(CallInfo, RtcpState) -> Protocol` in function `voip_utils.voip.VoipDatagramProtocol.__init__` [bad-argument-type] ERROR homeassistant/components/voip/voip.py:95:17-100:18: Argument `(call_info: CallInfo, rtcp_state: RtcpState) -> PreRecordMessageProtocol` is not assignable to parameter `invalid_protocol_factory` with type `((CallInfo, RtcpState) -> Protocol) | None` in function `voip_utils.voip.VoipDatagramProtocol.__init__` [bad-argument-type] -ERROR homeassistant/components/voip/voip.py:114:45-67: Argument `BoundMethod[Event, (self: Event) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/components/volkszaehler/sensor.py:8:1-38: Could not find import of `volkszaehler` [missing-import] ERROR homeassistant/components/volkszaehler/sensor.py:9:1-67: Could not find import of `volkszaehler.exceptions` [missing-import] ERROR homeassistant/components/volkszaehler/sensor.py:45:9-12: Unexpected keyword argument `key` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -34962,7 +34511,6 @@ ERROR homeassistant/components/w800rf32/binary_sensor.py:130:36-132:14: `() -> N ERROR homeassistant/components/wallbox/coordinator.py:128:5-17: Class member `WallboxCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/wallbox/coordinator.py:214:14-29: Class member `WallboxCoordinator.update_interval` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/wallbox/coordinator.py:214:32-217:10: `timedelta` is not assignable to attribute `update_interval` with type `(self: Self@WallboxCoordinator, value: timedelta | None) -> None` [bad-assignment] -ERROR homeassistant/components/wallbox/coordinator.py:218:55-69: Argument `BoundMethod[Self@WallboxCoordinator, (Self@WallboxCoordinator) -> Any]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/wallbox/lock.py:21:9-12: Unexpected keyword argument `key` in function `homeassistant.components.lock.LockEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/wallbox/lock.py:22:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.lock.LockEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/wallbox/lock.py:56:14-32: Class member `WallboxLock.entity_description` overrides parent class `WallboxEntity` in an inconsistent manner [bad-override] @@ -35042,8 +34590,6 @@ ERROR homeassistant/components/waqi/sensor.py:148:5-23: Class member `WaqiSensor ERROR homeassistant/components/water_heater/__init__.py:182:5-23: Class member `WaterHeaterEntity.entity_description` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/water_heater/__init__.py:190:5-16: Class member `WaterHeaterEntity._attr_state` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/components/water_heater/__init__.py:191:5-29: Class member `WaterHeaterEntity._attr_supported_features` overrides parent class `Entity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/water_heater/__init__.py:384:48-70: Argument `BoundMethod[Self@WaterHeaterEntity, (self: Self@WaterHeaterEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/water_heater/__init__.py:392:48-71: Argument `BoundMethod[Self@WaterHeaterEntity, (self: Self@WaterHeaterEntity) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/water_heater/device_action.py:78:17-24: `service` may be uninitialized [unbound-name] ERROR homeassistant/components/waterfurnace/__init__.py:9:1-83: Could not find import of `waterfurnace.waterfurnace` [missing-import] ERROR homeassistant/components/waterfurnace/sensor.py:21:29-33: Unexpected keyword argument `name` in function `homeassistant.components.sensor.SensorEntityDescription.__init__` [unexpected-keyword] @@ -35431,14 +34977,11 @@ ERROR homeassistant/components/webostv/media_player.py:245:39-62: Cannot index i ERROR homeassistant/components/webostv/media_player.py:247:38-61: Cannot index into `dict[str, Any]` [bad-index] ERROR homeassistant/components/webostv/media_player.py:342:40-52: `str` is not assignable to attribute `_current_source` with type `None` [bad-assignment] ERROR homeassistant/components/websocket_api/__init__.py:67:5-13: `handlers` may be uninitialized [unbound-name] -ERROR homeassistant/components/websocket_api/commands.py:813:36-54: Argument `BoundMethod[TrackTemplateResultInfo, (self: TrackTemplateResultInfo) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/components/websocket_api/connection.py:31:33-58: Expected a type form, got instance of `Literal['ActiveConnection | None']` [not-a-type] ERROR homeassistant/components/websocket_api/connection.py:282:27-39: Module `voluptuous.humanize` exists, but was not imported explicitly. You are relying on other modules to load it. [implicit-import] ERROR homeassistant/components/websocket_api/http.py:53:5-8: Class member `WebsocketAPIView.url` overrides parent class `HomeAssistantView` in an inconsistent manner [bad-override] ERROR homeassistant/components/websocket_api/http.py:231:46-66: `queue_size_after_add` is uninitialized [unbound-name] -ERROR homeassistant/components/websocket_api/http.py:232:34-74: Argument `BoundMethod[Self@WebSocketHandler, (self: Self@WebSocketHandler) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon` [bad-argument-type] ERROR homeassistant/components/websocket_api/http.py:236:12-32: `queue_size_after_add` is uninitialized [unbound-name] -ERROR homeassistant/components/websocket_api/http.py:266:34-74: Argument `BoundMethod[Self@WebSocketHandler, (self: Self@WebSocketHandler) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon` [bad-argument-type] ERROR homeassistant/components/weheat/binary_sensor.py:33:9-24: Unexpected keyword argument `translation_key` in function `WeHeatBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/weheat/binary_sensor.py:34:9-12: Unexpected keyword argument `key` in function `WeHeatBinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/weheat/binary_sensor.py:39:9-24: Unexpected keyword argument `translation_key` in function `WeHeatBinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -35494,18 +35037,13 @@ ERROR homeassistant/components/weheat/sensor.py:217:9-24: Unexpected keyword arg ERROR homeassistant/components/weheat/sensor.py:218:9-12: Unexpected keyword argument `key` in function `WeHeatSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/weheat/sensor.py:275:5-23: Class member `WeheatHeatPumpSensor.entity_description` overrides parent class `WeheatEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/weheat/sensor.py:275:5-23: Class member `WeheatHeatPumpSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/wemo/__init__.py:89:39-53: Argument `BoundMethod[SubscriptionRegistry, (self: SubscriptionRegistry) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/wemo/__init__.py:92:27-38: Module `pywemo.ssdp` exists, but was not imported explicitly. You are relying on other modules to load it. [implicit-import] -ERROR homeassistant/components/wemo/__init__.py:93:39-64: Argument `BoundMethod[DiscoveryResponder, (self: DiscoveryResponder) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/wemo/__init__.py:153:12-21: `unload_ok` may be uninitialized [unbound-name] ERROR homeassistant/components/wemo/__init__.py:273:17-40: Argument `(*, debug: bool = False, **kwargs: Any) -> list[Device]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/wemo/binary_sensor.py:42:5-9: Class member `MakerBinarySensor.wemo` overrides parent class `WemoEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/wemo/binary_sensor.py:54:5-9: Class member `InsightBinarySensor.wemo` overrides parent class `WemoBinarySensor` in an inconsistent manner [bad-override] ERROR homeassistant/components/wemo/config_flow.py:21:51-74: Argument `(*, debug: bool = False, **kwargs: Any) -> list[Device]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/wemo/coordinator.py:91:5-17: Class member `DeviceCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/wemo/coordinator.py:176:21-63: Argument `BoundMethod[LongPressMixin, (self: LongPressMixin) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/wemo/coordinator.py:180:21-63: Argument `BoundMethod[LongPressMixin, (self: LongPressMixin) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/wemo/entity.py:83:31-70: Argument `BoundMethod[DeviceCoordinator, (self: DeviceCoordinator) -> None]` is not assignable to parameter `target` with type `((**tuple[*@_]) -> Any) | Coroutine[Any, Any, Any]` in function `homeassistant.core.HomeAssistant.add_job` [bad-argument-type] ERROR homeassistant/components/wemo/fan.py:77:5-29: Class member `WemoHumidifier._attr_supported_features` overrides parent class `WemoBinaryStateEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/wemo/fan.py:82:5-9: Class member `WemoHumidifier.wemo` overrides parent class `WemoBinaryStateEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/wemo/fan.py:113:43-54: Argument `tuple[Literal[FanMode.Minimum], Literal[FanMode.Maximum]]` is not assignable to parameter `low_high_range` with type `tuple[float, float]` in function `homeassistant.util.percentage.ranged_value_to_percentage` [bad-argument-type] @@ -35918,7 +35456,6 @@ ERROR homeassistant/components/wolflink/sensor.py:156:5-23: Class member `WolfLi ERROR homeassistant/components/wolflink/sensor.py:156:5-23: Class member `WolfLinkSensor.entity_description` overrides parent class `SensorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/workday/config_flow.py:223:9-31: Class member `WorkdayConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/workday/util.py:38:53-80: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[str, str | None, Iterable[int] | int | None, bool, bool, str | None, str | None, str | None, Iterable[str] | str | None]` in function `homeassistant.core.HomeAssistant.async_add_import_executor_job` [bad-argument-type] -ERROR homeassistant/components/worldclock/config_flow.py:53:13-41: Argument `() -> set[str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/worldtidesinfo/sensor.py:58:8-22: Object of class `NoneType` has no attribute `get` [missing-attribute] ERROR homeassistant/components/worldtidesinfo/sensor.py:88:26-47: `None` is not subscriptable [unsupported-operation] ERROR homeassistant/components/worldtidesinfo/sensor.py:89:42-63: `None` is not subscriptable [unsupported-operation] @@ -35937,7 +35474,6 @@ ERROR homeassistant/components/worxlandroid/sensor.py:129:31-78: `Literal['no', ERROR homeassistant/components/worxlandroid/sensor.py:136:27-31: `Literal['no']` is not assignable to attribute `_state` with type `None` [bad-assignment] ERROR homeassistant/components/ws66i/config_flow.py:129:9-31: Class member `WS66iConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/ws66i/coordinator.py:21:5-17: Class member `Ws66iDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/ws66i/coordinator.py:56:55-77: Argument `BoundMethod[Self@Ws66iDataUpdateCoordinator, (self: Self@Ws66iDataUpdateCoordinator) -> list[ZoneStatus]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/ws66i/media_player.py:50:5-29: Class member `Ws66iZone._attr_supported_features` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/ws66i/media_player.py:102:14-25: Class member `Ws66iZone._attr_state` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/ws66i/media_player.py:105:14-26: Class member `Ws66iZone._attr_source` overrides parent class `MediaPlayerEntity` in an inconsistent manner [bad-override] @@ -36048,7 +35584,6 @@ ERROR homeassistant/components/xiaomi_aqara/binary_sensor.py:607:29-39: `Literal ERROR homeassistant/components/xiaomi_aqara/binary_sensor.py:635:21-53: No matching overload found for function `typing.MutableMapping.update` called with arguments: (Mapping[str, Any] | None) [no-matching-overload] ERROR homeassistant/components/xiaomi_aqara/binary_sensor.py:666:33-41: `Literal['rotate']` is not assignable to attribute `_last_action` with type `None` [bad-assignment] ERROR homeassistant/components/xiaomi_aqara/binary_sensor.py:682:33-41: `Literal['rotate']` is not assignable to attribute `_last_action` with type `None` [bad-assignment] -ERROR homeassistant/components/xiaomi_aqara/config_flow.py:115:52-76: Argument `BoundMethod[XiaomiGatewayDiscovery, (self: XiaomiGatewayDiscovery) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/xiaomi_aqara/config_flow.py:120:25-40: `defaultdict[Unknown, list[Unknown]]` is not assignable to attribute `gateways` with type `dict[str, XiaomiGateway]` [bad-assignment] ERROR homeassistant/components/xiaomi_aqara/entity.py:130:47-132:10: `() -> None` is not assignable to attribute `_remove_unavailability_tracker` with type `None` [bad-assignment] ERROR homeassistant/components/xiaomi_aqara/light.py:89:20-52: `tuple[float, float]` is not assignable to attribute `_hs` with type `tuple[Literal[0], Literal[0]]` [bad-assignment] @@ -36148,8 +35683,6 @@ ERROR homeassistant/components/xiaomi_ble/sensor.py:197:9-13: Unexpected keyword ERROR homeassistant/components/xiaomi_ble/sensor.py:208:13-79: Cannot index into `dict[tuple[ExtendedSensorDeviceClass, Units] | tuple[ExtendedSensorDeviceClass, str] | tuple[ExtendedSensorDeviceClass, None] | tuple[SensorDeviceClass, Units], SensorEntityDescription]` [bad-index] ERROR homeassistant/components/xiaomi_ble/sensor.py:264:7-34: Field `entity_description` is declared `EntityDescription` in ancestor `class PassiveBluetoothProcessorEntity: ... `, which is not assignable to the type `SensorEntityDescription` implied by multiple inheritance [inconsistent-inheritance] -ERROR homeassistant/components/xiaomi_miio/__init__.py:268:59-65: Argument `() -> VacuumCoordinatorData` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/xiaomi_miio/__init__.py:270:24-29: Returned type `object` is not assignable to declared return type `VacuumCoordinatorData` [bad-return] ERROR homeassistant/components/xiaomi_miio/__init__.py:390:43-49: Argument `AirFresh | AirFreshA1 | AirFreshT2017 | AirHumidifier | AirHumidifierMiot | AirHumidifierMjjsq | AirPurifier | AirPurifierMiot | Fan | Fan1C | FanMiot | FanP5 | FanZA5 | RoborockVacuum` is not assignable to parameter `device` with type `RoborockVacuum` in function `_async_update_data_vacuum` [bad-argument-type] ERROR homeassistant/components/xiaomi_miio/air_quality.py:71:60-79: Object of class `Device` has no attribute `status` [missing-attribute] ERROR homeassistant/components/xiaomi_miio/air_quality.py:73:47-57: Object of class `object` has no attribute `co2e` [missing-attribute] @@ -36233,7 +35766,6 @@ ERROR homeassistant/components/xiaomi_miio/button.py:159:5-23: Class member `Xia ERROR homeassistant/components/xiaomi_miio/button.py:159:5-23: Class member `XiaomiGenericCoordinatedButton.entity_description` overrides parent class `ButtonEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/xiaomi_miio/button.py:161:5-23: Class member `XiaomiGenericCoordinatedButton._attr_device_class` overrides parent class `XiaomiCoordinatedMiioEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/xiaomi_miio/config_flow.py:123:9-31: Class member `XiaomiMiioFlowHandler.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] -ERROR homeassistant/components/xiaomi_miio/config_flow.py:241:63-79: Argument `BoundMethod[MiCloud, (self: MiCloud) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/xiaomi_miio/config_flow.py:258:69-260:18: Unpacked argument `tuple[Any]` is not assignable to parameter `*args` with type `tuple[Unknown | None, bool | Unknown, bool | Unknown, str | Unknown]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/xiaomi_miio/config_flow.py:389:24-59: `str` is not assignable to attribute `mac` with type `Never` [bad-assignment] ERROR homeassistant/components/xiaomi_miio/device.py:37:28-47: `Device` is not assignable to attribute `_device` with type `None` [bad-assignment] @@ -36741,9 +36273,6 @@ ERROR homeassistant/components/yale/sensor.py:204:5-23: Class member `YaleBatter ERROR homeassistant/components/yale/sensor.py:210:68-80: Argument `DoorbellDetail | LockDetail` is not assignable to parameter with type `T` [bad-argument-type] ERROR homeassistant/components/yale/util.py:38:12-17: Returned type `Literal[False]` is not assignable to declared return type `Activity | None` [bad-return] ERROR homeassistant/components/yale_smart_alarm/alarm_control_panel.py:42:5-29: Class member `YaleAlarmDevice._attr_supported_features` overrides parent class `YaleAlarmEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/yale_smart_alarm/alarm_control_panel.py:73:21-51: Argument `BoundMethod[YaleSmartAlarmClient, (self: YaleSmartAlarmClient) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/yale_smart_alarm/alarm_control_panel.py:77:21-54: Argument `BoundMethod[YaleSmartAlarmClient, (self: YaleSmartAlarmClient) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/yale_smart_alarm/alarm_control_panel.py:81:21-49: Argument `BoundMethod[YaleSmartAlarmClient, (self: YaleSmartAlarmClient) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/yale_smart_alarm/alarm_control_panel.py:93:12-23: `alarm_state` may be uninitialized [unbound-name] ERROR homeassistant/components/yale_smart_alarm/binary_sensor.py:20:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/yale_smart_alarm/binary_sensor.py:22:9-24: Unexpected keyword argument `entity_category` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] @@ -36764,16 +36293,12 @@ ERROR homeassistant/components/yale_smart_alarm/binary_sensor.py:103:5-23: Class ERROR homeassistant/components/yale_smart_alarm/button.py:19:9-12: Unexpected keyword argument `key` in function `homeassistant.components.button.ButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/yale_smart_alarm/button.py:20:9-24: Unexpected keyword argument `translation_key` in function `homeassistant.components.button.ButtonEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/yale_smart_alarm/button.py:42:5-23: Class member `YalePanicButton.entity_description` overrides parent class `YaleAlarmEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/yale_smart_alarm/button.py:61:17-59: Argument `BoundMethod[YaleSmartAlarmClient, (self: YaleSmartAlarmClient) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/yale_smart_alarm/config_flow.py:73:9-31: Class member `YaleConfigFlow.async_get_options_flow` overrides parent class `ConfigFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/yale_smart_alarm/coordinator.py:27:5-17: Class member `YaleDataUpdateCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] ERROR homeassistant/components/yale_smart_alarm/coordinator.py:44:63-48:14: Unpacked argument `tuple[Any, Any]` is not assignable to parameter `*args` with type `tuple[str, str, int]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/yale_smart_alarm/coordinator.py:49:65-84: Argument `BoundMethod[YaleSmartAlarmClient, (self: YaleSmartAlarmClient) -> list[YaleLock]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/yale_smart_alarm/coordinator.py:58:58-74: Argument `BoundMethod[Self@YaleDataUpdateCoordinator, (self: Self@YaleDataUpdateCoordinator) -> dict[str, Any]]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/yale_smart_alarm/entity.py:22:14-29: Class member `YaleEntity._attr_unique_id` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/yale_smart_alarm/entity.py:23:14-31: Class member `YaleEntity._attr_device_info` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/yale_smart_alarm/entity.py:40:14-29: Class member `YaleLockEntity._attr_unique_id` overrides parent class `CoordinatorEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/yale_smart_alarm/lock.py:74:21-41: Argument `BoundMethod[YaleLock, (self: YaleLock) -> bool]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/yale_smart_alarm/select.py:42:14-29: Class member `YaleLockVolumeSelect._attr_unique_id` overrides parent class `SelectEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/yale_smart_alarm/sensor.py:35:5-23: Class member `YaleTemperatureSensor._attr_device_class` overrides parent class `YaleEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/yale_smart_alarm/switch.py:42:14-29: Class member `YaleAutolockSwitch._attr_unique_id` overrides parent class `SwitchEntity` in an inconsistent manner [bad-override] @@ -36941,10 +36466,7 @@ ERROR homeassistant/components/yolink/valve.py:90:9-24: Unexpected keyword argum ERROR homeassistant/components/yolink/valve.py:132:5-23: Class member `YoLinkValveEntity.entity_description` overrides parent class `YoLinkEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/yolink/valve.py:132:5-23: Class member `YoLinkValveEntity.entity_description` overrides parent class `ValveEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/yolink/valve.py:142:14-38: Class member `YoLinkValveEntity._attr_supported_features` overrides parent class `YoLinkEntity` in an inconsistent manner [bad-override] -ERROR homeassistant/components/youless/__init__.py:26:43-57: Argument `BoundMethod[YoulessAPI, (self: YoulessAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/components/youless/config_flow.py:35:56-70: Argument `BoundMethod[YoulessAPI, (self: YoulessAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/youless/coordinator.py:18:5-17: Class member `YouLessCoordinator.config_entry` overrides parent class `DataUpdateCoordinator` in an inconsistent manner [bad-override] -ERROR homeassistant/components/youless/coordinator.py:34:48-66: Argument `BoundMethod[YoulessAPI, (self: YoulessAPI) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/youless/sensor.py:44:9-12: Unexpected keyword argument `key` in function `YouLessSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/youless/sensor.py:46:9-24: Unexpected keyword argument `translation_key` in function `YouLessSensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/youless/sensor.py:55:9-12: Unexpected keyword argument `key` in function `YouLessSensorEntityDescription.__init__` [unexpected-keyword] @@ -37140,7 +36662,6 @@ ERROR homeassistant/components/zha/climate.py:223:15-60: Object of class `GroupE Object of class `PlatformEntity` has no attribute `async_set_preset_mode` [missing-attribute] ERROR homeassistant/components/zha/climate.py:229:15-60: Object of class `GroupEntity` has no attribute `async_set_temperature` Object of class `PlatformEntity` has no attribute `async_set_temperature` [missing-attribute] -ERROR homeassistant/components/zha/config_flow.py:134:52-69: Argument `() -> Sequence[USBDevice]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/zha/config_flow.py:206:9-13: Class member `BaseZhaFlow.hass` overrides parent class `ConfigEntryBaseFlow` in an inconsistent manner [bad-override] ERROR homeassistant/components/zha/config_flow.py:251:61-89: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[PathLike[@_]]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/zha/cover.py:66:18-36: Class member `ZhaCover._attr_device_class` overrides parent class `ZHAEntity` in an inconsistent manner [bad-override] @@ -37353,7 +36874,6 @@ ERROR homeassistant/components/zha/websocket_api.py:1023:59-67: Argument `list[h ERROR homeassistant/components/zha/websocket_api.py:1444:23-49: Cannot index into `Endpoint` [bad-index] ERROR homeassistant/components/zhong_hong/climate.py:9:1-49: Could not find import of `zhong_hong_hvac.hub` [missing-import] ERROR homeassistant/components/zhong_hong/climate.py:10:1-55: Could not find import of `zhong_hong_hvac.hvac` [missing-import] -ERROR homeassistant/components/zhong_hong/climate.py:120:43-53: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/zhong_hong/climate.py:175:39-177:14: `HVACMode` is not assignable to attribute `_current_operation` with type `None` [bad-assignment] ERROR homeassistant/components/zhong_hong/climate.py:200:20-43: Returned type `None` is not assignable to declared return type `HVACMode` [bad-return] ERROR homeassistant/components/ziggo_mediabox_xl/media_player.py:9:1-46: Could not find import of `ziggo_mediabox_xl` [missing-import] @@ -37476,7 +36996,6 @@ ERROR homeassistant/components/zwave_js/button.py:137:7-34: Field `entity_descri `, which is not assignable to the type `ButtonEntityDescription` implied by multiple inheritance [inconsistent-inheritance] ERROR homeassistant/components/zwave_js/climate.py:126:7-19: Field `entity_description` is declared `EntityDescription` in ancestor `class ZWaveBaseEntity: ... `, which is not assignable to the type `ClimateEntityDescription` implied by multiple inheritance [inconsistent-inheritance] -ERROR homeassistant/components/zwave_js/config_flow.py:199:46-59: Argument `() -> dict[str, str]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/zwave_js/config_flow.py:496:16-35: Object of class `object` has no attribute `get` [missing-attribute] ERROR homeassistant/components/zwave_js/config_flow.py:568:12-34: `current_config_entries` may be uninitialized [unbound-name] ERROR homeassistant/components/zwave_js/cover.py:82:7-25: Field `entity_description` is declared `EntityDescription` in ancestor `class ZWaveBaseEntity: ... @@ -37689,7 +37208,6 @@ ERROR homeassistant/components/zwave_js/update.py:62:5-8: Unexpected keyword arg ERROR homeassistant/components/zwave_js/update.py:76:5-8: Unexpected keyword argument `key` in function `ZWaveUpdateEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/zwave_js/update.py:170:5-23: Class member `ZWaveFirmwareUpdateEntity.entity_description` overrides parent class `UpdateEntity` in an inconsistent manner [bad-override] ERROR homeassistant/components/zwave_js/update.py:294:34-60: Argument `str | None` is not assignable to parameter `version` with type `str` in function `awesomeversion.awesomeversion.AwesomeVersion.__new__` [bad-argument-type] -ERROR homeassistant/components/zwave_me/__init__.py:108:39-71: Argument `BoundMethod[ZWaveMe, (self: ZWaveMe) -> Unknown]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/components/zwave_me/binary_sensor.py:23:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/zwave_me/binary_sensor.py:26:9-12: Unexpected keyword argument `key` in function `homeassistant.components.binary_sensor.BinarySensorEntityDescription.__init__` [unexpected-keyword] ERROR homeassistant/components/zwave_me/binary_sensor.py:72:14-32: Class member `ZWaveMeBinarySensor.entity_description` overrides parent class `ZWaveMeEntity` in an inconsistent manner [bad-override] @@ -37720,7 +37238,6 @@ ERROR homeassistant/config.py:960:9-33: Unexpected keyword argument `translation ERROR homeassistant/config.py:960:34-46: `placeholders` may be uninitialized [unbound-name] ERROR homeassistant/config.py:981:21-36: `platform_config` may be uninitialized [unbound-name] ERROR homeassistant/config.py:1015:69-77: Argument `Hashable` is not assignable to parameter `element` with type `str` in function `set.add` [bad-argument-type] -ERROR homeassistant/config.py:1348:39-56: Argument `() -> None` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/config_entries.py:166:9-20: Object of class `object` has no attribute `_value_` [missing-attribute] ERROR homeassistant/config_entries.py:167:9-25: Object of class `object` has no attribute `_recoverable` [missing-attribute] ERROR homeassistant/config_entries.py:168:16-19: Returned type `object` is not assignable to declared return type `Self@ConfigEntryState` [bad-return] @@ -37756,18 +37273,14 @@ ERROR homeassistant/core.py:858:48-54: Argument `(**tuple[*_Ts]) -> _T` is not a ERROR homeassistant/core.py:875:64-70: Argument `(**tuple[*_Ts]) -> _T` is not assignable to parameter `func` with type `(**tuple[*@_]) -> _T` in function `asyncio.events.AbstractEventLoop.run_in_executor` [bad-argument-type] ERROR homeassistant/core.py:925:9-22: Implementation signature `(self: Self@HomeAssistant, target: ((**tuple[*_Ts]) -> Coroutine[Any, Any, _R] | _R) | Coroutine[Any, Any, _R], *args: *_Ts) -> Future[_R] | None` does not accept all arguments that overload signature `(self: Self@HomeAssistant, target: (**tuple[*_Ts]) -> Coroutine[Any, Any, _R], *args: *_Ts) -> Future[_R] | None` accepts [inconsistent-overload] ERROR homeassistant/core.py:931:9-22: Implementation signature `(self: Self@HomeAssistant, target: ((**tuple[*_Ts]) -> Coroutine[Any, Any, _R] | _R) | Coroutine[Any, Any, _R], *args: *_Ts) -> Future[_R] | None` does not accept all arguments that overload signature `(self: Self@HomeAssistant, target: (**tuple[*_Ts]) -> Coroutine[Any, Any, _R] | _R, *args: *_Ts) -> Future[_R] | None` accepts [inconsistent-overload] -ERROR homeassistant/core.py:1470:57-77: Argument `BoundMethod[Self@EventBus, (self: Self@EventBus) -> dict[EventType[Any] | str, int]]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> @_` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] ERROR homeassistant/core.py:1481:45-1483:10: Unpacked argument `tuple[EventType[_DataT] | str, _DataT | None, EventOrigin, Context | None]` is not assignable to parameter `*args` with type `tuple[EventType[Mapping[str, Any]] | str, Mapping[str, Any] | None, EventOrigin, Context | None, float | None]` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/core.py:1570:56-1572:10: Unpacked argument `tuple[EventType[_DataT] | str, (Event[_DataT]) -> Coroutine[Any, Any, None] | None]` is not assignable to parameter `*args` with type `tuple[EventType[Mapping[str, Any]] | str, (Event[Mapping[str, Any]]) -> Coroutine[Any, Any, None] | None, ((Mapping[str, Any]) -> bool) | None, bool | object]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] -ERROR homeassistant/core.py:1576:54-75: Argument `() -> None` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> @_` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] ERROR homeassistant/core.py:1647:56-1649:10: Unpacked argument `tuple[EventType[_DataT] | str, (Event[_DataT]) -> Coroutine[Any, Any, None] | None]` is not assignable to parameter `*args` with type `tuple[EventType[Mapping[str, Any]] | str, (Event[Mapping[str, Any]]) -> Coroutine[Any, Any, None] | None, bool | object]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] -ERROR homeassistant/core.py:1653:54-75: Argument `() -> None` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> @_` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] ERROR homeassistant/core.py:2001:21-28: `context` may be uninitialized [unbound-name] ERROR homeassistant/core.py:2048:9-20: Class member `States.__setitem__` overrides parent class `UserDict` in an inconsistent manner [bad-param-name-override] ERROR homeassistant/core.py:2180:39-2182:10: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[str, Context | None]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] ERROR homeassistant/core.py:2227:32-2235:10: Unpacked argument `tuple[str, str, Mapping[str, Any] | None, bool, Context | None]` is not assignable to parameter `*args` with type `tuple[str, str, Mapping[str, Any] | None, bool, Context | None, TypedDict[StateInfo] | None, float | None]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] ERROR homeassistant/core.py:2357:17-2362:18: Argument `dict[str, State | datetime | str | None]` is not assignable to parameter `event_data` with type `TypedDict[EventStateReportedData] | None` in function `EventBus.async_fire_internal` [bad-argument-type] -ERROR homeassistant/core.py:2499:57-76: Argument `BoundMethod[Self@ServiceRegistry, (self: Self@ServiceRegistry) -> dict[str, dict[str, Service]]]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> @_` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] ERROR homeassistant/core.py:2568:32-2576:10: Unpacked argument `tuple[str, str, (ServiceCall) -> Coroutine[Any, Any, dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None] | None] | dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None] | None, Schema | None, SupportsResponse]` is not assignable to parameter `*args` with type `tuple[str, str, (ServiceCall) -> Coroutine[Any, Any, dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None] | dict[str, dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None] | None] | None] | dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None] | dict[str, dict[str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None] | None] | None, All | Any | Schema | None, SupportsResponse, HassJobType | None]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] ERROR homeassistant/core_config.py:143:25-28: Argument `Any | None` is not assignable to parameter `element` with type `str` in function `set.add` [bad-argument-type] ERROR homeassistant/core_config.py:373:69-78: `auth_conf` may be uninitialized [unbound-name] @@ -37832,7 +37345,6 @@ ERROR homeassistant/helpers/config_validation.py:1663:28-44: `CONDITION_SCHEMA` ERROR homeassistant/helpers/config_validation.py:1675:28-44: `CONDITION_SCHEMA` is uninitialized [unbound-name] ERROR homeassistant/helpers/config_validation.py:1686:28-44: `CONDITION_SCHEMA` is uninitialized [unbound-name] ERROR homeassistant/helpers/config_validation.py:1754:28-44: `CONDITION_SCHEMA` is uninitialized [unbound-name] -ERROR homeassistant/helpers/debounce.py:201:32-49: Argument `BoundMethod[Self@Debouncer, (self: Self@Debouncer) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_later` [bad-argument-type] ERROR homeassistant/helpers/deprecation.py:151:51-58: `Args[_P]` is not subscriptable [unsupported-operation] ERROR homeassistant/helpers/deprecation.py:152:56-70: `Kwargs[_P]` is not subscriptable [unsupported-operation] ERROR homeassistant/helpers/deprecation.py:169:24-41: Expected *-unpacked _P.args and **-unpacked _P.kwargs [invalid-param-spec] @@ -37845,14 +37357,12 @@ ERROR homeassistant/helpers/discovery_flow.py:59:19-61: `dict[str, object]` is n ERROR homeassistant/helpers/dispatcher.py:40:5-23: Implementation signature `(hass: HomeAssistant, signal: SignalType[*_Ts], target: (**tuple[*_Ts]) -> None) -> () -> None` does not accept all arguments that overload signature `(hass: HomeAssistant, signal: SignalType[*_Ts], target: (**tuple[*_Ts]) -> None) -> () -> None` accepts [inconsistent-overload] ERROR homeassistant/helpers/dispatcher.py:47:5-23: Implementation signature `(hass: HomeAssistant, signal: SignalType[*_Ts], target: (**tuple[*_Ts]) -> None) -> () -> None` does not accept all arguments that overload signature `(hass: HomeAssistant, signal: str, target: (...) -> None) -> () -> None` accepts [inconsistent-overload] ERROR homeassistant/helpers/dispatcher.py:59:42-61:6: Unpacked argument `tuple[HomeAssistant, SignalType[*_Ts], (**tuple[*_Ts]) -> None]` is not assignable to parameter `*args` with type `tuple[HomeAssistant, SignalType[*_Ts], (**tuple[*_Ts]) -> Any]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] -ERROR homeassistant/helpers/dispatcher.py:65:44-55: Argument `() -> None` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> @_` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] ERROR homeassistant/helpers/dispatcher.py:93:5-29: Implementation signature `(hass: HomeAssistant, signal: SignalType[*_Ts] | str, target: ((**tuple[*_Ts]) -> Any) | ((...) -> Any)) -> () -> None` does not accept all arguments that overload signature `(hass: HomeAssistant, signal: SignalType[*_Ts], target: (**tuple[*_Ts]) -> Any) -> () -> None` accepts [inconsistent-overload] ERROR homeassistant/helpers/dispatcher.py:130:5-20: Implementation signature `(hass: HomeAssistant, signal: SignalType[*_Ts], *args: *_Ts) -> None` does not accept all arguments that overload signature `(hass: HomeAssistant, signal: SignalType[*_Ts], *args: *_Ts) -> None` accepts [inconsistent-overload] ERROR homeassistant/helpers/dispatcher.py:137:5-20: Implementation signature `(hass: HomeAssistant, signal: SignalType[*_Ts], *args: *_Ts) -> None` does not accept all arguments that overload signature `(hass: HomeAssistant, signal: str, *args: Any) -> None` accepts [inconsistent-overload] -ERROR homeassistant/helpers/dispatcher.py:145:35-88: Unpacked argument `tuple[HomeAssistant, SignalType[*_Ts], *tuple[object, ...]]` is not assignable to parameter `*args` with type `tuple[HomeAssistant, SignalType[*Unknown] | str, *Unknown]` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] +ERROR homeassistant/helpers/dispatcher.py:145:35-88: Unpacked argument `tuple[HomeAssistant, SignalType[*_Ts], *_Ts]` is not assignable to parameter `*args` with type `tuple[HomeAssistant, SignalType[*Unknown] | str, *Unknown]` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/helpers/dispatcher.py:174:28-176:10: No matching overload found for function `homeassistant.util.logging.catch_log_exception` called with arguments: (((**tuple[*_Ts]) -> Any) | ((...) -> Any), partial[str], job_type=Literal[HassJobType.Coroutinefunction, HassJobType.Executor]) [no-matching-overload] ERROR homeassistant/helpers/dispatcher.py:185:5-26: Implementation signature `(hass: HomeAssistant, signal: SignalType[*_Ts] | str, *args: *_Ts) -> None` does not accept all arguments that overload signature `(hass: HomeAssistant, signal: SignalType[*_Ts], *args: *_Ts) -> None` accepts [inconsistent-overload] -ERROR homeassistant/helpers/dispatcher.py:215:35-56: Unpacked argument `tuple[object, ...]` is not assignable to parameter `*args` with type `tuple[*_Ts]` in function `async_dispatcher_send_internal` [bad-argument-type] ERROR homeassistant/helpers/dispatcher.py:215:42-48: Argument `SignalType[*_Ts] | str` is not assignable to parameter `signal` with type `SignalType[*_Ts] | str` in function `async_dispatcher_send_internal` [bad-argument-type] ERROR homeassistant/helpers/dispatcher.py:240:33-39: Argument `SignalType[*_Ts] | str` is not assignable to parameter `signal` with type `SignalType[*_Ts] | str` in function `_generate_job` [bad-argument-type] ERROR homeassistant/helpers/entity.py:1001:42-46: `Literal[True]` is not assignable to attribute `_no_platform_reported` with type `Never` [bad-assignment] @@ -37861,8 +37371,6 @@ ERROR homeassistant/helpers/entity.py:1173:21-44: `capabilities_updated_at` may ERROR homeassistant/helpers/entity.py:1174:38-61: `capabilities_updated_at` may be uninitialized [unbound-name] ERROR homeassistant/helpers/entity.py:1175:25-48: `capabilities_updated_at` may be uninitialized [unbound-name] ERROR homeassistant/helpers/entity.py:1176:28-51: `capabilities_updated_at` may be uninitialized [unbound-name] -ERROR homeassistant/helpers/entity.py:1255:17-69: Argument `BoundMethod[Self@Entity, (self: Self@Entity) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] -ERROR homeassistant/helpers/entity.py:1307:57-88: Argument `BoundMethod[Self@Entity, (self: Self@Entity) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_at` [bad-argument-type] ERROR homeassistant/helpers/entity.py:1320:17-28: `update_warn` may be uninitialized [unbound-name] ERROR homeassistant/helpers/entity.py:1649:5-23: Class member `ToggleEntity.entity_description` overrides parent class `Entity` in an inconsistent manner [bad-override] ERROR homeassistant/helpers/entity.py:1651:5-16: Class member `ToggleEntity._attr_state` overrides parent class `Entity` in an inconsistent manner [bad-override] @@ -37888,8 +37396,6 @@ ERROR homeassistant/helpers/event.py:356:45-68: `_StateEventDataT` is not subscr ERROR homeassistant/helpers/event.py:364:17-40: `_StateEventDataT` is not subscriptable [unsupported-operation] ERROR homeassistant/helpers/event.py:376:12-35: `_StateEventDataT` is not subscriptable [unsupported-operation] ERROR homeassistant/helpers/event.py:1491:48-57: Argument `HassJob[[utc_now: datetime], None]` is not assignable to parameter `action` with type `((datetime) -> Coroutine[Any, Any, None] | None) | HassJob[[datetime], Coroutine[Any, Any, None] | None]` in function `async_track_point_in_utc_time` [bad-argument-type] -ERROR homeassistant/helpers/event.py:1509:71-75: Argument `Self@_TrackPointUTCTime` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_at` [bad-argument-type] -ERROR homeassistant/helpers/event.py:1529:71-75: Argument `Self@_TrackPointUTCTime` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_at` [bad-argument-type] ERROR homeassistant/helpers/frame.py:142:21-32: `integration` may be uninitialized [unbound-name] ERROR homeassistant/helpers/frame.py:144:58-63: `index` may be uninitialized [unbound-name] ERROR homeassistant/helpers/httpx_client.py:55:12-18: `client` may be uninitialized [unbound-name] @@ -37939,9 +37445,6 @@ ERROR homeassistant/helpers/singleton.py:20:5-14: Overload return type `((HomeAs ERROR homeassistant/helpers/singleton.py:26:5-14: Overload return type `((HomeAssistant) -> object) -> (HomeAssistant) -> object` is not assignable to implementation return type `[_S]((HomeAssistant) -> _S) -> [_T, _U](HomeAssistant) -> _S` [inconsistent-overload] ERROR homeassistant/helpers/singleton.py:68:26-42: Type `_U` is not awaitable [not-async] ERROR homeassistant/helpers/singleton.py:83:12-19: Returned type `Overload[(func: (HomeAssistant) -> Coroutine[Any, Any, _T]) -> (HomeAssistant) -> Coroutine[Any, Any, _T], (func: (HomeAssistant) -> _U) -> (HomeAssistant) -> _U]` is not assignable to declared return type `((HomeAssistant) -> _S) -> (HomeAssistant) -> _S` [bad-return] -ERROR homeassistant/helpers/storage.py:79:48-63: Argument `() -> Unknown` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/helpers/storage.py:123:43-65: Argument `BoundMethod[Self@_StoreManager, (self: Self@_StoreManager) -> None]` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] -ERROR homeassistant/helpers/storage.py:180:36-55: Argument `BoundMethod[Self@_StoreManager, (self: Self@_StoreManager) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_later` [bad-argument-type] ERROR homeassistant/helpers/storage.py:330:62-332:18: Unpacked argument `tuple[Unknown]` is not assignable to parameter `*args` with type `tuple[PathLike[str] | str, bool | dict[str, Unknown] | float | int | list[Unknown] | str | None]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/helpers/storage.py:391:12-39: `not in` is not supported between `Literal['minor_version']` and `bool` [not-iterable] ERROR homeassistant/helpers/storage.py:391:12-39: `not in` is not supported between `Literal['minor_version']` and `float` [not-iterable] @@ -38026,9 +37529,7 @@ ERROR homeassistant/helpers/storage.py:418:30-42: Cannot index into `int` [bad-i ERROR homeassistant/helpers/storage.py:418:30-42: Cannot index into `list[Unknown]` [bad-index] ERROR homeassistant/helpers/storage.py:418:30-42: Cannot index into `str` [bad-index] ERROR homeassistant/helpers/storage.py:418:30-42: `None` is not subscriptable [unsupported-operation] -ERROR homeassistant/helpers/storage.py:470:19-62: Argument `BoundMethod[Self@Store, (self: Self@Store) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_at` [bad-argument-type] ERROR homeassistant/helpers/sun.py:90:5-105:17: `ValueError | None` is not assignable to `None` (caused by inconsistent types when breaking cycles) [bad-assignment] -ERROR homeassistant/helpers/system_info.py:43:54-69: Argument `() -> str` is not assignable to parameter `target` with type `(**tuple[*@_]) -> @_` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type] ERROR homeassistant/helpers/system_info.py:88:31-35: Cannot set item in `dict[str, bool | str]` [unsupported-operation] ERROR homeassistant/helpers/system_info.py:113:37-41: `info` may be uninitialized [unbound-name] ERROR homeassistant/helpers/system_info.py:113:37-59: Cannot set item in `dict[str, bool | str]` [unsupported-operation] @@ -38039,7 +37540,6 @@ ERROR homeassistant/helpers/system_info.py:116:34-53: Cannot set item in `dict[s ERROR homeassistant/helpers/system_info.py:118:12-16: `info` may be uninitialized [unbound-name] ERROR homeassistant/helpers/template/__init__.py:261:35-41: No matching overload found for function `set.__init__` called with arguments: (Self@gen_result_wrapper.Wrapper) [no-matching-overload] ERROR homeassistant/helpers/template/__init__.py:397:16-19: `ret` may be uninitialized [unbound-name] -ERROR homeassistant/helpers/template/__init__.py:535:53-69: Argument `BoundMethod[Event, (self: Event) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/helpers/template/__init__.py:604:39-609:10: Unpacked argument `tuple[Unknown, object | Unknown]` is not assignable to parameter `*args` with type `tuple[Any, Any, dict[str, Any] | None, bool]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type] ERROR homeassistant/helpers/template/__init__.py:605:13-27: Object of class `NoneType` has no attribute `loop` [missing-attribute] ERROR homeassistant/helpers/template/__init__.py:899:9-18: Class member `TemplateStateBase.entity_id` overrides parent class `State` in an inconsistent manner [bad-override] @@ -38115,7 +37615,6 @@ ERROR homeassistant/helpers/trace.py:189:44-49: `trace` may be uninitialized [un ERROR homeassistant/helpers/trace.py:190:9-14: `trace` may be uninitialized [unbound-name] ERROR homeassistant/helpers/trace.py:191:5-10: `trace` may be uninitialized [unbound-name] ERROR homeassistant/helpers/trace.py:191:11-15: `path` may be uninitialized [unbound-name] -ERROR homeassistant/helpers/trace.py:283:27-34: Unpacked argument `tuple[object, ...]` is not assignable to varargs type `tuple[*_Ts]` [bad-argument-type] ERROR homeassistant/helpers/trace.py:285:16-29: Returned type `(*args: *_Ts) -> Coroutine[Unknown, Unknown, None]` is not assignable to declared return type `(**tuple[*_Ts]) -> Coroutine[Any, Any, None]` [bad-return] ERROR homeassistant/helpers/translation.py:453:20-27: `message` may be uninitialized [unbound-name] ERROR homeassistant/helpers/translation.py:455:23-30: `message` may be uninitialized [unbound-name] @@ -38129,7 +37628,6 @@ ERROR homeassistant/helpers/trigger.py:476:16-73: Returned type `tuple[str, Modu ERROR homeassistant/helpers/trigger.py:792:28-44: `missing_triggers` may be uninitialized [unbound-name] ERROR homeassistant/helpers/trigger_template_entity.py:290:49-58: `available` may be uninitialized [unbound-name] ERROR homeassistant/helpers/update_coordinator.py:62:10-28: Function declared to return `() -> None` but is missing an explicit `return` [bad-return] -ERROR homeassistant/helpers/update_coordinator.py:271:27-62: Argument `BoundMethod[Self@DataUpdateCoordinator, (self: Self@DataUpdateCoordinator) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_at` [bad-argument-type] ERROR homeassistant/helpers/update_coordinator.py:508:16-26: `log_timing` may be uninitialized [unbound-name] ERROR homeassistant/helpers/update_coordinator.py:512:35-40: `start` may be uninitialized [unbound-name] ERROR homeassistant/loader.py:297:16-33: Could not find import of `custom_components` [missing-import] @@ -38168,8 +37666,6 @@ ERROR homeassistant/util/__init__.py:174:24-38: Object of class `FunctionType` h ERROR homeassistant/util/__init__.py:177:24-41: Returned type `Coroutine[Unknown, Unknown, None] | None` is not assignable to declared return type `((...) -> Unknown) | Coroutine[Unknown, Unknown, Unknown]` [bad-return] ERROR homeassistant/util/__init__.py:188:24-41: Returned type `Coroutine[Unknown, Unknown, None] | None` is not assignable to declared return type `((...) -> Unknown) | Coroutine[Unknown, Unknown, Unknown]` [bad-return] ERROR homeassistant/util/aiohttp.py:128:36-63: Argument `Literal['utf-8'] | ((self: Response, value: str | None) -> None)` is not assignable to parameter `encoding` with type `str` in function `bytes.decode` [bad-argument-type] -ERROR homeassistant/util/async_.py:67:39-46: Unpacked argument `tuple[object, ...]` is not assignable to varargs type `tuple[*_Ts]` [bad-argument-type] -ERROR homeassistant/util/async_.py:74:31-43: Argument `() -> None` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] ERROR homeassistant/util/color.py:303:19-25: No matching overload found for function `max` called with arguments: (Literal[0], float | Unknown) [no-matching-overload] ERROR homeassistant/util/dt.py:237:27-32: `match` may be uninitialized [unbound-name] ERROR homeassistant/util/dt.py:237:27-42: Object of class `NoneType` has no attribute `groupdict` [missing-attribute] @@ -38184,16 +37680,11 @@ ERROR homeassistant/util/hass_dict.pyi:79:9-12: Class member `HassDict.pop` over ERROR homeassistant/util/hass_dict.pyi:138:16-50: assert_type(dict[int, bool] | dict[Any, Any], dict[int, bool]) failed [assert-type] ERROR homeassistant/util/hass_dict.pyi:140:16-46: assert_type(set[str] | set[Any], set[str]) failed [assert-type] ERROR homeassistant/util/language.py:153:46-56: `region_idx` may be uninitialized [unbound-name] -ERROR homeassistant/util/logging.py:166:30-37: Unpacked argument `tuple[object, ...]` is not assignable to varargs type `tuple[*_Ts]` [bad-argument-type] -ERROR homeassistant/util/logging.py:177:25-32: Unpacked argument `tuple[object, ...]` is not assignable to varargs type `tuple[*_Ts]` [bad-argument-type] ERROR homeassistant/util/logging.py:179:23-33: Argument `(**tuple[*_Ts]) -> Any` is not assignable to parameter `format_err` with type `(**tuple[*@_]) -> Any` in function `log_exception` [bad-argument-type] -ERROR homeassistant/util/logging.py:187:13-20: Unpacked argument `tuple[object, ...]` is not assignable to varargs type `tuple[*_Ts]` [bad-argument-type] ERROR homeassistant/util/logging.py:189:23-33: Argument `(**tuple[*_Ts]) -> Any` is not assignable to parameter `format_err` with type `(**tuple[*@_]) -> Any` in function `log_exception` [bad-argument-type] -ERROR homeassistant/util/logging.py:198:13-20: Unpacked argument `tuple[object, ...]` is not assignable to varargs type `tuple[*_Ts]` [bad-argument-type] ERROR homeassistant/util/logging.py:200:23-33: Argument `(**tuple[*_Ts]) -> Any` is not assignable to parameter `format_err` with type `(**tuple[*@_]) -> Any` in function `log_exception` [bad-argument-type] ERROR homeassistant/util/logging.py:252:27-37: Argument `(**tuple[*_Ts]) -> Any` is not assignable to parameter `format_err` with type `(**tuple[*@_]) -> Any` in function `log_exception` [bad-argument-type] -ERROR homeassistant/util/logging.py:255:24-31: Unpacked argument `tuple[object, ...]` is not assignable to parameter `*args` with type `_Ts` in function `coro_wrapper` [bad-argument-type] -ERROR homeassistant/util/logging.py:271:9-274:10: Argument `() -> str` is not assignable to parameter `format_err` with type `(**tuple[*@_]) -> Any` in function `catch_log_coro_exception` [bad-argument-type] +ERROR homeassistant/util/logging.py:255:24-31: Unpacked argument `tuple[*_Ts]` is not assignable to parameter `*args` with type `_Ts` in function `coro_wrapper` [bad-argument-type] ERROR homeassistant/util/loop.py:107:19-36: `integration_frame` may be uninitialized [unbound-name] ERROR homeassistant/util/loop.py:113:28-45: `integration_frame` may be uninitialized [unbound-name] ERROR homeassistant/util/loop.py:114:16-33: `integration_frame` may be uninitialized [unbound-name] @@ -38218,15 +37709,9 @@ ERROR homeassistant/util/read_only_dict.py:17:5-16: Class member `ReadOnlyDict._ ERROR homeassistant/util/read_only_dict.py:18:5-8: Class member `ReadOnlyDict.pop` overrides parent class `dict` in an inconsistent manner [bad-override] ERROR homeassistant/util/read_only_dict.py:21:5-11: Class member `ReadOnlyDict.update` overrides parent class `dict` in an inconsistent manner [bad-override] ERROR homeassistant/util/read_only_dict.py:22:5-15: Class member `ReadOnlyDict.setdefault` overrides parent class `dict` in an inconsistent manner [bad-override] -ERROR homeassistant/util/timeout.py:50:41-52: Argument `BoundMethod[Self@_GlobalFreezeContext, (self: Self@_GlobalFreezeContext) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] -ERROR homeassistant/util/timeout.py:59:41-51: Argument `BoundMethod[Self@_GlobalFreezeContext, (self: Self@_GlobalFreezeContext) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] -ERROR homeassistant/util/timeout.py:116:41-52: Argument `BoundMethod[Self@_ZoneFreezeContext, (self: Self@_ZoneFreezeContext) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] -ERROR homeassistant/util/timeout.py:125:41-51: Argument `BoundMethod[Self@_ZoneFreezeContext, (self: Self@_ZoneFreezeContext) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type] -ERROR homeassistant/util/timeout.py:218:36-52: Argument `BoundMethod[Self@_GlobalTaskContext, (self: Self@_GlobalTaskContext) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_at` [bad-argument-type] -ERROR homeassistant/util/timeout.py:341:36-52: Argument `BoundMethod[Self@_ZoneTaskContext, (self: Self@_ZoneTaskContext) -> None]` is not assignable to parameter `callback` with type `(**tuple[*@_]) -> object` in function `asyncio.events.AbstractEventLoop.call_at` [bad-argument-type] ERROR homeassistant/util/unit_conversion.py:174:25-42: No matching overload found for function `max` called with arguments: (Literal[0], float) [no-matching-overload] ERROR homeassistant/util/variance.py:41:43-61: `-` is not supported between `_R` and `_R` [unsupported-operation] ERROR homeassistant/util/variance.py:41:43-61: `-` is not supported between `_R` and `_R` [unsupported-operation] ERROR homeassistant/util/variance.py:41:43-61: Argument `float | int | timedelta` is not assignable to parameter `x` with type `SupportsAbs[float]` in function `abs` [bad-argument-type] INFO Checking project configured at `/pyrefly.toml` - INFO 37,601 errors (560 suppressed) + INFO 37,086 errors (560 suppressed) diff --git a/scripts/ty_benchmark/snapshots/homeassistant_ty.txt b/scripts/ty_benchmark/snapshots/homeassistant_ty.txt index 3317a1deca..f6f7f863f6 100644 --- a/scripts/ty_benchmark/snapshots/homeassistant_ty.txt +++ b/scripts/ty_benchmark/snapshots/homeassistant_ty.txt @@ -7,7 +7,6 @@ homeassistant/auth/mfa_modules/notify.py:226:31: warning[possibly-missing-attrib homeassistant/auth/mfa_modules/notify.py:249:31: warning[possibly-missing-attribute] Attribute `get` may be missing on object of type `dict[str, NotifySetting] | None` homeassistant/auth/permissions/merge.py:63:13: error[invalid-assignment] Cannot assign to a subscript on an object of type `Mapping[str, SubCategoryType]` homeassistant/auth/providers/__init__.py:268:23: error[call-non-callable] Object of type `object` is not callable -homeassistant/auth/providers/command_line.py:76:24: error[unresolved-attribute] Module `asyncio` has no member `subprocess` homeassistant/auth/providers/homeassistant.py:325:13: warning[possibly-missing-attribute] Attribute `validate_login` may be missing on object of type `Data | None` homeassistant/auth/providers/homeassistant.py:334:48: warning[possibly-missing-attribute] Attribute `add_auth` may be missing on object of type `Data | None` homeassistant/auth/providers/homeassistant.py:335:15: warning[possibly-missing-attribute] Attribute `async_save` may be missing on object of type `Data | None` @@ -52,6 +51,7 @@ homeassistant/components/actron_air/climate.py:182:15: warning[possibly-missing- homeassistant/components/actron_air/climate.py:182:65: error[invalid-argument-type] Argument to bound method `set_temperature` is incorrect: Expected `int | float`, found `Any | None` homeassistant/components/actron_air/climate.py:227:16: warning[possibly-missing-attribute] Attribute `zones` may be missing on object of type `Unknown | ActronAirNeoACSystem` homeassistant/components/actron_air/coordinator.py:55:30: error[non-subscriptable] Cannot subscript object of type `ActronAirNeoACSystem` with no `__getitem__` method +homeassistant/components/actron_air/coordinator.py:60:15: error[invalid-method-override] Invalid override of method `_async_update_data`: Definition is incompatible with `DataUpdateCoordinator._async_update_data` homeassistant/components/actron_air/coordinator.py:65:16: error[invalid-return-type] Return type does not match returned value: expected `ActronAirNeoStatus`, found `Unknown | ActronAirNeoStatus | None` homeassistant/components/adguard/entity.py:63:25: error[invalid-argument-type] Invalid argument to key "identifiers" with declared type `set[tuple[str, str]]` on TypedDict `DeviceInfo`: value of type `set[Unknown | tuple[str, Unknown | str, Unknown | int, Unknown | str]]` homeassistant/components/ads/__init__.py:5:8: error[unresolved-import] Cannot resolve imported module `pyads` @@ -97,7 +97,7 @@ homeassistant/components/alexa/state_report.py:343:9: error[invalid-argument-typ homeassistant/components/alpha_vantage/sensor.py:8:6: error[unresolved-import] Cannot resolve imported module `alpha_vantage.foreignexchange` homeassistant/components/alpha_vantage/sensor.py:9:6: error[unresolved-import] Cannot resolve imported module `alpha_vantage.timeseries` homeassistant/components/altruist/sensor.py:274:16: error[unresolved-attribute] Object of type `SensorEntityDescription` has no attribute `native_value_fn` -homeassistant/components/amazon_polly/tts.py:101:19: error[unresolved-attribute] Module `botocore` has no member `config` +homeassistant/components/amazon_polly/tts.py:101:19: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `botocore` homeassistant/components/amazon_polly/tts.py:143:23: error[invalid-type-form] Variable of type `def client(...) -> Unknown` is not allowed in a type expression homeassistant/components/amcrest/__init__.py:15:6: error[unresolved-import] Cannot resolve imported module `amcrest` homeassistant/components/amcrest/binary_sensor.py:11:6: error[unresolved-import] Cannot resolve imported module `amcrest` @@ -105,16 +105,16 @@ homeassistant/components/amcrest/binary_sensor.py:215:32: error[unresolved-attri homeassistant/components/amcrest/binary_sensor.py:272:28: error[unresolved-attribute] Object of type `BinarySensorEntityDescription` has no attribute `event_codes` homeassistant/components/amcrest/binary_sensor.py:273:19: error[unresolved-attribute] Object of type `BinarySensorEntityDescription` has no attribute `should_poll` homeassistant/components/amcrest/camera.py:13:6: error[unresolved-import] Cannot resolve imported module `amcrest` -homeassistant/components/amcrest/camera.py:177:30: error[unresolved-attribute] Module `asyncio` has no member `tasks` homeassistant/components/amcrest/camera.py:259:49: error[invalid-argument-type] Argument to bound method `open_camera` is incorrect: Expected `str | None`, found `Unknown | list[str]` homeassistant/components/amcrest/camera.py:266:17: error[invalid-argument-type] Argument to function `async_aiohttp_proxy_stream` is incorrect: Expected `StreamReader`, found `StreamReader` homeassistant/components/amcrest/sensor.py:9:6: error[unresolved-import] Cannot resolve imported module `amcrest` homeassistant/components/ampio/air_quality.py:8:6: error[unresolved-import] Cannot resolve imported module `asmog` homeassistant/components/analytics/analytics.py:167:16: error[invalid-return-type] Return type does not match returned value: expected `AnalyticsPlatformProtocol | None`, found `ModuleType` -homeassistant/components/androidtv/entity.py:46:16: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/androidtv/entity.py:46:49: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/androidtv/entity.py:54:15: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/androidtv/entity.py:55:10: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 +homeassistant/components/androidtv/entity.py:46:43: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/androidtv/entity.py:46:82: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/androidtv/entity.py:54:42: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/androidtv/entity.py:55:43: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/androidtv/entity.py:75:21: error[unresolved-attribute] Object of type `(...) -> Awaitable[Unknown]` has no attribute `__name__` homeassistant/components/anel_pwrctrl/switch.py:9:6: error[unresolved-import] Cannot resolve imported module `anel_pwrctrl` homeassistant/components/anthemav/config_flow.py:74:47: error[unresolved-attribute] Object of type `Protocol` has no attribute `macaddress` homeassistant/components/anthemav/config_flow.py:75:38: error[unresolved-attribute] Object of type `Protocol` has no attribute `model` @@ -161,6 +161,7 @@ homeassistant/components/apple_tv/__init__.py:392:57: error[invalid-argument-typ homeassistant/components/apple_tv/__init__.py:392:57: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `str | None`, found `Unknown | set[Unknown | tuple[str, Unknown | str | None]] | str` homeassistant/components/apple_tv/__init__.py:392:57: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `Mapping[str, str] | None`, found `Unknown | set[Unknown | tuple[str, Unknown | str | None]] | str` homeassistant/components/apple_tv/__init__.py:392:57: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `tuple[str, str] | None | UndefinedType`, found `Unknown | set[Unknown | tuple[str, Unknown | str | None]] | str` +homeassistant/components/apple_tv/config_flow.py:292:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/apple_tv/media_player.py:484:41: error[invalid-argument-type] Argument to bound method `insert` is incorrect: Expected `Never`, found `BrowseMedia` homeassistant/components/application_credentials/__init__.py:309:12: error[invalid-return-type] Return type does not match returned value: expected `ApplicationCredentialsProtocol | None`, found `ModuleType` homeassistant/components/aprilaire/coordinator.py:57:13: error[invalid-assignment] Object of type `~AlwaysFalsy` is not assignable to attribute `data` of type `dict[str, Any]` @@ -176,18 +177,9 @@ homeassistant/components/apsystems/coordinator.py:82:61: error[invalid-argument- homeassistant/components/aqualogic/__init__.py:10:6: error[unresolved-import] Cannot resolve imported module `aqualogic.core` homeassistant/components/aqualogic/switch.py:7:6: error[unresolved-import] Cannot resolve imported module `aqualogic.core` homeassistant/components/aquostv/media_player.py:9:8: error[unresolved-import] Cannot resolve imported module `sharp_aquos_rc` -homeassistant/components/arest/binary_sensor.py:51:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/arest/binary_sensor.py:56:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/arest/binary_sensor.py:111:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/arest/sensor.py:74:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/arest/sensor.py:79:12: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/arest/sensor.py:172:39: error[call-non-callable] Object of type `None` is not callable -homeassistant/components/arest/sensor.py:207:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/arest/switch.py:62:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/arest/switch.py:67:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/arest/switch.py:160:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/arest/switch.py:207:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/arris_tg2492lg/device_tracker.py:6:6: error[unresolved-import] Cannot resolve imported module `arris_tg2492lg` +homeassistant/components/arve/coordinator.py:49:15: error[invalid-method-override] Invalid override of method `_async_update_data`: Definition is incompatible with `DataUpdateCoordinator._async_update_data` homeassistant/components/arve/entity.py:47:13: error[unsupported-operator] Operator `in` is not supported for types `Unknown` and `ArveSensProData`, in comparing `Unknown | str` with `Unknown | ArveSensProData` homeassistant/components/arve/entity.py:53:16: error[non-subscriptable] Cannot subscript object of type `ArveSensProData` with no `__getitem__` method homeassistant/components/assist_pipeline/select.py:90:13: error[invalid-argument-type] Argument to function `replace` is incorrect: Argument type `Unknown | SelectEntityDescription` does not satisfy upper bound `DataclassInstance` of type variable `_DataclassT` @@ -210,7 +202,7 @@ homeassistant/components/atag/climate.py:86:15: warning[possibly-missing-attribu homeassistant/components/atag/climate.py:86:54: error[invalid-argument-type] Argument to bound method `set_temp` is incorrect: Expected `int | float`, found `Any | None` homeassistant/components/atag/climate.py:91:15: warning[possibly-missing-attribute] Attribute `set_hvac_mode` may be missing on object of type `Unknown | None | Climate` homeassistant/components/atag/climate.py:96:15: warning[possibly-missing-attribute] Attribute `set_preset_mode` may be missing on object of type `Unknown | None | Climate` -homeassistant/components/atag/config_flow.py:16:37: error[unresolved-attribute] Module `pyatag` has no member `const` +homeassistant/components/atag/config_flow.py:16:37: warning[possibly-missing-attribute] Submodule `const` may not be available as an attribute on module `pyatag` homeassistant/components/atag/sensor.py:45:12: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/atag/sensor.py:49:39: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/atag/sensor.py:50:12: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method @@ -270,7 +262,7 @@ homeassistant/components/august/lock.py:113:54: error[invalid-argument-type] Arg homeassistant/components/august/lock.py:128:22: warning[possibly-missing-attribute] Attribute `keypad` may be missing on object of type `DoorbellDetail | LockDetail` homeassistant/components/august/sensor.py:94:48: error[invalid-argument-type] Argument is incorrect: Expected `LockDetail`, found `DoorbellDetail | LockDetail` homeassistant/components/august/sensor.py:100:22: warning[possibly-missing-attribute] Attribute `keypad` may be missing on object of type `DoorbellDetail | LockDetail` -homeassistant/components/august/sensor.py:108:9: error[invalid-argument-type] Argument to class `AugustBatterySensor` is incorrect: Expected `LockDetail | KeypadDetail`, found `Doorbell` +homeassistant/components/august/sensor.py:108:29: error[invalid-type-arguments] Type `Doorbell` is not assignable to upper bound `LockDetail | KeypadDetail` of type variable `T@AugustBatterySensor` homeassistant/components/august/sensor.py:110:48: error[invalid-argument-type] Argument is incorrect: Expected `LockDetail`, found `DoorbellDetail | LockDetail` homeassistant/components/august/sensor.py:212:68: error[invalid-argument-type] Argument is incorrect: Expected `T@AugustBatterySensor`, found `DoorbellDetail | LockDetail` homeassistant/components/august/util.py:38:12: error[invalid-return-type] Return type does not match returned value: expected `Activity | None`, found `Literal[False]` @@ -312,8 +304,6 @@ homeassistant/components/baidu/tts.py:5:6: error[unresolved-import] Cannot resol homeassistant/components/bang_olufsen/media_player.py:932:53: error[invalid-argument-type] Argument to function `loads` is incorrect: Expected `str | bytes | bytearray`, found `Unknown | None` homeassistant/components/bbox/device_tracker.py:9:8: error[unresolved-import] Cannot resolve imported module `pybbox` homeassistant/components/bbox/sensor.py:8:8: error[unresolved-import] Cannot resolve imported module `pybbox` -homeassistant/components/bbox/sensor.py:105:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/bbox/sensor.py:201:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/beewi_smartclim/sensor.py:5:6: error[unresolved-import] Cannot resolve imported module `beewi_smartclim` homeassistant/components/bitcoin/sensor.py:8:6: error[unresolved-import] Cannot resolve imported module `blockchain` homeassistant/components/bizkaibus/sensor.py:7:6: error[unresolved-import] Cannot resolve imported module `bizkaibus.bizkaibus` @@ -361,8 +351,7 @@ homeassistant/components/bond/button.py:230:9: error[invalid-argument-type] Argu homeassistant/components/bond/button.py:237:9: error[invalid-argument-type] Argument is incorrect: Expected `Action | None`, found `Unknown | Literal["SetPosition"]` homeassistant/components/bond/button.py:244:9: error[invalid-argument-type] Argument is incorrect: Expected `Action | None`, found `Unknown | Literal["SetPosition"]` homeassistant/components/bond/button.py:280:42: error[invalid-argument-type] Argument to bound method `has_action` is incorrect: Expected `str`, found `Action` -homeassistant/components/bosch_alarm/config_flow.py:120:17: error[unresolved-attribute] Module `asyncio` has no member `exceptions` -homeassistant/components/bosch_alarm/config_flow.py:191:13: error[unresolved-attribute] Module `asyncio` has no member `exceptions` +homeassistant/components/bosch_alarm/config_flow.py:99:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/bosch_shc/binary_sensor.py:34:13: error[unsupported-operator] Operator `+` is unsupported between objects of type `Sequence[SHCShutterContact]` and `Sequence[SHCShutterContact2]` homeassistant/components/bosch_shc/binary_sensor.py:46:13: error[unsupported-operator] Operator `+` is unsupported between objects of type `Sequence[SHCMotionDetector]` and `Sequence[SHCShutterContact]` homeassistant/components/bosch_shc/binary_sensor.py:76:13: warning[possibly-missing-attribute] Attribute `device_class` may be missing on object of type `Unknown | SHCDevice | SHCIntrusionSystem` @@ -397,11 +386,11 @@ homeassistant/components/brottsplatskartan/sensor.py:68:59: error[invalid-assign homeassistant/components/brunt/cover.py:159:27: error[invalid-argument-type] Argument to bound method `async_change_request_position` is incorrect: Expected `str`, found `Unknown | str | None` homeassistant/components/brunt/cover.py:173:16: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[str, int].__getitem__(key: str, /) -> int` cannot be called with key of type `Unknown | str | None` on object of type `dict[str, int]` homeassistant/components/bryant_evolution/climate.py:48:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `BryantEvolutionLocalClient`, found `BryantEvolutionLocalClient | None` -homeassistant/components/bryant_evolution/climate.py:193:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[Unknown | str, Unknown | tuple[str, bool] | str]` +homeassistant/components/bryant_evolution/climate.py:193:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[str, str | (Unknown & ~AlwaysFalsy) | tuple[str, bool]] & dict[Unknown | str, Unknown | tuple[str, bool] | str]` homeassistant/components/bt_home_hub_5/device_tracker.py:7:8: error[unresolved-import] Cannot resolve imported module `bthomehub5_devicelist` homeassistant/components/bt_smarthub/device_tracker.py:8:6: error[unresolved-import] Cannot resolve imported module `btsmarthub_devicelist` -homeassistant/components/bthome/__init__.py:109:6: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/components/bthome/__init__.py:114:52: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 2 +homeassistant/components/bthome/__init__.py:109:17: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/components/bthome/__init__.py:114:63: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 2 homeassistant/components/bthome/event.py:70:43: error[invalid-argument-type] Argument to function `replace` is incorrect: Argument type `Unknown | EventEntityDescription` does not satisfy upper bound `DataclassInstance` of type variable `_DataclassT` homeassistant/components/bthome/logbook.py:34:16: error[invalid-return-type] Return type does not match returned value: expected `dict[str, str]`, found `dict[str, str | (DeviceEntry & ~AlwaysTruthy & ~AlwaysFalsy)]` homeassistant/components/buienradar/sensor.py:783:28: warning[possibly-missing-attribute] Attribute `data` may be missing on object of type `BrData | None` @@ -430,16 +419,19 @@ homeassistant/components/caldav/todo.py:71:39: error[invalid-argument-type] Argu homeassistant/components/caldav/todo.py:75:36: error[invalid-argument-type] Argument to function `get_attr_value` is incorrect: Expected `CalendarObjectResource`, found `~AlwaysFalsy` homeassistant/components/caldav/todo.py:84:28: error[invalid-argument-type] Argument to function `get_attr_value` is incorrect: Expected `CalendarObjectResource`, found `~AlwaysFalsy` homeassistant/components/caldav/todo.py:88:36: error[invalid-argument-type] Argument to function `get_attr_value` is incorrect: Expected `CalendarObjectResource`, found `~AlwaysFalsy` -homeassistant/components/calendar/trigger.py:172:14: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/components/calendar/trigger.py:172:27: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/components/cambridge_audio/entity.py:32:38: error[unresolved-attribute] Object of type `(...) -> Awaitable[None]` has no attribute `__name__` homeassistant/components/canary/camera.py:173:17: error[invalid-argument-type] Argument to function `async_aiohttp_proxy_stream` is incorrect: Expected `StreamReader`, found `StreamReader` -homeassistant/components/cast/const.py:27:25: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/components/cast/const.py:31:22: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/components/cast/const.py:34:29: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 4 +homeassistant/components/cast/const.py:27:36: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/components/cast/const.py:31:33: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/components/cast/const.py:35:5: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 4 +homeassistant/components/cast/discovery.py:64:13: error[invalid-method-override] Invalid override of method `add_cast`: Definition is incompatible with `AbstractCastListener.add_cast` +homeassistant/components/cast/discovery.py:68:13: error[invalid-method-override] Invalid override of method `update_cast`: Definition is incompatible with `AbstractCastListener.update_cast` homeassistant/components/cast/helpers.py:132:13: error[unknown-argument] Argument `is_dynamic_group` does not match any known parameter homeassistant/components/cast/helpers.py:268:12: error[unresolved-attribute] Object of type `object` has no attribute `ClientError` -homeassistant/components/cast/media_player.py:94:11: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/cast/media_player.py:95:6: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 +homeassistant/components/cast/media_player.py:94:39: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/cast/media_player.py:95:34: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/cast/media_player.py:105:46: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__` homeassistant/components/cast/media_player.py:353:28: warning[possibly-missing-attribute] Attribute `status` may be missing on object of type `Chromecast | None` homeassistant/components/cast/media_player.py:354:29: warning[possibly-missing-attribute] Attribute `media_controller` may be missing on object of type `Chromecast | None` homeassistant/components/cast/media_player.py:460:35: warning[possibly-missing-attribute] Attribute `get_multizone_memberships` may be missing on object of type `Unknown | None` @@ -459,34 +451,30 @@ homeassistant/components/cisco_webex_teams/notify.py:8:6: error[unresolved-impor homeassistant/components/citybikes/sensor.py:11:6: error[unresolved-import] Cannot resolve imported module `citybikes` homeassistant/components/citybikes/sensor.py:12:6: error[unresolved-import] Cannot resolve imported module `citybikes.asyncio` homeassistant/components/clementine/media_player.py:8:6: error[unresolved-import] Cannot resolve imported module `clementineremote` -homeassistant/components/cloud/__init__.py:85:32: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 +homeassistant/components/cloud/__init__.py:85:43: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 homeassistant/components/cloud/__init__.py:281:51: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, Any]`, found `Unknown | (str & ~AlwaysFalsy)` homeassistant/components/cloud/__init__.py:281:63: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, Any]`, found `Unknown | (str & ~AlwaysFalsy)` homeassistant/components/cloud/__init__.py:282:51: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Literal["development", "production"]`, found `Unknown | str` homeassistant/components/cloud/__init__.py:282:51: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[Literal["remote_access_resolve_dns_cname", "subscription_info", "subscription_migrate_paypal", "voice_connection_details"], str] | None`, found `Unknown | str` homeassistant/components/cloud/__init__.py:282:51: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Literal["development", "production"]`, found `Unknown | str` homeassistant/components/cloud/__init__.py:282:51: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[Literal["remote_access_resolve_dns_cname", "subscription_info", "subscription_migrate_paypal", "voice_connection_details"], str] | None`, found `Unknown | str` -homeassistant/components/cloud/alexa_config.py:272:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventEntityRegistryUpdatedData]` +homeassistant/components/cloud/alexa_config.py:272:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` homeassistant/components/cloud/alexa_config.py:273:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `bound method Self@async_initialize._handle_entity_registry_updated(event: Event[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]) -> CoroutineType[Any, Any, None]` homeassistant/components/cloud/alexa_config.py:543:28: error[invalid-key] Unknown key "changes" for TypedDict `_EventEntityRegistryUpdatedData_CreateRemove`: Unknown key "changes" homeassistant/components/cloud/alexa_config.py:547:45: error[invalid-key] Unknown key "old_entity_id" for TypedDict `_EventEntityRegistryUpdatedData_CreateRemove`: Unknown key "old_entity_id" homeassistant/components/cloud/client.py:96:33: error[unresolved-attribute] Object of type `object` has no attribute `AppRunner` -homeassistant/components/cloud/const.py:90:27: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/components/cloud/google_config.py:269:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventEntityRegistryUpdatedData]` +homeassistant/components/cloud/const.py:90:38: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/components/cloud/google_config.py:269:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` homeassistant/components/cloud/google_config.py:270:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `bound method Self@async_initialize._handle_entity_registry_updated(event: Event[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]) -> None` -homeassistant/components/cloud/google_config.py:275:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventDeviceRegistryUpdatedData]` +homeassistant/components/cloud/google_config.py:275:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]` homeassistant/components/cloud/google_config.py:276:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `bound method Self@async_initialize._handle_device_registry_updated(event: Event[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]) -> None` homeassistant/components/cloud/google_config.py:471:28: error[invalid-key] Unknown key "changes" for TypedDict `_EventEntityRegistryUpdatedData_CreateRemove`: Unknown key "changes" homeassistant/components/cloud/google_config.py:495:76: error[invalid-key] Unknown key "changes" for TypedDict `_EventDeviceRegistryUpdatedData_Create`: Unknown key "changes" homeassistant/components/cloud/google_config.py:495:76: error[invalid-key] Unknown key "changes" for TypedDict `_EventDeviceRegistryUpdatedData_Remove`: Unknown key "changes" homeassistant/components/cmus/media_player.py:8:6: error[unresolved-import] Cannot resolve imported module `pycmus` homeassistant/components/comfoconnect/__init__.py:104:26: warning[possibly-missing-attribute] Attribute `hex` may be missing on object of type `Unknown | str` -homeassistant/components/command_line/utils.py:54:20: error[unresolved-attribute] Module `asyncio` has no member `subprocess` homeassistant/components/concord232/alarm_control_panel.py:8:6: error[unresolved-import] Cannot resolve imported module `concord232` -homeassistant/components/concord232/alarm_control_panel.py:62:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/concord232/alarm_control_panel.py:90:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/concord232/binary_sensor.py:8:6: error[unresolved-import] Cannot resolve imported module `concord232` -homeassistant/components/concord232/binary_sensor.py:71:12: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/concord232/binary_sensor.py:129:16: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/concord232/binary_sensor.py:135:21: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/concord232/binary_sensor.py:144:52: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method @@ -499,7 +487,7 @@ homeassistant/components/conversation/chat_log.py:426:39: error[invalid-key] Unk homeassistant/components/conversation/default_agent.py:274:33: error[invalid-key] Unknown key "changes" for TypedDict `_EventEntityRegistryUpdatedData_CreateRemove`: Unknown key "changes" homeassistant/components/conversation/default_agent.py:289:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventAreaRegistryUpdatedData]` homeassistant/components/conversation/default_agent.py:293:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventFloorRegistryUpdatedData]` -homeassistant/components/conversation/default_agent.py:297:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventEntityRegistryUpdatedData]` +homeassistant/components/conversation/default_agent.py:297:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` homeassistant/components/conversation/default_agent.py:299:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `bound method Self@_listen_clear_slot_list._filter_entity_registry_changes(event_data: _EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update) -> bool` homeassistant/components/conversation/default_agent.py:302:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventStateChangedData]` homeassistant/components/conversation/default_agent.py:304:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `bound method Self@_listen_clear_slot_list._filter_state_changes(event_data: EventStateChangedData) -> bool` @@ -533,9 +521,7 @@ homeassistant/components/danfoss_air/binary_sensor.py:5:6: error[unresolved-impo homeassistant/components/danfoss_air/sensor.py:7:6: error[unresolved-import] Cannot resolve imported module `pydanfossair.commands` homeassistant/components/danfoss_air/switch.py:8:6: error[unresolved-import] Cannot resolve imported module `pydanfossair.commands` homeassistant/components/datadog/__init__.py:124:31: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventStateChangedData]` -homeassistant/components/ddwrt/device_tracker.py:153:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/deconz/button.py:104:13: error[unresolved-attribute] Object of type `ButtonEntityDescription` has no attribute `button_fn` -homeassistant/components/deconz/entity.py:141:39: warning[possibly-missing-attribute] Attribute `reachable` may be missing on object of type `_DeviceT@DeconzDevice & ~Scene` homeassistant/components/deconz/light.py:255:12: error[unsupported-operator] Operator `not in` is not supported for types `Unknown` and `None`, in comparing `Unknown | ColorMode` with `set[ColorMode] | set[str] | None` homeassistant/components/deconz/light.py:303:16: error[unsupported-operator] Operator `in` is not supported for types `Literal[ColorMode.XY]` and `None`, in comparing `Literal[ColorMode.XY]` with `set[ColorMode] | set[str] | None` homeassistant/components/decora_wifi/light.py:8:6: error[unresolved-import] Cannot resolve imported module `decora_wifi` @@ -563,9 +549,9 @@ homeassistant/components/denonavr/receiver.py:102:27: error[unresolved-attribute homeassistant/components/devialet/config_flow.py:51:13: error[invalid-argument-type] Argument to bound method `async_create_entry` is incorrect: Expected `str`, found `str | None` homeassistant/components/devialet/diagnostics.py:16:12: error[invalid-return-type] Return type does not match returned value: expected `dict[str, Any]`, found `Unknown | None` homeassistant/components/devialet/media_player.py:112:16: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `Unknown | bool | None` -homeassistant/components/device_tracker/config_entry.py:166:27: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventDeviceRegistryUpdatedData]` -homeassistant/components/device_tracker/config_entry.py:166:61: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def handle_device_event(ev: Event[EventDeviceRegistryUpdatedData]) -> None` -homeassistant/components/device_tracker/const.py:52:31: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 +homeassistant/components/device_tracker/config_entry.py:166:27: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]` +homeassistant/components/device_tracker/config_entry.py:166:61: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def handle_device_event(ev: Event[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]) -> None` +homeassistant/components/device_tracker/const.py:52:42: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 homeassistant/components/device_tracker/legacy.py:409:12: error[missing-argument] No argument provided for required parameter `config` homeassistant/components/device_tracker/legacy.py:409:34: error[invalid-argument-type] Argument is incorrect: Expected `tuple[str, ...]`, found `str` homeassistant/components/device_tracker/legacy.py:409:42: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `ModuleType` @@ -609,7 +595,7 @@ homeassistant/components/directv/media_player.py:70:29: warning[possibly-missing homeassistant/components/directv/media_player.py:161:20: error[invalid-return-type] Return type does not match returned value: expected `MediaType | None`, found `Unknown | str` homeassistant/components/directv/remote.py:39:29: warning[possibly-missing-attribute] Attribute `locations` may be missing on object of type `Device | None` homeassistant/components/discogs/sensor.py:9:8: error[unresolved-import] Cannot resolve imported module `discogs_client` -homeassistant/components/dlink/data.py:44:16: error[unresolved-attribute] Module `urllib` has no member `error` +homeassistant/components/dlink/data.py:44:16: warning[possibly-missing-attribute] Submodule `error` may not be available as an attribute on module `urllib` homeassistant/components/dlna_dmr/media_player.py:79:70: error[unresolved-attribute] Object of type `(...) -> Awaitable[_R@catch_request_errors]` has no attribute `__name__` homeassistant/components/dlna_dmr/media_player.py:86:55: error[unresolved-attribute] Object of type `(...) -> Awaitable[_R@catch_request_errors]` has no attribute `__name__` homeassistant/components/dlna_dms/dms.py:137:73: error[unresolved-attribute] Object of type `(_DlnaDmsDeviceMethod@catch_request_errors, str, /) -> Coroutine[Any, Any, _R@catch_request_errors]` has no attribute `__name__` @@ -617,7 +603,6 @@ homeassistant/components/dominos/__init__.py:6:6: error[unresolved-import] Canno homeassistant/components/doods/image_processing.py:12:6: error[unresolved-import] Cannot resolve imported module `pydoods` homeassistant/components/doods/image_processing.py:246:23: error[invalid-argument-type] Argument to function `draw_box` is incorrect: Expected `tuple[int | float, int | float, int | float, int | float]`, found `Unknown | list[Unknown | int] | list[Unknown]` homeassistant/components/dovado/__init__.py:47:9: error[unresolved-reference] Name `dovado` used when not defined -homeassistant/components/downloader/services.py:127:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/drop_connect/__init__.py:42:24: error[invalid-argument-type] Argument to bound method `parse_drop_message` is incorrect: Expected `str | bytes`, found `str | bytes | bytearray` homeassistant/components/drop_connect/config_flow.py:51:39: error[invalid-argument-type] Argument to bound method `parse_discovery` is incorrect: Expected `str | bytes`, found `(str & ~AlwaysFalsy) | (bytes & ~AlwaysFalsy) | (bytearray & ~AlwaysFalsy)` homeassistant/components/dunehd/media_player.py:109:23: warning[possibly-missing-attribute] Attribute `volume_up` may be missing on object of type `Unknown | DuneHDPlayer` @@ -705,27 +690,24 @@ homeassistant/components/econet/climate.py:68:30: error[invalid-argument-type] A homeassistant/components/econet/sensor.py:125:16: warning[possibly-missing-attribute] Attribute `energy_type` may be missing on object of type `Unknown | Equipment` homeassistant/components/econet/switch.py:29:33: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Thermostat`, found `Equipment` homeassistant/components/econet/water_heater.py:57:31: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `WaterHeater`, found `Equipment` -homeassistant/components/ecovacs/number.py:111:30: error[too-many-positional-arguments] Too many positional arguments to class `CapabilitySet`: expected 1, got 2 +homeassistant/components/ecovacs/number.py:111:52: error[invalid-type-arguments] Too many type arguments to class `CapabilitySet`: expected 1, got 2 homeassistant/components/ecovacs/number.py:111:52: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[int]`? -homeassistant/components/ecovacs/number.py:121:21: error[too-many-positional-arguments] Too many positional arguments to class `CapabilitySet`: expected 1, got 2 +homeassistant/components/ecovacs/number.py:121:43: error[invalid-type-arguments] Too many type arguments to class `CapabilitySet`: expected 1, got 2 homeassistant/components/ecovacs/number.py:121:43: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[int]`? homeassistant/components/ecovacs/select.py:87:46: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `CapabilityMap`, found `CapabilityMap | None` -homeassistant/components/ecovacs/select.py:97:30: error[too-many-positional-arguments] Too many positional arguments to class `CapabilitySetTypes`: expected 2, got 3 homeassistant/components/ecovacs/select.py:97:57: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[str]`? -homeassistant/components/ecovacs/select.py:108:21: error[too-many-positional-arguments] Too many positional arguments to class `CapabilitySetTypes`: expected 2, got 3 +homeassistant/components/ecovacs/select.py:97:64: error[invalid-type-arguments] Too many type arguments to class `CapabilitySetTypes`: expected 2, got 3 homeassistant/components/ecovacs/select.py:108:48: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[str]`? +homeassistant/components/ecovacs/select.py:108:55: error[invalid-type-arguments] Too many type arguments to class `CapabilitySetTypes`: expected 2, got 3 homeassistant/components/ecowitt/binary_sensor.py:51:13: error[invalid-argument-type] Argument to function `replace` is incorrect: Argument type `Unknown | BinarySensorEntityDescription` does not satisfy upper bound `DataclassInstance` of type variable `_DataclassT` homeassistant/components/ecowitt/sensor.py:283:13: error[invalid-argument-type] Argument to function `replace` is incorrect: Argument type `Unknown | SensorEntityDescription` does not satisfy upper bound `DataclassInstance` of type variable `_DataclassT` homeassistant/components/edimax/switch.py:7:6: error[unresolved-import] Cannot resolve imported module `pyedimax.smartplug` homeassistant/components/efergy/sensor.py:129:17: error[invalid-argument-type] Argument to function `replace` is incorrect: Argument type `SensorEntityDescription` does not satisfy upper bound `DataclassInstance` of type variable `_DataclassT` homeassistant/components/egardia/__init__.py:5:6: error[unresolved-import] Cannot resolve imported module `pythonegardia` -homeassistant/components/egardia/__init__.py:98:12: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/egardia/alarm_control_panel.py:104:44: warning[possibly-missing-attribute] Attribute `items` may be missing on object of type `Unknown | None` -homeassistant/components/egardia/alarm_control_panel.py:132:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/egardia/alarm_control_panel.py:142:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/egardia/alarm_control_panel.py:152:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/ekeybionyx/config_flow.py:110:47: error[invalid-assignment] Object of type `list[dict[Unknown | str, Unknown | str] | Unknown]` is not assignable to `list[SelectOptionDict]` homeassistant/components/eliqonline/sensor.py:8:8: error[unresolved-import] Cannot resolve imported module `eliqonline` +homeassistant/components/elkm1/config_flow.py:202:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/elmax/__init__.py:50:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `SSLContext`, found `None | SSLContext` homeassistant/components/elmax/config_flow.py:167:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `SSLContext`, found `None | Unknown` homeassistant/components/elmax/config_flow.py:330:30: error[invalid-argument-type] Argument to function `_store_panel_by_name` is incorrect: Expected `str`, found `str | None` @@ -739,25 +721,25 @@ homeassistant/components/emby/media_player.py:7:6: error[unresolved-import] Cann homeassistant/components/emoncms_history/__init__.py:67:70: error[invalid-argument-type] Argument to bound method `async_input_post` is incorrect: Expected `str | None`, found `str | int` homeassistant/components/emonitor/sensor.py:48:36: error[unresolved-attribute] Object of type `list[Unknown]` has no attribute `items` homeassistant/components/emonitor/sensor.py:56:33: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `DataUpdateCoordinator[dict[str, Any]]`, found `DataUpdateCoordinator[EmonitorStatus]` -homeassistant/components/emonitor/sensor.py:63:27: error[invalid-argument-type] Argument to class `CoordinatorEntity` is incorrect: Expected `DataUpdateCoordinator[Any]`, found `EmonitorStatus` +homeassistant/components/emonitor/sensor.py:63:45: error[invalid-type-arguments] Type `EmonitorStatus` is not assignable to upper bound `DataUpdateCoordinator[Any]` of type variable `_DataUpdateCoordinatorT@CoordinatorEntity` homeassistant/components/emulated_roku/binding.py:135:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | str | None` homeassistant/components/emulated_roku/binding.py:136:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `int`, found `Unknown | int | None` homeassistant/components/emulated_roku/binding.py:137:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool`, found `Unknown | bool | None` homeassistant/components/energenie_power_sockets/__init__.py:21:44: error[invalid-assignment] Object of type `Device | None` is not assignable to `PowerStripUSB | None` homeassistant/components/energy/data.py:367:29: error[invalid-assignment] Invalid assignment to key "energy_sources" with declared type `list[SourceType]` on TypedDict `EnergyPreferences`: value of type `list[SourceType] | list[DeviceConsumption]` homeassistant/components/energy/data.py:367:29: error[invalid-assignment] Invalid assignment to key "device_consumption" with declared type `list[DeviceConsumption]` on TypedDict `EnergyPreferences`: value of type `list[SourceType] | list[DeviceConsumption]` -homeassistant/components/energy/validate.py:174:36: error[unresolved-attribute] Module `homeassistant.components.recorder` has no member `models` -homeassistant/components/energy/validate.py:234:36: error[unresolved-attribute] Module `homeassistant.components.recorder` has no member `models` -homeassistant/components/energy/validate.py:305:36: error[unresolved-attribute] Module `homeassistant.components.recorder` has no member `models` -homeassistant/components/energy/validate.py:338:36: error[unresolved-attribute] Module `homeassistant.components.recorder` has no member `models` -homeassistant/components/energy/validate.py:392:47: error[unresolved-attribute] Module `homeassistant.components.recorder` has no member `models` -homeassistant/components/energy/validate.py:521:47: error[unresolved-attribute] Module `homeassistant.components.recorder` has no member `models` -homeassistant/components/energy/validate.py:581:47: error[unresolved-attribute] Module `homeassistant.components.recorder` has no member `models` -homeassistant/components/energy/validate.py:641:47: error[unresolved-attribute] Module `homeassistant.components.recorder` has no member `models` -homeassistant/components/energy/validate.py:749:17: error[unresolved-attribute] Module `homeassistant.components.recorder` has no member `statistics` -homeassistant/components/energy/websocket_api.py:276:9: error[unresolved-attribute] Module `homeassistant.components.recorder` has no member `statistics` -homeassistant/components/energy/websocket_api.py:361:43: error[unresolved-attribute] Module `homeassistant.components.recorder` has no member `statistics` -homeassistant/components/energy/websocket_api.py:372:13: error[unresolved-attribute] Module `homeassistant.components.recorder` has no member `statistics` +homeassistant/components/energy/validate.py:174:36: warning[possibly-missing-attribute] Submodule `models` may not be available as an attribute on module `homeassistant.components.recorder` +homeassistant/components/energy/validate.py:234:36: warning[possibly-missing-attribute] Submodule `models` may not be available as an attribute on module `homeassistant.components.recorder` +homeassistant/components/energy/validate.py:305:36: warning[possibly-missing-attribute] Submodule `models` may not be available as an attribute on module `homeassistant.components.recorder` +homeassistant/components/energy/validate.py:338:36: warning[possibly-missing-attribute] Submodule `models` may not be available as an attribute on module `homeassistant.components.recorder` +homeassistant/components/energy/validate.py:392:47: warning[possibly-missing-attribute] Submodule `models` may not be available as an attribute on module `homeassistant.components.recorder` +homeassistant/components/energy/validate.py:521:47: warning[possibly-missing-attribute] Submodule `models` may not be available as an attribute on module `homeassistant.components.recorder` +homeassistant/components/energy/validate.py:581:47: warning[possibly-missing-attribute] Submodule `models` may not be available as an attribute on module `homeassistant.components.recorder` +homeassistant/components/energy/validate.py:641:47: warning[possibly-missing-attribute] Submodule `models` may not be available as an attribute on module `homeassistant.components.recorder` +homeassistant/components/energy/validate.py:749:17: warning[possibly-missing-attribute] Submodule `statistics` may not be available as an attribute on module `homeassistant.components.recorder` +homeassistant/components/energy/websocket_api.py:276:9: warning[possibly-missing-attribute] Submodule `statistics` may not be available as an attribute on module `homeassistant.components.recorder` +homeassistant/components/energy/websocket_api.py:361:43: warning[possibly-missing-attribute] Submodule `statistics` may not be available as an attribute on module `homeassistant.components.recorder` +homeassistant/components/energy/websocket_api.py:372:13: warning[possibly-missing-attribute] Submodule `statistics` may not be available as an attribute on module `homeassistant.components.recorder` homeassistant/components/enphase_envoy/entity.py:65:31: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, Any]` has no attribute `__name__` homeassistant/components/entur_public_transport/sensor.py:8:6: error[unresolved-import] Cannot resolve imported module `enturclient` homeassistant/components/entur_public_transport/sensor.py:87:16: error[invalid-return-type] Return type does not match returned value: expected `int`, found `None` @@ -766,25 +748,13 @@ homeassistant/components/entur_public_transport/sensor.py:215:52: warning[possib homeassistant/components/entur_public_transport/sensor.py:216:47: warning[possibly-missing-attribute] Attribute `latitude` may be missing on object of type `(Unknown & ~None) | dict[Unknown, Unknown]` homeassistant/components/entur_public_transport/sensor.py:217:48: warning[possibly-missing-attribute] Attribute `longitude` may be missing on object of type `(Unknown & ~None) | dict[Unknown, Unknown]` homeassistant/components/entur_public_transport/sensor.py:219:26: warning[possibly-missing-attribute] Attribute `estimated_calls` may be missing on object of type `(Unknown & ~None) | dict[Unknown, Unknown]` -homeassistant/components/environment_canada/coordinator.py:67:19: error[invalid-argument-type] Argument to bound method `update` is incorrect: Expected `ECAirQuality`, found `DataT@ECDataUpdateCoordinator` -homeassistant/components/environment_canada/coordinator.py:67:19: error[invalid-argument-type] Argument to bound method `update` is incorrect: Expected `ECRadar`, found `DataT@ECDataUpdateCoordinator` -homeassistant/components/environment_canada/coordinator.py:67:19: error[invalid-argument-type] Argument to bound method `update` is incorrect: Expected `ECWeather`, found `DataT@ECDataUpdateCoordinator` -homeassistant/components/environment_canada/sensor.py:292:34: warning[possibly-missing-attribute] Attribute `attribution` may be missing on object of type `Unknown | MetaData | dict[Unknown | str, Unknown | str] | MetaData` -homeassistant/components/environment_canada/sensor.py:316:28: warning[possibly-missing-attribute] Attribute `location` may be missing on object of type `Unknown | MetaData | dict[Unknown | str, Unknown | str] | MetaData` -homeassistant/components/environment_canada/sensor.py:317:27: warning[possibly-missing-attribute] Attribute `station` may be missing on object of type `Unknown | MetaData | dict[Unknown | str, Unknown | str] | MetaData` homeassistant/components/environment_canada/weather.py:250:13: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[Forecast]`, found `GeneratorType[dict[Unknown | str, Unknown | int], None, None]` homeassistant/components/envisalink/__init__.py:6:6: error[unresolved-import] Cannot resolve imported module `pyenvisalink` homeassistant/components/ephember/climate.py:10:6: error[unresolved-import] Cannot resolve imported module `pyephember2.pyephember2` homeassistant/components/ephember/climate.py:196:16: error[no-matching-overload] No overload of function `getattr` matches arguments homeassistant/components/esphome/encryption_key_storage.py:49:13: error[invalid-assignment] Object of type `(Unknown & ~AlwaysFalsy) | (EncryptionKeyData & ~AlwaysFalsy) | dict[Unknown | str, Unknown | dict[Unknown, Unknown]]` is not assignable to attribute `_data` of type `EncryptionKeyData | None` -homeassistant/components/esphome/entity.py:181:28: error[invalid-argument-type] Argument to bound method `__call__` is incorrect: Expected `Iterable[Entity]`, found `list[typing.TypeVar] & ~AlwaysFalsy` homeassistant/components/esphome/entry_data.py:195:16: error[invalid-return-type] Return type does not match returned value: expected `str`, found `(DeviceInfo & ~AlwaysTruthy & ~AlwaysFalsy) | str` homeassistant/components/esphome/entry_data.py:201:16: error[invalid-return-type] Return type does not match returned value: expected `str`, found `(DeviceInfo & ~AlwaysTruthy & ~AlwaysFalsy) | str` -homeassistant/components/esphome/ffmpeg_proxy.py:66:11: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/esphome/ffmpeg_proxy.py:195:20: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/esphome/ffmpeg_proxy.py:196:20: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/esphome/ffmpeg_proxy.py:213:15: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/esphome/ffmpeg_proxy.py:258:15: error[unresolved-attribute] Module `asyncio` has no member `subprocess` homeassistant/components/esphome/light.py:337:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[int, int, int, int]`, found `tuple[@Todo, Unknown]` homeassistant/components/esphome/light.py:358:20: error[invalid-return-type] Return type does not match returned value: expected `tuple[int, int, int, int, int]`, found `tuple[@Todo, Unknown, Unknown]` homeassistant/components/esphome/light.py:363:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[int, int, int, int, int]`, found `tuple[@Todo, Unknown, Unknown]` @@ -804,9 +774,9 @@ homeassistant/components/ezviz/alarm_control_panel.py:126:17: error[invalid-argu homeassistant/components/familyhub/camera.py:5:6: error[unresolved-import] Cannot resolve imported module `pyfamilyhublocal` homeassistant/components/feedreader/coordinator.py:161:13: error[unresolved-attribute] Unresolved attribute `entries` on type `FeedParserDict`. homeassistant/components/ffmpeg/camera.py:96:17: error[invalid-argument-type] Argument to function `async_aiohttp_proxy_stream` is incorrect: Expected `StreamReader`, found `StreamReader` -homeassistant/components/ffmpeg/const.py:7:23: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/components/ffmpeg/const.py:8:22: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/components/ffmpeg/const.py:9:25: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 +homeassistant/components/ffmpeg/const.py:7:34: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/components/ffmpeg/const.py:8:33: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/components/ffmpeg/const.py:9:36: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 homeassistant/components/fibaro/__init__.py:188:25: error[invalid-argument-type] Invalid argument to key "identifiers" with declared type `set[tuple[str, str]]` on TypedDict `DeviceInfo`: value of type `set[Unknown | tuple[str, int]]` homeassistant/components/fibaro/__init__.py:238:17: error[invalid-assignment] Object of type `Self@_read_devices` is not assignable to attribute `fibaro_controller` on type `Unknown | DeviceModel` homeassistant/components/fibaro/__init__.py:242:17: error[invalid-assignment] Object of type `str & ~AlwaysFalsy` is not assignable to attribute `room_name` on type `Unknown | DeviceModel` @@ -846,7 +816,6 @@ homeassistant/components/fivem/config_flow.py:35:17: error[non-subscriptable] Ca homeassistant/components/fixer/sensor.py:9:6: error[unresolved-import] Cannot resolve imported module `fixerio` homeassistant/components/fixer/sensor.py:10:6: error[unresolved-import] Cannot resolve imported module `fixerio.exceptions` homeassistant/components/fleetgo/device_tracker.py:8:6: error[unresolved-import] Cannot resolve imported module `ritassist` -homeassistant/components/fleetgo/device_tracker.py:100:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/flo/__init__.py:31:23: warning[possibly-missing-attribute] Attribute `get_info` may be missing on object of type `User | None` homeassistant/components/flux/switch.py:261:13: error[call-non-callable] Object of type `None` is not callable homeassistant/components/flux/switch.py:286:25: error[unsupported-operator] Operator `<` is not supported for types `datetime` and `None`, in comparing `datetime` with `datetime | None` @@ -858,6 +827,7 @@ homeassistant/components/flux/switch.py:310:61: warning[possibly-missing-attribu homeassistant/components/flux/switch.py:322:58: error[invalid-argument-type] Argument to function `color_RGB_to_xy_brightness` is incorrect: Expected `int`, found `int | float` homeassistant/components/flux/switch.py:322:58: error[invalid-argument-type] Argument to function `color_RGB_to_xy_brightness` is incorrect: Expected `int`, found `int | float` homeassistant/components/flux/switch.py:322:58: error[invalid-argument-type] Argument to function `color_RGB_to_xy_brightness` is incorrect: Expected `int`, found `int | float` +homeassistant/components/flux_led/config_flow.py:179:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/flux_led/util.py:98:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[int, int, int, int]`, found `tuple[@Todo, int]` homeassistant/components/flux_led/util.py:99:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[int, int, int, int]`, found `tuple[@Todo, int]` homeassistant/components/flux_led/util.py:114:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[int, int, int, int, int]`, found `tuple[@Todo, int, int]` @@ -906,8 +876,10 @@ homeassistant/components/forked_daapd/media_player.py:747:13: error[non-subscrip homeassistant/components/forked_daapd/media_player.py:876:19: warning[possibly-missing-attribute] Attribute `get` may be missing on object of type `Unknown | None` homeassistant/components/fortios/device_tracker.py:12:6: error[unresolved-import] Cannot resolve imported module `fortiosapi` homeassistant/components/free_mobile/notify.py:8:6: error[unresolved-import] Cannot resolve imported module `freesms` +homeassistant/components/fritz/config_flow.py:199:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/fritz/image.py:71:13: warning[possibly-missing-attribute] Attribute `get_wifi_qr_code` may be missing on object of type `Unknown | FritzGuestWLAN` -homeassistant/components/fritzbox/diagnostics.py:27:33: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | FritzhomeDevice | FritzhomeTemplate]` is not assignable to `dict[str, dict[Unknown, Unknown]]` +homeassistant/components/fritzbox/config_flow.py:149:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` +homeassistant/components/fritzbox/diagnostics.py:27:33: error[invalid-assignment] Object of type `dict[str, dict[Unknown, Unknown] | FritzhomeDevice | FritzhomeTemplate]` is not assignable to `dict[str, dict[Unknown, Unknown]]` homeassistant/components/fritzbox/entity.py:51:16: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `bool | Unknown | None` homeassistant/components/fritzbox/light.py:104:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[int | float, int | float]`, found `tuple[Unknown | None | int, int | float]` homeassistant/components/fritzbox/light.py:104:28: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | Buffer | SupportsFloat | SupportsIndex`, found `Unknown | None | int` @@ -924,8 +896,6 @@ homeassistant/components/fujitsu_fglair/coordinator.py:68:71: warning[possibly-m homeassistant/components/fujitsu_fglair/coordinator.py:77:16: error[invalid-return-type] Return type does not match returned value: expected `dict[str, FujitsuHVAC]`, found `dict[str | None | Unknown, Device | Unknown]` homeassistant/components/fujitsu_fglair/entity.py:22:25: error[invalid-argument-type] Invalid argument to key "identifiers" with declared type `set[tuple[str, str]]` on TypedDict `DeviceInfo`: value of type `set[Unknown | tuple[str, str | None]]` homeassistant/components/futurenow/light.py:7:8: error[unresolved-import] Cannot resolve imported module `pyfnip` -homeassistant/components/garadget/cover.py:122:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/garadget/cover.py:238:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/gardena_bluetooth/config_flow.py:73:51: error[invalid-argument-type] Argument to function `get_connection` is incorrect: Expected `str`, found `str | None` homeassistant/components/gardena_bluetooth/switch.py:72:38: error[invalid-argument-type] Argument to bound method `write` is incorrect: Expected `Characteristic[Literal[0]]`, found `Unknown | CharacteristicLong` homeassistant/components/gardena_bluetooth/valve.py:72:38: error[invalid-argument-type] Argument to bound method `write` is incorrect: Expected `Characteristic[(Unknown & ~AlwaysFalsy) | Literal[3600]]`, found `Unknown | CharacteristicLong` @@ -947,14 +917,14 @@ homeassistant/components/geonetnz_quakes/__init__.py:139:13: error[invalid-argum homeassistant/components/geonetnz_quakes/geo_location.py:146:31: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/geonetnz_quakes/geo_location.py:147:32: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/github/__init__.py:26:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[GitHubClientKwarg, Any]`, found `Literal["HomeAssistant/2025.12.0.dev0 aiohttp/3.13.2 Python/3.13"]` -homeassistant/components/github/config_flow.py:41:46: error[invalid-argument-type] Argument to bound method `starred` is incorrect: Expected `dict[GitHubRequestKwarg, Any]`, found `dict[Unknown | str, Unknown | int]` -homeassistant/components/github/config_flow.py:46:25: error[invalid-argument-type] Argument to bound method `starred` is incorrect: Expected `dict[GitHubRequestKwarg, Any]`, found `dict[Unknown | str, Unknown | int]` +homeassistant/components/github/config_flow.py:41:46: error[invalid-argument-type] Argument to bound method `starred` is incorrect: Expected `dict[GitHubRequestKwarg, Any]`, found `dict[str, Any]` +homeassistant/components/github/config_flow.py:46:25: error[invalid-argument-type] Argument to bound method `starred` is incorrect: Expected `dict[GitHubRequestKwarg, Any]`, found `dict[str, Any]` homeassistant/components/github/config_flow.py:49:25: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `SupportsIndex`, found `int | None` homeassistant/components/github/config_flow.py:49:52: error[unsupported-operator] Operator `+` is unsupported between objects of type `int | None` and `Literal[1]` homeassistant/components/github/config_flow.py:54:17: warning[possibly-missing-attribute] Attribute `extend` may be missing on object of type `list[GitHubRepositoryModel] | None` homeassistant/components/github/config_flow.py:56:29: error[invalid-argument-type] Argument to bound method `update` is incorrect: Expected `Iterable[Unknown]`, found `list[GitHubRepositoryModel] | None` -homeassistant/components/github/config_flow.py:59:44: error[invalid-argument-type] Argument to bound method `repos` is incorrect: Expected `dict[GitHubRequestKwarg, Any]`, found `dict[Unknown | str, Unknown | int]` -homeassistant/components/github/config_flow.py:64:25: error[invalid-argument-type] Argument to bound method `repos` is incorrect: Expected `dict[GitHubRequestKwarg, Any]`, found `dict[Unknown | str, Unknown | int]` +homeassistant/components/github/config_flow.py:59:44: error[invalid-argument-type] Argument to bound method `repos` is incorrect: Expected `dict[GitHubRequestKwarg, Any]`, found `dict[str, Any]` +homeassistant/components/github/config_flow.py:64:25: error[invalid-argument-type] Argument to bound method `repos` is incorrect: Expected `dict[GitHubRequestKwarg, Any]`, found `dict[str, Any]` homeassistant/components/github/config_flow.py:67:25: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `SupportsIndex`, found `int | None` homeassistant/components/github/config_flow.py:67:52: error[unsupported-operator] Operator `+` is unsupported between objects of type `int | None` and `Literal[1]` homeassistant/components/github/config_flow.py:72:17: warning[possibly-missing-attribute] Attribute `extend` may be missing on object of type `list[GitHubRepositoryModel] | None` @@ -963,6 +933,7 @@ homeassistant/components/github/config_flow.py:132:17: error[invalid-argument-ty homeassistant/components/github/config_flow.py:140:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[GitHubClientKwarg, Any]`, found `Literal["HomeAssistant/2025.12.0.dev0 aiohttp/3.13.2 Python/3.13"]` homeassistant/components/github/config_flow.py:165:13: error[invalid-argument-type] Argument to bound method `async_show_progress` is incorrect: Expected `Mapping[str, str] | None`, found `dict[Unknown | str, Unknown | str | None]` homeassistant/components/github/config_flow.py:183:62: error[invalid-argument-type] Argument to function `get_repositories` is incorrect: Expected `str`, found `str | None` +homeassistant/components/github/coordinator.py:132:15: error[invalid-method-override] Invalid override of method `_async_update_data`: Definition is incompatible with `DataUpdateCoordinator._async_update_data` homeassistant/components/github/coordinator.py:149:16: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/github/coordinator.py:166:13: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(() -> Awaitable[None]) | None`, found `def _handle_error(error: GitHubException) -> CoroutineType[Any, Any, None]` homeassistant/components/github/diagnostics.py:28:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[GitHubClientKwarg, Any]`, found `Literal["HomeAssistant/2025.12.0.dev0 aiohttp/3.13.2 Python/3.13"]` @@ -970,10 +941,7 @@ homeassistant/components/github/diagnostics.py:36:30: warning[possibly-missing-a homeassistant/components/gitlab_ci/sensor.py:8:6: error[unresolved-import] Cannot resolve imported module `gitlab` homeassistant/components/gitter/sensor.py:7:6: error[unresolved-import] Cannot resolve imported module `gitterpy.client` homeassistant/components/gitter/sensor.py:8:6: error[unresolved-import] Cannot resolve imported module `gitterpy.errors` -homeassistant/components/go2rtc/server.py:87:24: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/go2rtc/server.py:116:20: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/go2rtc/server.py:117:20: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/go2rtc/server.py:139:42: error[unresolved-attribute] Module `asyncio` has no member `subprocess` +homeassistant/components/gogogate2/config_flow.py:76:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/gogogate2/entity.py:45:16: error[invalid-return-type] Return type does not match returned value: expected `AbstractDoor`, found `Unknown | DoorStatus | TransitionDoorStatus` homeassistant/components/goodwe/__init__.py:38:21: error[invalid-argument-type] Invalid argument to key "identifiers" with declared type `set[tuple[str, str]]` on TypedDict `DeviceInfo`: value of type `set[Unknown | tuple[str, str | None]]` homeassistant/components/goodwe/sensor.py:215:38: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `SensorKind`, found `SensorKind | None` @@ -1013,8 +981,30 @@ homeassistant/components/google_assistant/report_state.py:178:17: error[invalid- homeassistant/components/google_assistant/report_state.py:190:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventStateChangedData]` homeassistant/components/google_assistant/report_state.py:191:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _async_entity_state_listener(event: Event[EventStateChangedData]) -> CoroutineType[Any, Any, None]` homeassistant/components/google_assistant/report_state.py:192:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def _async_entity_state_filter(data: EventStateChangedData) -> bool` +homeassistant/components/google_assistant/trait.py:381:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:420:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:478:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:668:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:717:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:766:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:806:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:861:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:1027:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:1177:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:1447:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:1534:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:1600:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:1738:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` homeassistant/components/google_assistant/trait.py:1832:21: error[invalid-argument-type] Argument to function `ordered_list_item_to_percentage` is incorrect: Expected `list[Unknown & ~AlwaysFalsy]`, found `Unknown | list[str | Unknown]` +homeassistant/components/google_assistant/trait.py:1889:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` homeassistant/components/google_assistant/trait.py:1928:13: warning[possibly-missing-attribute] Attribute `append` may be missing on object of type `Unknown | list[Unknown | dict[Unknown | str, Unknown | list[Unknown | str] | str]] | list[Unknown] | bool` +homeassistant/components/google_assistant/trait.py:2120:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:2192:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:2345:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:2526:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:2645:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:2672:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` +homeassistant/components/google_assistant/trait.py:2771:9: error[invalid-method-override] Invalid override of method `supported`: Definition is incompatible with `_Trait.supported` homeassistant/components/google_generative_ai_conversation/ai_task.py:93:16: warning[possibly-missing-attribute] Attribute `content` may be missing on object of type `SystemContent | UserContent | AssistantContent | ToolResultContent` homeassistant/components/google_generative_ai_conversation/config_flow.py:132:21: error[invalid-argument-type] Argument to bound method `async_create_entry` is incorrect: Expected `Iterable[ConfigSubentryData] | None`, found `list[Unknown | dict[Unknown | str, Unknown | str | dict[Unknown | str, Unknown | str | list[Unknown | str] | bool] | None] | dict[Unknown | str, Unknown | str | dict[Unknown | str, Unknown | bool] | None] | dict[Unknown | str, Unknown | str | dict[Unknown | str, Unknown | str | bool] | None]]` homeassistant/components/google_generative_ai_conversation/entity.py:518:37: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `ToolResultContent`, found `SystemContent | UserContent | AssistantContent | ToolResultContent` @@ -1040,7 +1030,6 @@ homeassistant/components/google_tasks/api.py:156:67: warning[possibly-missing-at homeassistant/components/google_weather/config_flow.py:134:21: error[invalid-argument-type] Argument to bound method `async_create_entry` is incorrect: Expected `Iterable[ConfigSubentryData] | None`, found `list[Unknown | dict[Unknown | str, Unknown | str | None]]` homeassistant/components/google_weather/weather.py:248:16: error[invalid-return-type] Return type does not match returned value: expected `list[Forecast] | None`, found `list[dict[Unknown | str, Unknown | str | None | int | float] | Unknown]` homeassistant/components/google_weather/weather.py:290:16: error[invalid-return-type] Return type does not match returned value: expected `list[Forecast] | None`, found `list[dict[Unknown | str, Unknown | str | None | int | float] | Unknown]` -homeassistant/components/google_wifi/sensor.py:187:29: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/google_wifi/sensor.py:199:20: error[unsupported-operator] Operator `in` is not supported for types `str` and `None`, in comparing `str` with `Unknown | None` homeassistant/components/google_wifi/sensor.py:200:36: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/google_wifi/sensor.py:217:59: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method @@ -1062,22 +1051,18 @@ homeassistant/components/gree/climate.py:189:9: error[invalid-assignment] Object homeassistant/components/gree/climate.py:261:9: error[invalid-assignment] Object of type `Unknown | FanSpeed | None` is not assignable to attribute `fan_speed` on type `Unknown | Device` homeassistant/components/greenwave/light.py:10:8: error[unresolved-import] Cannot resolve imported module `greenwavereality` homeassistant/components/group/sensor.py:705:20: error[invalid-return-type] Return type does not match returned value: expected `set[str | None]`, found `set[type[StrEnum] | str | None]` -homeassistant/components/growatt_server/config_flow.py:79:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/growatt_server/config_flow.py:114:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/growatt_server/config_flow.py:200:20: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/growatt_server/config_flow.py:228:40: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/growatt_server/config_flow.py:230:9: error[no-matching-overload] No overload of bound method `update` matches arguments homeassistant/components/growatt_server/coordinator.py:94:30: warning[possibly-missing-attribute] Attribute `plant_energy_overview` may be missing on object of type `Unknown | GrowattApi` homeassistant/components/growatt_server/coordinator.py:112:31: warning[possibly-missing-attribute] Attribute `min_detail` may be missing on object of type `Unknown | GrowattApi` homeassistant/components/growatt_server/coordinator.py:113:32: warning[possibly-missing-attribute] Attribute `min_settings` may be missing on object of type `Unknown | GrowattApi` homeassistant/components/growatt_server/coordinator.py:114:30: warning[possibly-missing-attribute] Attribute `min_energy` may be missing on object of type `Unknown | GrowattApi` -homeassistant/components/growatt_server/coordinator.py:182:16: error[unresolved-attribute] Module `json` has no member `decoder` homeassistant/components/growatt_server/number.py:144:17: warning[possibly-missing-attribute] Attribute `min_write_parameter` may be missing on object of type `Unknown | GrowattApi` homeassistant/components/growatt_server/switch.py:121:17: warning[possibly-missing-attribute] Attribute `min_write_parameter` may be missing on object of type `Unknown | GrowattApi` homeassistant/components/gtfs/sensor.py:11:8: error[unresolved-import] Cannot resolve imported module `pygtfs` homeassistant/components/guardian/services.py:93:42: error[unresolved-attribute] Object of type `(ServiceCall, GuardianData, /) -> Coroutine[Any, Any, None]` has no attribute `__name__` homeassistant/components/guardian/util.py:77:40: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, Any]` has no attribute `__name__` -homeassistant/components/hardware/models.py:26:16: error[invalid-type-form] Variable of type `` is not allowed in a type expression +homeassistant/components/hardware/models.py:26:16: error[invalid-type-form] Module `psutil_home_assistant` is not valid in a type expression homeassistant/components/harman_kardon_avr/media_player.py:5:8: error[unresolved-import] Cannot resolve imported module `hkavr` homeassistant/components/harmony/config_flow.py:116:34: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `str | None | bytes` homeassistant/components/harmony/data.py:113:68: error[invalid-argument-type] Argument is incorrect: Expected `Future[Unknown] | Event | ((object, Any | None, /) -> Any) | None`, found `Unknown | (bound method Self@connect._config_updated(_: dict[Unknown, Unknown] | None = None) -> None) | (bound method Self@connect._connected(_: str | None = None) -> None) | ... omitted 3 union elements` @@ -1086,26 +1071,25 @@ homeassistant/components/harmony/data.py:113:68: error[invalid-argument-type] Ar homeassistant/components/harmony/data.py:113:68: error[invalid-argument-type] Argument is incorrect: Expected `Future[Unknown] | Event | ((object, Any | None, /) -> Any) | None`, found `Unknown | (bound method Self@connect._config_updated(_: dict[Unknown, Unknown] | None = None) -> None) | (bound method Self@connect._connected(_: str | None = None) -> None) | ... omitted 3 union elements` homeassistant/components/harmony/data.py:113:68: error[invalid-argument-type] Argument is incorrect: Expected `Future[Unknown] | Event | ((object, Any | None, /) -> Any) | None`, found `Unknown | (bound method Self@connect._config_updated(_: dict[Unknown, Unknown] | None = None) -> None) | (bound method Self@connect._connected(_: str | None = None) -> None) | ... omitted 3 union elements` homeassistant/components/harmony/data.py:234:21: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `str` -homeassistant/components/harmony/subscriber.py:13:24: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 homeassistant/components/harmony/subscriber.py:13:32: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `tuple[()]`? -homeassistant/components/harmony/subscriber.py:14:25: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/components/harmony/subscriber.py:13:36: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/components/harmony/subscriber.py:14:33: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[tuple[Unknown, ...]]`? -homeassistant/components/hassio/addon_manager.py:38:6: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/hassio/addon_manager.py:38:42: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/hassio/addon_manager.py:44:15: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/hassio/addon_manager.py:45:10: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 +homeassistant/components/harmony/subscriber.py:14:42: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/components/hassio/addon_manager.py:38:36: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/hassio/addon_manager.py:38:78: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/hassio/addon_manager.py:44:45: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/hassio/addon_manager.py:45:46: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 homeassistant/components/hassio/repairs.py:226:18: warning[possibly-missing-attribute] Attribute `key` may be missing on object of type `(SupervisorIssues & ~AlwaysTruthy & ~AlwaysFalsy) | (Issue & ~AlwaysFalsy)` homeassistant/components/hassio/repairs.py:228:18: warning[possibly-missing-attribute] Attribute `key` may be missing on object of type `(SupervisorIssues & ~AlwaysTruthy & ~AlwaysFalsy) | (Issue & ~AlwaysFalsy)` homeassistant/components/hassio/repairs.py:230:18: warning[possibly-missing-attribute] Attribute `key` may be missing on object of type `(SupervisorIssues & ~AlwaysTruthy & ~AlwaysFalsy) | (Issue & ~AlwaysFalsy)` homeassistant/components/haveibeenpwned/sensor.py:94:17: error[invalid-argument-type] Argument to function `as_local` is incorrect: Expected `datetime`, found `datetime | None` -homeassistant/components/haveibeenpwned/sensor.py:165:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/hddtemp/sensor.py:68:23: error[no-matching-overload] No overload of function `iter` matches arguments homeassistant/components/hdmi_cec/__init__.py:258:49: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `list[int]`, found `Unknown | Literal[""]` homeassistant/components/heatmiser/climate.py:8:6: error[unresolved-import] Cannot resolve imported module `heatmiserv3` -homeassistant/components/heos/media_player.py:144:16: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/heos/media_player.py:144:36: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/heos/media_player.py:147:25: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/heos/media_player.py:147:47: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 +homeassistant/components/heos/media_player.py:144:30: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/heos/media_player.py:144:56: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/heos/media_player.py:147:39: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/heos/media_player.py:147:67: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 homeassistant/components/here_travel_time/coordinator.py:226:21: error[invalid-argument-type] Argument is incorrect: Expected `int | float`, found `str` homeassistant/components/here_travel_time/coordinator.py:226:48: error[invalid-argument-type] Argument is incorrect: Expected `int | float`, found `str` homeassistant/components/here_travel_time/coordinator.py:229:21: error[invalid-argument-type] Argument is incorrect: Expected `int | float`, found `str` @@ -1113,9 +1097,7 @@ homeassistant/components/here_travel_time/coordinator.py:229:53: error[invalid-a homeassistant/components/hikvision/binary_sensor.py:8:6: error[unresolved-import] Cannot resolve imported module `pyhik.hikvision` homeassistant/components/hikvisioncam/switch.py:8:8: error[unresolved-import] Cannot resolve imported module `hikvision.api` homeassistant/components/hikvisioncam/switch.py:9:6: error[unresolved-import] Cannot resolve imported module `hikvision.error` -homeassistant/components/hitron_coda/device_tracker.py:89:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/hitron_coda/device_tracker.py:113:55: error[invalid-argument-type] Argument to function `get` is incorrect: Expected `CookieJar | MutableMapping[str, str] | None`, found `dict[Unknown | str, Unknown | None | str]` -homeassistant/components/hitron_coda/device_tracker.py:114:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/hive/binary_sensor.py:83:20: error[not-iterable] Object of type `Unknown | None` may not be iterable homeassistant/components/hive/binary_sensor.py:91:20: error[not-iterable] Object of type `Unknown | None` may not be iterable homeassistant/components/hive/climate.py:127:61: error[invalid-argument-type] Argument to bound method `setBoostOn` is incorrect: Expected `str`, found `Literal[30]` @@ -1124,14 +1106,14 @@ homeassistant/components/hive/light.py:83:26: error[invalid-argument-type] Argum homeassistant/components/hive/light.py:83:42: error[invalid-argument-type] Argument to bound method `turnOn` is incorrect: Expected `int`, found `None | Any` homeassistant/components/hive/light.py:83:58: error[invalid-argument-type] Argument to bound method `turnOn` is incorrect: Expected `list[Unknown]`, found `None | tuple[int, int, Literal[100]]` homeassistant/components/hlk_sw16/config_flow.py:56:17: warning[possibly-missing-attribute] Attribute `set_exception` may be missing on object of type `Unknown | None` -homeassistant/components/home_connect/switch.py:286:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[Unknown | str, Unknown | str | UndefinedType]` +homeassistant/components/home_connect/switch.py:286:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[str, str | UndefinedType] & dict[Unknown | str, Unknown | str | UndefinedType]` homeassistant/components/homeassistant_alerts/__init__.py:103:55: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _component_loaded(_: Event[EventComponentLoaded]) -> None` homeassistant/components/homeassistant_hardware/firmware_config_flow.py:271:41: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `str | None` homeassistant/components/homeassistant_hardware/firmware_config_flow.py:273:16: error[unsupported-operator] Operator `>=` is not supported for types `Version` and `Version`, in comparing `Version` with `Version | None` homeassistant/components/homeassistant_hardware/helpers.py:184:35: error[call-non-callable] Object of type `object` is not callable homeassistant/components/homekit/__init__.py:913:56: error[invalid-argument-type] Argument to function `accessory_friendly_name` is incorrect: Expected `Accessory`, found `Accessory | None` homeassistant/components/homekit/__init__.py:915:13: warning[possibly-missing-attribute] Attribute `xhm_uri` may be missing on object of type `Accessory | None` -homeassistant/components/homekit/__init__.py:959:13: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `set[tuple[str, str]] | None | UndefinedType`, found `set[Unknown | tuple[str, Unknown | str, str]]` +homeassistant/components/homekit/__init__.py:959:13: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `set[tuple[str, str]] | None | UndefinedType`, found `set[tuple[str, str] | tuple[str, Unknown | str, str]]` homeassistant/components/homekit/__init__.py:964:61: error[invalid-argument-type] Argument to function `accessory_friendly_name` is incorrect: Expected `Accessory`, found `Accessory | None` homeassistant/components/homekit/__init__.py:1025:16: error[invalid-return-type] Return type does not match returned value: expected `HomeAccessory`, found `HomeBridge` homeassistant/components/homekit/accessories.py:331:13: error[parameter-already-assigned] Multiple values provided for parameter 2 (`driver`) of bound method `__init__` @@ -1147,7 +1129,7 @@ homeassistant/components/homekit/accessories.py:765:15: warning[possibly-missing homeassistant/components/homekit/accessories.py:767:32: error[invalid-assignment] Object of type `Service | None` is not assignable to `Service` homeassistant/components/homekit/accessories.py:769:17: error[invalid-argument-type] Argument to bound method `get_or_allocate_iid` is incorrect: Expected `int`, found `int | None` homeassistant/components/homekit/accessories.py:773:17: error[invalid-argument-type] Argument to bound method `get_or_allocate_iid` is incorrect: Expected `int`, found `int | None` -homeassistant/components/homekit/const.py:17:25: error[too-many-positional-arguments] Too many positional arguments to class `SignalTypeFormat`: expected 0, got 1 +homeassistant/components/homekit/const.py:17:42: error[invalid-type-arguments] Too many type arguments to class `SignalTypeFormat`: expected 0, got 1 homeassistant/components/homekit/diagnostics.py:42:66: error[invalid-argument-type] Argument to function `_get_accessory_diagnostics` is incorrect: Expected `HomeAccessory`, found `Accessory & ~AlwaysFalsy & ~HomeBridge` homeassistant/components/homekit/doorbell.py:55:50: error[invalid-argument-type] Argument to bound method `add_preload_service` is incorrect: Expected `Service`, found `Literal["Doorbell"]` homeassistant/components/homekit/doorbell.py:62:13: error[invalid-argument-type] Argument to bound method `add_preload_service` is incorrect: Expected `Service`, found `Literal["StatelessProgrammableSwitch"]` @@ -1228,6 +1210,7 @@ homeassistant/components/homekit/type_triggers.py:69:17: error[invalid-argument- homeassistant/components/homekit/type_triggers.py:70:17: error[invalid-argument-type] Argument to bound method `add_preload_service` is incorrect: Expected `Iterable[Characteristic] | None`, found `list[Unknown | str]` homeassistant/components/homekit/type_triggers.py:88:17: error[invalid-argument-type] Argument to bound method `add_preload_service` is incorrect: Expected `Service`, found `Literal["ServiceLabel"]` homeassistant/components/homekit/type_triggers.py:107:13: error[invalid-argument-type] Argument to function `async_initialize_triggers` is incorrect: Expected `str`, found `str | None` +homeassistant/components/homekit_controller/config_flow.py:338:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/homekit_controller/config_flow.py:383:31: warning[possibly-missing-attribute] Attribute `async_find` may be missing on object of type `Controller | None` homeassistant/components/homekit_controller/switch.py:201:36: error[unresolved-attribute] Object of type `SwitchEntityDescription` has no attribute `true_value` homeassistant/components/homekit_controller/switch.py:206:31: error[unresolved-attribute] Object of type `SwitchEntityDescription` has no attribute `true_value` @@ -1305,7 +1288,7 @@ homeassistant/components/homematic/switch.py:70:21: error[unresolved-attribute] homeassistant/components/homematicip_cloud/__init__.py:99:15: error[unresolved-attribute] Object of type `AsyncHome` has no attribute `label` homeassistant/components/homematicip_cloud/__init__.py:99:29: error[unresolved-attribute] Object of type `AsyncHome` has no attribute `label` homeassistant/components/homematicip_cloud/__init__.py:99:72: error[unresolved-attribute] Object of type `AsyncHome` has no attribute `label` -homeassistant/components/homematicip_cloud/__init__.py:103:9: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `set[tuple[str, str]] | None | UndefinedType`, found `set[Unknown | tuple[str, Unknown | None]]` +homeassistant/components/homematicip_cloud/__init__.py:103:9: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `set[tuple[str, str]] | None | UndefinedType`, found `set[tuple[str, str] | tuple[str, Unknown | None]]` homeassistant/components/homematicip_cloud/__init__.py:128:8: error[unsupported-operator] Operator `<` is not supported for types `None` and `str`, in comparing `Unknown | None` with `Literal["2.2.12"]` homeassistant/components/homematicip_cloud/alarm_control_panel.py:58:24: error[invalid-argument-type] Invalid argument to key "via_device" with declared type `tuple[str, str]` on TypedDict `DeviceInfo`: value of type `tuple[Literal["homematicip_cloud"], Unknown | None]` homeassistant/components/homematicip_cloud/alarm_control_panel.py:80:16: error[invalid-return-type] Return type does not match returned value: expected `SecurityAndAlarmHome`, found `FunctionalHome | None` @@ -1327,7 +1310,7 @@ homeassistant/components/homematicip_cloud/cover.py:298:15: warning[possibly-mis homeassistant/components/homematicip_cloud/entity.py:205:21: error[unresolved-attribute] Object of type `AsyncHome` has no attribute `name` homeassistant/components/homematicip_cloud/entity.py:206:23: error[unresolved-attribute] Object of type `AsyncHome` has no attribute `name` homeassistant/components/homematicip_cloud/entity.py:265:16: error[invalid-return-type] Return type does not match returned value: expected `FunctionalChannel`, found `None` -homeassistant/components/homematicip_cloud/hap.py:35:15: error[unresolved-attribute] Module `homeassistant` has no member `util` +homeassistant/components/homematicip_cloud/hap.py:35:15: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `homeassistant` homeassistant/components/homematicip_cloud/hap.py:39:9: error[invalid-argument-type] Argument to bound method `build_context_async` is incorrect: Expected `str`, found `str | None` homeassistant/components/homematicip_cloud/hap.py:291:9: error[unresolved-attribute] Unresolved attribute `name` on type `AsyncHome`. homeassistant/components/homematicip_cloud/hap.py:293:9: error[unresolved-attribute] Unresolved attribute `label` on type `AsyncHome`. @@ -1358,27 +1341,27 @@ homeassistant/components/homematicip_cloud/valve.py:59:16: warning[possibly-miss homeassistant/components/homematicip_cloud/weather.py:127:9: error[unresolved-attribute] Unresolved attribute `modelType` on type `AsyncHome`. homeassistant/components/homematicip_cloud/weather.py:133:16: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `Unknown | None` homeassistant/components/homematicip_cloud/weather.py:138:27: warning[possibly-missing-attribute] Attribute `city` may be missing on object of type `Unknown | None | Location` -homeassistant/components/honeywell/__init__.py:61:12: error[unresolved-attribute] Module `aiosomecomfort` has no member `device` -homeassistant/components/honeywell/__init__.py:65:9: error[unresolved-attribute] Module `aiosomecomfort` has no member `device` -homeassistant/components/honeywell/__init__.py:66:9: error[unresolved-attribute] Module `aiosomecomfort` has no member `device` -homeassistant/components/honeywell/__init__.py:67:9: error[unresolved-attribute] Module `aiosomecomfort` has no member `device` -homeassistant/components/honeywell/__init__.py:102:24: error[unresolved-attribute] Module `aiosomecomfort` has no member `device` +homeassistant/components/honeywell/__init__.py:61:12: warning[possibly-missing-attribute] Submodule `device` may not be available as an attribute on module `aiosomecomfort` +homeassistant/components/honeywell/__init__.py:65:9: warning[possibly-missing-attribute] Submodule `device` may not be available as an attribute on module `aiosomecomfort` +homeassistant/components/honeywell/__init__.py:66:9: warning[possibly-missing-attribute] Submodule `device` may not be available as an attribute on module `aiosomecomfort` +homeassistant/components/honeywell/__init__.py:67:9: warning[possibly-missing-attribute] Submodule `device` may not be available as an attribute on module `aiosomecomfort` +homeassistant/components/honeywell/__init__.py:102:24: warning[possibly-missing-attribute] Submodule `device` may not be available as an attribute on module `aiosomecomfort` homeassistant/components/honeywell/climate.py:286:16: error[invalid-return-type] Return type does not match returned value: expected `int | None`, found `Unknown | int | float | None` homeassistant/components/horizon/media_player.py:9:6: error[unresolved-import] Cannot resolve imported module `horimote` homeassistant/components/horizon/media_player.py:10:6: error[unresolved-import] Cannot resolve imported module `horimote.exceptions` homeassistant/components/hp_ilo/sensor.py:8:8: error[unresolved-import] Cannot resolve imported module `hpilo` homeassistant/components/html5/notify.py:481:13: warning[possibly-missing-attribute] Attribute `get` may be missing on object of type `Unknown | str | dict[Unknown, Unknown]` homeassistant/components/html5/notify.py:484:13: error[invalid-assignment] Cannot assign to a subscript on an object of type `str` -homeassistant/components/http/decorators.py:33:6: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/http/decorators.py:34:5: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/http/decorators.py:44:12: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/http/decorators.py:45:6: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/http/decorators.py:53:12: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/http/decorators.py:59:10: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/http/decorators.py:60:9: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/http/decorators.py:62:7: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/http/decorators.py:67:15: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/http/decorators.py:68:10: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 +homeassistant/components/http/decorators.py:33:41: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/http/decorators.py:34:40: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/http/decorators.py:44:47: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/http/decorators.py:45:41: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/http/decorators.py:53:47: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/http/decorators.py:59:45: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/http/decorators.py:60:44: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/http/decorators.py:62:42: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/http/decorators.py:67:50: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/http/decorators.py:68:45: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 homeassistant/components/huawei_lte/sensor.py:903:69: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Unknown | None` homeassistant/components/hue/__init__.py:40:37: warning[possibly-missing-attribute] Attribute `bridge_id` may be missing on object of type `Unknown | Config | None | ConfigController` homeassistant/components/hue/__init__.py:76:54: warning[possibly-missing-attribute] Attribute `mac_address` may be missing on object of type `Unknown | Config | None | ConfigController` @@ -1406,7 +1389,9 @@ homeassistant/components/hue/event.py:71:17: error[invalid-argument-type] Argume homeassistant/components/hue/event.py:92:22: warning[possibly-missing-attribute] Attribute `id` may be missing on object of type `Unknown | Device | None` homeassistant/components/hue/event.py:93:20: warning[possibly-missing-attribute] Attribute `devices` may be missing on object of type `Unknown | HueBridgeV1 | HueBridgeV2` homeassistant/components/hue/event.py:100:9: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | int]` is not assignable to attribute `_attr_translation_placeholders` of type `Mapping[str, str]` +homeassistant/components/hue/event.py:105:9: error[invalid-method-override] Invalid override of method `_handle_event`: Definition is incompatible with `HueBaseEntity._handle_event` homeassistant/components/hue/event.py:115:43: error[invalid-argument-type] Argument to bound method `_handle_event` is incorrect: Expected `HueResource`, found `Button | BellButton` +homeassistant/components/hue/event.py:145:9: error[invalid-method-override] Invalid override of method `_handle_event`: Definition is incompatible with `HueBaseEntity._handle_event` homeassistant/components/hue/event.py:162:43: error[invalid-argument-type] Argument to bound method `_handle_event` is incorrect: Expected `HueResource`, found `RelativeRotary` homeassistant/components/hue/migration.py:89:16: error[invalid-context-manager] Object of type `HueBridgeV2` cannot be used with `async with` because it does not correctly implement `__aexit__` homeassistant/components/hue/migration.py:130:42: error[no-matching-overload] No overload of function `iter` matches arguments @@ -1465,15 +1450,15 @@ homeassistant/components/hue/v1/sensor_base.py:134:24: warning[possibly-missing- homeassistant/components/hue/v1/sensor_base.py:135:29: error[call-non-callable] Object of type `str` is not callable homeassistant/components/hue/v2/binary_sensor.py:75:27: warning[possibly-missing-attribute] Attribute `get_parent` may be missing on object of type `ControllerType` homeassistant/components/hue/v2/binary_sensor.py:92:24: error[invalid-assignment] Object of type `Unknown | HueBridgeV1 | HueBridgeV2` is not assignable to `HueBridgeV2` -homeassistant/components/hue/v2/binary_sensor.py:96:45: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `(...) -> Unknown`, found `SensorType` +homeassistant/components/hue/v2/binary_sensor.py:96:45: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `(...) -> Unknown`, found `CameraMotion | Contact | Motion | ... omitted 4 union elements` homeassistant/components/hue/v2/binary_sensor.py:109:32: error[invalid-argument-type] Argument to function `_resource_valid` is incorrect: Expected `SensorType`, found `type[CameraMotion] | type[Contact] | type[Motion] | ... omitted 4 union elements` -homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: SensorType) -> None` -homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: SensorType) -> None` -homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: SensorType) -> None` -homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: SensorType) -> None` -homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: SensorType) -> None` -homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: SensorType) -> None` -homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: SensorType) -> None` +homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: CameraMotion | Contact | Motion | ... omitted 4 union elements) -> None` +homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: CameraMotion | Contact | Motion | ... omitted 4 union elements) -> None` +homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: CameraMotion | Contact | Motion | ... omitted 4 union elements) -> None` +homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: CameraMotion | Contact | Motion | ... omitted 4 union elements) -> None` +homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: CameraMotion | Contact | Motion | ... omitted 4 union elements) -> None` +homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: CameraMotion | Contact | Motion | ... omitted 4 union elements) -> None` +homeassistant/components/hue/v2/binary_sensor.py:115:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: CameraMotion | Contact | Motion | ... omitted 4 union elements) -> None` homeassistant/components/hue/v2/binary_sensor.py:120:47: error[invalid-argument-type] Argument to function `register_items` is incorrect: Expected `SensorType`, found `` homeassistant/components/hue/v2/binary_sensor.py:121:40: error[invalid-argument-type] Argument to function `register_items` is incorrect: Expected `SensorType`, found `` homeassistant/components/hue/v2/binary_sensor.py:122:60: error[invalid-argument-type] Argument to function `register_items` is incorrect: Expected `SensorType`, found `` @@ -1594,13 +1579,13 @@ homeassistant/components/hue/v2/light.py:318:13: warning[possibly-missing-attrib homeassistant/components/hue/v2/light.py:327:13: warning[possibly-missing-attribute] Attribute `set_flash` may be missing on object of type `Unknown | LightsController | BaseResourcesController[Unknown]` homeassistant/components/hue/v2/sensor.py:71:16: warning[possibly-missing-attribute] Attribute `children` may be missing on object of type `(Room & ~AlwaysFalsy) | (GroupedLight & ~AlwaysFalsy) | (Bridge & ~AlwaysFalsy) | ... omitted 5 union elements` homeassistant/components/hue/v2/sensor.py:84:24: error[invalid-assignment] Object of type `Unknown | HueBridgeV1 | HueBridgeV2` is not assignable to `HueBridgeV2` -homeassistant/components/hue/v2/sensor.py:89:38: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `(...) -> Unknown`, found `SensorType` +homeassistant/components/hue/v2/sensor.py:89:38: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `(...) -> Unknown`, found `DevicePower | LightLevel | Temperature | ZigbeeConnectivity | GroupedLightLevel` homeassistant/components/hue/v2/sensor.py:102:32: error[invalid-argument-type] Argument to function `_resource_valid` is incorrect: Expected `SensorType`, found `type[DevicePower] | type[LightLevel] | type[Temperature] | type[ZigbeeConnectivity] | type[GroupedLightLevel]` -homeassistant/components/hue/v2/sensor.py:108:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: SensorType) -> None` -homeassistant/components/hue/v2/sensor.py:108:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: SensorType) -> None` -homeassistant/components/hue/v2/sensor.py:108:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: SensorType) -> None` -homeassistant/components/hue/v2/sensor.py:108:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: SensorType) -> None` -homeassistant/components/hue/v2/sensor.py:108:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: SensorType) -> None` +homeassistant/components/hue/v2/sensor.py:108:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: DevicePower | LightLevel | Temperature | ZigbeeConnectivity | GroupedLightLevel) -> None` +homeassistant/components/hue/v2/sensor.py:108:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: DevicePower | LightLevel | Temperature | ZigbeeConnectivity | GroupedLightLevel) -> None` +homeassistant/components/hue/v2/sensor.py:108:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: DevicePower | LightLevel | Temperature | ZigbeeConnectivity | GroupedLightLevel) -> None` +homeassistant/components/hue/v2/sensor.py:108:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: DevicePower | LightLevel | Temperature | ZigbeeConnectivity | GroupedLightLevel) -> None` +homeassistant/components/hue/v2/sensor.py:108:17: error[invalid-argument-type] Argument to bound method `subscribe` is incorrect: Expected `(EventType, dict[Unknown, Unknown] | None, /) -> None`, found `def async_add_sensor(event_type: EventType, resource: DevicePower | LightLevel | Temperature | ZigbeeConnectivity | GroupedLightLevel) -> None` homeassistant/components/hue/v2/sensor.py:113:43: error[invalid-argument-type] Argument to function `register_items` is incorrect: Expected `SensorType`, found `` homeassistant/components/hue/v2/sensor.py:114:43: error[invalid-argument-type] Argument to function `register_items` is incorrect: Expected `SensorType`, found `` homeassistant/components/hue/v2/sensor.py:115:44: error[invalid-argument-type] Argument to function `register_items` is incorrect: Expected `SensorType`, found `` @@ -1621,8 +1606,8 @@ homeassistant/components/hue/v2/sensor.py:229:12: warning[possibly-missing-attri homeassistant/components/hue/v2/sensor.py:231:34: warning[possibly-missing-attribute] Attribute `power_state` may be missing on object of type `Unknown | DevicePower | LightLevel | ... omitted 6 union elements` homeassistant/components/hue/v2/sensor.py:256:16: warning[possibly-missing-attribute] Attribute `status` may be missing on object of type `Unknown | DevicePower | LightLevel | ... omitted 6 union elements` homeassistant/components/hue/v2/sensor.py:261:32: warning[possibly-missing-attribute] Attribute `mac_address` may be missing on object of type `Unknown | DevicePower | LightLevel | ... omitted 6 union elements` -homeassistant/components/hunterdouglas_powerview/__init__.py:71:9: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `set[tuple[str, str]] | None | UndefinedType`, found `set[Unknown | tuple[str, Unknown | None]]` -homeassistant/components/hunterdouglas_powerview/__init__.py:72:9: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `set[tuple[str, str]] | None | UndefinedType`, found `set[Unknown | tuple[str, Unknown | None]]` +homeassistant/components/hunterdouglas_powerview/__init__.py:71:9: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `set[tuple[str, str]] | None | UndefinedType`, found `set[tuple[str, str] | tuple[str, Unknown | None]]` +homeassistant/components/hunterdouglas_powerview/__init__.py:72:9: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `set[tuple[str, str]] | None | UndefinedType`, found `set[tuple[str, str] | tuple[str, Unknown | None]]` homeassistant/components/hunterdouglas_powerview/__init__.py:77:20: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Version | None` homeassistant/components/hunterdouglas_powerview/__init__.py:114:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Room]`, found `dict[str, BaseShade | Hub | Automation | Scene | Room]` homeassistant/components/hunterdouglas_powerview/__init__.py:115:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Scene]`, found `dict[str, BaseShade | Hub | Automation | Scene | Room]` @@ -1630,6 +1615,7 @@ homeassistant/components/hunterdouglas_powerview/__init__.py:116:9: error[invali homeassistant/components/hunterdouglas_powerview/button.py:83:52: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `str`, found `int` homeassistant/components/hunterdouglas_powerview/button.py:119:19: error[unresolved-attribute] Object of type `ButtonEntityDescription` has no attribute `press_action` homeassistant/components/hunterdouglas_powerview/config_flow.py:44:12: error[invalid-return-type] Return type does not match returned value: expected `dict[str, str]`, found `dict[str, str | int]` +homeassistant/components/hunterdouglas_powerview/config_flow.py:168:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/hunterdouglas_powerview/cover.py:75:52: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `str`, found `int` homeassistant/components/hunterdouglas_powerview/cover.py:115:13: error[unsupported-operator] Operator `|=` is unsupported between objects of type `None` and `Literal[CoverEntityFeature.STOP]` homeassistant/components/hunterdouglas_powerview/cover.py:146:16: error[unsupported-operator] Operator `<=` is not supported for types `None` and `int`, in comparing `int | float | None` with `Literal[0]` @@ -1690,7 +1676,6 @@ homeassistant/components/icloud/config_flow.py:163:53: error[invalid-argument-ty homeassistant/components/icloud/config_flow.py:164:53: warning[possibly-missing-attribute] Attribute `entry_id` may be missing on object of type `ConfigEntry[Any] | None` homeassistant/components/icloud/services.py:105:16: error[invalid-return-type] Return type does not match returned value: expected `IcloudAccount`, found `None` homeassistant/components/idteck_prox/__init__.py:7:6: error[unresolved-import] Cannot resolve imported module `rfk101py.rfk101py` -homeassistant/components/ifttt/__init__.py:87:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/iglo/light.py:7:6: error[unresolved-import] Cannot resolve imported module `iglo` homeassistant/components/iglo/light.py:8:6: error[unresolved-import] Cannot resolve imported module `iglo.lamp` homeassistant/components/ign_sismologia/geo_location.py:221:20: error[invalid-return-type] Return type does not match returned value: expected `str | None`, found `(Unknown & ~AlwaysFalsy) | (int & ~AlwaysFalsy) | (float & ~AlwaysFalsy)` @@ -1733,7 +1718,7 @@ homeassistant/components/insteon/binary_sensor.py:61:13: error[invalid-argument- homeassistant/components/insteon/climate.py:70:13: error[invalid-argument-type] Argument to function `async_add_insteon_entities` is incorrect: Expected `dict[str, Any]`, found `Unknown | None` homeassistant/components/insteon/cover.py:33:75: error[invalid-argument-type] Argument to function `async_add_insteon_entities` is incorrect: Expected `dict[str, Any]`, found `Unknown | None` homeassistant/components/insteon/fan.py:37:71: error[invalid-argument-type] Argument to function `async_add_insteon_entities` is incorrect: Expected `dict[str, Any]`, found `Unknown | None` -homeassistant/components/insteon/ipdb.py:52:64: error[invalid-assignment] Object of type `dict[Unknown | | | ... omitted 39 union elements, Unknown | dict[Unknown | EntityPlatforms, Unknown | list[Unknown | int]] | dict[Unknown | EntityPlatforms, Unknown | list[Unknown | int] | range] | dict[Unknown | EntityPlatforms, Unknown | range]]` is not assignable to `dict[Device, dict[EntityPlatforms, Iterable[int]]]` +homeassistant/components/insteon/ipdb.py:52:64: error[invalid-assignment] Object of type `dict[Device | | | ... omitted 39 union elements, dict[EntityPlatforms, Iterable[int]]]` is not assignable to `dict[Device, dict[EntityPlatforms, Iterable[int]]]` homeassistant/components/insteon/ipdb.py:114:12: error[no-matching-overload] No overload of bound method `get` matches arguments homeassistant/components/insteon/light.py:37:13: error[invalid-argument-type] Argument to function `async_add_insteon_entities` is incorrect: Expected `dict[str, Any]`, found `Unknown | None` homeassistant/components/insteon/lock.py:28:73: error[invalid-argument-type] Argument to function `async_add_insteon_entities` is incorrect: Expected `dict[str, Any]`, found `Unknown | None` @@ -1753,6 +1738,7 @@ homeassistant/components/iotty/cover.py:148:16: error[invalid-return-type] Retur homeassistant/components/iperf3/__init__.py:8:8: error[unresolved-import] Cannot resolve imported module `iperf3` homeassistant/components/ipma/weather.py:186:16: error[invalid-return-type] Return type does not match returned value: expected `list[Forecast]`, found `list[dict[Unknown | str, Unknown] | Unknown]` homeassistant/components/irish_rail_transport/sensor.py:8:6: error[unresolved-import] Cannot resolve imported module `pyirishrail.pyirishrail` +homeassistant/components/irm_kmi/config_flow.py:48:9: error[invalid-method-override] Invalid override of method `async_get_options_flow`: Definition is incompatible with `ConfigFlow.async_get_options_flow` homeassistant/components/irm_kmi/coordinator.py:91:59: error[invalid-argument-type] Argument to bound method `get_current_weather` is incorrect: Expected `ZoneInfo`, found `ZoneInfo | None` homeassistant/components/irm_kmi/coordinator.py:92:57: error[invalid-argument-type] Argument to bound method `get_daily_forecast` is incorrect: Expected `ZoneInfo`, found `ZoneInfo | None` homeassistant/components/irm_kmi/coordinator.py:93:59: error[invalid-argument-type] Argument to bound method `get_hourly_forecast` is incorrect: Expected `ZoneInfo`, found `ZoneInfo | None` @@ -1763,7 +1749,6 @@ homeassistant/components/irm_kmi/weather.py:119:32: error[invalid-assignment] Ob homeassistant/components/iskra/sensor.py:250:45: warning[possibly-missing-attribute] Attribute `non_resettable` may be missing on object of type `Unknown | None` homeassistant/components/iskra/sensor.py:256:45: warning[possibly-missing-attribute] Attribute `resettable` may be missing on object of type `Unknown | None` homeassistant/components/islamic_prayer_times/coordinator.py:90:16: warning[redundant-cast] Value is already of type `dict[str, Any]` -homeassistant/components/iss/__init__.py:50:28: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/iss/__init__.py:58:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> Awaitable[dict[str, Any]]) | None`, found `def async_update() -> CoroutineType[Any, Any, IssData]` homeassistant/components/ista_ecotrend/__init__.py:26:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str | None`, found `Logger` homeassistant/components/ista_ecotrend/config_flow.py:54:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str | None`, found `Logger` @@ -1806,6 +1791,7 @@ homeassistant/components/isy994/climate.py:102:24: warning[possibly-missing-attr homeassistant/components/isy994/climate.py:113:29: warning[possibly-missing-attribute] Attribute `aux_properties` may be missing on object of type `Node | Program | Variable` homeassistant/components/isy994/climate.py:122:30: warning[possibly-missing-attribute] Attribute `aux_properties` may be missing on object of type `Node | Program | Variable` homeassistant/components/isy994/climate.py:142:23: warning[possibly-missing-attribute] Attribute `aux_properties` may be missing on object of type `Node | Program | Variable` +homeassistant/components/isy994/climate.py:153:13: error[invalid-argument-type] Argument to function `convert_isy_value_to_hass` is incorrect: Expected `int | float | None`, found `object` homeassistant/components/isy994/climate.py:153:43: warning[possibly-missing-attribute] Attribute `prec` may be missing on object of type `Node | Program | Variable` homeassistant/components/isy994/climate.py:168:18: warning[possibly-missing-attribute] Attribute `aux_properties` may be missing on object of type `Node | Program | Variable` homeassistant/components/isy994/climate.py:176:18: warning[possibly-missing-attribute] Attribute `aux_properties` may be missing on object of type `Node | Program | Variable` @@ -1819,6 +1805,7 @@ homeassistant/components/isy994/climate.py:214:43: error[invalid-argument-type] homeassistant/components/isy994/config_flow.py:105:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `int | float`, found `Any | None` homeassistant/components/isy994/cover.py:32:42: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `str`, found `str | None` homeassistant/components/isy994/cover.py:58:12: warning[possibly-missing-attribute] Attribute `uom` may be missing on object of type `Node | Program | Variable` +homeassistant/components/isy994/cover.py:60:27: error[invalid-argument-type] Argument to function `sorted` is incorrect: Argument type `object` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT` homeassistant/components/isy994/cover.py:71:22: warning[possibly-missing-attribute] Attribute `turn_on` may be missing on object of type `Node | Program | Variable` homeassistant/components/isy994/cover.py:76:22: warning[possibly-missing-attribute] Attribute `turn_off` may be missing on object of type `Node | Program | Variable` homeassistant/components/isy994/cover.py:82:12: warning[possibly-missing-attribute] Attribute `uom` may be missing on object of type `Node | Program | Variable` @@ -1836,6 +1823,7 @@ homeassistant/components/isy994/entity.py:176:15: warning[possibly-missing-attri homeassistant/components/isy994/entity.py:186:52: error[invalid-parameter-default] Default value of type `None` is not assignable to annotated parameter type `Program` homeassistant/components/isy994/entity.py:252:38: warning[possibly-missing-attribute] Attribute `status_events` may be missing on object of type `Unknown | Nodes | None` homeassistant/components/isy994/fan.py:36:40: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `str`, found `str | None` +homeassistant/components/isy994/fan.py:62:56: error[invalid-argument-type] Argument to function `ranged_value_to_percentage` is incorrect: Expected `int | float`, found `object` homeassistant/components/isy994/fan.py:81:19: warning[possibly-missing-attribute] Attribute `turn_off` may be missing on object of type `Node | Program | Variable` homeassistant/components/isy994/fan.py:86:15: warning[possibly-missing-attribute] Attribute `turn_on` may be missing on object of type `Node | Program | Variable` homeassistant/components/isy994/fan.py:99:15: warning[possibly-missing-attribute] Attribute `turn_off` may be missing on object of type `Node | Program | Variable` @@ -1849,9 +1837,14 @@ homeassistant/components/isy994/helpers.py:401:34: warning[possibly-missing-attr homeassistant/components/isy994/helpers.py:429:48: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `tuple[str, Program, Program]`, found `tuple[@Todo, @Todo & ~AlwaysFalsy, None | (@Todo & ~AlwaysFalsy)]` homeassistant/components/isy994/light.py:37:24: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Node`, found `Node | Group` homeassistant/components/isy994/light.py:37:63: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `str`, found `str | None` +homeassistant/components/isy994/light.py:64:20: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `object` homeassistant/components/isy994/light.py:72:12: warning[possibly-missing-attribute] Attribute `uom` may be missing on object of type `Node | Program | Variable` +homeassistant/components/isy994/light.py:74:20: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `object` homeassistant/components/isy994/light.py:79:22: warning[possibly-missing-attribute] Attribute `turn_off` may be missing on object of type `Node | Program | Variable` +homeassistant/components/isy994/light.py:86:13: error[invalid-assignment] Object of type `object` is not assignable to attribute `_last_brightness` of type `int | None` homeassistant/components/isy994/light.py:87:16: warning[possibly-missing-attribute] Attribute `uom` may be missing on object of type `Node | Program | Variable` +homeassistant/components/isy994/light.py:88:47: error[unsupported-operator] Operator `*` is unsupported between objects of type `object` and `float` +homeassistant/components/isy994/light.py:90:17: error[invalid-assignment] Object of type `object` is not assignable to attribute `_last_brightness` of type `int | None` homeassistant/components/isy994/light.py:98:39: warning[possibly-missing-attribute] Attribute `uom` may be missing on object of type `Node | Program | Variable` homeassistant/components/isy994/light.py:100:22: warning[possibly-missing-attribute] Attribute `turn_on` may be missing on object of type `Node | Program | Variable` homeassistant/components/isy994/lock.py:56:41: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `str`, found `str | None` @@ -1873,6 +1866,7 @@ homeassistant/components/isy994/number.py:135:51: error[invalid-argument-type] A homeassistant/components/isy994/number.py:135:51: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `EntityDescription`, found `Unknown | Node | str | NumberEntityDescription` homeassistant/components/isy994/number.py:135:51: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `DeviceInfo | None`, found `Unknown | Node | str | NumberEntityDescription` homeassistant/components/isy994/number.py:169:43: error[invalid-argument-type] Argument to bound method `set_on_level` is incorrect: Expected `int`, found `int | float` +homeassistant/components/isy994/number.py:219:13: error[invalid-argument-type] Argument to function `convert_isy_value_to_hass` is incorrect: Expected `int | float | None`, found `object` homeassistant/components/isy994/number.py:267:39: warning[possibly-missing-attribute] Attribute `status_events` may be missing on object of type `Unknown | Nodes | None` homeassistant/components/isy994/select.py:51:34: error[invalid-argument-type] Argument to function `time_string` is incorrect: Expected `int`, found `Unknown | int | float` homeassistant/components/isy994/select.py:94:44: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `str`, found `str | None` @@ -1911,15 +1905,14 @@ homeassistant/components/isy994/switch.py:79:45: error[invalid-argument-type] Ar homeassistant/components/isy994/switch.py:97:22: warning[possibly-missing-attribute] Attribute `turn_off` may be missing on object of type `Node | Program | Variable` homeassistant/components/isy994/switch.py:102:22: warning[possibly-missing-attribute] Attribute `turn_on` may be missing on object of type `Node | Program | Variable` homeassistant/components/isy994/switch.py:163:32: warning[possibly-missing-attribute] Attribute `status_events` may be missing on object of type `Unknown | Nodes | None` +homeassistant/components/isy994/switch.py:173:9: error[invalid-method-override] Invalid override of method `async_on_update`: Definition is incompatible with `ISYAuxControlEntity.async_on_update` homeassistant/components/itach/remote.py:9:8: error[unresolved-import] Cannot resolve imported module `pyitachip2ir` -homeassistant/components/itunes/media_player.py:75:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/itunes/media_player.py:77:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/itunes/media_player.py:279:17: warning[possibly-missing-attribute] Attribute `update_state` may be missing on object of type `Unknown | None` homeassistant/components/itunes/media_player.py:298:16: error[unsupported-operator] Operator `/` is unsupported between objects of type `Unknown | None` and `float` -homeassistant/components/izone/climate.py:122:16: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/izone/climate.py:122:46: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/izone/climate.py:123:20: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/izone/climate.py:123:52: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 +homeassistant/components/izone/climate.py:122:40: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/izone/climate.py:122:70: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/izone/climate.py:123:44: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/izone/climate.py:123:76: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 homeassistant/components/izone/climate.py:367:16: error[invalid-return-type] Return type does not match returned value: expected `int | float`, found `Unknown | int | float | None` homeassistant/components/izone/climate.py:469:25: error[invalid-argument-type] Invalid argument to key "identifiers" with declared type `set[tuple[str, str]]` on TypedDict `DeviceInfo`: value of type `set[Unknown | tuple[str, Unknown & ~AlwaysFalsy, int]]` homeassistant/components/izone/climate.py:539:16: error[invalid-return-type] Return type does not match returned value: expected `int | float`, found `Unknown | int | float | None` @@ -1968,7 +1961,7 @@ homeassistant/components/knx/sensor.py:217:16: error[unresolved-attribute] Objec homeassistant/components/knx/sensor.py:222:12: error[unresolved-attribute] Object of type `SensorEntityDescription` has no attribute `always_available` homeassistant/components/knx/storage/config_store.py:88:25: error[missing-typed-dict-key] Missing required key 'entities' in TypedDict `KNXConfigStoreModel` constructor homeassistant/components/knx/storage/serialize.py:36:16: error[invalid-return-type] Return type does not match returned value: expected `dict[str, Any] | list[dict[str, Any]] | UnsupportedType`, found `Top[dict[str | Unknown, dict[str, Unknown] | Unknown | str]]` -homeassistant/components/knx/telegrams.py:28:22: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 2 +homeassistant/components/knx/telegrams.py:28:33: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 2 homeassistant/components/knx/websocket.py:135:19: error[invalid-await] `Awaitable[None] | None` is not awaitable homeassistant/components/kodi/browse_media.py:54:23: error[call-non-callable] Object of type `None` is not callable homeassistant/components/kodi/browse_media.py:230:42: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[Unknown]`, found `Unknown | Sequence[BrowseMedia] | None` @@ -1976,7 +1969,6 @@ homeassistant/components/kodi/config_flow.py:289:13: error[invalid-argument-type homeassistant/components/kodi/media_player.py:151:17: error[unresolved-attribute] Object of type `(...) -> Awaitable[Any]` has no attribute `__name__` homeassistant/components/kodi/media_player.py:322:37: warning[possibly-missing-attribute] Attribute `id` may be missing on object of type `DeviceEntry | None` homeassistant/components/kodi/media_player.py:323:27: warning[possibly-missing-attribute] Attribute `id` may be missing on object of type `DeviceEntry | None` -homeassistant/components/konnected/__init__.py:338:16: error[unresolved-attribute] Module `json` has no member `decoder` homeassistant/components/konnected/panel.py:136:16: warning[possibly-missing-attribute] Attribute `ClientError` may be missing on object of type `Unknown | None | Client` homeassistant/components/konnected/panel.py:191:16: warning[possibly-missing-attribute] Attribute `ClientError` may be missing on object of type `Unknown | None | Client` homeassistant/components/konnected/panel.py:320:28: warning[possibly-missing-attribute] Attribute `get` may be missing on object of type `Unknown | None` @@ -2048,9 +2040,9 @@ homeassistant/components/lg_soundbar/media_player.py:211:9: warning[possibly-mis homeassistant/components/lg_soundbar/media_player.py:215:9: warning[possibly-missing-attribute] Attribute `set_func` may be missing on object of type `Unknown | None | temescal` homeassistant/components/lg_soundbar/media_player.py:219:9: warning[possibly-missing-attribute] Attribute `set_eq` may be missing on object of type `Unknown | None | temescal` homeassistant/components/lg_soundbar/media_player.py:231:9: warning[possibly-missing-attribute] Attribute `send_packet` may be missing on object of type `Unknown | None | temescal` -homeassistant/components/lg_thinq/binary_sensor.py:92:5: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | tuple[ThinQBinarySensorEntityDescription] | tuple[ThinQBinarySensorEntityDescription, ThinQBinarySensorEntityDescription, ThinQBinarySensorEntityDescription, ThinQBinarySensorEntityDescription, ThinQBinarySensorEntityDescription, ThinQBinarySensorEntityDescription] | tuple[ThinQBinarySensorEntityDescription, ThinQBinarySensorEntityDescription, ThinQBinarySensorEntityDescription, ThinQBinarySensorEntityDescription]]` is not assignable to `dict[DeviceType, tuple[ThinQBinarySensorEntityDescription, ...]]` +homeassistant/components/lg_thinq/binary_sensor.py:92:5: error[invalid-assignment] Object of type `dict[DeviceType | Unknown | str, tuple[ThinQBinarySensorEntityDescription, ...]]` is not assignable to `dict[DeviceType, tuple[ThinQBinarySensorEntityDescription, ...]]` homeassistant/components/lg_thinq/binary_sensor.py:147:17: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceType`, found `Unknown | str` -homeassistant/components/lg_thinq/climate.py:32:83: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | tuple[ClimateEntityDescription]]` is not assignable to `dict[DeviceType, tuple[ClimateEntityDescription, ...]]` +homeassistant/components/lg_thinq/climate.py:32:83: error[invalid-assignment] Object of type `dict[DeviceType | Unknown | str, tuple[ClimateEntityDescription, ...]]` is not assignable to `dict[DeviceType, tuple[ClimateEntityDescription, ...]]` homeassistant/components/lg_thinq/climate.py:87:17: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceType`, found `Unknown | str` homeassistant/components/lg_thinq/climate.py:141:12: error[unresolved-attribute] Object of type `PropertyState` has no attribute `support_temperature_range` homeassistant/components/lg_thinq/climate.py:160:35: error[no-matching-overload] No overload of bound method `get` matches arguments @@ -2060,30 +2052,30 @@ homeassistant/components/lg_thinq/climate.py:310:35: error[invalid-argument-type homeassistant/components/lg_thinq/climate.py:338:16: error[unsupported-operator] Operator `>=` is not supported for types `None` and `int`, in comparing `int | float | None` with `Literal[1]` homeassistant/components/lg_thinq/climate.py:351:16: error[unsupported-operator] Operator `>=` is not supported for types `None` and `int`, in comparing `int | float | None` with `Literal[1]` homeassistant/components/lg_thinq/coordinator.py:41:9: error[invalid-assignment] Object of type `dict[str, PropertyState] | None` is not assignable to attribute `data` of type `dict[str, Any]` -homeassistant/components/lg_thinq/event.py:30:79: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | tuple[EventEntityDescription] | tuple[EventEntityDescription, EventEntityDescription]]` is not assignable to `dict[DeviceType, tuple[EventEntityDescription, ...]]` +homeassistant/components/lg_thinq/event.py:30:79: error[invalid-assignment] Object of type `dict[DeviceType | Unknown | str, tuple[EventEntityDescription, ...]]` is not assignable to `dict[DeviceType, tuple[EventEntityDescription, ...]]` homeassistant/components/lg_thinq/event.py:67:17: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceType`, found `Unknown | str` homeassistant/components/lg_thinq/event.py:95:9: error[invalid-assignment] Object of type `list[str] | None` is not assignable to attribute `_attr_event_types` of type `list[str]` -homeassistant/components/lg_thinq/fan.py:38:80: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | tuple[ThinQFanEntityDescription]]` is not assignable to `dict[DeviceType, tuple[ThinQFanEntityDescription, ...]]` +homeassistant/components/lg_thinq/fan.py:38:80: error[invalid-assignment] Object of type `dict[DeviceType | Unknown | str, tuple[ThinQFanEntityDescription, ...]]` is not assignable to `dict[DeviceType, tuple[ThinQFanEntityDescription, ...]]` homeassistant/components/lg_thinq/fan.py:71:53: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceType`, found `Unknown | str` homeassistant/components/lg_thinq/fan.py:104:23: error[not-iterable] Object of type `list[str] | None` may not be iterable homeassistant/components/lg_thinq/fan.py:115:29: error[unsupported-operator] Operator `not in` is not supported for types `Unknown` and `None`, in comparing `Unknown | str` with `list[str] | None` -homeassistant/components/lg_thinq/number.py:55:67: error[invalid-assignment] Object of type `dict[Unknown | Property | TimerProperty, Unknown | NumberEntityDescription]` is not assignable to `dict[Property, NumberEntityDescription]` +homeassistant/components/lg_thinq/number.py:55:67: error[invalid-assignment] Object of type `dict[Property | TimerProperty, NumberEntityDescription]` is not assignable to `dict[Property, NumberEntityDescription]` homeassistant/components/lg_thinq/number.py:85:5: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Property, NumberEntityDescription].__getitem__(key: Property, /) -> NumberEntityDescription` cannot be called with key of type `Literal[TimerProperty.RELATIVE_HOUR_TO_START_WM]` on object of type `dict[Property, NumberEntityDescription]` homeassistant/components/lg_thinq/number.py:86:5: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Property, NumberEntityDescription].__getitem__(key: Property, /) -> NumberEntityDescription` cannot be called with key of type `Literal[TimerProperty.RELATIVE_HOUR_TO_STOP_WM]` on object of type `dict[Property, NumberEntityDescription]` -homeassistant/components/lg_thinq/number.py:89:81: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | tuple[NumberEntityDescription, NumberEntityDescription, NumberEntityDescription] | tuple[NumberEntityDescription, NumberEntityDescription] | tuple[NumberEntityDescription]]` is not assignable to `dict[DeviceType, tuple[NumberEntityDescription, ...]]` +homeassistant/components/lg_thinq/number.py:89:81: error[invalid-assignment] Object of type `dict[DeviceType | Unknown | str, tuple[NumberEntityDescription, ...]]` is not assignable to `dict[DeviceType, tuple[NumberEntityDescription, ...]]` homeassistant/components/lg_thinq/number.py:114:25: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Property, NumberEntityDescription].__getitem__(key: Property, /) -> NumberEntityDescription` cannot be called with key of type `Literal[TimerProperty.RELATIVE_HOUR_TO_STOP_WM]` on object of type `dict[Property, NumberEntityDescription]` homeassistant/components/lg_thinq/number.py:144:17: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceType`, found `Unknown | str` -homeassistant/components/lg_thinq/select.py:86:81: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | tuple[SelectEntityDescription, SelectEntityDescription] | tuple[SelectEntityDescription, SelectEntityDescription, SelectEntityDescription, SelectEntityDescription] | tuple[SelectEntityDescription]]` is not assignable to `dict[DeviceType, tuple[SelectEntityDescription, ...]]` +homeassistant/components/lg_thinq/select.py:86:81: error[invalid-assignment] Object of type `dict[DeviceType | Unknown | str, tuple[SelectEntityDescription, ...]]` is not assignable to `dict[DeviceType, tuple[SelectEntityDescription, ...]]` homeassistant/components/lg_thinq/select.py:164:17: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceType`, found `Unknown | str` -homeassistant/components/lg_thinq/sensor.py:127:70: error[invalid-assignment] Object of type `dict[Unknown | Property | ThinQPropertyEx, Unknown | SensorEntityDescription]` is not assignable to `dict[Property, SensorEntityDescription]` -homeassistant/components/lg_thinq/sensor.py:262:73: error[invalid-assignment] Object of type `dict[Unknown | Property | ThinQPropertyEx, Unknown | SensorEntityDescription]` is not assignable to `dict[Property, SensorEntityDescription]` -homeassistant/components/lg_thinq/sensor.py:356:66: error[invalid-assignment] Object of type `dict[Unknown | TimerProperty, Unknown | SensorEntityDescription]` is not assignable to `dict[Property, SensorEntityDescription]` -homeassistant/components/lg_thinq/sensor.py:373:67: error[invalid-assignment] Object of type `dict[Unknown | TimerProperty, Unknown | SensorEntityDescription]` is not assignable to `dict[Property, SensorEntityDescription]` +homeassistant/components/lg_thinq/sensor.py:127:70: error[invalid-assignment] Object of type `dict[Property | ThinQPropertyEx, SensorEntityDescription]` is not assignable to `dict[Property, SensorEntityDescription]` +homeassistant/components/lg_thinq/sensor.py:262:73: error[invalid-assignment] Object of type `dict[Property | ThinQPropertyEx, SensorEntityDescription]` is not assignable to `dict[Property, SensorEntityDescription]` +homeassistant/components/lg_thinq/sensor.py:356:66: error[invalid-assignment] Object of type `dict[Property | TimerProperty, SensorEntityDescription]` is not assignable to `dict[Property, SensorEntityDescription]` +homeassistant/components/lg_thinq/sensor.py:373:67: error[invalid-assignment] Object of type `dict[Property | TimerProperty, SensorEntityDescription]` is not assignable to `dict[Property, SensorEntityDescription]` homeassistant/components/lg_thinq/sensor.py:426:5: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Property, SensorEntityDescription].__getitem__(key: Property, /) -> SensorEntityDescription` cannot be called with key of type `Literal[TimerProperty.TOTAL]` on object of type `dict[Property, SensorEntityDescription]` homeassistant/components/lg_thinq/sensor.py:427:5: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Property, SensorEntityDescription].__getitem__(key: Property, /) -> SensorEntityDescription` cannot be called with key of type `Literal[TimerProperty.RELATIVE_TO_START_WM]` on object of type `dict[Property, SensorEntityDescription]` homeassistant/components/lg_thinq/sensor.py:428:5: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Property, SensorEntityDescription].__getitem__(key: Property, /) -> SensorEntityDescription` cannot be called with key of type `Literal[TimerProperty.RELATIVE_TO_STOP_WM]` on object of type `dict[Property, SensorEntityDescription]` homeassistant/components/lg_thinq/sensor.py:429:5: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Property, SensorEntityDescription].__getitem__(key: Property, /) -> SensorEntityDescription` cannot be called with key of type `Literal[TimerProperty.REMAIN]` on object of type `dict[Property, SensorEntityDescription]` -homeassistant/components/lg_thinq/sensor.py:431:81: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | tuple[SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription] | tuple[SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription, SensorEntityDescription] | ... omitted 9 union elements]` is not assignable to `dict[DeviceType, tuple[SensorEntityDescription, ...]]` +homeassistant/components/lg_thinq/sensor.py:431:81: error[invalid-assignment] Object of type `dict[DeviceType | Unknown | str, tuple[SensorEntityDescription, ...]]` is not assignable to `dict[DeviceType, tuple[SensorEntityDescription, ...]]` homeassistant/components/lg_thinq/sensor.py:441:9: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Property, SensorEntityDescription].__getitem__(key: Property, /) -> SensorEntityDescription` cannot be called with key of type `Literal[TimerProperty.RELATIVE_TO_START]` on object of type `dict[Property, SensorEntityDescription]` homeassistant/components/lg_thinq/sensor.py:442:9: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Property, SensorEntityDescription].__getitem__(key: Property, /) -> SensorEntityDescription` cannot be called with key of type `Literal[TimerProperty.RELATIVE_TO_STOP]` on object of type `dict[Property, SensorEntityDescription]` homeassistant/components/lg_thinq/sensor.py:443:9: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Property, SensorEntityDescription].__getitem__(key: Property, /) -> SensorEntityDescription` cannot be called with key of type `Literal[TimerProperty.SLEEP_TIMER_RELATIVE_TO_STOP]` on object of type `dict[Property, SensorEntityDescription]` @@ -2113,12 +2105,13 @@ homeassistant/components/lg_thinq/sensor.py:577:9: error[invalid-argument-type] homeassistant/components/lg_thinq/sensor.py:578:9: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Property, SensorEntityDescription].__getitem__(key: Property, /) -> SensorEntityDescription` cannot be called with key of type `Literal[TimerProperty.SLEEP_TIMER_RELATIVE_TO_STOP]` on object of type `dict[Property, SensorEntityDescription]` homeassistant/components/lg_thinq/sensor.py:648:17: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceType`, found `Unknown | str` homeassistant/components/lg_thinq/sensor.py:838:13: error[invalid-assignment] Object of type `Unknown | dict[Unknown, Unknown] | None` is not assignable to attribute `_attr_native_value` of type `StateType | date | Decimal` -homeassistant/components/lg_thinq/switch.py:43:86: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | tuple[ThinQSwitchEntityDescription, ThinQSwitchEntityDescription, ThinQSwitchEntityDescription, ThinQSwitchEntityDescription] | tuple[ThinQSwitchEntityDescription, ThinQSwitchEntityDescription, ThinQSwitchEntityDescription] | ... omitted 3 union elements]` is not assignable to `dict[DeviceType, tuple[ThinQSwitchEntityDescription, ...]]` +homeassistant/components/lg_thinq/switch.py:43:86: error[invalid-assignment] Object of type `dict[DeviceType | Unknown | str, tuple[ThinQSwitchEntityDescription, ...]]` is not assignable to `dict[DeviceType, tuple[ThinQSwitchEntityDescription, ...]]` homeassistant/components/lg_thinq/switch.py:226:17: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceType`, found `Unknown | str` -homeassistant/components/lg_thinq/vacuum.py:24:86: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | tuple[StateVacuumEntityDescription]]` is not assignable to `dict[DeviceType, tuple[StateVacuumEntityDescription, ...]]` +homeassistant/components/lg_thinq/vacuum.py:24:86: error[invalid-assignment] Object of type `dict[DeviceType | Unknown | str, tuple[StateVacuumEntityDescription, ...]]` is not assignable to `dict[DeviceType, tuple[StateVacuumEntityDescription, ...]]` homeassistant/components/lg_thinq/vacuum.py:84:17: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceType`, found `Unknown | str` -homeassistant/components/lg_thinq/water_heater.py:29:70: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | WaterHeaterEntityDescription]` is not assignable to `dict[DeviceType, WaterHeaterEntityDescription]` +homeassistant/components/lg_thinq/water_heater.py:29:70: error[invalid-assignment] Object of type `dict[DeviceType | Unknown | str, WaterHeaterEntityDescription]` is not assignable to `dict[DeviceType, WaterHeaterEntityDescription]` homeassistant/components/lg_thinq/water_heater.py:61:51: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceType`, found `Unknown | str` +homeassistant/components/lifx/config_flow.py:107:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/lifx/config_flow.py:147:46: error[invalid-assignment] Invalid assignment to key "title_placeholders" with declared type `Mapping[str, str]` on TypedDict `ConfigFlowContext`: value of type `dict[Unknown | str, Unknown | None]` homeassistant/components/lifx/config_flow.py:149:42: error[invalid-argument-type] Argument to bound method `async_show_form` is incorrect: Expected `Mapping[str, str] | None`, found `dict[Unknown | str, Unknown | None]` homeassistant/components/lifx/config_flow.py:219:13: error[invalid-argument-type] Argument to bound method `async_create_entry` is incorrect: Expected `str`, found `Unknown | None` @@ -2132,6 +2125,7 @@ homeassistant/components/lifx/coordinator.py:202:27: error[non-subscriptable] Ca homeassistant/components/lifx/coordinator.py:203:23: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/lifx/coordinator.py:209:48: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Unknown]`, found `Unknown | None | list[Unknown | None]` homeassistant/components/lifx/coordinator.py:210:17: error[invalid-assignment] Cannot assign to a subscript on an object of type `int` +homeassistant/components/lifx/coordinator.py:210:17: error[invalid-assignment] Cannot assign to a subscript on an object of type `None` homeassistant/components/lifx/coordinator.py:294:27: error[invalid-argument-type] Argument is incorrect: Expected `Message`, found `Light` homeassistant/components/lifx/coordinator.py:294:33: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any] | None`, found `Message` homeassistant/components/lifx/coordinator.py:385:47: error[unresolved-attribute] Object of type `Message` has no attribute `signal` @@ -2208,8 +2202,8 @@ homeassistant/components/livisi/coordinator.py:107:42: error[invalid-assignment] homeassistant/components/locative/device_tracker.py:58:9: error[call-non-callable] Object of type `None` is not callable homeassistant/components/logbook/helpers.py:220:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventStateChangedData]` homeassistant/components/logbook/helpers.py:221:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _forward_state_events_filtered(event: Event[EventStateChangedData]) -> None` -homeassistant/components/logentries/__init__.py:51:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/logentries/__init__.py:54:21: error[invalid-argument-type] Argument to bound method `listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventStateChangedData]` +homeassistant/components/london_underground/config_flow.py:36:9: error[invalid-method-override] Invalid override of method `async_get_options_flow`: Definition is incompatible with `ConfigFlow.async_get_options_flow` homeassistant/components/lookin/__init__.py:81:78: error[invalid-argument-type] Argument to function `start_lookin_udp` is incorrect: Expected `str`, found `None` homeassistant/components/lookin/__init__.py:82:20: error[invalid-return-type] Return type does not match returned value: expected `LookinUDPSubscriptions`, found `LookinUDPSubscriptions | None` homeassistant/components/lookin/__init__.py:157:33: error[invalid-argument-type] Argument to bound method `update_from_value` is incorrect: Expected `str`, found `str | None` @@ -2287,10 +2281,11 @@ homeassistant/components/matter/light.py:157:17: error[invalid-argument-type] Ar homeassistant/components/matter/light.py:160:17: error[invalid-argument-type] Argument is incorrect: Expected `uint`, found `Literal[1]` homeassistant/components/matter/light.py:161:17: error[invalid-argument-type] Argument is incorrect: Expected `uint`, found `Literal[1]` homeassistant/components/matter/light.py:184:17: error[invalid-argument-type] Argument is incorrect: Expected `Nullable | uint`, found `int` +homeassistant/components/matter/light.py:271:17: error[invalid-argument-type] Argument to function `renormalize` is incorrect: Expected `int | float`, found `Unknown | Nullable | uint` homeassistant/components/matter/number.py:147:17: error[invalid-argument-type] Argument is incorrect: Expected `uint`, found `int | @Todo` homeassistant/components/matter/number.py:354:17: error[invalid-argument-type] Argument is incorrect: Expected `uint | None`, found `int` -homeassistant/components/matter/select.py:146:34: error[invalid-assignment] Object of type `Unknown | None` is not assignable to `SelectCluster` -homeassistant/components/matter/select.py:163:34: error[invalid-assignment] Object of type `Unknown | None` is not assignable to `SelectCluster` +homeassistant/components/matter/select.py:146:34: error[invalid-assignment] Object of type `Unknown | ModeSelect | OvenMode | ... omitted 9 union elements` is not assignable to `SelectCluster` +homeassistant/components/matter/select.py:163:34: error[invalid-assignment] Object of type `Unknown | ModeSelect | OvenMode | ... omitted 9 union elements` is not assignable to `SelectCluster` homeassistant/components/matter/valve.py:63:60: error[invalid-argument-type] Argument is incorrect: Expected `uint | None`, found `int` homeassistant/components/matter/water_heater.py:94:13: error[invalid-argument-type] Argument is incorrect: Expected `uint`, found `int` homeassistant/components/matter/water_heater.py:96:13: error[invalid-argument-type] Argument is incorrect: Expected `int | None`, found `int | ` @@ -2336,8 +2331,6 @@ homeassistant/components/meteoclimatic/weather.py:68:35: warning[possibly-missin homeassistant/components/metoffice/__init__.py:72:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> Awaitable[dict[str, Any]]) | None`, found `def async_update_hourly() -> CoroutineType[Any, Any, Forecast]` homeassistant/components/metoffice/__init__.py:81:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> Awaitable[dict[str, Any]]) | None`, found `def async_update_daily() -> CoroutineType[Any, Any, Forecast]` homeassistant/components/metoffice/__init__.py:90:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> Awaitable[dict[str, Any]]) | None`, found `def async_update_twice_daily() -> CoroutineType[Any, Any, Forecast]` -homeassistant/components/mfi/sensor.py:79:28: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/mfi/switch.py:67:28: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/microbees/binary_sensor.py:80:16: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `int | float` homeassistant/components/microbees/climate.py:112:9: error[invalid-assignment] Object of type `Any | None` is not assignable to attribute `targetTemp` of type `int | float` homeassistant/components/microbees/light.py:46:9: error[invalid-assignment] Object of type `list[int]` is not assignable to attribute `_attr_rgbw_color` of type `tuple[int, int, int, int] | None` @@ -2350,6 +2343,7 @@ homeassistant/components/mill/climate.py:125:19: warning[possibly-missing-attrib homeassistant/components/mill/climate.py:126:17: error[invalid-argument-type] Argument to bound method `heater_control` is incorrect: Expected `str`, found `Unknown | str | None` homeassistant/components/mill/climate.py:130:19: warning[possibly-missing-attribute] Attribute `heater_control` may be missing on object of type `Unknown | Mill | Mill` homeassistant/components/mill/climate.py:131:17: error[invalid-argument-type] Argument to bound method `heater_control` is incorrect: Expected `str`, found `Unknown | str | None` +homeassistant/components/mill/climate.py:136:9: error[invalid-method-override] Invalid override of method `_update_attr`: Definition is incompatible with `MillBaseEntity._update_attr` homeassistant/components/mill/climate.py:178:19: warning[possibly-missing-attribute] Attribute `mac_address` may be missing on object of type `Unknown | Mill | Mill` homeassistant/components/mill/climate.py:182:35: warning[possibly-missing-attribute] Attribute `url` may be missing on object of type `Unknown | Mill | Mill` homeassistant/components/mill/climate.py:185:22: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Unknown | Mill | Mill` @@ -2366,7 +2360,7 @@ homeassistant/components/mill/sensor.py:221:19: warning[possibly-missing-attribu homeassistant/components/mill/sensor.py:225:35: warning[possibly-missing-attribute] Attribute `url` may be missing on object of type `Unknown | Mill | Mill` homeassistant/components/mill/sensor.py:228:22: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Unknown | Mill | Mill` homeassistant/components/mill/sensor.py:229:28: warning[possibly-missing-attribute] Attribute `version` may be missing on object of type `Unknown | Mill | Mill` -homeassistant/components/min_max/sensor.py:257:57: error[invalid-assignment] Object of type `Event[dict[Unknown | str, Unknown | str | State | None]]` is not assignable to `Event[EventStateChangedData]` +homeassistant/components/min_max/sensor.py:257:57: error[invalid-assignment] Object of type `Event[EventStateChangedData | dict[Unknown | str, Unknown | str | State | None]]` is not assignable to `Event[EventStateChangedData]` homeassistant/components/mobile_app/device_tracker.py:70:16: error[invalid-return-type] Return type does not match returned value: expected `int | None`, found `Unknown | None | tuple[Any | None, Any | None]` homeassistant/components/mobile_app/device_tracker.py:70:16: warning[possibly-missing-attribute] Attribute `get` may be missing on object of type `Unknown | None | dict[Unknown, Unknown] | dict[Unknown | str, Unknown | tuple[Any | None, Any | None] | None]` homeassistant/components/mobile_app/device_tracker.py:77:26: warning[possibly-missing-attribute] Attribute `get` may be missing on object of type `Unknown | None | dict[Unknown, Unknown] | dict[Unknown | str, Unknown | tuple[Any | None, Any | None] | None]` @@ -2377,13 +2371,14 @@ homeassistant/components/mobile_app/device_tracker.py:98:20: warning[possibly-mi homeassistant/components/mobile_app/device_tracker.py:106:29: warning[possibly-missing-attribute] Attribute `get` may be missing on object of type `Unknown | None | dict[Unknown, Unknown] | dict[Unknown | str, Unknown | tuple[Any | None, Any | None] | None]` homeassistant/components/mobile_app/device_tracker.py:113:20: error[invalid-return-type] Return type does not match returned value: expected `str | None`, found `(Unknown & ~AlwaysFalsy & ~Literal["home"]) | tuple[Any | None, Any | None]` homeassistant/components/mobile_app/entity.py:83:28: error[invalid-argument-type] Argument to function `device_info` is incorrect: Expected `dict[Unknown, Unknown]`, found `Unknown | MappingProxyType[str, Any]` -homeassistant/components/mobile_app/webhook.py:171:23: error[unresolved-attribute] Module `voluptuous` has no member `humanize` -homeassistant/components/mobile_app/webhook.py:212:15: error[unresolved-attribute] Module `voluptuous` has no member `humanize` -homeassistant/components/mobile_app/webhook.py:674:23: error[unresolved-attribute] Module `voluptuous` has no member `humanize` +homeassistant/components/mobile_app/webhook.py:171:23: warning[possibly-missing-attribute] Submodule `humanize` may not be available as an attribute on module `voluptuous` +homeassistant/components/mobile_app/webhook.py:212:15: warning[possibly-missing-attribute] Submodule `humanize` may not be available as an attribute on module `voluptuous` +homeassistant/components/mobile_app/webhook.py:674:23: warning[possibly-missing-attribute] Submodule `humanize` may not be available as an attribute on module `voluptuous` homeassistant/components/modbus/cover.py:100:34: error[invalid-argument-type] Argument to bound method `_set_attr_state` is incorrect: Expected `str | int`, found `Unknown | bool | None` homeassistant/components/modbus/light.py:202:20: error[unsupported-operator] Operator `-` is unsupported between objects of type `int | None` and `int | None` homeassistant/components/modbus/light.py:219:16: error[unsupported-operator] Operator `-` is unsupported between objects of type `int` and `int | None` homeassistant/components/modbus/light.py:221:16: error[unsupported-operator] Operator `-` is unsupported between objects of type `int | None` and `int | None` +homeassistant/components/modern_forms/coordinator.py:46:15: error[invalid-method-override] Invalid override of method `_async_update_data`: Definition is incompatible with `DataUpdateCoordinator._async_update_data` homeassistant/components/modern_forms/fan.py:144:49: error[invalid-argument-type] Argument to bound method `fan` is incorrect: Expected `str | None`, found `Unknown | bool` homeassistant/components/moehlenhoff_alpha2/config_flow.py:29:13: error[unresolved-attribute] Object of type `object` has no attribute `ClientConnectorError` homeassistant/components/mold_indicator/__init__.py:75:44: error[invalid-key] Unknown key "changes" for TypedDict `_EventEntityRegistryUpdatedData_CreateRemove`: Unknown key "changes" @@ -2461,7 +2456,6 @@ homeassistant/components/motion_blinds/sensor.py:90:12: warning[possibly-missing homeassistant/components/motion_blinds/sensor.py:92:16: warning[possibly-missing-attribute] Attribute `battery_level` may be missing on object of type `Unknown | MotionGateway | MotionBlind` homeassistant/components/motion_blinds/sensor.py:98:12: warning[possibly-missing-attribute] Attribute `battery_voltage` may be missing on object of type `Unknown | MotionGateway | MotionBlind` homeassistant/components/motion_blinds/sensor.py:99:48: warning[possibly-missing-attribute] Attribute `battery_voltage` may be missing on object of type `Unknown | MotionGateway | MotionBlind` -homeassistant/components/motioneye/__init__.py:403:13: error[unresolved-attribute] Module `json` has no member `decoder` homeassistant/components/mpd/config_flow.py:39:13: error[unresolved-attribute] Unresolved attribute `timeout` on type `MPDClient`. homeassistant/components/mpd/config_flow.py:40:13: error[unresolved-attribute] Unresolved attribute `idletimeout` on type `MPDClient`. homeassistant/components/mpd/config_flow.py:45:31: error[unresolved-attribute] Object of type `MPDClient` has no attribute `password` @@ -2508,8 +2502,8 @@ homeassistant/components/mpd/media_player.py:515:19: warning[possibly-missing-at homeassistant/components/mpd/media_player.py:520:19: warning[possibly-missing-attribute] Attribute `play` may be missing on object of type `Unknown | MPDClient` homeassistant/components/mpd/media_player.py:526:19: warning[possibly-missing-attribute] Attribute `clear` may be missing on object of type `Unknown | MPDClient` homeassistant/components/mpd/media_player.py:531:19: warning[possibly-missing-attribute] Attribute `seekcur` may be missing on object of type `Unknown | MPDClient` -homeassistant/components/mqtt/client.py:270:10: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 homeassistant/components/mqtt/client.py:270:18: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[ReceiveMessage]`? +homeassistant/components/mqtt/client.py:270:36: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/components/mqtt/client.py:838:30: error[unresolved-attribute] Object of type `object` has no attribute `__name__` homeassistant/components/mqtt/client.py:840:30: error[unresolved-attribute] Object of type `((ReceiveMessage, /) -> Coroutine[Any, Any, None] | None) & ~Top[partial[Unknown]]` has no attribute `__name__` homeassistant/components/mqtt/config_flow.py:3376:65: error[no-matching-overload] No overload of bound method `__init__` matches arguments @@ -2522,9 +2516,9 @@ homeassistant/components/mqtt/config_flow.py:4638:13: error[no-matching-overload homeassistant/components/mqtt/config_flow.py:4639:13: error[no-matching-overload] No overload of bound method `update` matches arguments homeassistant/components/mqtt/debug_info.py:64:13: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[Unknown | str, Unknown | int | deque[Unknown]]` on object of type `dict[str, SubscriptionDebugInfo]` homeassistant/components/mqtt/debug_info.py:120:5: error[invalid-assignment] Invalid subscript assignment with key of type `tuple[str, str]` and value of type `dict[Unknown | str, Unknown | str | dict[str, Any]]` on object of type `dict[tuple[str, str], TriggerDebugInfo]` -homeassistant/components/mqtt/discovery.py:63:25: error[too-many-positional-arguments] Too many positional arguments to class `SignalTypeFormat`: expected 0, got 1 -homeassistant/components/mqtt/discovery.py:66:21: error[too-many-positional-arguments] Too many positional arguments to class `SignalTypeFormat`: expected 0, got 1 -homeassistant/components/mqtt/discovery.py:69:22: error[too-many-positional-arguments] Too many positional arguments to class `SignalTypeFormat`: expected 0, got 1 +homeassistant/components/mqtt/discovery.py:63:42: error[invalid-type-arguments] Too many type arguments to class `SignalTypeFormat`: expected 0, got 1 +homeassistant/components/mqtt/discovery.py:66:38: error[invalid-type-arguments] Too many type arguments to class `SignalTypeFormat`: expected 0, got 1 +homeassistant/components/mqtt/discovery.py:69:39: error[invalid-type-arguments] Too many type arguments to class `SignalTypeFormat`: expected 0, got 1 homeassistant/components/mqtt/discovery.py:544:13: error[invalid-assignment] Invalid subscript assignment with key of type `tuple[str, str]` and value of type `dict[Unknown | str, Unknown | (() -> None) | deque[Unknown]]` on object of type `dict[tuple[str, str], PendingDiscovered]` homeassistant/components/mqtt/entity.py:382:17: error[no-matching-overload] No overload of bound method `update` matches arguments homeassistant/components/mqtt/entity.py:383:17: error[no-matching-overload] No overload of bound method `update` matches arguments @@ -2554,6 +2548,7 @@ homeassistant/components/mystrom/sensor.py:63:29: error[invalid-assignment] Obje homeassistant/components/mystrom/sensor.py:91:25: error[invalid-argument-type] Invalid argument to key "identifiers" with declared type `set[tuple[str, str]]` on TypedDict `DeviceInfo`: value of type `set[Unknown | tuple[str, str | None]]` homeassistant/components/nad/media_player.py:5:6: error[unresolved-import] Cannot resolve imported module `nad_receiver` homeassistant/components/nasweb/sensor.py:155:41: error[unsupported-operator] Operator `in` is not supported for types `Unknown` and `None`, in comparing `(Unknown & ~None) | str` with `list[str] | None` +homeassistant/components/neato/api.py:31:9: error[invalid-method-override] Invalid override of method `refresh_tokens`: Definition is incompatible with `OAuthSession.refresh_tokens` homeassistant/components/neato/vacuum.py:298:13: error[invalid-assignment] Cannot assign to a subscript on an object of type `None` homeassistant/components/neato/vacuum.py:299:13: error[invalid-assignment] Cannot assign to a subscript on an object of type `None` homeassistant/components/neato/vacuum.py:300:13: error[invalid-assignment] Cannot assign to a subscript on an object of type `None` @@ -2616,7 +2611,6 @@ homeassistant/components/nmap_tracker/__init__.py:430:50: error[invalid-argument homeassistant/components/nmap_tracker/__init__.py:432:54: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `(Unknown & ~AlwaysFalsy) | str | None` homeassistant/components/nmbs/sensor.py:272:19: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/noaa_tides/sensor.py:9:8: error[unresolved-import] Cannot resolve imported module `noaa_coops` -homeassistant/components/noaa_tides/sensor.py:75:12: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/nobo_hub/config_flow.py:169:38: warning[possibly-missing-attribute] Attribute `items` may be missing on object of type `dict[str, Any] | None` homeassistant/components/notify_events/notify.py:76:61: error[invalid-argument-type] Argument to bound method `add_image_from_url` is incorrect: Expected `str`, found `None | Unknown` homeassistant/components/notify_events/notify.py:76:72: error[invalid-argument-type] Argument to bound method `add_image_from_url` is incorrect: Expected `str`, found `None | Unknown` @@ -2634,8 +2628,6 @@ homeassistant/components/nsw_fuel_station/__init__.py:64:13: error[invalid-argum homeassistant/components/nsw_rural_fire_service_feed/geo_location.py:166:16: error[invalid-return-type] Return type does not match returned value: expected `NswRuralFireServiceIncidentsFeedEntry | None`, found `Unknown | None | FeedEntry` homeassistant/components/nsw_rural_fire_service_feed/geo_location.py:249:31: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/nsw_rural_fire_service_feed/geo_location.py:250:32: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method -homeassistant/components/nuheat/__init__.py:42:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/nuheat/__init__.py:44:12: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/nuki/binary_sensor.py:60:38: warning[possibly-missing-attribute] Attribute `is_door_sensor_activated` may be missing on object of type `Unknown | NukiDevice` homeassistant/components/nuki/binary_sensor.py:65:16: warning[possibly-missing-attribute] Attribute `door_sensor_state` may be missing on object of type `Unknown | NukiDevice` homeassistant/components/nuki/binary_sensor.py:70:16: warning[possibly-missing-attribute] Attribute `door_sensor_state_name` may be missing on object of type `Unknown | NukiDevice` @@ -2649,10 +2641,6 @@ homeassistant/components/nws/__init__.py:134:9: error[invalid-argument-type] Arg homeassistant/components/nws/config_flow.py:45:12: error[invalid-return-type] Return type does not match returned value: expected `dict[str, str]`, found `dict[str, str | None]` homeassistant/components/nws/weather.py:323:31: error[invalid-argument-type] Argument to bound method `_forecast` is incorrect: Expected `list[dict[str, Any]]`, found `Unknown | list[dict[str, Any]] | None` homeassistant/components/nws/weather.py:328:31: error[invalid-argument-type] Argument to bound method `_forecast` is incorrect: Expected `list[dict[str, Any]]`, found `Unknown | list[dict[str, Any]] | None` -homeassistant/components/nx584/alarm_control_panel.py:62:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/nx584/alarm_control_panel.py:108:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/nx584/binary_sensor.py:64:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/nx584/binary_sensor.py:157:20: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/oasa_telematics/sensor.py:9:8: error[unresolved-import] Cannot resolve imported module `oasatelematics` homeassistant/components/oasa_telematics/sensor.py:120:34: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/oasa_telematics/sensor.py:121:33: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method @@ -2663,15 +2651,13 @@ homeassistant/components/obihai/connectivity.py:70:9: error[invalid-assignment] homeassistant/components/octoprint/config_flow.py:158:40: warning[possibly-missing-attribute] Attribute `upnp_uuid` may be missing on object of type `DiscoverySettings | None` homeassistant/components/octoprint/sensor.py:31:9: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `(OctoprintPrinterInfo & ~AlwaysTruthy) | (PrinterState & ~AlwaysTruthy) | (PrinterFlags & ~AlwaysTruthy) | bool` homeassistant/components/oem/climate.py:7:6: error[unresolved-import] Cannot resolve imported module `oemthermostat` -homeassistant/components/ohmconnect/sensor.py:87:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/ollama/ai_task.py:60:16: warning[possibly-missing-attribute] Attribute `content` may be missing on object of type `SystemContent | UserContent | AssistantContent | ToolResultContent` -homeassistant/components/ollama/entity.py:66:16: error[unresolved-attribute] Module `json` has no member `decoder` homeassistant/components/ombi/__init__.py:5:8: error[unresolved-import] Cannot resolve imported module `pyombi` homeassistant/components/ombi/sensor.py:8:6: error[unresolved-import] Cannot resolve imported module `pyombi` homeassistant/components/ondilo_ico/coordinator.py:181:55: error[invalid-argument-type] Argument to bound method `get_last_pool_measures` is incorrect: Expected `int`, found `Unknown | str` homeassistant/components/onedrive/backup.py:92:17: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@handle_backup_errors]` has no attribute `__name__` homeassistant/components/onedrive/backup.py:100:17: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@handle_backup_errors]` has no attribute `__name__` -homeassistant/components/onewire/onewirehub.py:47:31: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 2 +homeassistant/components/onewire/onewirehub.py:47:42: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 2 homeassistant/components/onvif/camera.py:182:17: error[invalid-argument-type] Argument to function `async_aiohttp_proxy_stream` is incorrect: Expected `StreamReader`, found `StreamReader` homeassistant/components/onvif/device.py:189:20: error[call-non-callable] Object of type `None` is not callable homeassistant/components/onvif/device.py:480:15: error[call-non-callable] Object of type `None` is not callable @@ -2775,11 +2761,11 @@ homeassistant/components/openai_conversation/entity.py:603:39: error[invalid-ass homeassistant/components/openai_conversation/entity.py:603:39: error[invalid-assignment] Invalid assignment to key "content" with declared type `Iterable[Content]` on TypedDict `ResponseReasoningItemParam`: value of type `list[Unknown | dict[Unknown | str, Unknown | str]]` homeassistant/components/openai_conversation/entity.py:603:39: error[invalid-assignment] Invalid assignment to key "content" with declared type `str | list[ResponseInputTextParam | ResponseInputImageParam | ResponseInputFileParam]` on TypedDict `EasyInputMessageParam`: value of type `list[Unknown | dict[Unknown | str, Unknown | str]]` homeassistant/components/openevse/sensor.py:7:8: error[unresolved-import] Cannot resolve imported module `openevsewifi` -homeassistant/components/openhardwaremonitor/sensor.py:162:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/openhome/media_player.py:71:6: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/openhome/media_player.py:71:44: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/openhome/media_player.py:76:15: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/openhome/media_player.py:77:10: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 +homeassistant/components/openhome/media_player.py:71:38: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/openhome/media_player.py:71:82: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/openhome/media_player.py:76:47: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/openhome/media_player.py:77:48: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/openhome/media_player.py:88:55: error[unresolved-attribute] Object of type `(...) -> Awaitable[Unknown]` has no attribute `__name__` homeassistant/components/opensensemap/air_quality.py:8:6: error[unresolved-import] Cannot resolve imported module `opensensemap_api` homeassistant/components/opensensemap/air_quality.py:9:6: error[unresolved-import] Cannot resolve imported module `opensensemap_api.exceptions` homeassistant/components/openweathermap/coordinator.py:190:25: error[invalid-argument-type] Invalid argument to key "temperature" with declared type `None` on TypedDict `Forecast`: value of type `Decimal` @@ -2835,8 +2821,8 @@ homeassistant/components/panasonic_viera/__init__.py:198:33: warning[possibly-mi homeassistant/components/peco/__init__.py:73:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> Awaitable[dict[str, Any]]) | None`, found `def async_update_outage_data() -> CoroutineType[Any, Any, PECOCoordinatorData]` homeassistant/components/peco/__init__.py:103:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> Awaitable[dict[str, Any]]) | None`, found `def async_update_meter_data() -> CoroutineType[Any, Any, bool]` homeassistant/components/pencom/switch.py:8:6: error[unresolved-import] Cannot resolve imported module `pencompy.pencompy` -homeassistant/components/persistent_notification/__init__.py:54:43: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 2 -homeassistant/components/person/__init__.py:238:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventEntityRegistryUpdatedData]` +homeassistant/components/persistent_notification/__init__.py:55:5: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 2 +homeassistant/components/person/__init__.py:238:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` homeassistant/components/person/__init__.py:239:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `bound method Self@async_load._entity_registry_updated(event: Event[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]) -> CoroutineType[Any, Any, None]` homeassistant/components/person/__init__.py:240:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `bound method Self@async_load._entity_registry_filter(event_data: _EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update) -> bool` homeassistant/components/pglab/__init__.py:48:38: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `str | bytes | bytearray` @@ -2871,9 +2857,6 @@ homeassistant/components/pi_hole/update.py:26:27: error[invalid-type-form] Varia homeassistant/components/pi_hole/update.py:94:14: error[invalid-type-form] Variable of type `def Hole(*args, *, version=Literal[6], **kwargs) -> Unknown` is not allowed in a type expression homeassistant/components/picnic/__init__.py:30:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Any | None` homeassistant/components/picnic/__init__.py:31:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Any | None` -homeassistant/components/picnic/config_flow.py:63:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/ping/helpers.py:113:20: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/ping/helpers.py:114:20: error[unresolved-attribute] Module `asyncio` has no member `subprocess` homeassistant/components/plant/__init__.py:409:16: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Unknown | None | deque[Unknown]` homeassistant/components/plant/__init__.py:410:22: warning[possibly-missing-attribute] Attribute `popleft` may be missing on object of type `Unknown | None | deque[Unknown]` homeassistant/components/plant/__init__.py:412:9: warning[possibly-missing-attribute] Attribute `append` may be missing on object of type `Unknown | None | deque[Unknown]` @@ -2972,8 +2955,8 @@ homeassistant/components/plex/server.py:218:31: warning[possibly-missing-attribu homeassistant/components/plex/server.py:243:25: warning[possibly-missing-attribute] Attribute `version` may be missing on object of type `Unknown | None | PlexServer` homeassistant/components/plex/server.py:316:13: warning[possibly-missing-attribute] Attribute `clients` may be missing on object of type `Unknown | None | PlexServer` homeassistant/components/plex/server.py:317:13: warning[possibly-missing-attribute] Attribute `sessions` may be missing on object of type `Unknown | None | PlexServer` -homeassistant/components/plex/server.py:348:16: error[unresolved-attribute] Module `plexapi` has no member `exceptions` -homeassistant/components/plex/server.py:355:13: error[unresolved-attribute] Module `plexapi` has no member `exceptions` +homeassistant/components/plex/server.py:348:16: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `plexapi` +homeassistant/components/plex/server.py:355:13: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `plexapi` homeassistant/components/plex/server.py:403:27: warning[possibly-missing-attribute] Attribute `createToken` may be missing on object of type `Unknown | None | PlexServer` homeassistant/components/plex/server.py:563:16: warning[possibly-missing-attribute] Attribute `friendlyName` may be missing on object of type `Unknown | None | PlexServer` homeassistant/components/plex/server.py:568:16: warning[possibly-missing-attribute] Attribute `machineIdentifier` may be missing on object of type `Unknown | None | PlexServer` @@ -2986,6 +2969,7 @@ homeassistant/components/plex/server.py:598:16: warning[possibly-missing-attribu homeassistant/components/plex/server.py:602:16: warning[possibly-missing-attribute] Attribute `playlist` may be missing on object of type `Unknown | None | PlexServer` homeassistant/components/plex/server.py:606:16: warning[possibly-missing-attribute] Attribute `playlists` may be missing on object of type `Unknown | None | PlexServer` homeassistant/components/plex/server.py:622:16: warning[possibly-missing-attribute] Attribute `fetchItem` may be missing on object of type `Unknown | None | PlexServer` +homeassistant/components/plugwise/config_flow.py:183:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/pocketcasts/sensor.py:8:6: error[unresolved-import] Cannot resolve imported module `pycketcasts` homeassistant/components/powerwall/__init__.py:229:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> Awaitable[dict[str, Any]]) | None`, found `bound method PowerwallDataManager.async_update_data() -> CoroutineType[Any, Any, PowerwallData]` homeassistant/components/powerwall/__init__.py:236:43: error[invalid-assignment] Invalid assignment to key "coordinator" with declared type `DataUpdateCoordinator[PowerwallData] | None` on TypedDict `PowerwallRuntimeData`: value of type `DataUpdateCoordinator[dict[str, Any]]` @@ -2994,7 +2978,7 @@ homeassistant/components/progettihwsw/switch.py:85:16: error[invalid-argument-ty homeassistant/components/proliphix/climate.py:7:8: error[unresolved-import] Cannot resolve imported module `proliphix` homeassistant/components/prometheus/__init__.py:152:21: error[invalid-argument-type] Argument to bound method `listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventStateChangedData]` homeassistant/components/prometheus/__init__.py:152:42: error[invalid-argument-type] Argument to bound method `listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `bound method PrometheusMetrics.handle_state_changed_event(event: Event[EventStateChangedData]) -> None` -homeassistant/components/prometheus/__init__.py:154:9: error[invalid-argument-type] Argument to bound method `listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventEntityRegistryUpdatedData]` +homeassistant/components/prometheus/__init__.py:154:9: error[invalid-argument-type] Argument to bound method `listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` homeassistant/components/prometheus/__init__.py:155:9: error[invalid-argument-type] Argument to bound method `listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `bound method PrometheusMetrics.handle_entity_registry_updated(event: Event[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]) -> None` homeassistant/components/prometheus/__init__.py:291:34: error[invalid-key] Unknown key "changes" for TypedDict `_EventEntityRegistryUpdatedData_CreateRemove`: Unknown key "changes" homeassistant/components/proximity/coordinator.py:125:63: error[invalid-key] Unknown key "changes" for TypedDict `_EventEntityRegistryUpdatedData_CreateRemove`: Unknown key "changes" @@ -3005,7 +2989,7 @@ homeassistant/components/proxmoxve/common.py:8:6: error[unresolved-import] Canno homeassistant/components/prusalink/config_flow.py:48:65: error[invalid-key] Unknown key "server" for TypedDict `VersionInfo`: Unknown key "server" homeassistant/components/prusalink/config_flow.py:79:30: error[invalid-key] Unknown key "hostname" for TypedDict `VersionInfo`: Unknown key "hostname" homeassistant/components/prusalink/coordinator.py:55:55: error[invalid-argument-type] Argument to bound method `_get_update_interval` is incorrect: Argument type `None` does not satisfy constraints (`PrinterStatus`, `LegacyPrinterStatus`, `JobInfo`) of type variable `T` -homeassistant/components/prusalink/coordinator.py:118:29: error[invalid-argument-type] Argument to class `PrusaLinkUpdateCoordinator` is incorrect: Expected `PrinterStatus | LegacyPrinterStatus | JobInfo`, found `PrinterInfo` +homeassistant/components/prusalink/coordinator.py:118:56: error[invalid-type-arguments] Type `PrinterInfo` does not satisfy constraints `PrinterStatus`, `LegacyPrinterStatus`, `JobInfo` of type variable `T@PrusaLinkUpdateCoordinator` homeassistant/components/pulseaudio_loopback/switch.py:8:6: error[unresolved-import] Cannot resolve imported module `pulsectl` homeassistant/components/pushbullet/notify.py:116:51: error[invalid-argument-type] Argument to bound method `_push_data` is incorrect: Expected `Pushbullet`, found `Device | Channel` homeassistant/components/pushsafer/notify.py:88:57: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Unknown | None` @@ -3034,13 +3018,13 @@ homeassistant/components/raspyrfm/switch.py:15:6: error[unresolved-import] Canno homeassistant/components/recollect_waste/__init__.py:60:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> Awaitable[dict[str, Any]]) | None`, found `def async_get_pickup_events() -> CoroutineType[Any, Any, list[PickupEvent]]` homeassistant/components/recorder/core.py:284:13: error[call-non-callable] Object of type `object` is not callable homeassistant/components/recorder/entity_registry.py:29:36: error[invalid-key] Unknown key "old_entity_id" for TypedDict `_EventEntityRegistryUpdatedData_CreateRemove`: Unknown key "old_entity_id" -homeassistant/components/recorder/entity_registry.py:52:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventEntityRegistryUpdatedData]` -homeassistant/components/recorder/entity_registry.py:53:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _async_entity_id_changed(event: Event[EventEntityRegistryUpdatedData]) -> None` -homeassistant/components/recorder/entity_registry.py:54:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def entity_registry_changed_filter(event_data: EventEntityRegistryUpdatedData) -> bool` +homeassistant/components/recorder/entity_registry.py:52:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` +homeassistant/components/recorder/entity_registry.py:53:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _async_entity_id_changed(event: Event[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]) -> None` +homeassistant/components/recorder/entity_registry.py:54:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def entity_registry_changed_filter(event_data: _EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update) -> bool` homeassistant/components/recorder/executor.py:55:19: error[invalid-argument-type] Argument to bound method `put` is incorrect: Expected `_WorkItem[Any]`, found `None` homeassistant/components/recorder/history/__init__.py:911:53: error[unresolved-reference] Name `prev_state` used when not defined homeassistant/components/recorder/history/__init__.py:927:49: error[unresolved-reference] Name `prev_state` used when not defined -homeassistant/components/recorder/migration.py:758:34: error[invalid-assignment] Object of type `list[dict[Unknown | str, Unknown | ForeignKeyConstraint] | Unknown]` is not assignable to `list[_FKAlterDict]` +homeassistant/components/recorder/migration.py:758:34: error[invalid-assignment] Object of type `list[dict[Unknown | str, Unknown | ForeignKeyConstraint | list[str]] | Unknown]` is not assignable to `list[_FKAlterDict]` homeassistant/components/recorder/statistics.py:555:13: error[invalid-assignment] Invalid subscript assignment with key of type `Any` and value of type `dict[Unknown | str, Unknown | int | float]` on object of type `dict[int, StatisticDataTimestamp]` homeassistant/components/recorder/statistics.py:579:17: error[invalid-assignment] Invalid subscript assignment with key of type `Any` and value of type `dict[Unknown | str, Unknown | int | float]` on object of type `dict[int, StatisticDataTimestamp]` homeassistant/components/recorder/statistics.py:2406:12: error[invalid-return-type] Return type does not match returned value: expected `list[StatisticsRow]`, found `list[dict[Unknown | str, Unknown | None | int | float] | Unknown]` @@ -3049,29 +3033,29 @@ homeassistant/components/recorder/statistics.py:2440:12: error[invalid-return-ty homeassistant/components/recorder/statistics.py:2458:12: error[invalid-return-type] Return type does not match returned value: expected `list[StatisticsRow]`, found `list[dict[Unknown | str, Unknown | None | int | float] | Unknown]` homeassistant/components/recorder/util.py:386:10: error[unresolved-import] Cannot resolve imported module `MySQLdb.constants` homeassistant/components/recorder/util.py:387:10: error[unresolved-import] Cannot resolve imported module `MySQLdb.converters` -homeassistant/components/recorder/util.py:587:16: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/recorder/util.py:587:38: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/recorder/util.py:593:24: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/recorder/util.py:593:48: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/recorder/util.py:601:16: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/recorder/util.py:601:45: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/recorder/util.py:607:24: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/recorder/util.py:607:55: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/recorder/util.py:614:10: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/recorder/util.py:615:6: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/recorder/util.py:643:16: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/recorder/util.py:643:36: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/recorder/util.py:653:14: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/recorder/util.py:654:10: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/recorder/util.py:664:16: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/recorder/util.py:664:43: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/recorder/util.py:674:14: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/recorder/util.py:675:10: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/recorder/util.py:684:10: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/recorder/util.py:688:6: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 +homeassistant/components/recorder/util.py:587:30: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/recorder/util.py:587:52: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/recorder/util.py:593:38: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/recorder/util.py:593:62: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/recorder/util.py:601:37: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/recorder/util.py:601:66: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/recorder/util.py:607:45: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/recorder/util.py:607:76: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/recorder/util.py:614:30: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/recorder/util.py:615:26: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/recorder/util.py:643:30: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/recorder/util.py:643:50: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/recorder/util.py:653:28: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/recorder/util.py:654:24: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/recorder/util.py:664:37: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/recorder/util.py:664:64: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/recorder/util.py:674:35: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/recorder/util.py:675:31: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/recorder/util.py:684:30: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/recorder/util.py:688:26: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 homeassistant/components/recswitch/switch.py:8:6: error[unresolved-import] Cannot resolve imported module `pyrecswitch` -homeassistant/components/reddit/sensor.py:88:12: error[unresolved-attribute] Module `praw` has no member `exceptions` -homeassistant/components/reddit/sensor.py:156:16: error[unresolved-attribute] Module `praw` has no member `exceptions` +homeassistant/components/reddit/sensor.py:88:12: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `praw` +homeassistant/components/reddit/sensor.py:156:16: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `praw` homeassistant/components/refoss/sensor.py:179:17: warning[possibly-missing-attribute] Attribute `get_value` may be missing on object of type `Unknown | BaseDevice` homeassistant/components/refoss/switch.py:65:16: warning[possibly-missing-attribute] Attribute `is_on` may be missing on object of type `Unknown | BaseDevice` homeassistant/components/refoss/switch.py:69:15: warning[possibly-missing-attribute] Attribute `async_turn_on` may be missing on object of type `Unknown | BaseDevice` @@ -3081,7 +3065,6 @@ homeassistant/components/rehlko/__init__.py:45:39: error[invalid-argument-type] homeassistant/components/rejseplanen/sensor.py:14:8: error[unresolved-import] Cannot resolve imported module `rjpl` homeassistant/components/remember_the_milk/__init__.py:127:51: error[invalid-argument-type] Argument to bound method `set_token` is incorrect: Expected `str`, found `Unknown | None` homeassistant/components/remember_the_milk/__init__.py:135:13: error[invalid-argument-type] Argument to function `_create_instance` is incorrect: Expected `str`, found `Unknown | None` -homeassistant/components/remote_rpi_gpio/binary_sensor.py:104:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/renson/fan.py:197:62: error[invalid-argument-type] Argument to bound method `get_field_value` is incorrect: Expected `str`, found `FieldEnum` homeassistant/components/renson/fan.py:241:13: error[invalid-argument-type] Argument to bound method `set_pollution` is incorrect: Expected `bool`, found `str` homeassistant/components/renson/fan.py:242:13: error[invalid-argument-type] Argument to bound method `set_pollution` is incorrect: Expected `bool`, found `int` @@ -3101,8 +3084,8 @@ homeassistant/components/rflink/entity.py:292:13: error[unresolved-attribute] Ob homeassistant/components/rfxtrx/__init__.py:192:38: error[unresolved-attribute] Object of type `RFXtrxEvent & ~ConnectionLost` has no attribute `data` homeassistant/components/rfxtrx/__init__.py:234:41: error[unresolved-attribute] Object of type `RFXtrxEvent` has no attribute `data` homeassistant/components/rfxtrx/__init__.py:239:39: error[unresolved-attribute] Object of type `RFXtrxEvent` has no attribute `data` -homeassistant/components/rfxtrx/__init__.py:276:31: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventDeviceRegistryUpdatedData]` -homeassistant/components/rfxtrx/__init__.py:276:65: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _updated_device(event: Event[EventDeviceRegistryUpdatedData]) -> None` +homeassistant/components/rfxtrx/__init__.py:276:31: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]` +homeassistant/components/rfxtrx/__init__.py:276:65: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _updated_device(event: Event[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]) -> None` homeassistant/components/rfxtrx/cover.py:52:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `RFXtrxEvent`, found `RFXtrxEvent | None` homeassistant/components/rfxtrx/cover.py:70:9: error[invalid-parameter-default] Default value of type `None` is not assignable to annotated parameter type `RFXtrxEvent` homeassistant/components/rfxtrx/cover.py:104:36: warning[possibly-missing-attribute] Attribute `send_up05sec` may be missing on object of type `RollerTrolDevice | RfyDevice | LightingDevice` @@ -3118,7 +3101,9 @@ homeassistant/components/rfxtrx/sensor.py:265:34: error[unresolved-attribute] Ob homeassistant/components/rfxtrx/sensor.py:305:31: error[invalid-argument-type] Argument to bound method `_apply_event` is incorrect: Expected `RFXtrxEvent`, found `RFXtrxEvent | None` homeassistant/components/rfxtrx/sensor.py:312:17: error[unresolved-attribute] Object of type `RFXtrxEvent & ~AlwaysFalsy` has no attribute `values` homeassistant/components/rfxtrx/sensor.py:321:47: error[unresolved-attribute] Object of type `RFXtrxEvent` has no attribute `values` +homeassistant/components/rfxtrx/siren.py:164:9: error[invalid-method-override] Invalid override of method `_apply_event`: Definition is incompatible with `RfxtrxEntity._apply_event` homeassistant/components/rfxtrx/siren.py:179:31: error[invalid-argument-type] Argument to bound method `_apply_event` is incorrect: Expected `ControlEvent`, found `RFXtrxEvent` +homeassistant/components/rfxtrx/siren.py:226:9: error[invalid-method-override] Invalid override of method `_apply_event`: Definition is incompatible with `RfxtrxEntity._apply_event` homeassistant/components/rfxtrx/siren.py:244:31: error[invalid-argument-type] Argument to bound method `_apply_event` is incorrect: Expected `SensorEvent`, found `RFXtrxEvent` homeassistant/components/rfxtrx/switch.py:138:36: error[unresolved-attribute] Object of type `RFXtrxDevice` has no attribute `send_command` homeassistant/components/rfxtrx/switch.py:140:36: error[unresolved-attribute] Object of type `RFXtrxDevice` has no attribute `send_on` @@ -3142,10 +3127,10 @@ homeassistant/components/roborock/vacuum.py:200:16: error[invalid-return-type] R homeassistant/components/rocketchat/notify.py:8:6: error[unresolved-import] Cannot resolve imported module `rocketchat_API.APIExceptions.RocketExceptions` homeassistant/components/rocketchat/notify.py:12:6: error[unresolved-import] Cannot resolve imported module `rocketchat_API.rocketchat` homeassistant/components/roku/browse_media.py:252:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool`, found `Literal[False, ""] | Unknown` -homeassistant/components/roku/helpers.py:31:16: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/roku/helpers.py:31:46: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/roku/helpers.py:35:15: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 -homeassistant/components/roku/helpers.py:36:10: error[too-many-positional-arguments] Too many positional arguments: expected 1, got 2 +homeassistant/components/roku/helpers.py:31:40: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/roku/helpers.py:31:76: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/roku/helpers.py:35:39: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 +homeassistant/components/roku/helpers.py:36:40: error[invalid-type-arguments] Too many type arguments: expected 1, got 2 homeassistant/components/roomba/vacuum.py:200:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[int, int]`, found `tuple[Unknown | int | float, Unknown]` homeassistant/components/roon/media_browser.py:94:24: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | str | bool | None` homeassistant/components/roon/media_browser.py:94:24: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | str | bool | None` @@ -3181,6 +3166,7 @@ homeassistant/components/samsungtv/bridge.py:454:41: error[invalid-argument-type homeassistant/components/samsungtv/bridge.py:454:41: error[invalid-argument-type] Argument to bound method `is_alive` is incorrect: Expected `SamsungTVEncryptedWSAsyncRemote`, found `_RemoteT@SamsungTVWSBaseBridge` homeassistant/components/samsungtv/bridge.py:472:23: error[invalid-argument-type] Argument to bound method `close` is incorrect: Expected `SamsungTVWSAsyncConnection`, found `_RemoteT@SamsungTVWSBaseBridge` homeassistant/components/samsungtv/bridge.py:472:23: error[invalid-argument-type] Argument to bound method `close` is incorrect: Expected `SamsungTVEncryptedWSAsyncRemote`, found `_RemoteT@SamsungTVWSBaseBridge` +homeassistant/components/samsungtv/config_flow.py:442:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/schluter/__init__.py:6:6: error[unresolved-import] Cannot resolve imported module `schluter.api` homeassistant/components/schluter/__init__.py:7:6: error[unresolved-import] Cannot resolve imported module `schluter.authenticator` homeassistant/components/scrape/sensor.py:157:42: error[invalid-argument-type] Argument to function `__init__` is incorrect: Expected `DataUpdateCoordinator[dict[str, Any]]`, found `ScrapeCoordinator` @@ -3255,15 +3241,7 @@ homeassistant/components/seventeentrack/sensor.py:42:25: error[invalid-argument- homeassistant/components/seventeentrack/services.py:141:34: error[unresolved-attribute] Object of type `str & ~AlwaysFalsy` has no attribute `isoformat` homeassistant/components/sharkiq/coordinator.py:74:19: error[unsupported-operator] Operator `-` is unsupported between objects of type `Unknown | datetime | None` and `timedelta` homeassistant/components/sharkiq/vacuum.py:233:36: error[invalid-argument-type] Argument to bound method `async_set_property_value` is incorrect: Expected `str | int | Enum`, found `Unknown | PowerModes | None` -homeassistant/components/shell_command/__init__.py:73:24: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/shell_command/__init__.py:74:24: error[unresolved-attribute] Module `asyncio` has no member `subprocess` homeassistant/components/shell_command/__init__.py:80:47: error[invalid-argument-type] Argument to function `split` is incorrect: Expected `str | _ShlexInstream`, found `Any | None` -homeassistant/components/shell_command/__init__.py:85:24: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/shell_command/__init__.py:86:24: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/shelly/coordinator.py:203:15: error[invalid-argument-type] Argument to bound method `shutdown` is incorrect: Expected `BlockDevice`, found `_DeviceT@ShellyCoordinatorBase` -homeassistant/components/shelly/coordinator.py:203:15: error[invalid-argument-type] Argument to bound method `shutdown` is incorrect: Expected `RpcDevice`, found `_DeviceT@ShellyCoordinatorBase` -homeassistant/components/shelly/coordinator.py:214:19: error[invalid-argument-type] Argument to bound method `initialize` is incorrect: Expected `BlockDevice`, found `_DeviceT@ShellyCoordinatorBase` -homeassistant/components/shelly/coordinator.py:214:19: error[invalid-argument-type] Argument to bound method `initialize` is incorrect: Expected `RpcDevice`, found `_DeviceT@ShellyCoordinatorBase` homeassistant/components/shelly/entity.py:642:42: warning[possibly-missing-attribute] Attribute `split` may be missing on object of type `str | None` homeassistant/components/shelly/event.py:290:15: error[unresolved-attribute] Object of type `, ShellyRpcScriptEvent>` has no attribute `async_added_to_hass` homeassistant/components/shelly/light.py:226:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[int, int, int, int]`, found `tuple[@Todo, int]` @@ -3271,7 +3249,7 @@ homeassistant/components/shelly/light.py:400:16: error[invalid-return-type] Retu homeassistant/components/shelly/utils.py:288:13: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[IPv4Address]`, found `GeneratorType[IPv4Address | IPv6Address, None, None]` homeassistant/components/shodan/sensor.py:8:8: error[unresolved-import] Cannot resolve imported module `shodan` homeassistant/components/sia/hub.py:103:17: error[invalid-argument-type] Argument is incorrect: Expected `tuple[int, int]`, found `None | tuple[Literal[80], Literal[40]]` -homeassistant/components/sigfox/sensor.py:71:22: error[unresolved-attribute] Module `requests` has no member `auth` +homeassistant/components/sigfox/sensor.py:71:22: warning[possibly-missing-attribute] Submodule `auth` may not be available as an attribute on module `requests` homeassistant/components/sighthound/image_processing.py:141:44: error[invalid-argument-type] Argument to function `bbox_to_tf_style` is incorrect: Expected `int`, found `int | None` homeassistant/components/sighthound/image_processing.py:141:63: error[invalid-argument-type] Argument to function `bbox_to_tf_style` is incorrect: Expected `int`, found `int | None` homeassistant/components/simplefin/entity.py:43:16: error[invalid-return-type] Return type does not match returned value: expected `Account`, found `Unknown | Account | None` @@ -3367,28 +3345,28 @@ homeassistant/components/sonos/__init__.py:117:5: error[invalid-assignment] Obje homeassistant/components/sonos/__init__.py:118:5: error[unresolved-attribute] Unresolved attribute `EVENT_CACHE_TIMEOUT` on type ``. homeassistant/components/sonos/__init__.py:374:21: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown` and value of type `SonosAlarms | SonosFavorites` on object of type `dict[str, SonosAlarms]` homeassistant/components/sonos/__init__.py:374:21: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown` and value of type `SonosAlarms | SonosFavorites` on object of type `dict[str, SonosFavorites]` -homeassistant/components/sonos/helpers.py:46:16: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/sonos/helpers.py:46:40: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/sonos/helpers.py:52:16: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/sonos/helpers.py:52:40: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/sonos/helpers.py:57:16: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/sonos/helpers.py:57:40: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/sonos/helpers.py:60:26: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/components/sonos/helpers.py:60:52: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 +homeassistant/components/sonos/helpers.py:46:34: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/sonos/helpers.py:46:58: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/sonos/helpers.py:52:34: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/sonos/helpers.py:52:64: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/sonos/helpers.py:57:34: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/sonos/helpers.py:57:64: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/sonos/helpers.py:60:44: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/sonos/helpers.py:60:76: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/components/sonos/helpers.py:70:28: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__qualname__` +homeassistant/components/sonos/helpers.py:87:17: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__qualname__` homeassistant/components/sonos/media_browser.py:259:21: error[call-non-callable] Object of type `None` is not callable homeassistant/components/sonos/media_browser.py:285:31: error[invalid-argument-type] Argument to function `can_expand` is incorrect: Expected `DidlObject`, found `str` homeassistant/components/sonos/media_browser.py:304:21: error[call-non-callable] Object of type `None` is not callable homeassistant/components/sonos/media_browser.py:497:21: error[invalid-argument-type] Argument to function `get_thumbnail_url_full` is incorrect: Expected `MusicServiceItem | None`, found `DidlFavorite` homeassistant/components/sonos/media_player.py:381:22: error[unresolved-attribute] Object of type `DidlFavorite` has no attribute `resource_meta_data` -homeassistant/components/sonos/media_player.py:487:21: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[Unknown | str, Unknown | str | dict[str, Any]]` +homeassistant/components/sonos/media_player.py:487:21: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[str, str | Unknown | dict[str, Any]] & dict[Unknown | str, Unknown | str | dict[str, Any]]` homeassistant/components/sonos/speaker.py:131:13: error[invalid-assignment] Object of type `bound method Self@__init__.async_dispatch_event(event: Event) -> None` is not assignable to attribute `callback` on type `SubscriptionBase & ~AlwaysFalsy` homeassistant/components/sonos/speaker.py:337:22: error[unresolved-attribute] Object of type `SubscriptionBase` has no attribute `event_listener` -homeassistant/components/sonos/speaker.py:356:31: error[unresolved-attribute] Module `asyncio` has no member `exceptions` homeassistant/components/sonos/statistics.py:75:9: error[invalid-assignment] Invalid subscript assignment with key of type `Literal["soco:from_didl_string"]` and value of type `_CacheInfo` on object of type `dict[str, dict[str, int | float]]` homeassistant/components/sonos/statistics.py:76:9: error[invalid-assignment] Invalid subscript assignment with key of type `Literal["soco:parse_event_xml"]` and value of type `_CacheInfo` on object of type `dict[str, dict[str, int | float]]` homeassistant/components/sonos/switch.py:257:16: error[invalid-return-type] Return type does not match returned value: expected `Alarm`, found `Unknown | Alarm | None` homeassistant/components/sony_projector/switch.py:8:8: error[unresolved-import] Cannot resolve imported module `pysdcp` -homeassistant/components/soundtouch/__init__.py:139:12: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/soundtouch/media_player.py:120:16: warning[possibly-missing-attribute] Attribute `actual` may be missing on object of type `Unknown | None` homeassistant/components/soundtouch/media_player.py:136:16: warning[possibly-missing-attribute] Attribute `source` may be missing on object of type `Unknown | None` homeassistant/components/soundtouch/media_player.py:141:16: warning[possibly-missing-attribute] Attribute `muted` may be missing on object of type `Unknown | None` @@ -3410,36 +3388,37 @@ homeassistant/components/squeezebox/browse_media.py:162:43: error[invalid-argume homeassistant/components/squeezebox/browse_media.py:174:43: error[invalid-argument-type] Argument to bound method `async_query` is incorrect: Expected `str`, found `Unknown | str | int` homeassistant/components/squeezebox/browse_media.py:266:20: warning[redundant-cast] Value is already of type `str` homeassistant/components/squeezebox/browse_media.py:274:15: warning[redundant-cast] Value is already of type `str` +homeassistant/components/squeezebox/browse_media.py:392:15: warning[possibly-missing-attribute] Attribute `get` may be missing on object of type `Divergent | None` homeassistant/components/squeezebox/coordinator.py:46:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | str | None` homeassistant/components/squeezebox/media_player.py:422:27: error[not-iterable] Object of type `Unknown | list[str] | None` may not be iterable homeassistant/components/squeezebox/media_player.py:581:50: error[invalid-argument-type] Argument to bound method `set_announce_volume` is incorrect: Expected `int | None`, found `int | float | None` homeassistant/components/squeezebox/media_player.py:889:17: error[invalid-argument-type] Argument to function `safe_library_call` is incorrect: Expected `(...) -> Awaitable[Any]`, found `Unknown | (bound method Player.generate_image_url_from_track_id(track_id: int) -> str)` homeassistant/components/squeezebox/switch.py:150:16: warning[redundant-cast] Value is already of type `bool` homeassistant/components/ssdp/common.py:18:42: warning[possibly-missing-attribute] Attribute `scope_id` may be missing on object of type `IPv4Address | IPv6Address` -homeassistant/components/ssdp/scanner.py:63:28: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 homeassistant/components/ssdp/scanner.py:64:5: error[invalid-type-form] List literals are not allowed in this context in a type expression +homeassistant/components/ssdp/scanner.py:64:37: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/components/ssdp/scanner.py:263:24: warning[possibly-missing-attribute] Attribute `scope_id` may be missing on object of type `IPv4Address | IPv6Address` homeassistant/components/ssdp/scanner.py:268:25: warning[possibly-missing-attribute] Attribute `scope_id` may be missing on object of type `IPv4Address | IPv6Address` homeassistant/components/ssdp/server.py:174:28: warning[possibly-missing-attribute] Attribute `scope_id` may be missing on object of type `IPv4Address | IPv6Address` homeassistant/components/ssdp/server.py:179:29: warning[possibly-missing-attribute] Attribute `scope_id` may be missing on object of type `IPv4Address | IPv6Address` homeassistant/components/starlingbank/sensor.py:9:6: error[unresolved-import] Cannot resolve imported module `starlingbank` -homeassistant/components/starlingbank/sensor.py:72:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/statsd/__init__.py:91:21: error[invalid-argument-type] Argument to bound method `listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventStateChangedData]` -homeassistant/components/steam_online/config_flow.py:30:5: error[unresolved-attribute] Module `steam` has no member `api` -homeassistant/components/steam_online/config_flow.py:31:17: error[unresolved-attribute] Module `steam` has no member `api` -homeassistant/components/steam_online/config_flow.py:61:21: error[unresolved-attribute] Module `steam` has no member `api` -homeassistant/components/steam_online/config_flow.py:61:42: error[unresolved-attribute] Module `steam` has no member `api` -homeassistant/components/steam_online/config_flow.py:159:16: error[unresolved-attribute] Module `steam` has no member `api` -homeassistant/components/steam_online/config_flow.py:176:21: error[unresolved-attribute] Module `steam` has no member `api` -homeassistant/components/steam_online/config_flow.py:182:16: error[unresolved-attribute] Module `steam` has no member `api` -homeassistant/components/steam_online/coordinator.py:40:9: error[unresolved-attribute] Module `steam` has no member `api` -homeassistant/components/steam_online/coordinator.py:47:35: error[unresolved-attribute] Module `steam` has no member `api` -homeassistant/components/steam_online/coordinator.py:48:37: error[unresolved-attribute] Module `steam` has no member `api` +homeassistant/components/steam_online/config_flow.py:30:5: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `steam` +homeassistant/components/steam_online/config_flow.py:31:17: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `steam` +homeassistant/components/steam_online/config_flow.py:61:21: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `steam` +homeassistant/components/steam_online/config_flow.py:61:42: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `steam` +homeassistant/components/steam_online/config_flow.py:159:16: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `steam` +homeassistant/components/steam_online/config_flow.py:176:21: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `steam` +homeassistant/components/steam_online/config_flow.py:182:16: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `steam` +homeassistant/components/steam_online/coordinator.py:40:9: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `steam` +homeassistant/components/steam_online/coordinator.py:47:35: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `steam` +homeassistant/components/steam_online/coordinator.py:48:37: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `steam` homeassistant/components/steam_online/coordinator.py:51:23: warning[possibly-missing-attribute] Attribute `GetOwnedGames` may be missing on object of type `(_interface_method & ~AlwaysFalsy) | Unknown` homeassistant/components/steam_online/coordinator.py:57:20: warning[possibly-missing-attribute] Attribute `GetPlayerSummaries` may be missing on object of type `(_interface_method & ~AlwaysFalsy) | Unknown` homeassistant/components/steam_online/coordinator.py:64:20: warning[possibly-missing-attribute] Attribute `GetSteamLevel` may be missing on object of type `(_interface_method & ~AlwaysFalsy) | Unknown` -homeassistant/components/steam_online/coordinator.py:73:17: error[unresolved-attribute] Module `steam` has no member `api` -homeassistant/components/steam_online/coordinator.py:73:38: error[unresolved-attribute] Module `steam` has no member `api` +homeassistant/components/steam_online/coordinator.py:73:17: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `steam` +homeassistant/components/steam_online/coordinator.py:73:38: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `steam` +homeassistant/components/steamist/config_flow.py:96:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/stiebel_eltron/climate.py:169:36: error[invalid-argument-type] Argument to bound method `set_operation` is incorrect: Expected `str`, found `Unknown | str | None` homeassistant/components/stiebel_eltron/climate.py:182:36: error[invalid-argument-type] Argument to bound method `set_operation` is incorrect: Expected `str`, found `Unknown | str | None` homeassistant/components/stream/worker.py:389:13: error[invalid-assignment] Object of type `int | Unknown | Fraction | float` is not assignable to attribute `_part_start_dts` of type `int | float` @@ -3451,10 +3430,6 @@ homeassistant/components/swiss_hydrological_data/sensor.py:8:6: error[unresolved homeassistant/components/swiss_hydrological_data/sensor.py:106:19: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/swiss_public_transport/coordinator.py:114:23: error[invalid-argument-type] Invalid argument to key "start" with declared type `str` on TypedDict `DataConnection`: value of type `Unknown | None` homeassistant/components/swiss_public_transport/coordinator.py:115:29: error[invalid-argument-type] Invalid argument to key "destination" with declared type `str` on TypedDict `DataConnection`: value of type `Unknown | None` -homeassistant/components/swisscom/device_tracker.py:94:13: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/swisscom/device_tracker.py:95:13: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/swisscom/device_tracker.py:96:13: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/swisscom/device_tracker.py:106:37: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/switchbot/__init__.py:217:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `SwitchbotDevice`, found `Unknown | SwitchbotCeilingLight | SwitchbotCurtain | ... omitted 14 union elements` homeassistant/components/switchbot/__init__.py:217:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `SwitchbotDevice`, found `Unknown | SwitchbotCeilingLight | SwitchbotCurtain | ... omitted 14 union elements` homeassistant/components/switchbot/climate.py:75:16: error[unresolved-attribute] Object of type `SwitchbotDevice` has no attribute `min_temperature` @@ -3469,11 +3444,11 @@ homeassistant/components/switchbot/climate.py:122:16: error[unresolved-attribute homeassistant/components/switchbot/climate.py:127:22: error[unresolved-attribute] Object of type `SwitchbotDevice` has no attribute `set_hvac_mode` homeassistant/components/switchbot/climate.py:134:22: error[unresolved-attribute] Object of type `SwitchbotDevice` has no attribute `set_preset_mode` homeassistant/components/switchbot/climate.py:140:22: error[unresolved-attribute] Object of type `SwitchbotDevice` has no attribute `set_target_temperature` -homeassistant/components/switchbot/const.py:144:5: error[invalid-assignment] Object of type `dict[Unknown | SwitchbotModel, Unknown | | | ... omitted 6 union elements]` is not assignable to `dict[SwitchbotModel, SwitchbotEncryptedDevice]` +homeassistant/components/switchbot/const.py:144:5: error[invalid-assignment] Object of type `dict[SwitchbotModel, SwitchbotEncryptedDevice | | | ... omitted 6 union elements]` is not assignable to `dict[SwitchbotModel, SwitchbotEncryptedDevice]` homeassistant/components/switchbot/cover.py:117:71: error[invalid-argument-type] Argument to bound method `set_position` is incorrect: Expected `int`, found `Any | None` homeassistant/components/switchbot/cover.py:200:71: error[invalid-argument-type] Argument to bound method `set_position` is incorrect: Expected `int`, found `Any | None` homeassistant/components/switchbot/cover.py:286:71: error[invalid-argument-type] Argument to bound method `set_position` is incorrect: Expected `int`, found `Any | None` -homeassistant/components/switchbot/humidifier.py:27:66: error[invalid-assignment] Object of type `dict[Unknown | switchbot.const.evaporative_humidifier.HumidifierAction, Unknown | homeassistant.components.humidifier.const.HumidifierAction]` is not assignable to `dict[int, homeassistant.components.humidifier.const.HumidifierAction]` +homeassistant/components/switchbot/humidifier.py:27:66: error[invalid-assignment] Object of type `dict[int | switchbot.const.evaporative_humidifier.HumidifierAction, homeassistant.components.humidifier.const.HumidifierAction]` is not assignable to `dict[int, homeassistant.components.humidifier.const.HumidifierAction]` homeassistant/components/switchbot/humidifier.py:109:16: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `HumidifierMode | None` homeassistant/components/switchbot/light.py:64:64: error[unresolved-attribute] Object of type `SwitchbotBaseLight` has no attribute `color_modes` homeassistant/components/switchbot/light.py:74:38: error[unsupported-operator] Operator `*` is unsupported between objects of type `int | None` and `float` @@ -3488,13 +3463,13 @@ homeassistant/components/switchbot_cloud/entity.py:54:13: error[invalid-argument homeassistant/components/switchbot_cloud/sensor.py:343:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Device`, found `Device | Remote` homeassistant/components/switcher_kis/sensor.py:138:16: error[unresolved-attribute] Object of type `SensorEntityDescription` has no attribute `value_fn` homeassistant/components/switchmate/switch.py:8:6: error[unresolved-import] Cannot resolve imported module `switchmate` -homeassistant/components/syncthing/__init__.py:48:12: error[unresolved-attribute] Module `aiosyncthing` has no member `exceptions` -homeassistant/components/syncthing/__init__.py:155:20: error[unresolved-attribute] Module `aiosyncthing` has no member `exceptions` -homeassistant/components/syncthing/__init__.py:174:16: error[unresolved-attribute] Module `aiosyncthing` has no member `exceptions` -homeassistant/components/syncthing/config_flow.py:36:12: error[unresolved-attribute] Module `aiosyncthing` has no member `exceptions` -homeassistant/components/syncthing/sensor.py:36:12: error[unresolved-attribute] Module `aiosyncthing` has no member `exceptions` +homeassistant/components/syncthing/__init__.py:48:12: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `aiosyncthing` +homeassistant/components/syncthing/__init__.py:155:20: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `aiosyncthing` +homeassistant/components/syncthing/__init__.py:174:16: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `aiosyncthing` +homeassistant/components/syncthing/config_flow.py:36:12: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `aiosyncthing` +homeassistant/components/syncthing/sensor.py:36:12: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `aiosyncthing` homeassistant/components/syncthing/sensor.py:111:16: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method -homeassistant/components/syncthing/sensor.py:127:16: error[unresolved-attribute] Module `aiosyncthing` has no member `exceptions` +homeassistant/components/syncthing/sensor.py:127:16: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `aiosyncthing` homeassistant/components/synology_dsm/entity.py:154:9: error[unsupported-operator] Operator `+=` is unsupported between objects of type `None` and `str` homeassistant/components/synology_srm/device_tracker.py:7:8: error[unresolved-import] Cannot resolve imported module `synology_srm` homeassistant/components/system_bridge/__init__.py:290:16: error[invalid-return-type] Return type does not match returned value: expected `ServiceResponse`, found `dict[Unknown | str, Unknown | int | list[dict[str, Any]]]` @@ -3507,14 +3482,12 @@ homeassistant/components/tado/climate.py:813:20: error[unsupported-operator] Ope homeassistant/components/tado/coordinator.py:315:33: error[invalid-argument-type] Argument to bound method `_update_zone` is incorrect: Expected `int`, found `Unknown | None` homeassistant/components/tami4/sensor.py:89:42: error[invalid-argument-type] Argument to function `__init__` is incorrect: Expected `DataUpdateCoordinator[dict[str, Any]]`, found `Tami4EdgeCoordinator` homeassistant/components/tank_utility/sensor.py:9:6: error[unresolved-import] Cannot resolve imported module `tank_utility` -homeassistant/components/tank_utility/sensor.py:62:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/tank_utility/sensor.py:123:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/tapsaff/binary_sensor.py:8:6: error[unresolved-import] Cannot resolve imported module `tapsaff` homeassistant/components/tasmota/camera.py:103:24: error[unresolved-attribute] Object of type `object` has no attribute `Request` homeassistant/components/tasmota/camera.py:104:10: error[unresolved-attribute] Object of type `object` has no attribute `StreamResponse` -homeassistant/components/tasmota/device_automation.py:61:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventDeviceRegistryUpdatedData]` -homeassistant/components/tasmota/device_automation.py:62:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def async_device_removed(event: Event[EventDeviceRegistryUpdatedData]) -> CoroutineType[Any, Any, None]` -homeassistant/components/tasmota/device_automation.py:63:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def _async_device_removed_filter(event_data: EventDeviceRegistryUpdatedData) -> bool` +homeassistant/components/tasmota/device_automation.py:61:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]` +homeassistant/components/tasmota/device_automation.py:62:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def async_device_removed(event: Event[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]) -> CoroutineType[Any, Any, None]` +homeassistant/components/tasmota/device_automation.py:63:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def _async_device_removed_filter(event_data: _EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update) -> bool` homeassistant/components/tautulli/entity.py:35:25: error[invalid-argument-type] Invalid argument to key "identifiers" with declared type `set[tuple[str, str]]` on TypedDict `DeviceInfo`: value of type `set[Unknown | tuple[str, int | None | str]]` homeassistant/components/tautulli/sensor.py:42:17: error[not-iterable] Object of type `PyTautulliApiHomeStats` is not iterable homeassistant/components/tautulli/sensor.py:252:13: error[invalid-argument-type] Argument is incorrect: Expected `PyTautulliApiHomeStats`, found `Unknown | list[PyTautulliApiHomeStats] | None` @@ -3523,9 +3496,9 @@ homeassistant/components/tautulli/sensor.py:278:28: error[not-iterable] Object o homeassistant/components/technove/number.py:46:48: error[invalid-argument-type] Argument to bound method `set_max_current` is incorrect: Expected `int`, found `int | float` homeassistant/components/technove/number.py:93:60: error[invalid-argument-type] Argument is incorrect: Expected `TechnoVE`, found `Unknown | Station` homeassistant/components/technove/number.py:98:56: error[invalid-argument-type] Argument is incorrect: Expected `TechnoVE`, found `Unknown | Station` -homeassistant/components/ted5000/sensor.py:132:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/telegram_bot/bot.py:455:50: warning[possibly-missing-attribute] Attribute `split` may be missing on object of type `@Todo | None` homeassistant/components/telegram_bot/bot.py:491:47: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__` +homeassistant/components/tellduslive/config_flow.py:120:15: error[invalid-method-override] Invalid override of method `async_step_discovery`: Definition is incompatible with `ConfigFlow.async_step_discovery` homeassistant/components/tellstick/__init__.py:5:6: error[unresolved-import] Cannot resolve imported module `tellcore.constants` homeassistant/components/tellstick/__init__.py:6:6: error[unresolved-import] Cannot resolve imported module `tellcore.telldus` homeassistant/components/tellstick/__init__.py:7:6: error[unresolved-import] Cannot resolve imported module `tellcorenet` @@ -3659,12 +3632,10 @@ homeassistant/components/todoist/calendar.py:647:45: warning[possibly-missing-at homeassistant/components/todoist/calendar.py:651:16: warning[possibly-missing-attribute] Attribute `date` may be missing on object of type `datetime | None` homeassistant/components/todoist/calendar.py:651:45: warning[possibly-missing-attribute] Attribute `date` may be missing on object of type `datetime | None` homeassistant/components/todoist/calendar.py:662:44: error[unsupported-operator] Operator `<` is not supported for types `datetime` and `None`, in comparing `datetime | None` with `datetime | None` -homeassistant/components/tomato/device_tracker.py:69:18: error[unresolved-attribute] Module `requests` has no member `auth` -homeassistant/components/tomato/device_tracker.py:125:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/tomato/device_tracker.py:133:16: error[unresolved-attribute] Module `requests` has no member `exceptions` +homeassistant/components/tomato/device_tracker.py:69:18: warning[possibly-missing-attribute] Submodule `auth` may not be available as an attribute on module `requests` homeassistant/components/tomorrowio/sensor.py:349:18: error[unsupported-operator] Operator `*` is unsupported between objects of type `float` and `(((int | float, /) -> int | float) & ~(() -> object)) | (int & ~(() -> object)) | (float & ~(() -> object))` homeassistant/components/tomorrowio/weather.py:211:13: error[invalid-argument-type] Argument to function `_translate_condition` is incorrect: Expected `int | None`, found `int | str | float | None` -homeassistant/components/toon/__init__.py:113:9: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `set[tuple[str, str]] | None | UndefinedType`, found `set[Unknown | tuple[str, str | None, str]]` +homeassistant/components/toon/__init__.py:113:9: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `set[tuple[str, str]] | None | UndefinedType`, found `set[tuple[str, str] | tuple[str, str | None, str]]` homeassistant/components/toon/__init__.py:122:9: error[invalid-argument-type] Argument to bound method `async_get_or_create` is incorrect: Expected `tuple[str, str] | None | UndefinedType`, found `tuple[Literal["toon"], str | None]` homeassistant/components/toon/climate.py:112:58: error[invalid-argument-type] Argument to bound method `set_current_setpoint` is incorrect: Expected `int | float`, found `Any | None` homeassistant/components/toon/coordinator.py:153:20: error[invalid-return-type] Return type does not match returned value: expected `Status`, found `Unknown | Status | None` @@ -3683,12 +3654,12 @@ homeassistant/components/toon/entity.py:124:25: error[invalid-argument-type] Inv homeassistant/components/toon/entity.py:131:24: error[invalid-argument-type] Invalid argument to key "via_device" with declared type `tuple[str, str]` on TypedDict `DeviceInfo`: value of type `tuple[Literal["toon"], Unknown | str | None]` homeassistant/components/toon/entity.py:144:25: error[invalid-argument-type] Invalid argument to key "identifiers" with declared type `set[tuple[str, str]]` on TypedDict `DeviceInfo`: value of type `set[Unknown | tuple[str, Unknown | str | None, str]]` homeassistant/components/toon/entity.py:147:24: error[invalid-argument-type] Invalid argument to key "via_device" with declared type `tuple[str, str]` on TypedDict `DeviceInfo`: value of type `tuple[Literal["toon"], Unknown | str | None, Literal["boiler_module"]]` -homeassistant/components/totalconnect/alarm_control_panel.py:139:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[Unknown | str, Unknown | None]` -homeassistant/components/totalconnect/alarm_control_panel.py:162:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[Unknown | str, Unknown | None]` -homeassistant/components/totalconnect/alarm_control_panel.py:185:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[Unknown | str, Unknown | None]` -homeassistant/components/totalconnect/alarm_control_panel.py:208:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[Unknown | str, Unknown | None]` -homeassistant/components/totalconnect/alarm_control_panel.py:230:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[Unknown | str, Unknown | None]` -homeassistant/components/totalconnect/alarm_control_panel.py:252:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[Unknown | str, Unknown | None]` +homeassistant/components/totalconnect/alarm_control_panel.py:139:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[str, str | Unknown | None] & dict[Unknown | str, Unknown | None]` +homeassistant/components/totalconnect/alarm_control_panel.py:162:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[str, str | Unknown | None] & dict[Unknown | str, Unknown | None]` +homeassistant/components/totalconnect/alarm_control_panel.py:185:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[str, str | Unknown | None] & dict[Unknown | str, Unknown | None]` +homeassistant/components/totalconnect/alarm_control_panel.py:208:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[str, str | Unknown | None] & dict[Unknown | str, Unknown | None]` +homeassistant/components/totalconnect/alarm_control_panel.py:230:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[str, str | Unknown | None] & dict[Unknown | str, Unknown | None]` +homeassistant/components/totalconnect/alarm_control_panel.py:252:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str] | None`, found `dict[str, str | Unknown | None] & dict[Unknown | str, Unknown | None]` homeassistant/components/totalconnect/binary_sensor.py:141:64: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | int` homeassistant/components/totalconnect/binary_sensor.py:151:25: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | int` homeassistant/components/totalconnect/button.py:55:61: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | int` @@ -3701,28 +3672,30 @@ homeassistant/components/totalconnect/entity.py:32:25: error[invalid-argument-ty homeassistant/components/touchline/climate.py:7:6: error[unresolved-import] Cannot resolve imported module `pytouchline_extended` homeassistant/components/touchline_sl/climate.py:102:38: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `GlobalScheduleModel | LocalScheduleModel | None` homeassistant/components/tplink/camera.py:228:17: error[invalid-argument-type] Argument to function `async_aiohttp_proxy_stream` is incorrect: Expected `StreamReader`, found `StreamReader` +homeassistant/components/tplink/config_flow.py:201:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/tplink/entity.py:132:29: error[unresolved-attribute] Object of type `(...) -> Awaitable[None]` has no attribute `__name__` homeassistant/components/tplink/entity.py:141:29: error[unresolved-attribute] Object of type `(...) -> Awaitable[None]` has no attribute `__name__` homeassistant/components/tplink/entity.py:150:29: error[unresolved-attribute] Object of type `(...) -> Awaitable[None]` has no attribute `__name__` homeassistant/components/tplink/entity.py:391:17: error[invalid-argument-type] Argument to function `replace` is incorrect: Argument type `_D@_description_for_feature & ~AlwaysFalsy` does not satisfy upper bound `DataclassInstance` of type variable `_DataclassT` +homeassistant/components/tplink/light.py:176:5: error[invalid-method-override] Invalid override of method `unique_id_fn`: Definition is incompatible with `TPLinkModuleEntityDescription.unique_id_fn` homeassistant/components/tplink_lte/__init__.py:11:8: error[unresolved-import] Cannot resolve imported module `tp_connected` homeassistant/components/tplink_lte/notify.py:9:8: error[unresolved-import] Cannot resolve imported module `tp_connected` homeassistant/components/traccar/device_tracker.py:129:9: error[invalid-assignment] Object of type `DeviceInfo` is not assignable to attribute `_attr_device_info` of type `None` homeassistant/components/traccar/device_tracker.py:176:9: error[call-non-callable] Object of type `None` is not callable homeassistant/components/traccar_server/coordinator.py:134:13: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown` and value of type `dict[Unknown | str, Unknown | (DeviceModel & ~None) | GeofenceModel | None | dict[str, Any]]` on object of type `dict[int, TraccarServerCoordinatorDataDevice]` homeassistant/components/traccar_server/helpers.py:37:23: error[invalid-key] Unknown key "geofenceIds" for TypedDict `DeviceModel`: Unknown key "geofenceIds" -homeassistant/components/tractive/__init__.py:62:14: error[unresolved-attribute] Module `aiotractive` has no member `tracker` -homeassistant/components/tractive/__init__.py:92:12: error[unresolved-attribute] Module `aiotractive` has no member `exceptions` -homeassistant/components/tractive/__init__.py:95:12: error[unresolved-attribute] Module `aiotractive` has no member `exceptions` -homeassistant/components/tractive/__init__.py:106:12: error[unresolved-attribute] Module `aiotractive` has no member `exceptions` -homeassistant/components/tractive/__init__.py:130:16: error[unresolved-attribute] Module `aiotractive` has no member `trackable_object` -homeassistant/components/tractive/__init__.py:199:15: error[unresolved-attribute] Module `aiotractive` has no member `trackable_object` -homeassistant/components/tractive/__init__.py:202:18: error[unresolved-attribute] Module `aiotractive` has no member `trackable_object` -homeassistant/components/tractive/__init__.py:206:43: error[unresolved-attribute] Module `aiotractive` has no member `tracker` -homeassistant/components/tractive/__init__.py:248:20: error[unresolved-attribute] Module `aiotractive` has no member `exceptions` -homeassistant/components/tractive/__init__.py:259:20: error[unresolved-attribute] Module `aiotractive` has no member `exceptions` -homeassistant/components/tractive/config_flow.py:32:14: error[unresolved-attribute] Module `aiotractive` has no member `api` -homeassistant/components/tractive/config_flow.py:35:12: error[unresolved-attribute] Module `aiotractive` has no member `exceptions` +homeassistant/components/tractive/__init__.py:62:14: warning[possibly-missing-attribute] Submodule `tracker` may not be available as an attribute on module `aiotractive` +homeassistant/components/tractive/__init__.py:92:12: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `aiotractive` +homeassistant/components/tractive/__init__.py:95:12: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `aiotractive` +homeassistant/components/tractive/__init__.py:106:12: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `aiotractive` +homeassistant/components/tractive/__init__.py:130:16: warning[possibly-missing-attribute] Submodule `trackable_object` may not be available as an attribute on module `aiotractive` +homeassistant/components/tractive/__init__.py:199:15: warning[possibly-missing-attribute] Submodule `trackable_object` may not be available as an attribute on module `aiotractive` +homeassistant/components/tractive/__init__.py:202:18: warning[possibly-missing-attribute] Submodule `trackable_object` may not be available as an attribute on module `aiotractive` +homeassistant/components/tractive/__init__.py:206:43: warning[possibly-missing-attribute] Submodule `tracker` may not be available as an attribute on module `aiotractive` +homeassistant/components/tractive/__init__.py:248:20: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `aiotractive` +homeassistant/components/tractive/__init__.py:259:20: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `aiotractive` +homeassistant/components/tractive/config_flow.py:32:14: warning[possibly-missing-attribute] Submodule `api` may not be available as an attribute on module `aiotractive` +homeassistant/components/tractive/config_flow.py:35:12: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `aiotractive` homeassistant/components/tradfri/__init__.py:116:9: warning[possibly-missing-attribute] Attribute `append` may be missing on object of type `Unknown | Gateway | (bound method APIFactory.request(api_commands, timeout=None) -> Unknown) | list[Unknown]` homeassistant/components/tradfri/light.py:240:29: error[unsupported-operator] Operator `+` is unsupported between objects of type `Unknown | None` and `None | Unknown` homeassistant/components/travisci/sensor.py:8:6: error[unresolved-import] Cannot resolve imported module `travispy` @@ -3731,9 +3704,6 @@ homeassistant/components/tts/__init__.py:292:53: error[invalid-argument-type] Ar homeassistant/components/tts/__init__.py:292:53: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `MediaSourceOptions | str` homeassistant/components/tts/__init__.py:292:62: error[invalid-key] Unknown key "options" for TypedDict `ParsedMediaSourceStreamId`: Unknown key "options" homeassistant/components/tts/__init__.py:293:41: error[invalid-key] Unknown key "message" for TypedDict `ParsedMediaSourceStreamId`: Unknown key "message" -homeassistant/components/tts/__init__.py:355:15: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/tts/__init__.py:356:16: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/tts/__init__.py:357:16: error[unresolved-attribute] Module `asyncio` has no member `subprocess` homeassistant/components/tts/__init__.py:371:41: error[invalid-argument-type] Argument to bound method `write` is incorrect: Expected `bytes | bytearray | memoryview[int]`, found `object` homeassistant/components/tts/media_source.py:98:16: error[invalid-return-type] Return type does not match returned value: expected `ParsedMediaSourceId | ParsedMediaSourceStreamId`, found `dict[Unknown | str, Unknown]` homeassistant/components/tts/media_source.py:122:12: error[invalid-return-type] Return type does not match returned value: expected `ParsedMediaSourceId | ParsedMediaSourceStreamId`, found `dict[Unknown | str, Unknown | MediaSourceOptions]` @@ -3772,7 +3742,7 @@ homeassistant/components/tuya/sensor.py:1750:44: error[invalid-argument-type] Ar homeassistant/components/tuya/siren.py:66:43: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceCategory`, found `str` homeassistant/components/tuya/switch.py:947:45: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceCategory`, found `str` homeassistant/components/tuya/valve.py:95:43: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `DeviceCategory`, found `str` -homeassistant/components/twilio_call/notify.py:63:28: error[unresolved-attribute] Module `urllib` has no member `parse` +homeassistant/components/twilio_call/notify.py:63:28: warning[possibly-missing-attribute] Submodule `parse` may not be available as an attribute on module `urllib` homeassistant/components/twinkly/coordinator.py:97:13: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `Unknown | bool | None` homeassistant/components/twitter/notify.py:13:6: error[unresolved-import] Cannot resolve imported module `TwitterAPI` homeassistant/components/ubus/device_tracker.py:8:6: error[unresolved-import] Cannot resolve imported module `openwrt.ubus` @@ -3869,9 +3839,7 @@ homeassistant/components/vesync/switch.py:136:38: warning[possibly-missing-attri homeassistant/components/vesync/switch.py:143:38: warning[possibly-missing-attribute] Attribute `message` may be missing on object of type `Unknown | ResponseInfo | None` homeassistant/components/vicare/__init__.py:80:12: error[invalid-return-type] Return type does not match returned value: expected `PyViCare`, found `ViCareData` homeassistant/components/vicare/binary_sensor.py:236:73: error[invalid-argument-type] Argument is incorrect: Expected `Device`, found `Device | HeatingDeviceWithComponent` -homeassistant/components/vicare/binary_sensor.py:237:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/vicare/button.py:107:54: error[invalid-argument-type] Argument is incorrect: Expected `Device`, found `Device | HeatingDeviceWithComponent` -homeassistant/components/vicare/button.py:108:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/vicare/climate.py:91:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `HeatingCircuit`, found `HeatingDeviceWithComponent` homeassistant/components/vicare/climate.py:148:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Unknown | str | None` homeassistant/components/vicare/climate.py:152:47: error[unresolved-attribute] Object of type `Device | HeatingDeviceWithComponent` has no attribute `getPrograms` @@ -3888,7 +3856,6 @@ homeassistant/components/vicare/climate.py:199:21: error[unresolved-attribute] O homeassistant/components/vicare/climate.py:203:52: error[unresolved-attribute] Object of type `Device | HeatingDeviceWithComponent` has no attribute `getModes` homeassistant/components/vicare/climate.py:209:68: error[unresolved-attribute] Object of type `HeatingDeviceWithComponent` has no attribute `getActive` homeassistant/components/vicare/climate.py:214:49: error[unresolved-attribute] Object of type `HeatingDeviceWithComponent` has no attribute `getActive` -homeassistant/components/vicare/climate.py:217:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/vicare/climate.py:243:9: error[unresolved-attribute] Object of type `Device | HeatingDeviceWithComponent` has no attribute `setMode` homeassistant/components/vicare/climate.py:281:13: error[unresolved-attribute] Object of type `Device | HeatingDeviceWithComponent` has no attribute `setProgramTemperature` homeassistant/components/vicare/climate.py:287:44: error[invalid-argument-type] Argument to function `to_ha_preset` is incorrect: Expected `str`, found `str | None` @@ -3915,8 +3882,6 @@ homeassistant/components/vicare/number.py:448:63: error[invalid-argument-type] A homeassistant/components/vicare/number.py:453:62: error[invalid-argument-type] Argument to function `_get_value` is incorrect: Expected `HeatingDeviceWithComponent`, found `Device | HeatingDeviceWithComponent` homeassistant/components/vicare/number.py:470:39: error[invalid-argument-type] Argument is incorrect: Expected `Device`, found `HeatingDeviceWithComponent` homeassistant/components/vicare/sensor.py:1370:21: error[invalid-argument-type] Argument is incorrect: Expected `Device`, found `Device | HeatingDeviceWithComponent` -homeassistant/components/vicare/sensor.py:1375:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/vicare/utils.py:75:12: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/vicare/utils.py:103:16: error[unresolved-attribute] Object of type `Device` has no attribute `burners` homeassistant/components/vicare/utils.py:114:16: error[unresolved-attribute] Object of type `Device` has no attribute `circuits` homeassistant/components/vicare/utils.py:125:16: error[unresolved-attribute] Object of type `Device` has no attribute `compressors` @@ -3925,7 +3890,6 @@ homeassistant/components/vicare/utils.py:147:16: error[unresolved-attribute] Obj homeassistant/components/vicare/water_heater.py:73:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `HeatingCircuit`, found `HeatingDeviceWithComponent` homeassistant/components/vicare/water_heater.py:123:21: error[unresolved-attribute] Object of type `Device | HeatingDeviceWithComponent` has no attribute `getDomesticHotWaterStorageTemperature` homeassistant/components/vicare/water_heater.py:128:21: error[unresolved-attribute] Object of type `Device | HeatingDeviceWithComponent` has no attribute `getDomesticHotWaterDesiredTemperature` -homeassistant/components/vicare/water_heater.py:134:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/vicare/water_heater.py:146:13: error[unresolved-attribute] Object of type `Device | HeatingDeviceWithComponent` has no attribute `setDomesticHotWaterTemperature` homeassistant/components/victron_remote_monitoring/coordinator.py:57:9: error[invalid-argument-type] Argument is incorrect: Expected `ForecastAggregations | None`, found `dict[Unknown, Unknown] | ForecastAggregations | None` homeassistant/components/victron_remote_monitoring/coordinator.py:57:15: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Literal["records", "totals"], dict[Unknown, Unknown]].__getitem__(key: Literal["records", "totals"], /) -> dict[Unknown, Unknown]` cannot be called with key of type `Literal["solar_yield"]` on object of type `dict[Literal["records", "totals"], dict[Unknown, Unknown]]` @@ -3944,8 +3908,8 @@ homeassistant/components/vizio/media_player.py:454:25: error[invalid-argument-ty homeassistant/components/vlc/media_player.py:8:8: error[unresolved-import] Cannot resolve imported module `vlc` homeassistant/components/voicerss/tts.py:196:46: error[invalid-argument-type] Argument to function `async_get_clientsession` is incorrect: Expected `HomeAssistant`, found `HomeAssistant | None | Unknown` homeassistant/components/voip/assist_satellite.py:168:9: error[invalid-assignment] Object of type `Self@async_added_to_hass` is not assignable to attribute `protocol` on type `Unknown | VoIPDevice` -homeassistant/components/voip/devices.py:122:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventDeviceRegistryUpdatedData]` -homeassistant/components/voip/devices.py:123:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def async_device_removed(ev: Event[EventDeviceRegistryUpdatedData]) -> None` +homeassistant/components/voip/devices.py:122:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]` +homeassistant/components/voip/devices.py:123:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def async_device_removed(ev: Event[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]) -> None` homeassistant/components/voip/voip.py:58:16: error[invalid-return-type] Return type does not match returned value: expected `VoipDatagramProtocol`, found `PreRecordMessageProtocol` homeassistant/components/voip/voip.py:68:5: error[unresolved-attribute] Object of type `VoipDatagramProtocol` has no attribute `_rtp_input` homeassistant/components/voip/voip.py:69:5: error[unresolved-attribute] Object of type `VoipDatagramProtocol` has no attribute `_rtp_output` @@ -3960,15 +3924,6 @@ homeassistant/components/volvo/entity.py:95:12: error[unresolved-attribute] Obje homeassistant/components/volvo/entity.py:97:17: error[unresolved-attribute] Object of type `EntityDescription` has no attribute `api_field` homeassistant/components/w800rf32/__init__.py:6:8: error[unresolved-import] Cannot resolve imported module `W800rf32` homeassistant/components/w800rf32/binary_sensor.py:8:8: error[unresolved-import] Cannot resolve imported module `W800rf32` -homeassistant/components/wallbox/coordinator.py:96:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/wallbox/coordinator.py:112:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/wallbox/coordinator.py:202:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/wallbox/coordinator.py:234:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/wallbox/coordinator.py:264:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/wallbox/coordinator.py:294:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/wallbox/coordinator.py:323:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/wallbox/coordinator.py:351:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/wallbox/coordinator.py:375:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/waterfurnace/__init__.py:9:6: error[unresolved-import] Cannot resolve imported module `waterfurnace.waterfurnace` homeassistant/components/watergate/__init__.py:107:50: warning[possibly-missing-attribute] Attribute `state` may be missing on object of type `AutoShutOffReportData | TelemetryEventData | ValveEventData | ... omitted 3 union elements` homeassistant/components/watergate/__init__.py:109:22: warning[possibly-missing-attribute] Attribute `errors` may be missing on object of type `AutoShutOffReportData | TelemetryEventData | ValveEventData | ... omitted 3 union elements` @@ -4004,11 +3959,12 @@ homeassistant/components/weatherflow_cloud/weather.py:120:16: error[invalid-retu homeassistant/components/weatherflow_cloud/weather.py:125:16: error[invalid-return-type] Return type does not match returned value: expected `list[Forecast] | None`, found `list[dict[Unknown, Unknown] | Unknown]` homeassistant/components/weatherkit/coordinator.py:73:17: error[invalid-argument-type] Argument to bound method `get_weather_data` is incorrect: Expected `list[DataSetType]`, found `list[DataSetType] | None` homeassistant/components/webdav/backup.py:85:17: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@handle_backup_errors]` has no attribute `__name__` +homeassistant/components/webostv/config_flow.py:137:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/webostv/media_player.py:128:51: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@cmd]` has no attribute `__name__` homeassistant/components/webostv/media_player.py:134:29: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@cmd]` has no attribute `__name__` homeassistant/components/webostv/media_player.py:145:29: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@cmd]` has no attribute `__name__` homeassistant/components/websocket_api/commands.py:446:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventStateChangedData]` -homeassistant/components/websocket_api/connection.py:282:27: error[unresolved-attribute] Module `voluptuous` has no member `humanize` +homeassistant/components/websocket_api/connection.py:282:27: warning[possibly-missing-attribute] Submodule `humanize` may not be available as an attribute on module `voluptuous` homeassistant/components/websocket_api/decorators.py:37:40: error[unresolved-attribute] Object of type `AsyncWebSocketCommandHandler` has no attribute `__name__` homeassistant/components/websocket_api/decorators.py:142:19: error[non-subscriptable] Cannot subscript object of type `All` with no `__getitem__` method homeassistant/components/websocket_api/decorators.py:144:19: warning[possibly-missing-attribute] Attribute `validators` may be missing on object of type `VolDictType | All` @@ -4048,9 +4004,9 @@ homeassistant/components/websocket_api/http.py:547:21: warning[possibly-missing- homeassistant/components/websocket_api/http.py:553:21: warning[possibly-missing-attribute] Attribute `warning` may be missing on object of type `Unknown | WebSocketAdapter | None` homeassistant/components/websocket_api/http.py:558:21: warning[possibly-missing-attribute] Attribute `data` may be missing on object of type `Unknown | HomeAssistant | None` homeassistant/components/websocket_api/http.py:561:17: error[no-matching-overload] No overload of function `async_dispatcher_send` matches arguments -homeassistant/components/wemo/__init__.py:92:27: error[unresolved-attribute] Module `pywemo` has no member `ssdp` -homeassistant/components/wemo/__init__.py:263:29: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/components/wemo/__init__.py:92:27: warning[possibly-missing-attribute] Submodule `ssdp` may not be available as an attribute on module `pywemo` homeassistant/components/wemo/__init__.py:263:37: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[datetime]`? +homeassistant/components/wemo/__init__.py:263:49: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/components/wemo/light.py:196:32: error[invalid-argument-type] Argument to bound method `turn_on` is incorrect: Expected `bool`, found `Unknown | int` homeassistant/components/whirlpool/binary_sensor.py:76:16: error[unresolved-attribute] Object of type `BinarySensorEntityDescription` has no attribute `value_fn` homeassistant/components/whirlpool/climate.py:88:16: error[invalid-return-type] Return type does not match returned value: expected `int | float`, found `int | float | None` @@ -4067,8 +4023,6 @@ homeassistant/components/whirlpool/sensor.py:452:16: error[unresolved-attribute] homeassistant/components/wiffi/entity.py:88:17: warning[possibly-missing-attribute] Attribute `endswith` may be missing on object of type `str | None` homeassistant/components/wiffi/entity.py:93:16: warning[possibly-missing-attribute] Attribute `endswith` may be missing on object of type `str | None` homeassistant/components/wiffi/entity.py:93:54: warning[possibly-missing-attribute] Attribute `endswith` may be missing on object of type `str | None` -homeassistant/components/wilight/parent_device.py:102:9: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/wilight/parent_device.py:103:9: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/wilight/parent_device.py:106:16: error[invalid-return-type] Return type does not match returned value: expected `PyWiLightDevice`, found `None` homeassistant/components/wilight/switch.py:74:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[Any]`, found `list[Unknown]` homeassistant/components/wirelesstag/__init__.py:7:6: error[unresolved-import] Cannot resolve imported module `wirelesstagpy` @@ -4114,8 +4068,6 @@ homeassistant/components/worldtidesinfo/sensor.py:94:42: error[non-subscriptable homeassistant/components/worldtidesinfo/sensor.py:95:40: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/worldtidesinfo/sensor.py:96:41: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/worldtidesinfo/sensor.py:97:39: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method -homeassistant/components/wyoming/assist_satellite.py:357:24: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/components/wyoming/assist_satellite.py:358:24: error[unresolved-attribute] Module `asyncio` has no member `subprocess` homeassistant/components/xbox/browse_media.py:31:12: error[missing-argument] No argument provided for required parameter `cls` homeassistant/components/xbox/browse_media.py:33:9: error[invalid-argument-type] Argument is incorrect: Expected `type`, found `Literal[MediaClass.APP]` homeassistant/components/xbox/browse_media.py:33:9: error[parameter-already-assigned] Multiple values provided for parameter `cls` @@ -4125,8 +4077,6 @@ homeassistant/components/xbox/browse_media.py:37:9: error[parameter-already-assi homeassistant/components/xeoma/camera.py:7:6: error[unresolved-import] Cannot resolve imported module `pyxeoma.xeoma` homeassistant/components/xiaomi/camera.py:181:34: error[invalid-argument-type] Argument to bound method `open_camera` is incorrect: Expected `str`, found `Unknown | None` homeassistant/components/xiaomi/camera.py:188:17: error[invalid-argument-type] Argument to function `async_aiohttp_proxy_stream` is incorrect: Expected `StreamReader`, found `StreamReader` -homeassistant/components/xiaomi/device_tracker.py:118:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/xiaomi/device_tracker.py:156:12: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/xiaomi_ble/event.py:149:43: error[invalid-argument-type] Argument to function `replace` is incorrect: Argument type `Unknown | EventEntityDescription` does not satisfy upper bound `DataclassInstance` of type variable `_DataclassT` homeassistant/components/xiaomi_miio/__init__.py:390:43: error[invalid-argument-type] Argument to function `_async_update_data_vacuum` is incorrect: Expected `RoborockVacuum`, found `AirHumidifierMiot | AirHumidifierMjjsq | AirHumidifier | ... omitted 11 union elements` homeassistant/components/xiaomi_miio/air_quality.py:71:60: warning[possibly-missing-attribute] Attribute `status` may be missing on object of type `Unknown | Device` @@ -4148,8 +4098,6 @@ homeassistant/components/xiaomi_miio/remote.py:252:24: error[invalid-argument-ty homeassistant/components/xiaomi_miio/switch.py:891:47: warning[possibly-missing-attribute] Attribute `set_wifi_led` may be missing on object of type `AirConditioningCompanionV3 | ChuangmiPlug | PowerStrip` homeassistant/components/xiaomi_miio/switch.py:900:48: warning[possibly-missing-attribute] Attribute `set_wifi_led` may be missing on object of type `AirConditioningCompanionV3 | ChuangmiPlug | PowerStrip` homeassistant/components/xiaomi_tv/media_player.py:7:8: error[unresolved-import] Cannot resolve imported module `pymitv` -homeassistant/components/xmpp/notify.py:223:20: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/xmpp/notify.py:225:20: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/xmpp/notify.py:243:16: warning[possibly-missing-attribute] Attribute `get` may be missing on object of type `Unknown | None` homeassistant/components/xmpp/notify.py:244:55: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/components/xmpp/notify.py:245:50: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method @@ -4218,13 +4166,12 @@ homeassistant/components/yale/lock.py:113:54: error[invalid-argument-type] Argum homeassistant/components/yale/lock.py:128:22: warning[possibly-missing-attribute] Attribute `keypad` may be missing on object of type `DoorbellDetail | LockDetail` homeassistant/components/yale/sensor.py:94:48: error[invalid-argument-type] Argument is incorrect: Expected `LockDetail`, found `DoorbellDetail | LockDetail` homeassistant/components/yale/sensor.py:98:22: warning[possibly-missing-attribute] Attribute `keypad` may be missing on object of type `DoorbellDetail | LockDetail` -homeassistant/components/yale/sensor.py:106:9: error[invalid-argument-type] Argument to class `YaleBatterySensor` is incorrect: Expected `LockDetail | KeypadDetail`, found `Doorbell` +homeassistant/components/yale/sensor.py:106:27: error[invalid-type-arguments] Type `Doorbell` is not assignable to upper bound `LockDetail | KeypadDetail` of type variable `T@YaleBatterySensor` homeassistant/components/yale/sensor.py:108:48: error[invalid-argument-type] Argument is incorrect: Expected `LockDetail`, found `DoorbellDetail | LockDetail` homeassistant/components/yale/sensor.py:210:68: error[invalid-argument-type] Argument is incorrect: Expected `T@YaleBatterySensor`, found `DoorbellDetail | LockDetail` homeassistant/components/yale/util.py:38:12: error[invalid-return-type] Return type does not match returned value: expected `Activity | None`, found `Literal[False]` -homeassistant/components/yamaha/media_player.py:157:12: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/yamaha/media_player.py:244:16: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/components/yamaha/media_player.py:369:16: error[unresolved-attribute] Module `rxv` has no member `exceptions` +homeassistant/components/yalexs_ble/config_flow.py:153:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` +homeassistant/components/yamaha/media_player.py:369:16: warning[possibly-missing-attribute] Submodule `exceptions` may not be available as an attribute on module `rxv` homeassistant/components/yamaha_musiccast/config_flow.py:92:13: error[invalid-argument-type] Argument to bound method `check_yamaha_ssdp` is incorrect: Expected `str`, found `str | None` homeassistant/components/yamaha_musiccast/entity.py:74:28: warning[possibly-missing-attribute] Attribute `values` may be missing on object of type `Unknown | dict[str, str] | None` homeassistant/components/yamaha_musiccast/entity.py:77:44: error[invalid-assignment] Invalid assignment to key "via_device" with declared type `tuple[str, str]` on TypedDict `DeviceInfo`: value of type `tuple[Literal["yamaha_musiccast"], Unknown | str | None]` @@ -4237,6 +4184,7 @@ homeassistant/components/yamaha_musiccast/media_player.py:392:13: error[invalid- homeassistant/components/yamaha_musiccast/media_player.py:393:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `str | None` homeassistant/components/yamaha_musiccast/number.py:65:35: error[invalid-argument-type] Argument to bound method `set` is incorrect: Expected `int`, found `int | float` homeassistant/components/yandextts/tts.py:123:46: error[invalid-argument-type] Argument to function `async_get_clientsession` is incorrect: Expected `HomeAssistant`, found `HomeAssistant | None | Unknown` +homeassistant/components/yeelight/config_flow.py:146:9: error[invalid-method-override] Invalid override of method `is_matching`: Definition is incompatible with `ConfigFlow.is_matching` homeassistant/components/yeelight/light.py:256:47: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@_async_cmd]` has no attribute `__name__` homeassistant/components/yeelight/light.py:264:43: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@_async_cmd]` has no attribute `__name__` homeassistant/components/yeelight/light.py:270:43: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, _R@_async_cmd]` has no attribute `__name__` @@ -4254,9 +4202,8 @@ homeassistant/components/zamg/coordinator.py:51:9: error[invalid-assignment] Obj homeassistant/components/zamg/coordinator.py:54:16: error[invalid-return-type] Return type does not match returned value: expected `ZamgData`, found `Unknown | dict[Unknown, Unknown] | None` homeassistant/components/zamg/sensor.py:203:26: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `DataUpdateCoordinator[dict[str, Any]]`, found `ZamgDataUpdateCoordinator` homeassistant/components/zamg/weather.py:47:26: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `DataUpdateCoordinator[dict[str, Any]]`, found `ZamgDataUpdateCoordinator` -homeassistant/components/zeroconf/discovery.py:487:13: error[invalid-argument-type] Argument to function `async_create_issue` is incorrect: Expected `dict[str, str] | None`, found `dict[Unknown | str, Unknown | None | str]` +homeassistant/components/zeroconf/discovery.py:487:13: error[invalid-argument-type] Argument to function `async_create_issue` is incorrect: Expected `dict[str, str] | None`, found `dict[str, str | Unknown | None]` homeassistant/components/zestimate/sensor.py:97:32: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | Buffer | SupportsFloat | SupportsIndex`, found `Unknown | None` -homeassistant/components/zestimate/sensor.py:121:16: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/components/zeversolar/sensor.py:89:16: error[invalid-return-type] Return type does not match returned value: expected `int | float`, found `kWh | Watt` homeassistant/components/zha/__init__.py:120:57: error[invalid-argument-type] Argument to function `async_register_firmware_info_provider` is incorrect: Expected `HardwareFirmwareInfoModule`, found `` homeassistant/components/zha/alarm_control_panel.py:83:16: error[unresolved-attribute] Object of type `PlatformEntity | GroupEntity` has no attribute `code_arm_required` @@ -4329,8 +4276,8 @@ homeassistant/components/zha/helpers.py:373:34: warning[possibly-missing-attribu homeassistant/components/zha/helpers.py:374:31: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Unknown | Relationship` homeassistant/components/zha/helpers.py:378:33: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Unknown | PermitJoins` homeassistant/components/zha/helpers.py:388:35: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Unknown | RouteStatus` -homeassistant/components/zha/helpers.py:533:44: error[unresolved-attribute] Module `logging` has no member `handlers` -homeassistant/components/zha/helpers.py:542:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventEntityRegistryUpdatedData]` +homeassistant/components/zha/helpers.py:533:44: warning[possibly-missing-attribute] Submodule `handlers` may not be available as an attribute on module `logging` +homeassistant/components/zha/helpers.py:542:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` homeassistant/components/zha/helpers.py:543:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `bound method Self@__init__._handle_entity_registry_updated(event: Event[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]) -> CoroutineType[Any, Any, None]` homeassistant/components/zha/helpers.py:603:27: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[tuple[Platform, str], PlatformEntity].__getitem__(key: tuple[Platform, str], /) -> PlatformEntity` cannot be called with key of type `tuple[str, str]` on object of type `dict[tuple[Platform, str], PlatformEntity]` homeassistant/components/zha/helpers.py:615:65: error[invalid-argument-type] Argument to bound method `_async_get_or_create_group_proxy` is incorrect: Expected `GroupInfo`, found `Unknown | Group` @@ -4370,7 +4317,7 @@ homeassistant/components/zha/number.py:71:16: error[unresolved-attribute] Object homeassistant/components/zha/number.py:76:15: error[unresolved-attribute] Object of type `PlatformEntity | GroupEntity` has no attribute `async_set_native_value` homeassistant/components/zha/radio_manager.py:429:27: warning[possibly-missing-attribute] Attribute `copy` may be missing on object of type `Unknown | dict[str, Any] | None` homeassistant/components/zha/radio_manager.py:436:34: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Unknown | RadioType | None` -homeassistant/components/zha/repairs/network_settings_inconsistent.py:100:9: error[invalid-argument-type] Argument to function `async_create_issue` is incorrect: Expected `dict[str, str | int | float | None] | None`, found `dict[Unknown | str, Unknown | str | dict[str, Any]]` +homeassistant/components/zha/repairs/network_settings_inconsistent.py:100:9: error[invalid-argument-type] Argument to function `async_create_issue` is incorrect: Expected `dict[str, str | int | float | None] | None`, found `dict[str, str | int | float | None | dict[str, Any]]` homeassistant/components/zha/select.py:61:16: error[unresolved-attribute] Object of type `PlatformEntity | GroupEntity` has no attribute `current_option` homeassistant/components/zha/select.py:66:15: error[unresolved-attribute] Object of type `PlatformEntity | GroupEntity` has no attribute `async_select_option` homeassistant/components/zha/select.py:73:13: error[unresolved-attribute] Object of type `PlatformEntity | GroupEntity` has no attribute `restore_external_state_attributes` @@ -4437,102 +4384,105 @@ homeassistant/components/zwave_me/fan.py:58:16: error[invalid-return-type] Retur homeassistant/components/zwave_me/number.py:48:16: error[invalid-return-type] Return type does not match returned value: expected `int | float`, found `(Unknown & ~Literal[99]) | str | (int & ~Literal[99]) | float` homeassistant/config.py:959:9: error[unknown-argument] Argument `translation_domain` does not match any known parameter of function `__new__` homeassistant/config.py:960:9: error[unknown-argument] Argument `translation_placeholders` does not match any known parameter of function `__new__` -homeassistant/config_entries.py:199:31: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 2 -homeassistant/config_entries.py:207:6: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 +homeassistant/config_entries.py:199:42: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 2 +homeassistant/config_entries.py:207:17: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 homeassistant/config_entries.py:1251:17: error[invalid-argument-type] Argument to bound method `async_init` is incorrect: Expected `ConfigFlowContext | None`, found `ConfigFlowContext | dict[str, object]` -homeassistant/config_entries.py:3834:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventEntityRegistryUpdatedData]` +homeassistant/config_entries.py:1811:9: error[invalid-method-override] Invalid override of method `__setitem__`: Definition is incompatible with `UserDict.__setitem__` +homeassistant/config_entries.py:1882:9: error[invalid-method-override] Invalid override of method `__delitem__`: Definition is incompatible with `UserDict.__delitem__` +homeassistant/config_entries.py:3834:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` homeassistant/config_entries.py:3835:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `bound method Self@async_setup._handle_entry_updated(event: Event[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]) -> None` -homeassistant/config_entries.py:3836:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def _handle_entry_updated_filter(event_data: EventEntityRegistryUpdatedData) -> bool` +homeassistant/config_entries.py:3836:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def _handle_entry_updated_filter(event_data: _EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update) -> bool` homeassistant/config_entries.py:3911:33: error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Literal["action"], /) -> Literal["create", "remove"], (key: Literal["entity_id"], /) -> str]) | (Overload[(key: Literal["action"], /) -> Literal["update"], (key: Literal["entity_id"], /) -> str, (key: Literal["changes"], /) -> dict[str, Any], (key: Literal["old_entity_id"], /) -> str])` cannot be called with key of type `Literal["changes"]` on object of type `EventEntityRegistryUpdatedData` homeassistant/config_entries.py:3912:12: error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Literal["action"], /) -> Literal["create", "remove"], (key: Literal["entity_id"], /) -> str]) | (Overload[(key: Literal["action"], /) -> Literal["update"], (key: Literal["entity_id"], /) -> str, (key: Literal["changes"], /) -> dict[str, Any], (key: Literal["old_entity_id"], /) -> str])` cannot be called with key of type `Literal["changes"]` on object of type `EventEntityRegistryUpdatedData` -homeassistant/const.py:977:32: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/core.py:359:10: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:648:18: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:658:18: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:667:18: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:698:18: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:707:18: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:715:18: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:735:32: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:743:32: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:748:32: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:881:18: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:890:18: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:898:18: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:917:32: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:1026:24: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:1032:24: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:1037:24: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/const.py:977:43: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/core.py:359:23: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:648:31: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:658:31: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:667:31: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:698:31: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:707:31: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:715:31: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:735:45: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:743:45: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:748:45: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:881:31: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:890:31: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:898:31: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:917:45: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:1026:37: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:1032:37: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:1037:37: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/core.py:1277:32: error[invalid-type-form] Variable of type `under_cached_property[Unknown]` is not allowed in a type expression homeassistant/core.py:1378:32: error[invalid-type-form] Variable of type `under_cached_property[Unknown]` is not allowed in a type expression -homeassistant/core.py:1398:5: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/core.py:1398:13: error[invalid-type-form] List literals are not allowed in this context in a type expression -homeassistant/core.py:1398:14: error[invalid-argument-type] Argument to class `Event` is incorrect: Expected `Mapping[str, Any]`, found `typing.TypeVar` -homeassistant/core.py:1406:19: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/core.py:1398:13: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[Unknown]]`? +homeassistant/core.py:1398:20: error[invalid-type-arguments] Type `typing.TypeVar` is not assignable to upper bound `Mapping[str, Any]` of type variable `_DataT@Event` +homeassistant/core.py:1398:30: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/core.py:1406:27: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[_DataT@_OneTimeListener]]`? +homeassistant/core.py:1406:44: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/core.py:1504:13: error[invalid-argument-type] Argument to bound method `async_fire_internal` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_DataT@async_fire] | str` homeassistant/core.py:1527:48: error[invalid-argument-type] Argument to function `_event_repr` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_DataT@async_fire_internal] | str` homeassistant/core.py:1621:50: error[invalid-argument-type] Argument to bound method `_async_listen_filterable_job` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_DataT@async_listen] | str` homeassistant/core.py:1687:13: error[invalid-argument-type] Argument to bound method `_async_listen_filterable_job` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_DataT@async_listen_once] | str` homeassistant/core.py:1925:32: error[invalid-type-form] Variable of type `under_cached_property[Unknown]` is not allowed in a type expression -homeassistant/core.py:2079:45: error[unresolved-attribute] Module `asyncio` has no member `events` +homeassistant/core.py:2048:9: error[invalid-method-override] Invalid override of method `__setitem__`: Definition is incompatible with `UserDict.__setitem__` homeassistant/core.py:2356:17: error[invalid-argument-type] Argument to bound method `async_fire_internal` is incorrect: Expected `EventType[dict[Unknown | str, Unknown | str | datetime | State | None]] | str`, found `EventType[EventStateReportedData]` homeassistant/data_entry_flow.py:365:27: warning[redundant-cast] Value is already of type `Schema` -homeassistant/data_entry_flow.py:1016:16: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/data_entry_flow.py:1016:50: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/data_entry_flow.py:1031:15: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 -homeassistant/data_entry_flow.py:1032:10: error[too-many-positional-arguments] Too many positional arguments: expected 2, got 3 +homeassistant/data_entry_flow.py:1016:45: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/data_entry_flow.py:1016:79: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/data_entry_flow.py:1031:44: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/data_entry_flow.py:1032:39: error[invalid-type-arguments] Too many type arguments: expected 2, got 3 +homeassistant/data_entry_flow.py:1037:23: error[unresolved-attribute] Object of type `(...) -> Coroutine[Any, Any, Unknown]` has no attribute `__name__` homeassistant/data_entry_flow.py:1063:21: error[invalid-argument-type] Argument to bound method `async_show_progress` is incorrect: Expected `Mapping[str, str] | None`, found `None | @Todo | (dict[str, str] & ~(() -> object)) | (((Any, /) -> dict[str, str]) & ~(() -> object))` homeassistant/helpers/area_registry.py:90:32: error[invalid-type-form] Variable of type `cached_property[Unknown]` is not allowed in a type expression homeassistant/helpers/area_registry.py:454:16: error[invalid-return-type] Return type does not match returned value: expected `AreasRegistryStoreData`, found `dict[Unknown | str, Unknown | list[dict[Unknown | str, Unknown | list[str] | str | None] | Unknown]]` homeassistant/helpers/area_registry.py:455:22: error[invalid-argument-type] Invalid argument to key "areas" with declared type `list[_AreaStoreData]` on TypedDict `AreasRegistryStoreData`: value of type `list[dict[Unknown | str, Unknown | list[str] | str | None] | Unknown]` homeassistant/helpers/area_registry.py:497:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventFloorRegistryUpdatedData]` homeassistant/helpers/area_registry.py:498:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def _removed_from_registry_filter(event_data: EventFloorRegistryUpdatedData | EventLabelRegistryUpdatedData) -> bool` -homeassistant/helpers/area_registry.py:499:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _handle_floor_registry_update(event: EventFloorRegistryUpdated) -> None` +homeassistant/helpers/area_registry.py:499:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _handle_floor_registry_update(event: Event[EventFloorRegistryUpdatedData]) -> None` homeassistant/helpers/area_registry.py:510:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventLabelRegistryUpdatedData]` homeassistant/helpers/area_registry.py:511:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def _removed_from_registry_filter(event_data: EventFloorRegistryUpdatedData | EventLabelRegistryUpdatedData) -> bool` -homeassistant/helpers/area_registry.py:512:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _handle_label_registry_update(event: EventLabelRegistryUpdated) -> None` +homeassistant/helpers/area_registry.py:512:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _handle_label_registry_update(event: Event[EventLabelRegistryUpdatedData]) -> None` homeassistant/helpers/category_registry.py:230:16: error[invalid-return-type] Return type does not match returned value: expected `CategoryRegistryStoreData`, found `dict[Unknown | str, Unknown | dict[str | Unknown, list[dict[Unknown | str, Unknown | str | None] | Unknown] | Unknown]]` homeassistant/helpers/category_registry.py:231:27: error[invalid-argument-type] Invalid argument to key "categories" with declared type `dict[str, list[_CategoryStoreData]]` on TypedDict `CategoryRegistryStoreData`: value of type `dict[str | Unknown, list[dict[Unknown | str, Unknown | str | None] | Unknown] | Unknown]` homeassistant/helpers/condition.py:359:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[str, ConditionProtocol | None]`, found `tuple[str, ModuleType]` homeassistant/helpers/condition.py:426:49: error[call-non-callable] Object of type `None` is not callable homeassistant/helpers/condition.py:427:39: error[call-non-callable] Object of type `None` is not callable homeassistant/helpers/config_validation.py:21:5: error[unresolved-import] Module `socket` has no member `_GLOBAL_DEFAULT_TIMEOUT` -homeassistant/helpers/debounce.py:43:20: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/debounce.py:43:28: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `tuple[()]`? +homeassistant/helpers/debounce.py:43:32: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/deprecation.py:44:25: error[unresolved-attribute] Object of type `(_ObjectT@deprecated_substitute, /) -> Any` has no attribute `__name__` homeassistant/helpers/deprecation.py:158:24: error[unresolved-attribute] Object of type `(...) -> _T@deprecated_hass_argument` has no attribute `__name__` homeassistant/helpers/deprecation.py:160:34: error[unresolved-attribute] Object of type `(...) -> _T@deprecated_hass_argument` has no attribute `__name__` homeassistant/helpers/device_registry.py:1307:20: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | str]` is not assignable to `EventDeviceRegistryUpdatedData` homeassistant/helpers/device_registry.py:1309:20: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | str | dict[str, Any]]` is not assignable to `EventDeviceRegistryUpdatedData` -homeassistant/helpers/device_registry.py:1456:13: error[invalid-argument-type] Argument to bound method `async_fire_internal` is incorrect: Expected `EventType[_EventDeviceRegistryUpdatedData_Remove] | str`, found `EventType[EventDeviceRegistryUpdatedData]` +homeassistant/helpers/device_registry.py:1456:13: error[invalid-argument-type] Argument to bound method `async_fire_internal` is incorrect: Expected `EventType[_EventDeviceRegistryUpdatedData_Remove] | str`, found `EventType[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]` homeassistant/helpers/device_registry.py:1832:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventLabelRegistryUpdatedData]` homeassistant/helpers/device_registry.py:1833:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def _label_removed_from_registry_filter(event_data: EventLabelRegistryUpdatedData) -> bool` -homeassistant/helpers/device_registry.py:1834:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _handle_label_registry_update(event: EventLabelRegistryUpdated) -> None` +homeassistant/helpers/device_registry.py:1834:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _handle_label_registry_update(event: Event[EventLabelRegistryUpdatedData]) -> None` homeassistant/helpers/device_registry.py:1861:36: error[invalid-argument-type] Method `__getitem__` of type `(Overload[(key: Literal["action"], /) -> Literal["create", "remove"], (key: Literal["entity_id"], /) -> str]) | (Overload[(key: Literal["action"], /) -> Literal["update"], (key: Literal["entity_id"], /) -> str, (key: Literal["changes"], /) -> dict[str, Any], (key: Literal["old_entity_id"], /) -> str])` cannot be called with key of type `Literal["changes"]` on object of type `EventEntityRegistryUpdatedData` -homeassistant/helpers/device_registry.py:1870:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventEntityRegistryUpdatedData]` -homeassistant/helpers/device_registry.py:1871:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _async_entity_registry_changed(event: Event[EventEntityRegistryUpdatedData]) -> None` -homeassistant/helpers/device_registry.py:1872:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def entity_registry_changed_filter(event_data: EventEntityRegistryUpdatedData) -> bool` -homeassistant/helpers/discovery.py:22:29: error[too-many-positional-arguments] Too many positional arguments to class `SignalTypeFormat`: expected 0, got 1 +homeassistant/helpers/device_registry.py:1870:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` +homeassistant/helpers/device_registry.py:1871:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _async_entity_registry_changed(event: Event[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]) -> None` +homeassistant/helpers/device_registry.py:1872:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def entity_registry_changed_filter(event_data: _EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update) -> bool` +homeassistant/helpers/discovery.py:22:46: error[invalid-type-arguments] Too many type arguments to class `SignalTypeFormat`: expected 0, got 1 homeassistant/helpers/discovery_flow.py:59:19: error[invalid-assignment] Object of type `dict[str, object]` is not assignable to `ConfigFlowContext` -homeassistant/helpers/dispatcher.py:30:5: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:33:9: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/helpers/dispatcher.py:41:34: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:55:13: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:72:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1 -homeassistant/helpers/dispatcher.py:73:13: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:94:34: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:110:13: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:119:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1 -homeassistant/helpers/dispatcher.py:131:34: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:142:34: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:149:13: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:163:13: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:164:6: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/helpers/dispatcher.py:186:34: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:199:34: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:221:34: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/helpers/dispatcher.py:234:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1 +homeassistant/helpers/dispatcher.py:30:16: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:33:22: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/dispatcher.py:41:45: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:55:24: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:72:38: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 +homeassistant/helpers/dispatcher.py:73:24: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:94:45: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:110:24: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:119:38: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 +homeassistant/helpers/dispatcher.py:131:45: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:142:45: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:149:24: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:163:24: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:164:19: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/dispatcher.py:186:45: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:199:45: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:221:45: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/helpers/dispatcher.py:234:38: error[invalid-type-arguments] Too many type arguments: expected 0, got 1 homeassistant/helpers/entity.py:1312:23: error[call-non-callable] Object of type `object` is not callable homeassistant/helpers/entity.py:1314:51: error[invalid-argument-type] Argument to bound method `async_add_executor_job` is incorrect: Expected `(...) -> Unknown`, found `object` homeassistant/helpers/entity.py:1527:32: error[invalid-key] Unknown key "changes" for TypedDict `_EventEntityRegistryUpdatedData_CreateRemove`: Unknown key "changes" @@ -4543,103 +4493,105 @@ homeassistant/helpers/entity.py:1576:73: error[invalid-key] Unknown key "changes homeassistant/helpers/entity_component.py:375:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `EntityPlatformModule | None`, found `ModuleType | None` homeassistant/helpers/entity_registry.py:218:5: error[call-non-callable] Object of type `_MISSING_TYPE` is not callable homeassistant/helpers/entity_registry.py:443:5: error[call-non-callable] Object of type `_MISSING_TYPE` is not callable -homeassistant/helpers/entity_registry.py:829:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventDeviceRegistryUpdatedData]` +homeassistant/helpers/entity_registry.py:829:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]` homeassistant/helpers/entity_registry.py:830:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `bound method Self@__init__.async_device_modified(event: Event[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]) -> None` homeassistant/helpers/entity_registry.py:1060:13: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `None | str` homeassistant/helpers/entity_registry.py:1063:13: error[invalid-argument-type] Argument is incorrect: Expected `ReadOnlyEntityOptionsType`, found `ReadOnlyDict[str, ReadOnlyDict[str, Any]] | @Todo | None` -homeassistant/helpers/entity_registry.py:1079:13: error[invalid-argument-type] Argument to bound method `async_fire_internal` is incorrect: Expected `EventType[_EventEntityRegistryUpdatedData_CreateRemove] | str`, found `EventType[EventEntityRegistryUpdatedData]` -homeassistant/helpers/entity_registry.py:1126:13: error[invalid-argument-type] Argument to bound method `async_fire_internal` is incorrect: Expected `EventType[_EventEntityRegistryUpdatedData_CreateRemove] | str`, found `EventType[EventEntityRegistryUpdatedData]` +homeassistant/helpers/entity_registry.py:1079:13: error[invalid-argument-type] Argument to bound method `async_fire_internal` is incorrect: Expected `EventType[_EventEntityRegistryUpdatedData_CreateRemove] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` +homeassistant/helpers/entity_registry.py:1126:13: error[invalid-argument-type] Argument to bound method `async_fire_internal` is incorrect: Expected `EventType[_EventEntityRegistryUpdatedData_CreateRemove] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` homeassistant/helpers/entity_registry.py:1149:46: error[invalid-key] Unknown key "device" for TypedDict `_EventDeviceRegistryUpdatedData_Create` - did you mean "device_id"? homeassistant/helpers/entity_registry.py:1149:46: error[invalid-key] Unknown key "device" for TypedDict `_EventDeviceRegistryUpdatedData_Update` - did you mean "device_id"? homeassistant/helpers/entity_registry.py:1179:45: error[invalid-key] Unknown key "changes" for TypedDict `_EventDeviceRegistryUpdatedData_Create`: Unknown key "changes" homeassistant/helpers/entity_registry.py:1179:45: error[invalid-key] Unknown key "changes" for TypedDict `_EventDeviceRegistryUpdatedData_Remove`: Unknown key "changes" homeassistant/helpers/entity_registry.py:1193:56: error[invalid-key] Unknown key "changes" for TypedDict `_EventDeviceRegistryUpdatedData_Create`: Unknown key "changes" homeassistant/helpers/entity_registry.py:1193:56: error[invalid-key] Unknown key "changes" for TypedDict `_EventDeviceRegistryUpdatedData_Remove`: Unknown key "changes" -homeassistant/helpers/entity_registry.py:1378:43: error[invalid-argument-type] Argument to bound method `async_fire_internal` is incorrect: Expected `EventType[_EventEntityRegistryUpdatedData_Update] | str`, found `EventType[EventEntityRegistryUpdatedData]` +homeassistant/helpers/entity_registry.py:1378:43: error[invalid-argument-type] Argument to bound method `async_fire_internal` is incorrect: Expected `EventType[_EventEntityRegistryUpdatedData_Update] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` homeassistant/helpers/entity_registry.py:1858:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventLabelRegistryUpdatedData]` homeassistant/helpers/entity_registry.py:1859:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def _removed_from_registry_filter(event_data: EventLabelRegistryUpdatedData | EventCategoryRegistryUpdatedData) -> bool` -homeassistant/helpers/entity_registry.py:1860:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _handle_label_registry_update(event: EventLabelRegistryUpdated) -> None` +homeassistant/helpers/entity_registry.py:1860:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _handle_label_registry_update(event: Event[EventLabelRegistryUpdatedData]) -> None` homeassistant/helpers/entity_registry.py:1871:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventCategoryRegistryUpdatedData]` homeassistant/helpers/entity_registry.py:1872:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def _removed_from_registry_filter(event_data: EventLabelRegistryUpdatedData | EventCategoryRegistryUpdatedData) -> bool` -homeassistant/helpers/entity_registry.py:1873:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _handle_category_registry_update(event: EventCategoryRegistryUpdated) -> None` +homeassistant/helpers/entity_registry.py:1873:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def _handle_category_registry_update(event: Event[EventCategoryRegistryUpdatedData]) -> None` homeassistant/helpers/entity_registry.py:1912:40: error[invalid-key] Unknown key "old_entity_id" for TypedDict `_EventEntityRegistryUpdatedData_CreateRemove`: Unknown key "old_entity_id" -homeassistant/helpers/entity_registry.py:1929:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventEntityRegistryUpdatedData]` -homeassistant/helpers/entity_registry.py:1930:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def cleanup_restored_states(event: Event[EventEntityRegistryUpdatedData]) -> None` -homeassistant/helpers/event.py:105:28: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/entity_registry.py:1929:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` +homeassistant/helpers/entity_registry.py:1930:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def cleanup_restored_states(event: Event[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]) -> None` homeassistant/helpers/event.py:105:36: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[_TypedDictT@_KeyedEventTracker]]`? -homeassistant/helpers/event.py:113:28: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:105:58: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:113:36: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[_TypedDictT@_KeyedEventTracker]]`? -homeassistant/helpers/event.py:125:38: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:113:58: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:125:46: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[_TypedDictT@_KeyedEventData]]`? +homeassistant/helpers/event.py:125:68: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:299:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventStateChangedData]` homeassistant/helpers/event.py:300:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def state_change_dispatcher(event: Event[EventStateChangedData]) -> None` homeassistant/helpers/event.py:301:9: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def state_change_filter(event_data: EventStateChangedData) -> bool` -homeassistant/helpers/event.py:342:31: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:342:39: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[_StateEventDataT@_async_dispatch_entity_id_event_soon]]`? -homeassistant/helpers/event.py:352:31: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:342:66: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:352:39: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[_StateEventDataT@_async_dispatch_entity_id_event]]`? -homeassistant/helpers/event.py:372:31: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:352:66: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:372:39: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[_StateEventDataT@_async_state_filter]]`? -homeassistant/helpers/event.py:437:10: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:372:66: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:437:18: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[_TypedDictT@_remove_listener]]`? -homeassistant/helpers/event.py:438:31: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:437:40: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:438:39: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[_TypedDictT@_remove_listener]]`? +homeassistant/helpers/event.py:438:61: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:474:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_TypedDictT@_async_track_event] | str` -homeassistant/helpers/event.py:501:31: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:501:39: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[EventEntityRegistryUpdatedData]]`? -homeassistant/helpers/event.py:525:31: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:501:80: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:525:39: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[EventEntityRegistryUpdatedData]]`? -homeassistant/helpers/event.py:568:31: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:525:80: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:568:39: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[EventDeviceRegistryUpdatedData]]`? -homeassistant/helpers/event.py:578:31: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:568:80: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:578:39: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[EventDeviceRegistryUpdatedData]]`? -homeassistant/helpers/event.py:622:31: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:578:80: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:622:39: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[EventStateChangedData]]`? -homeassistant/helpers/event.py:639:31: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:622:71: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:639:39: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[EventStateChangedData]]`? -homeassistant/helpers/event.py:689:31: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:639:71: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:689:39: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[Event[EventStateChangedData]]`? +homeassistant/helpers/event.py:689:71: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:861:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventStateChangedData]` homeassistant/helpers/event.py:861:34: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `Unknown | ((Event[EventStateChangedData], /) -> Any)` homeassistant/helpers/event.py:1447:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventStateChangedData]` homeassistant/helpers/event.py:1447:34: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `(Event[Mapping[str, Any]], /) -> Coroutine[Any, Any, None] | None`, found `def state_for_cancel_listener(event: Event[EventStateChangedData]) -> None` -homeassistant/helpers/event.py:1466:13: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:1466:21: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[datetime]`? -homeassistant/helpers/event.py:1500:10: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:1466:33: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:1500:18: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[datetime]`? -homeassistant/helpers/event.py:1546:13: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:1500:30: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:1546:21: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[datetime]`? -homeassistant/helpers/event.py:1571:31: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:1546:33: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:1571:39: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[datetime]`? -homeassistant/helpers/event.py:1581:13: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:1571:51: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:1581:21: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[datetime]`? -homeassistant/helpers/event.py:1602:13: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:1581:33: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:1602:21: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[datetime]`? -homeassistant/helpers/event.py:1632:17: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:1602:33: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:1632:25: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[datetime]`? -homeassistant/helpers/event.py:1633:15: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:1632:37: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:1633:23: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[datetime]`? -homeassistant/helpers/event.py:1708:10: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:1633:35: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:1708:18: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `tuple[()]`? -homeassistant/helpers/event.py:1805:10: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:1708:22: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:1805:18: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[datetime]`? -homeassistant/helpers/event.py:1807:40: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/event.py:1805:30: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/event.py:1807:48: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[datetime]`? +homeassistant/helpers/event.py:1807:60: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/floor_registry.py:287:16: error[invalid-return-type] Return type does not match returned value: expected `FloorRegistryStoreData`, found `dict[Unknown | str, Unknown | list[dict[Unknown | str, Unknown | list[str] | str | None | int] | Unknown]]` homeassistant/helpers/floor_registry.py:288:23: error[invalid-argument-type] Invalid argument to key "floors" with declared type `list[_FloorStoreData]` on TypedDict `FloorRegistryStoreData`: value of type `list[dict[Unknown | str, Unknown | list[str] | str | None | int] | Unknown]` homeassistant/helpers/helper_integration.py:73:32: error[invalid-key] Unknown key "changes" for TypedDict `_EventEntityRegistryUpdatedData_CreateRemove`: Unknown key "changes" homeassistant/helpers/helper_integration.py:81:60: error[invalid-key] Unknown key "changes" for TypedDict `_EventEntityRegistryUpdatedData_CreateRemove`: Unknown key "changes" -homeassistant/helpers/integration_platform.py:37:18: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/integration_platform.py:37:26: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `tuple[HomeAssistant, str, Any]`? +homeassistant/helpers/integration_platform.py:37:53: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/label_registry.py:250:16: error[invalid-return-type] Return type does not match returned value: expected `LabelRegistryStoreData`, found `dict[Unknown | str, Unknown | list[dict[Unknown | str, Unknown | str | None] | Unknown]]` homeassistant/helpers/label_registry.py:251:23: error[invalid-argument-type] Invalid argument to key "labels" with declared type `list[_LabelStoreData]` on TypedDict `LabelRegistryStoreData`: value of type `list[dict[Unknown | str, Unknown | str | None] | Unknown]` +homeassistant/helpers/registry.py:38:9: error[invalid-method-override] Invalid override of method `__setitem__`: Definition is incompatible with `UserDict.__setitem__` homeassistant/helpers/schema_config_entry_flow.py:258:40: error[invalid-assignment] Object of type `(((dict[str, Any], /) -> Coroutine[Any, Any, str | None]) & ~(() -> object)) | (str & ~(() -> object)) | None` is not assignable to `str | None` -homeassistant/helpers/script.py:153:25: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 3 -homeassistant/helpers/script.py:154:29: error[too-many-positional-arguments] Too many positional arguments to class `SignalTypeFormat`: expected 0, got 1 -homeassistant/helpers/service.py:920:18: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/script.py:153:36: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 3 +homeassistant/helpers/script.py:154:46: error[invalid-type-arguments] Too many type arguments to class `SignalTypeFormat`: expected 0, got 1 +homeassistant/helpers/script_variables.py:196:9: error[invalid-method-override] Invalid override of method `__setitem__`: Definition is incompatible with `UserDict.__setitem__` homeassistant/helpers/service.py:921:9: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `list[ServiceCall]`? -homeassistant/helpers/service.py:1131:25: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 -homeassistant/helpers/service.py:1169:25: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/service.py:922:9: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/service.py:1131:38: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/service.py:1169:38: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/singleton.py:68:32: error[invalid-await] `_Coro[_T@singleton] | _U@singleton` is not awaitable homeassistant/helpers/singleton.py:83:12: error[invalid-return-type] Return type does not match returned value: expected `(_FuncType[_S@singleton], /) -> _FuncType[_S@singleton]`, found `Overload[(func: _FuncType[_Coro[_T@singleton]]) -> _FuncType[_Coro[_T@singleton]], (func: _FuncType[_U@singleton]) -> _FuncType[_U@singleton]]` homeassistant/helpers/singleton.py:121:5: error[type-assertion-failure] Type `str` does not match asserted type `Unknown` @@ -4650,87 +4602,83 @@ homeassistant/helpers/storage.py:392:13: error[invalid-assignment] Cannot assign homeassistant/helpers/storage.py:392:13: error[invalid-assignment] Cannot assign to a subscript on an object of type `float` homeassistant/helpers/storage.py:392:13: error[invalid-assignment] Cannot assign to a subscript on an object of type `None` homeassistant/helpers/storage.py:392:13: error[invalid-assignment] Invalid subscript assignment with key of type `Literal["minor_version"]` and value of type `Literal[1]` on object of type `list[JsonValueType]` -homeassistant/helpers/storage.py:395:13: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[Any] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]` +homeassistant/helpers/storage.py:395:13: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]` homeassistant/helpers/storage.py:395:13: error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString, (key: SupportsIndex | slice[Any, Any, Any], /) -> str]` cannot be called with key of type `Literal["version"]` on object of type `str` homeassistant/helpers/storage.py:395:13: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method homeassistant/helpers/storage.py:395:13: error[non-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method homeassistant/helpers/storage.py:395:13: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method -homeassistant/helpers/storage.py:396:17: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[Any] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]` cannot be called with key of type `Literal["minor_version"]` on object of type `list[JsonValueType]` +homeassistant/helpers/storage.py:396:17: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["minor_version"]` on object of type `list[JsonValueType]` homeassistant/helpers/storage.py:396:17: error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString, (key: SupportsIndex | slice[Any, Any, Any], /) -> str]` cannot be called with key of type `Literal["minor_version"]` on object of type `str` homeassistant/helpers/storage.py:396:17: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method homeassistant/helpers/storage.py:396:17: error[non-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method homeassistant/helpers/storage.py:396:17: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/helpers/storage.py:398:22: error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString, (key: SupportsIndex | slice[Any, Any, Any], /) -> str]` cannot be called with key of type `Literal["data"]` on object of type `str` -homeassistant/helpers/storage.py:398:22: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[Any] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]` cannot be called with key of type `Literal["data"]` on object of type `list[JsonValueType]` +homeassistant/helpers/storage.py:398:22: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["data"]` on object of type `list[JsonValueType]` homeassistant/helpers/storage.py:398:22: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method homeassistant/helpers/storage.py:398:22: error[non-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method homeassistant/helpers/storage.py:398:22: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method -homeassistant/helpers/storage.py:403:17: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[Any] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]` +homeassistant/helpers/storage.py:403:17: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]` homeassistant/helpers/storage.py:403:17: error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString, (key: SupportsIndex | slice[Any, Any, Any], /) -> str]` cannot be called with key of type `Literal["version"]` on object of type `str` homeassistant/helpers/storage.py:403:17: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method homeassistant/helpers/storage.py:403:17: error[non-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method homeassistant/helpers/storage.py:403:17: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method -homeassistant/helpers/storage.py:404:17: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[Any] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]` cannot be called with key of type `Literal["minor_version"]` on object of type `list[JsonValueType]` +homeassistant/helpers/storage.py:404:17: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["minor_version"]` on object of type `list[JsonValueType]` homeassistant/helpers/storage.py:404:17: error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString, (key: SupportsIndex | slice[Any, Any, Any], /) -> str]` cannot be called with key of type `Literal["minor_version"]` on object of type `str` homeassistant/helpers/storage.py:404:17: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method homeassistant/helpers/storage.py:404:17: error[non-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method homeassistant/helpers/storage.py:404:17: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/helpers/storage.py:409:32: error[missing-argument] No argument provided for required parameter `old_data` of bound method `_async_migrate_func` -homeassistant/helpers/storage.py:409:57: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[Any] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]` +homeassistant/helpers/storage.py:409:57: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]` homeassistant/helpers/storage.py:409:57: error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString, (key: SupportsIndex | slice[Any, Any, Any], /) -> str]` cannot be called with key of type `Literal["version"]` on object of type `str` homeassistant/helpers/storage.py:409:57: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method homeassistant/helpers/storage.py:409:57: error[non-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method homeassistant/helpers/storage.py:409:57: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method -homeassistant/helpers/storage.py:409:74: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[Any] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]` cannot be called with key of type `Literal["data"]` on object of type `list[JsonValueType]` +homeassistant/helpers/storage.py:409:74: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["data"]` on object of type `list[JsonValueType]` homeassistant/helpers/storage.py:409:74: error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString, (key: SupportsIndex | slice[Any, Any, Any], /) -> str]` cannot be called with key of type `Literal["data"]` on object of type `str` homeassistant/helpers/storage.py:409:74: error[non-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method homeassistant/helpers/storage.py:409:74: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method homeassistant/helpers/storage.py:409:74: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method -homeassistant/helpers/storage.py:413:25: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[Any] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]` +homeassistant/helpers/storage.py:413:25: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]` homeassistant/helpers/storage.py:413:25: error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString, (key: SupportsIndex | slice[Any, Any, Any], /) -> str]` cannot be called with key of type `Literal["version"]` on object of type `str` homeassistant/helpers/storage.py:413:25: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method homeassistant/helpers/storage.py:413:25: error[non-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method homeassistant/helpers/storage.py:413:25: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method -homeassistant/helpers/storage.py:413:42: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[Any] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]` cannot be called with key of type `Literal["minor_version"]` on object of type `list[JsonValueType]` +homeassistant/helpers/storage.py:413:42: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["minor_version"]` on object of type `list[JsonValueType]` homeassistant/helpers/storage.py:413:42: error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString, (key: SupportsIndex | slice[Any, Any, Any], /) -> str]` cannot be called with key of type `Literal["minor_version"]` on object of type `str` homeassistant/helpers/storage.py:413:42: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method homeassistant/helpers/storage.py:413:42: error[non-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method homeassistant/helpers/storage.py:413:42: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method -homeassistant/helpers/storage.py:413:65: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[Any] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]` cannot be called with key of type `Literal["data"]` on object of type `list[JsonValueType]` +homeassistant/helpers/storage.py:413:65: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["data"]` on object of type `list[JsonValueType]` homeassistant/helpers/storage.py:413:65: error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString, (key: SupportsIndex | slice[Any, Any, Any], /) -> str]` cannot be called with key of type `Literal["data"]` on object of type `str` homeassistant/helpers/storage.py:413:65: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method homeassistant/helpers/storage.py:413:65: error[non-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method homeassistant/helpers/storage.py:413:65: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method -homeassistant/helpers/storage.py:416:24: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[Any] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]` +homeassistant/helpers/storage.py:416:24: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]` homeassistant/helpers/storage.py:416:24: error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString, (key: SupportsIndex | slice[Any, Any, Any], /) -> str]` cannot be called with key of type `Literal["version"]` on object of type `str` homeassistant/helpers/storage.py:416:24: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method homeassistant/helpers/storage.py:416:24: error[non-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method homeassistant/helpers/storage.py:416:24: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method -homeassistant/helpers/storage.py:418:30: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[Any] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | list[Any] | str | ... omitted 3 union elements]]` cannot be called with key of type `Literal["data"]` on object of type `list[JsonValueType]` +homeassistant/helpers/storage.py:418:30: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[Any, Any, Any], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["data"]` on object of type `list[JsonValueType]` homeassistant/helpers/storage.py:418:30: error[invalid-argument-type] Method `__getitem__` of type `Overload[(key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString, (key: SupportsIndex | slice[Any, Any, Any], /) -> str]` cannot be called with key of type `Literal["data"]` on object of type `str` homeassistant/helpers/storage.py:418:30: error[non-subscriptable] Cannot subscript object of type `int` with no `__getitem__` method homeassistant/helpers/storage.py:418:30: error[non-subscriptable] Cannot subscript object of type `float` with no `__getitem__` method homeassistant/helpers/storage.py:418:30: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method homeassistant/helpers/storage.py:419:35: error[invalid-argument-type] Argument to bound method `async_save` is incorrect: Argument type `Unknown | dict[str, Any] | list[Any] | ... omitted 4 union elements` does not satisfy upper bound `Mapping[str, Any] | Sequence[Any]` of type variable `_T` homeassistant/helpers/storage.py:419:35: error[invalid-argument-type] Argument to bound method `async_save` is incorrect: Expected `_T@Store`, found `Unknown | dict[str, Any] | list[Any] | ... omitted 4 union elements` -homeassistant/helpers/target.py:328:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventEntityRegistryUpdatedData]` -homeassistant/helpers/target.py:331:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventDeviceRegistryUpdatedData]` +homeassistant/helpers/target.py:328:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update]` +homeassistant/helpers/target.py:331:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[_EventDeviceRegistryUpdatedData_Create | _EventDeviceRegistryUpdatedData_Remove | _EventDeviceRegistryUpdatedData_Update]` homeassistant/helpers/target.py:334:17: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `EventType[Mapping[str, Any]] | str`, found `EventType[EventAreaRegistryUpdatedData]` homeassistant/helpers/template/__init__.py:605:13: warning[possibly-missing-attribute] Attribute `loop` may be missing on object of type `Unknown | HomeAssistant | None` -homeassistant/helpers/template/__init__.py:1787:14: error[unresolved-attribute] Module `jinja2` has no member `filters` -homeassistant/helpers/template/__init__.py:1795:14: error[unresolved-attribute] Module `jinja2` has no member `filters` -homeassistant/helpers/template/__init__.py:2181:19: error[unresolved-attribute] Module `jinja2` has no member `nodes` -homeassistant/helpers/template/__init__.py:2428:23: error[unresolved-attribute] Module `jinja2` has no member `nodes` -homeassistant/helpers/template/__init__.py:2438:23: error[unresolved-attribute] Module `jinja2` has no member `nodes` -homeassistant/helpers/template/__init__.py:2447:23: error[unresolved-attribute] Module `jinja2` has no member `nodes` -homeassistant/helpers/trigger.py:358:13: error[too-many-positional-arguments] Too many positional arguments to class `HassJob`: expected 1, got 2 +homeassistant/helpers/template/__init__.py:1787:14: warning[possibly-missing-attribute] Submodule `filters` may not be available as an attribute on module `jinja2` +homeassistant/helpers/template/__init__.py:1795:14: warning[possibly-missing-attribute] Submodule `filters` may not be available as an attribute on module `jinja2` +homeassistant/helpers/template/__init__.py:2181:19: warning[possibly-missing-attribute] Submodule `nodes` may not be available as an attribute on module `jinja2` +homeassistant/helpers/template/__init__.py:2428:23: warning[possibly-missing-attribute] Submodule `nodes` may not be available as an attribute on module `jinja2` +homeassistant/helpers/template/__init__.py:2438:23: warning[possibly-missing-attribute] Submodule `nodes` may not be available as an attribute on module `jinja2` +homeassistant/helpers/template/__init__.py:2447:23: warning[possibly-missing-attribute] Submodule `nodes` may not be available as an attribute on module `jinja2` homeassistant/helpers/trigger.py:358:21: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `tuple[dict[str, Any], Context | None]`? +homeassistant/helpers/trigger.py:358:55: error[invalid-type-arguments] Too many type arguments to class `HassJob`: expected 1, got 2 homeassistant/helpers/trigger.py:476:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[str, TriggerProtocol]`, found `tuple[Unknown | str, ModuleType]` homeassistant/helpers/update_coordinator.py:218:20: error[not-iterable] Object of type `GeneratorType[~None, None, None]` is not iterable -homeassistant/helpers/update_coordinator.py:360:13: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/helpers/update_coordinator.py:362:13: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/helpers/update_coordinator.py:421:31: error[unresolved-attribute] Module `requests` has no member `exceptions` -homeassistant/helpers/update_coordinator.py:428:38: error[unresolved-attribute] Module `requests` has no member `exceptions` homeassistant/loader.py:297:16: error[unresolved-import] Cannot resolve imported module `custom_components` homeassistant/loader.py:979:20: error[invalid-return-type] Return type does not match returned value: expected `ComponentProtocol`, found `Unknown | ModuleType | ComponentProtocol` homeassistant/loader.py:1057:20: error[invalid-return-type] Return type does not match returned value: expected `ComponentProtocol`, found `Unknown | ModuleType | ComponentProtocol` @@ -4738,7 +4686,6 @@ homeassistant/loader.py:1084:16: error[invalid-return-type] Return type does not homeassistant/loader.py:1487:9: error[invalid-argument-type] Argument to function `_resolve_integrations_dependencies` is incorrect: Expected `_ResolveDependenciesCacheProtocol`, found `dict[Unknown, Unknown]` homeassistant/loader.py:1673:16: error[unresolved-import] Cannot resolve imported module `custom_components` homeassistant/scripts/benchmark/__init__.py:39:32: error[unresolved-attribute] Object of type `_AbstractEventLoopPolicy` has no attribute `loop_name` -homeassistant/scripts/benchmark/__init__.py:56:16: error[unresolved-attribute] Object of type `_CallableT@benchmark` has no attribute `__name__` homeassistant/setup.py:650:13: error[invalid-argument-type] Argument to bound method `async_listen` is incorrect: Expected `((Mapping[str, Any], /) -> bool) | None`, found `def _async_is_component_filter(event_data: EventComponentLoaded) -> bool` homeassistant/util/__init__.py:153:28: error[unresolved-attribute] Object of type `((...) -> Unknown) & ~` has no attribute `__qualname__` homeassistant/util/__init__.py:170:17: error[invalid-assignment] Object of type `dict[Unknown, Unknown]` is not assignable to attribute `_throttle` on type `~` @@ -4747,6 +4694,11 @@ homeassistant/util/__init__.py:173:17: error[unresolved-attribute] Object of typ homeassistant/util/__init__.py:174:24: error[unresolved-attribute] Object of type `object` has no attribute `_throttle` homeassistant/util/__init__.py:177:24: error[invalid-return-type] Return type does not match returned value: expected `((...) -> Unknown) | Coroutine[Unknown, Unknown, Unknown]`, found `CoroutineType[Any, Any, None] | None` homeassistant/util/__init__.py:188:24: error[invalid-return-type] Return type does not match returned value: expected `((...) -> Unknown) | Coroutine[Unknown, Unknown, Unknown]`, found `CoroutineType[Any, Any, None] | None` +homeassistant/util/hass_dict.pyi:37:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `dict.__getitem__` +homeassistant/util/hass_dict.pyi:47:9: error[invalid-method-override] Invalid override of method `__setitem__`: Definition is incompatible with `dict.__setitem__` +homeassistant/util/hass_dict.pyi:59:9: error[invalid-method-override] Invalid override of method `setdefault`: Definition is incompatible with `MutableMapping.setdefault` +homeassistant/util/hass_dict.pyi:75:9: error[invalid-method-override] Invalid override of method `get`: Definition is incompatible with `dict.get` +homeassistant/util/hass_dict.pyi:97:9: error[invalid-method-override] Invalid override of method `pop`: Definition is incompatible with `dict.pop` homeassistant/util/hass_dict.pyi:134:5: error[type-assertion-failure] Type `dict[str, int] | bool` does not match asserted type `dict[str, int] | Literal[True]` homeassistant/util/hass_dict.pyi:138:5: error[type-assertion-failure] Type `dict[int, bool]` does not match asserted type `dict[int, bool] | dict[Unknown, Unknown]` homeassistant/util/hass_dict.pyi:140:5: error[type-assertion-failure] Type `set[str]` does not match asserted type `set[str] | set[Unknown]` @@ -4774,21 +4726,15 @@ homeassistant/util/loop.py:143:13: error[unresolved-attribute] Object of type `( homeassistant/util/loop.py:154:31: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__name__` homeassistant/util/loop.py:160:40: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__name__` homeassistant/util/loop.py:167:34: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__name__` -homeassistant/util/package.py:183:15: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/util/package.py:184:16: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/util/package.py:185:16: error[unresolved-attribute] Module `asyncio` has no member `subprocess` -homeassistant/util/signal_type.py:12:24: error[too-many-positional-arguments] Too many positional arguments to class `_SignalTypeBase`: expected 0, got 1 -homeassistant/util/signal_type.py:18:30: error[too-many-positional-arguments] Too many positional arguments to class `_SignalTypeBase`: expected 0, got 1 -homeassistant/util/signal_type.pyi:21:24: error[too-many-positional-arguments] Too many positional arguments to class `_SignalTypeBase`: expected 0, got 1 -homeassistant/util/signal_type.pyi:24:30: error[too-many-positional-arguments] Too many positional arguments to class `_SignalTypeBase`: expected 0, got 1 -homeassistant/util/signal_type.pyi:27:52: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/util/signal_type.pyi:52:15: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/util/signal_type.pyi:53:5: error[type-assertion-failure] Type `Unknown` does not match asserted type `SignalType[]` -homeassistant/util/signal_type.pyi:53:27: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 -homeassistant/util/signal_type.pyi:61:20: error[too-many-positional-arguments] Too many positional arguments to class `SignalTypeFormat`: expected 0, got 1 -homeassistant/util/signal_type.pyi:63:5: error[type-assertion-failure] Type `Unknown` does not match asserted type `SignalTypeFormat[]` -homeassistant/util/signal_type.pyi:63:32: error[too-many-positional-arguments] Too many positional arguments to class `SignalTypeFormat`: expected 0, got 1 -homeassistant/util/signal_type.pyi:64:27: error[too-many-positional-arguments] Too many positional arguments to class `SignalType`: expected 0, got 1 +homeassistant/util/signal_type.py:12:40: error[invalid-type-arguments] Too many type arguments to class `_SignalTypeBase`: expected 0, got 1 +homeassistant/util/signal_type.py:18:46: error[invalid-type-arguments] Too many type arguments to class `_SignalTypeBase`: expected 0, got 1 +homeassistant/util/signal_type.pyi:21:40: error[invalid-type-arguments] Too many type arguments to class `_SignalTypeBase`: expected 0, got 1 +homeassistant/util/signal_type.pyi:24:46: error[invalid-type-arguments] Too many type arguments to class `_SignalTypeBase`: expected 0, got 1 +homeassistant/util/signal_type.pyi:27:63: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/util/signal_type.pyi:52:26: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/util/signal_type.pyi:53:38: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 +homeassistant/util/signal_type.pyi:61:37: error[invalid-type-arguments] Too many type arguments to class `SignalTypeFormat`: expected 0, got 1 +homeassistant/util/signal_type.pyi:63:49: error[invalid-type-arguments] Too many type arguments to class `SignalTypeFormat`: expected 0, got 1 +homeassistant/util/signal_type.pyi:64:38: error[invalid-type-arguments] Too many type arguments to class `SignalType`: expected 0, got 1 homeassistant/util/variance.py:41:43: error[unsupported-operator] Operator `-` is unsupported between objects of type `_R@ignore_variance` and `_R@ignore_variance` -homeassistant/util/yaml/loader.py:82:43: error[unresolved-attribute] Module `yaml` has no member `nodes` -Found 4793 diagnostics +Found 4739 diagnostics diff --git a/scripts/ty_benchmark/snapshots/isort_ty.txt b/scripts/ty_benchmark/snapshots/isort_ty.txt index 692eba4803..eb9f854d6c 100644 --- a/scripts/ty_benchmark/snapshots/isort_ty.txt +++ b/scripts/ty_benchmark/snapshots/isort_ty.txt @@ -4,7 +4,7 @@ isort/core.py:126:40: error[invalid-argument-type] Argument to function `__new__ isort/output.py:534:25: error[invalid-argument-type] Argument to function `import_statement` is incorrect: Expected `Sequence[str]`, found `@Todo | None | list[Unknown]` isort/output.py:544:25: error[invalid-argument-type] Argument to function `import_statement` is incorrect: Expected `Sequence[str]`, found `@Todo | None | list[Unknown]` isort/output.py:552:29: error[invalid-argument-type] Argument to function `import_statement` is incorrect: Expected `Sequence[str]`, found `@Todo | None | list[Unknown]` -isort/place.py:104:31: error[unresolved-attribute] Module `importlib` has no member `machinery` +isort/place.py:104:31: warning[possibly-missing-attribute] Submodule `machinery` may not be available as an attribute on module `importlib` isort/settings.py:641:9: error[invalid-assignment] Property `_known_patterns` defined in `Self@known_patterns` is read-only isort/settings.py:665:9: error[invalid-assignment] Property `_section_comments` defined in `Self@section_comments` is read-only isort/settings.py:673:9: error[invalid-assignment] Property `_section_comments_end` defined in `Self@section_comments_end` is read-only diff --git a/scripts/ty_benchmark/snapshots/jinja_ty.txt b/scripts/ty_benchmark/snapshots/jinja_ty.txt index 7e835ee50f..2625260c28 100644 --- a/scripts/ty_benchmark/snapshots/jinja_ty.txt +++ b/scripts/ty_benchmark/snapshots/jinja_ty.txt @@ -18,7 +18,5 @@ src/jinja2/runtime.py:144:2: error[unresolved-attribute] Class `Mapping` has no src/jinja2/runtime.py:690:38: error[invalid-assignment] Object of type `(Unknown & ~(() -> object)) | bool | (((str | None, /) -> bool) & ~(() -> object))` is not assignable to `bool | None` src/jinja2/runtime.py:770:40: error[invalid-argument-type] Argument to bound method `_invoke` is incorrect: Expected `bool`, found `@Todo | bool | None` src/jinja2/runtime.py:948:14: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `Never` -src/jinja2/utils.py:100:23: error[unresolved-attribute] Object of type `F@internalcode` has no attribute `__code__` src/jinja2/utils.py:431:2: error[unresolved-attribute] Class `MutableMapping` has no attribute `register` -src/jinja2/utils.py:472:16: error[invalid-return-type] Return type does not match returned value: expected `Self@copy`, found `LRUCache` -Found 23 diagnostics +Found 21 diagnostics diff --git a/scripts/ty_benchmark/snapshots/pandas-stubs_ty.txt b/scripts/ty_benchmark/snapshots/pandas-stubs_ty.txt index da15b85ea3..eb515d3508 100644 --- a/scripts/ty_benchmark/snapshots/pandas-stubs_ty.txt +++ b/scripts/ty_benchmark/snapshots/pandas-stubs_ty.txt @@ -1,9 +1,49 @@ -pandas-stubs/_typing.pyi:861:25: error[invalid-argument-type] Argument to class `ndarray` is incorrect: Expected `tuple[int, ...]`, found `typing.TypeVar` -pandas-stubs/_typing.pyi:861:44: error[invalid-argument-type] Argument to class `dtype` is incorrect: Expected `generic[Any]`, found `typing.TypeVar` -pandas-stubs/_typing.pyi:865:48: error[invalid-argument-type] Argument to class `dtype` is incorrect: Expected `generic[Any]`, found `typing.TypeVar` -pandas-stubs/_typing.pyi:877:53: error[invalid-argument-type] Argument to class `dtype` is incorrect: Expected `generic[Any]`, found `typing.TypeVar` -pandas-stubs/core/series.pyi:338:57: error[invalid-argument-type] Argument to class `IndexOpsMixin` is incorrect: Expected `str | bytes | int | ... omitted 12 union elements`, found `typing.TypeVar` +pandas-stubs/_libs/missing.pyi:120:9: error[invalid-method-override] Invalid override of method `__eq__`: Definition is incompatible with `object.__eq__` +pandas-stubs/_libs/missing.pyi:130:9: error[invalid-method-override] Invalid override of method `__ne__`: Definition is incompatible with `object.__ne__` +pandas-stubs/_typing.pyi:861:36: error[invalid-type-arguments] Type `typing.TypeVar` is not assignable to upper bound `tuple[int, ...]` of type variable `_ShapeT_co@ndarray` +pandas-stubs/_typing.pyi:861:53: error[invalid-type-arguments] Type `typing.TypeVar` is not assignable to upper bound `generic[Any]` of type variable `_SCT_co@dtype` +pandas-stubs/_typing.pyi:865:57: error[invalid-type-arguments] Type `typing.TypeVar` is not assignable to upper bound `generic[Any]` of type variable `_SCT_co@dtype` +pandas-stubs/_typing.pyi:877:62: error[invalid-type-arguments] Type `typing.TypeVar` is not assignable to upper bound `generic[Any]` of type variable `_SCT_co@dtype` +pandas-stubs/core/arrays/categorical.pyi:114:9: error[invalid-method-override] Invalid override of method `__contains__`: Definition is incompatible with `ExtensionArray.__contains__` +pandas-stubs/core/arrays/categorical.pyi:118:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `ExtensionArray.__getitem__` +pandas-stubs/core/arrays/datetimelike.pyi:76:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `ExtensionArray.__getitem__` +pandas-stubs/core/arrays/interval.pyi:66:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `ExtensionArray.__getitem__` +pandas-stubs/core/arrays/sparse/array.pyi:66:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `ExtensionArray.__getitem__` +pandas-stubs/core/frame.pyi:193:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `_LocationIndexer.__getitem__` +pandas-stubs/core/frame.pyi:204:9: error[invalid-method-override] Invalid override of method `__setitem__`: Definition is incompatible with `_NDFrameIndexer.__setitem__` +pandas-stubs/core/frame.pyi:280:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `_LocationIndexer.__getitem__` +pandas-stubs/core/frame.pyi:303:9: error[invalid-method-override] Invalid override of method `__setitem__`: Definition is incompatible with `_NDFrameIndexer.__setitem__` +pandas-stubs/core/frame.pyi:320:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `_ScalarAccessIndexer.__getitem__` +pandas-stubs/core/frame.pyi:321:9: error[invalid-method-override] Invalid override of method `__setitem__`: Definition is incompatible with `_ScalarAccessIndexer.__setitem__` +pandas-stubs/core/frame.pyi:328:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `_ScalarAccessIndexer.__getitem__` +pandas-stubs/core/frame.pyi:339:9: error[invalid-method-override] Invalid override of method `__setitem__`: Definition is incompatible with `_ScalarAccessIndexer.__setitem__` +pandas-stubs/core/groupby/generic.pyi:247:9: error[invalid-method-override] Invalid override of method `apply`: Definition is incompatible with `GroupBy.apply` +pandas-stubs/core/groupby/generic.pyi:300:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `BaseGroupBy.__getitem__` +pandas-stubs/core/groupby/generic.pyi:452:9: error[invalid-method-override] Invalid override of method `__getattr__`: Definition is incompatible with `GroupBy.__getattr__` +pandas-stubs/core/groupby/groupby.pyi:74:35: error[invalid-type-arguments] Type `typing.TypeVar` is not assignable to upper bound `NDFrame` of type variable `NDFrameT@DatetimeIndexResamplerGroupby` +pandas-stubs/core/groupby/groupby.pyi:75:35: error[invalid-type-arguments] Type `typing.TypeVar` is not assignable to upper bound `NDFrame` of type variable `NDFrameT@PeriodIndexResamplerGroupby` +pandas-stubs/core/groupby/groupby.pyi:76:38: error[invalid-type-arguments] Type `typing.TypeVar` is not assignable to upper bound `NDFrame` of type variable `NDFrameT@TimedeltaIndexResamplerGroupby` +pandas-stubs/core/indexes/datetimes.pyi:76:9: error[invalid-method-override] Invalid override of method `__sub__`: Definition is incompatible with `Index.__sub__` +pandas-stubs/core/indexes/interval.pyi:242:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `Index.__getitem__` +pandas-stubs/core/indexes/interval.pyi:250:9: error[invalid-method-override] Invalid override of method `__gt__`: Definition is incompatible with `Index.__gt__` +pandas-stubs/core/indexes/interval.pyi:258:9: error[invalid-method-override] Invalid override of method `__ge__`: Definition is incompatible with `Index.__ge__` +pandas-stubs/core/indexes/interval.pyi:266:9: error[invalid-method-override] Invalid override of method `__le__`: Definition is incompatible with `Index.__le__` +pandas-stubs/core/indexes/interval.pyi:274:9: error[invalid-method-override] Invalid override of method `__lt__`: Definition is incompatible with `Index.__lt__` +pandas-stubs/core/indexes/interval.pyi:282:9: error[invalid-method-override] Invalid override of method `__eq__`: Definition is incompatible with `OpsMixin.__eq__` +pandas-stubs/core/indexes/interval.pyi:290:9: error[invalid-method-override] Invalid override of method `__ne__`: Definition is incompatible with `OpsMixin.__ne__` +pandas-stubs/core/indexes/period.pyi:57:9: error[invalid-method-override] Invalid override of method `__sub__`: Definition is incompatible with `Index.__sub__` +pandas-stubs/core/indexes/period.pyi:66:9: error[invalid-method-override] Invalid override of method `__rsub__`: Definition is incompatible with `Index.__rsub__` +pandas-stubs/core/indexes/range.pyi:84:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `Index.__getitem__` +pandas-stubs/core/indexes/timedeltas.pyi:77:9: error[invalid-method-override] Invalid override of method `__add__`: Definition is incompatible with `Index.__add__` +pandas-stubs/core/indexes/timedeltas.pyi:86:9: error[invalid-method-override] Invalid override of method `__radd__`: Definition is incompatible with `Index.__radd__` +pandas-stubs/core/indexes/timedeltas.pyi:98:9: error[invalid-method-override] Invalid override of method `__rsub__`: Definition is incompatible with `Index.__rsub__` +pandas-stubs/core/series.pyi:274:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `_LocationIndexer.__getitem__` +pandas-stubs/core/series.pyi:283:9: error[invalid-method-override] Invalid override of method `__setitem__`: Definition is incompatible with `_NDFrameIndexer.__setitem__` +pandas-stubs/core/series.pyi:300:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `_LocationIndexer.__getitem__` +pandas-stubs/core/series.pyi:330:9: error[invalid-method-override] Invalid override of method `__setitem__`: Definition is incompatible with `_NDFrameIndexer.__setitem__` +pandas-stubs/core/series.pyi:338:71: error[invalid-type-arguments] Type `typing.TypeVar` is not assignable to upper bound `str | bytes | int | ... omitted 12 union elements` of type variable `S1@IndexOpsMixin` +pandas-stubs/core/series.pyi:4630:9: error[invalid-method-override] Invalid override of method `xs`: Definition is incompatible with `NDFrame.xs` pandas-stubs/io/excel/_base.pyi:16:6: error[unresolved-import] Cannot resolve imported module `openpyxl.workbook.workbook` pandas-stubs/io/excel/_base.pyi:20:6: error[unresolved-import] Cannot resolve imported module `xlrd.book` -Found 7 diagnostics +Found 47 diagnostics WARN Ignoring the `tool.ty` section in `/pyproject.toml` because `/ty.toml` takes precedence. diff --git a/scripts/ty_benchmark/snapshots/pandas_ty.txt b/scripts/ty_benchmark/snapshots/pandas_ty.txt index 417ae2ef78..0bf4dbf365 100644 --- a/scripts/ty_benchmark/snapshots/pandas_ty.txt +++ b/scripts/ty_benchmark/snapshots/pandas_ty.txt @@ -1,6 +1,9 @@ pandas/__init__.py:178:10: error[unresolved-import] Cannot resolve imported module `pandas._version_meson` -pandas/_testing/__init__.py:507:25: error[unresolved-attribute] Module `pandas.core` has no member `arrays` -pandas/_testing/__init__.py:509:25: error[unresolved-attribute] Module `pandas.core` has no member `arrays` +pandas/_libs/sparse.pyi:43:9: error[invalid-method-override] Invalid override of method `intersect`: Definition is incompatible with `SparseIndex.intersect` +pandas/_libs/sparse.pyi:44:9: error[invalid-method-override] Invalid override of method `make_union`: Definition is incompatible with `SparseIndex.make_union` +pandas/_libs/tslibs/timestamps.pyi:159:9: error[invalid-method-override] Invalid override of method `__sub__`: Definition is incompatible with `date.__sub__` +pandas/_testing/__init__.py:507:25: warning[possibly-missing-attribute] Submodule `arrays` may not be available as an attribute on module `pandas.core` +pandas/_testing/__init__.py:509:25: warning[possibly-missing-attribute] Submodule `arrays` may not be available as an attribute on module `pandas.core` pandas/_version.py:44:5: error[unresolved-attribute] Unresolved attribute `VCS` on type `VersioneerConfig`. pandas/_version.py:45:5: error[unresolved-attribute] Unresolved attribute `style` on type `VersioneerConfig`. pandas/_version.py:46:5: error[unresolved-attribute] Unresolved attribute `tag_prefix` on type `VersioneerConfig`. @@ -9,8 +12,6 @@ pandas/_version.py:48:5: error[unresolved-attribute] Unresolved attribute `versi pandas/_version.py:49:5: error[unresolved-attribute] Unresolved attribute `verbose` on type `VersioneerConfig`. pandas/_version.py:101:16: error[unresolved-attribute] Object of type `BaseException | None` has no attribute `errno` pandas/_version.py:111:14: error[unresolved-attribute] Object of type `str` has no attribute `decode` -pandas/compat/__init__.py:50:5: error[unresolved-attribute] Unresolved attribute `__name__` on type `F@set_function_name`. -pandas/compat/__init__.py:51:5: error[unresolved-attribute] Unresolved attribute `__qualname__` on type `F@set_function_name`. pandas/core/_numba/executor.py:48:22: error[not-iterable] Object of type `prange` is not iterable pandas/core/_numba/executor.py:52:22: error[not-iterable] Object of type `prange` is not iterable pandas/core/_numba/executor.py:78:22: error[not-iterable] Object of type `prange` is not iterable @@ -24,9 +25,7 @@ pandas/core/_numba/extensions.py:32:5: error[unresolved-import] Module `numba.co pandas/core/_numba/extensions.py:61:9: error[unresolved-attribute] Unresolved attribute `_numba_data` on type `Index`. pandas/core/_numba/extensions.py:64:13: error[unresolved-attribute] Object of type `Index` has no attribute `_numba_data` pandas/core/_numba/extensions.py:74:48: error[invalid-type-form] Variable of type `def any(iterable: Iterable[object], /) -> bool` is not allowed in a type expression -pandas/core/_numba/extensions.py:94:16: error[invalid-return-type] Return type does not match returned value: expected `Self@copy`, found `IndexType` -pandas/core/_numba/extensions.py:124:16: error[invalid-return-type] Return type does not match returned value: expected `Self@copy`, found `SeriesType` -pandas/core/_numba/extensions.py:299:67: error[unresolved-attribute] Module `numba` has no member `typed` +pandas/core/_numba/extensions.py:299:67: warning[possibly-missing-attribute] Submodule `typed` may not be available as an attribute on module `numba` pandas/core/_numba/extensions.py:574:16: error[missing-argument] No argument provided for required parameter `obj` of bound method `__init__` pandas/core/_numba/kernels/mean_.py:135:21: error[unresolved-reference] Name `num_consecutive_same_value` used when not defined pandas/core/_numba/kernels/mean_.py:136:21: error[unresolved-reference] Name `prev_value` used when not defined @@ -126,6 +125,7 @@ pandas/core/arrays/_arrow_string_mixins.py:361:21: error[unresolved-attribute] M pandas/core/arrays/_arrow_string_mixins.py:362:29: error[unresolved-attribute] Module `pyarrow.compute` has no member `add` pandas/core/arrays/_arrow_string_mixins.py:363:22: error[unresolved-attribute] Module `pyarrow.compute` has no member `if_else` pandas/core/arrays/_mixins.py:135:20: error[invalid-return-type] Return type does not match returned value: expected `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]`, found `ndarray[tuple[Any, ...], type]` +pandas/core/arrays/_mixins.py:283:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `ExtensionArray.__getitem__` pandas/core/arrays/arrow/accessors.py:115:25: error[unresolved-attribute] Module `pyarrow.compute` has no member `list_value_length` pandas/core/arrays/arrow/accessors.py:163:23: error[unresolved-attribute] Module `pyarrow.compute` has no member `list_element` pandas/core/arrays/arrow/accessors.py:181:22: error[unresolved-attribute] Module `pyarrow.compute` has no member `list_slice` @@ -191,6 +191,7 @@ pandas/core/arrays/arrow/array.py:1003:22: error[unresolved-attribute] Module `p pandas/core/arrays/arrow/array.py:1007:17: error[unresolved-attribute] Module `pyarrow.compute` has no member `is_null` pandas/core/arrays/arrow/array.py:1073:20: error[unresolved-attribute] Module `pyarrow.compute` has no member `is_nan` pandas/core/arrays/arrow/array.py:1074:19: error[unresolved-attribute] Module `pyarrow.compute` has no member `replace_with_mask` +pandas/core/arrays/arrow/array.py:1109:9: error[invalid-method-override] Invalid override of method `__contains__`: Definition is incompatible with `ExtensionArray.__contains__` pandas/core/arrays/arrow/array.py:1116:24: error[unresolved-attribute] Module `pyarrow.compute` has no member `any` pandas/core/arrays/arrow/array.py:1116:31: error[unresolved-attribute] Module `pyarrow.compute` has no member `is_nan` pandas/core/arrays/arrow/array.py:1284:18: error[unresolved-attribute] Module `pyarrow.compute` has no member `array_sort_indices` @@ -259,7 +260,6 @@ pandas/core/arrays/arrow/array.py:2804:44: error[unresolved-attribute] Module `p pandas/core/arrays/arrow/array.py:2806:44: error[unresolved-attribute] Module `pyarrow.compute` has no member `split_pattern` pandas/core/arrays/arrow/array.py:2814:17: error[unresolved-attribute] Module `pyarrow.compute` has no member `utf8_split_whitespace` pandas/core/arrays/arrow/array.py:2817:13: error[unresolved-attribute] Module `pyarrow.compute` has no member `split_pattern` -pandas/core/arrays/arrow/array.py:2837:16: error[invalid-return-type] Return type does not match returned value: expected `Self@_str_zfill`, found `ArrowExtensionArray` pandas/core/arrays/arrow/array.py:2929:18: error[unresolved-attribute] Module `pyarrow.compute` has no member `year` pandas/core/arrays/arrow/array.py:2934:18: error[unresolved-attribute] Module `pyarrow.compute` has no member `day` pandas/core/arrays/arrow/array.py:2939:18: error[unresolved-attribute] Module `pyarrow.compute` has no member `day_of_week` @@ -311,15 +311,25 @@ pandas/core/arrays/arrow/array.py:3199:22: error[unresolved-attribute] Module `p pandas/core/arrays/arrow/extension_types.py:171:5: error[unresolved-attribute] Unresolved attribute `_hotfix_installed` on type ``. pandas/core/arrays/boolean.py:259:24: warning[possibly-missing-attribute] Attribute `shape` may be missing on object of type `@Todo | None` pandas/core/arrays/boolean.py:262:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[ndarray[tuple[Any, ...], dtype[Any]], ndarray[tuple[Any, ...], dtype[Any]]]`, found `tuple[@Todo, @Todo | None]` +pandas/core/arrays/boolean.py:385:9: error[invalid-method-override] Invalid override of method `_coerce_to_array`: Definition is incompatible with `BaseMaskedArray._coerce_to_array` pandas/core/arrays/categorical.py:494:25: warning[possibly-missing-attribute] Attribute `_codes` may be missing on object of type `Unknown | RangeIndex | ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]` pandas/core/arrays/categorical.py:1397:21: error[no-matching-overload] No overload of function `find_common_type` matches arguments +pandas/core/arrays/categorical.py:1655:9: error[invalid-method-override] Invalid override of method `_validate_scalar`: Definition is incompatible with `NDArrayBackedExtensionArray._validate_scalar` +pandas/core/arrays/categorical.py:2229:9: error[invalid-method-override] Invalid override of method `_box_func`: Definition is incompatible with `NDArrayBackedExtensionArray._box_func` +pandas/core/arrays/categorical.py:2252:9: error[invalid-method-override] Invalid override of method `__contains__`: Definition is incompatible with `ExtensionArray.__contains__` pandas/core/arrays/categorical.py:2567:16: error[invalid-return-type] Return type does not match returned value: expected `Self@unique`, found `Categorical` +pandas/core/arrays/categorical.py:2611:9: error[invalid-method-override] Invalid override of method `_concat_same_type`: Definition is incompatible with `NDArrayBacked._concat_same_type` +pandas/core/arrays/categorical.py:2989:9: error[invalid-method-override] Invalid override of method `_delegate_property_get`: Definition is incompatible with `PandasDelegate._delegate_property_get` +pandas/core/arrays/categorical.py:2992:9: error[invalid-method-override] Invalid override of method `_delegate_property_set`: Definition is incompatible with `PandasDelegate._delegate_property_set` +pandas/core/arrays/datetimelike.py:387:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `ExtensionArray.__getitem__` pandas/core/arrays/datetimelike.py:565:18: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(Unknown & ~str) | Period | Timestamp | Timedelta | NaTType` pandas/core/arrays/datetimelike.py:1315:20: error[invalid-return-type] Return type does not match returned value: expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `ndarray[tuple[int, ...], dtype[Any] | str]` pandas/core/arrays/datetimelike.py:1582:16: error[invalid-return-type] Return type does not match returned value: expected `Self@_quantile`, found `DatetimeLikeArrayMixin` +pandas/core/arrays/datetimelike.py:2375:9: error[invalid-method-override] Invalid override of method `_concat_same_type`: Definition is incompatible with `NDArrayBacked._concat_same_type` pandas/core/arrays/datetimelike.py:2399:16: error[invalid-return-type] Return type does not match returned value: expected `Self@copy`, found `TimelikeOps` pandas/core/arrays/datetimelike.py:2458:16: error[invalid-return-type] Return type does not match returned value: expected `Self@take`, found `TimelikeOps` pandas/core/arrays/datetimelike.py:2476:36: error[invalid-argument-type] Argument to function `py_get_unit_from_dtype` is incorrect: Expected `dtype[Any]`, found `ExtensionDtype` +pandas/core/arrays/datetimes.py:410:9: error[invalid-method-override] Invalid override of method `_generate_range`: Definition is incompatible with `TimelikeOps._generate_range` pandas/core/arrays/datetimes.py:483:62: warning[possibly-missing-attribute] Attribute `tz` may be missing on object of type `Timestamp | None` pandas/core/arrays/datetimes.py:501:51: error[invalid-argument-type] Argument to bound method `tz_localize` is incorrect: Expected `bool | Literal["NaT", "raise"]`, found `Literal["NaT", "infer", "raise"] | @Todo` pandas/core/arrays/datetimes.py:503:47: error[invalid-argument-type] Argument to bound method `tz_localize` is incorrect: Expected `bool | Literal["NaT", "raise"]`, found `Literal["NaT", "infer", "raise"] | @Todo` @@ -341,23 +351,24 @@ pandas/core/arrays/interval.py:396:37: warning[possibly-missing-attribute] Attri pandas/core/arrays/interval.py:399:50: warning[possibly-missing-attribute] Attribute `unit` may be missing on object of type `(Index & ~PeriodIndex) | (Unknown & ~PeriodIndex)` pandas/core/arrays/interval.py:399:63: warning[possibly-missing-attribute] Attribute `unit` may be missing on object of type `Index | Unknown` pandas/core/arrays/interval.py:401:35: warning[possibly-missing-attribute] Attribute `_ensure_matching_resos` may be missing on object of type `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]] | Unknown` +pandas/core/arrays/interval.py:831:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `ExtensionArray.__getitem__` pandas/core/arrays/interval.py:840:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `Unknown | ndarray[tuple[Any, ...], dtype[Any]]` does not satisfy constraints (`int`, `int | float`, `Timestamp`, `Timedelta`) of type variable `_OrderableT` pandas/core/arrays/interval.py:840:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `int`, found `Unknown | ndarray[tuple[Any, ...], dtype[Any]]` pandas/core/arrays/interval.py:1001:16: error[invalid-return-type] Return type does not match returned value: expected `Interval[Unknown] | int | float`, found `Self@min` pandas/core/arrays/interval.py:1018:16: error[invalid-return-type] Return type does not match returned value: expected `Interval[Unknown] | int | float`, found `Self@max` +pandas/core/arrays/interval.py:1127:9: error[invalid-method-override] Invalid override of method `_concat_same_type`: Definition is incompatible with `ExtensionArray._concat_same_type` pandas/core/arrays/interval.py:1801:50: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `Period | Timestamp | Timedelta | NaTType | ndarray[tuple[Any, ...], dtype[Any]]` does not satisfy constraints (`int`, `int | float`, `Timestamp`, `Timedelta`) of type variable `_OrderableT` pandas/core/arrays/interval.py:1801:50: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `int`, found `Period | Timestamp | Timedelta | NaTType | ndarray[tuple[Any, ...], dtype[Any]]` -pandas/core/arrays/masked.py:185:30: error[invalid-assignment] Object of type `ndarray[tuple[int, ...], type]` is not assignable to `ndarray[tuple[Any, ...], dtype[Any]]` -pandas/core/arrays/masked.py:441:16: error[invalid-return-type] Return type does not match returned value: expected `Self@ravel`, found `BaseMaskedArray` -pandas/core/arrays/masked.py:452:16: error[invalid-return-type] Return type does not match returned value: expected `Self@shift`, found `BaseMaskedArray` -pandas/core/arrays/masked.py:1424:16: error[invalid-return-type] Return type does not match returned value: expected `Self@_mode`, found `BaseMaskedArray` -pandas/core/arrays/numpy_.py:386:20: error[invalid-return-type] Return type does not match returned value: expected `Self@take`, found `NumpyExtensionArray` +pandas/core/arrays/masked.py:185:30: error[invalid-assignment] Object of type `ndarray[tuple[int, ...], dtype[Any] | type]` is not assignable to `ndarray[tuple[Any, ...], dtype[Any]]` +pandas/core/arrays/masked.py:385:9: error[invalid-method-override] Invalid override of method `__contains__`: Definition is incompatible with `ExtensionArray.__contains__` +pandas/core/arrays/masked.py:1036:9: error[invalid-method-override] Invalid override of method `_concat_same_type`: Definition is incompatible with `ExtensionArray._concat_same_type` +pandas/core/arrays/masked.py:1054:9: error[invalid-method-override] Invalid override of method `take`: Definition is incompatible with `ExtensionArray.take` +pandas/core/arrays/numeric.py:295:9: error[invalid-method-override] Invalid override of method `_coerce_to_array`: Definition is incompatible with `BaseMaskedArray._coerce_to_array` +pandas/core/arrays/numpy_.py:285:9: error[invalid-method-override] Invalid override of method `_validate_scalar`: Definition is incompatible with `NDArrayBackedExtensionArray._validate_scalar` pandas/core/arrays/numpy_.py:388:16: error[invalid-return-type] Return type does not match returned value: expected `Self@take`, found `NumpyExtensionArray` pandas/core/arrays/period.py:829:20: error[unresolved-attribute] Object of type `BaseOffset` has no attribute `_period_dtype_code` pandas/core/arrays/period.py:917:17: error[unresolved-attribute] Object of type `BaseOffset` has no attribute `_period_dtype_code` -pandas/core/arrays/period.py:933:16: error[invalid-return-type] Return type does not match returned value: expected `Self@asfreq`, found `PeriodArray` -pandas/core/arrays/period.py:1031:16: error[invalid-return-type] Return type does not match returned value: expected `Self@_addsub_int_array_or_scalar`, found `PeriodArray` -pandas/core/arrays/period.py:1102:16: error[invalid-return-type] Return type does not match returned value: expected `Self@_add_timedelta_arraylike`, found `PeriodArray` +pandas/core/arrays/period.py:1033:9: error[invalid-method-override] Invalid override of method `_add_offset`: Definition is incompatible with `DatetimeLikeArrayMixin._add_offset` pandas/core/arrays/period.py:1370:12: error[unresolved-attribute] Object of type `BaseOffset` has no attribute `_period_dtype_code` pandas/core/arrays/period.py:1464:45: error[invalid-argument-type] Argument to function `freq_to_dtype_code` is incorrect: Expected `BaseOffset`, found `None` pandas/core/arrays/period.py:1469:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[ndarray[tuple[Any, ...], dtype[Any]], BaseOffset]`, found `tuple[@Todo, BaseOffset | Unknown | None]` @@ -375,13 +386,15 @@ pandas/core/arrays/sparse/accessor.py:435:40: warning[possibly-missing-attribute pandas/core/arrays/sparse/accessor.py:446:67: warning[possibly-missing-attribute] Attribute `shape` may be missing on object of type `Unknown | None` pandas/core/arrays/sparse/accessor.py:464:62: warning[possibly-missing-attribute] Attribute `items` may be missing on object of type `Unknown | None` pandas/core/arrays/sparse/accessor.py:465:16: error[invalid-return-type] Return type does not match returned value: expected `int | float`, found `floating[Any]` -pandas/core/arrays/sparse/array.py:790:16: error[invalid-return-type] Return type does not match returned value: expected `Self@isna`, found `SparseArray` pandas/core/arrays/sparse/array.py:948:16: warning[possibly-missing-attribute] Attribute `any` may be missing on object of type `Unknown | ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]` +pandas/core/arrays/sparse/array.py:978:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `ExtensionArray.__getitem__` pandas/core/arrays/sparse/array.py:1078:42: error[invalid-argument-type] Argument to function `maybe_box_datetimelike` is incorrect: Expected `str | bytes | date | ... omitted 10 union elements`, found `ndarray[tuple[Any, ...], dtype[Any]]` -pandas/core/arrays/sparse/array.py:1095:16: error[invalid-return-type] Return type does not match returned value: expected `Self@take`, found `SparseArray` -pandas/core/arrays/sparse/array.py:1393:16: error[invalid-return-type] Return type does not match returned value: expected `Self@map`, found `SparseArray` +pandas/core/arrays/sparse/array.py:1188:9: error[invalid-method-override] Invalid override of method `searchsorted`: Definition is incompatible with `ExtensionArray.searchsorted` +pandas/core/arrays/sparse/array.py:1205:9: error[invalid-method-override] Invalid override of method `_concat_same_type`: Definition is incompatible with `ExtensionArray._concat_same_type` pandas/core/arrays/string_.py:225:23: error[invalid-type-form] Invalid subscript of object of type `property` in type expression pandas/core/arrays/string_.py:548:16: error[invalid-return-type] Return type does not match returned value: expected `Self@view`, found `BaseStringArray` +pandas/core/arrays/string_.py:689:9: error[invalid-method-override] Invalid override of method `_validate_scalar`: Definition is incompatible with `NumpyExtensionArray._validate_scalar` +pandas/core/arrays/string_arrow.py:245:9: error[invalid-method-override] Invalid override of method `_convert_bool_result`: Definition is incompatible with `ArrowExtensionArray._convert_bool_result` pandas/core/arrays/string_arrow.py:291:18: error[unresolved-attribute] Module `pyarrow.compute` has no member `is_in` pandas/core/arrays/string_arrow.py:446:18: error[unresolved-attribute] Module `pyarrow.compute` has no member `count_substring_regex` pandas/core/arrays/string_arrow.py:493:23: error[unresolved-attribute] Module `pyarrow.compute` has no member `is_null` @@ -390,8 +403,11 @@ pandas/core/arrays/string_arrow.py:494:41: error[unresolved-attribute] Module `p pandas/core/arrays/string_arrow.py:496:23: error[unresolved-attribute] Module `pyarrow.compute` has no member `not_equal` pandas/core/arrays/timedeltas.py:157:28: error[no-matching-overload] No overload of function `__new__` matches arguments pandas/core/arrays/timedeltas.py:188:47: error[invalid-argument-type] Argument to bound method `_from_value_and_reso` is incorrect: Expected `signedinteger[_64Bit]`, found `timedelta64[timedelta | int | None]` +pandas/core/arrays/timedeltas.py:243:9: error[invalid-method-override] Invalid override of method `_from_sequence`: Definition is incompatible with `ExtensionArray._from_sequence` pandas/core/arrays/timedeltas.py:250:46: error[invalid-argument-type] Argument to function `astype_overflowsafe` is incorrect: Expected `dtype[Any]`, found `(Unknown & ~AlwaysTruthy & ~None) | dtype[Any] | ExtensionDtype` pandas/core/arrays/timedeltas.py:276:46: error[invalid-argument-type] Argument to function `astype_overflowsafe` is incorrect: Expected `dtype[Any]`, found `(Unknown & ~AlwaysTruthy & ~None) | dtype[Any] | ExtensionDtype` +pandas/core/arrays/timedeltas.py:284:9: error[invalid-method-override] Invalid override of method `_generate_range`: Definition is incompatible with `TimelikeOps._generate_range` +pandas/core/arrays/timedeltas.py:470:9: error[invalid-method-override] Invalid override of method `_add_offset`: Definition is incompatible with `DatetimeLikeArrayMixin._add_offset` pandas/core/arrays/timedeltas.py:1147:20: error[unresolved-attribute] Object of type `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]` has no attribute `_mask` pandas/core/arrays/timedeltas.py:1148:20: error[unresolved-attribute] Object of type `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]` has no attribute `_data` pandas/core/arrays/timedeltas.py:1152:42: error[invalid-argument-type] Argument to function `cast_from_unit_vectorized` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]] | Unknown` @@ -448,8 +464,10 @@ pandas/core/frame.py:2541:20: error[unsupported-operator] Operator `in` is not s pandas/core/frame.py:2542:37: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method pandas/core/frame.py:2543:22: error[unsupported-operator] Operator `in` is not supported for types `int` and `None`, in comparing `int` with `Unknown | None` pandas/core/frame.py:2544:37: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method +pandas/core/frame.py:4106:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `NDFrame.__getitem__` pandas/core/frame.py:5232:32: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Unknown]`, found `Unknown | None | tuple[Unknown & ~None] | tuple[()]` pandas/core/frame.py:5232:52: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Unknown]`, found `Unknown | None | tuple[Unknown & ~None] | tuple[()]` +pandas/core/frame.py:7272:9: error[invalid-method-override] Invalid override of method `sort_values`: Definition is incompatible with `NDFrame.sort_values` pandas/core/frame.py:10299:23: error[invalid-assignment] Object of type `Top[list[Unknown]] & ~AlwaysFalsy` is not assignable to `list[Hashable]` pandas/core/frame.py:10614:43: error[unresolved-attribute] Object of type `int` has no attribute `is_integer` pandas/core/frame.py:10732:32: error[invalid-argument-type] Argument to function `frame_apply` is incorrect: Expected `((...) -> Unknown) | str | list[((...) -> Unknown) | str] | MutableMapping[Hashable, ((...) -> Unknown) | str | list[((...) -> Unknown) | str]]`, found `Unknown | None` @@ -491,6 +509,8 @@ pandas/core/groupby/numba_.py:116:18: error[not-iterable] Object of type `prange pandas/core/groupby/numba_.py:118:22: error[not-iterable] Object of type `prange` is not iterable pandas/core/groupby/numba_.py:176:18: error[not-iterable] Object of type `prange` is not iterable pandas/core/groupby/numba_.py:178:22: error[not-iterable] Object of type `prange` is not iterable +pandas/core/indexes/accessors.py:91:9: error[invalid-method-override] Invalid override of method `_delegate_property_get`: Definition is incompatible with `PandasDelegate._delegate_property_get` +pandas/core/indexes/accessors.py:175:9: error[invalid-method-override] Invalid override of method `_delegate_property_get`: Definition is incompatible with `PandasDelegate._delegate_property_get` pandas/core/indexes/base.py:428:11: error[invalid-type-form] Variable of type `Accessor` is not allowed in a type expression pandas/core/indexes/base.py:440:24: error[invalid-type-form] Variable of type `Accessor` is not allowed in a type expression pandas/core/indexes/base.py:441:23: error[invalid-type-form] Variable of type `Accessor` is not allowed in a type expression @@ -513,17 +533,18 @@ pandas/core/indexes/base.py:5310:18: error[no-matching-overload] No overload of pandas/core/indexes/base.py:6135:64: error[invalid-argument-type] Argument to bound method `get_indexer_non_unique` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `Unknown | ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]` pandas/core/indexes/base.py:6135:64: error[invalid-argument-type] Argument to bound method `get_indexer_non_unique` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `Unknown | ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]` pandas/core/indexes/base.py:6464:16: error[no-matching-overload] No overload of bound method `__init__` matches arguments +pandas/core/indexes/category.py:429:9: error[invalid-method-override] Invalid override of method `_maybe_cast_listlike_indexer`: Definition is incompatible with `Index._maybe_cast_listlike_indexer` pandas/core/indexes/datetimelike.py:139:10: error[invalid-argument-type] Argument to function `doc` is incorrect: Expected `None | str | ((...) -> Unknown)`, found `property` pandas/core/indexes/datetimelike.py:156:10: error[invalid-argument-type] Argument to function `doc` is incorrect: Expected `None | str | ((...) -> Unknown)`, found `property` -pandas/core/indexes/datetimelike.py:200:42: warning[possibly-missing-attribute] Attribute `asi8` may be missing on object of type `(Any & Index) | CategoricalIndex | DatetimeIndexOpsMixin` +pandas/core/indexes/datetimelike.py:200:42: warning[possibly-missing-attribute] Attribute `asi8` may be missing on object of type `(Any & Index) | CategoricalIndex | Self@equals` pandas/core/indexes/datetimelike.py:527:10: error[invalid-argument-type] Argument to function `doc` is incorrect: Expected `None | str | ((...) -> Unknown)`, found `property` pandas/core/indexes/datetimelike.py:756:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[Self@_wrap_join_result, @Todo | None, @Todo | None]`, found `tuple[DatetimeTimedeltaMixin | Unknown, @Todo | None, @Todo | None]` pandas/core/indexes/datetimelike.py:815:45: error[invalid-argument-type] Argument to bound method `is_on_offset` is incorrect: Expected `datetime`, found `Timestamp | NaTType | Timedelta` pandas/core/indexes/datetimelike.py:823:16: error[invalid-return-type] Return type does not match returned value: expected `Self@delete`, found `DatetimeTimedeltaMixin` pandas/core/indexes/datetimelike.py:855:13: error[invalid-assignment] Object of type `BaseOffset | None` is not assignable to attribute `_freq` on type `DatetimeArray | TimedeltaArray` pandas/core/indexes/datetimes.py:609:29: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `integer[Any] | int | float | ... omitted 3 union elements`, found `Unknown | NaTType` -pandas/core/indexes/frozen.py:82:16: error[invalid-return-type] Return type does not match returned value: expected `Self@__radd__`, found `FrozenList` -pandas/core/indexes/frozen.py:92:16: error[invalid-return-type] Return type does not match returned value: expected `Self@__mul__`, found `FrozenList` +pandas/core/indexes/frozen.py:72:15: error[invalid-method-override] Invalid override of method `__iadd__`: Definition is incompatible with `MutableSequence.__iadd__` +pandas/core/indexes/frozen.py:74:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `MutableSequence.__getitem__` pandas/core/indexes/interval.py:670:43: warning[possibly-missing-attribute] Attribute `left` may be missing on object of type `Unknown | Index` pandas/core/indexes/interval.py:671:44: warning[possibly-missing-attribute] Attribute `right` may be missing on object of type `Unknown | Index` pandas/core/indexes/interval.py:686:50: warning[possibly-missing-attribute] Attribute `asi8` may be missing on object of type `(Unknown & ~Top[Interval[Unknown]]) | (Index & ~Top[Interval[Unknown]])` @@ -533,14 +554,16 @@ pandas/core/indexes/interval.py:1397:20: error[no-matching-overload] No overload pandas/core/indexes/interval.py:1427:25: error[invalid-assignment] Object of type `object` is not assignable to `dtype[Any]` pandas/core/indexes/interval.py:1435:46: error[unsupported-operator] Operator `*` is unsupported between objects of type `Unknown | None | Literal[1, "D"]` and `float` pandas/core/indexes/interval.py:1440:32: error[unsupported-operator] Operator `-` is unsupported between objects of type `str | bytes | date | ... omitted 10 union elements` and `str | bytes | date | ... omitted 10 union elements` -pandas/core/indexes/multi.py:1393:16: error[invalid-return-type] Return type does not match returned value: expected `Self@copy`, found `MultiIndex` +pandas/core/indexes/multi.py:1589:9: error[invalid-method-override] Invalid override of method `_set_names`: Definition is incompatible with `Index._set_names` pandas/core/indexes/multi.py:2256:40: error[unsupported-operator] Operator `>` is not supported for types `object` and `int`, in comparing `~None` with `Literal[0]` +pandas/core/indexes/multi.py:4158:9: error[invalid-method-override] Invalid override of method `_validate_fill_value`: Definition is incompatible with `Index._validate_fill_value` pandas/core/indexes/multi.py:4484:9: error[no-matching-overload] No overload of function `tile` matches arguments pandas/core/indexes/period.py:243:29: error[invalid-argument-type] Argument to function `period_array` is incorrect: Expected `Sequence[Period | str | None] | ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]] | Index | Series`, found `Unknown | None` +pandas/core/indexes/range.py:808:9: error[invalid-method-override] Invalid override of method `sort_values`: Definition is incompatible with `Index.sort_values` pandas/core/indexes/range.py:817:20: error[invalid-return-type] Return type does not match returned value: expected `Self@sort_values | tuple[Self@sort_values, ndarray[tuple[Any, ...], dtype[Any]] | RangeIndex]`, found `RangeIndex | tuple[RangeIndex, ndarray[tuple[Any, ...], dtype[Any]]]` +pandas/core/indexes/range.py:1184:9: error[invalid-method-override] Invalid override of method `_concat`: Definition is incompatible with `Index._concat` pandas/core/indexes/range.py:1289:27: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `~EllipsisType & ~slice[object, object, object]` pandas/core/indexes/range.py:1305:23: error[unresolved-attribute] Object of type `~EllipsisType & ~slice[object, object, object]` has no attribute `to_numpy` -pandas/core/indexing.py:772:16: error[invalid-return-type] Return type does not match returned value: expected `Self@__call__`, found `_LocationIndexer` pandas/core/indexing.py:1242:6: error[invalid-argument-type] Argument to function `doc` is incorrect: Expected `None | str | ((...) -> Unknown)`, found `property` pandas/core/indexing.py:1430:24: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[Unknown]`, found `object` pandas/core/indexing.py:1447:45: error[unsupported-operator] Operator `>` is not supported for types `object` and `int`, in comparing `object` with `Literal[1]` @@ -554,26 +577,16 @@ pandas/core/indexing.py:2384:49: error[index-out-of-bounds] Index 1 is out of bo pandas/core/indexing.py:2557:6: error[invalid-argument-type] Argument to function `doc` is incorrect: Expected `None | str | ((...) -> Unknown)`, found `property` pandas/core/indexing.py:2607:6: error[invalid-argument-type] Argument to function `doc` is incorrect: Expected `None | str | ((...) -> Unknown)`, found `property` pandas/core/internals/api.py:113:57: error[invalid-argument-type] Argument to function `extract_pandas_array` is incorrect: Expected `int`, found `Unknown | None` -pandas/core/internals/blocks.py:260:16: error[invalid-return-type] Return type does not match returned value: expected `Self@make_block_same_class`, found `Block` -pandas/core/internals/blocks.py:287:16: error[invalid-return-type] Return type does not match returned value: expected `Self@slice_block_columns`, found `Block` -pandas/core/internals/blocks.py:302:16: error[invalid-return-type] Return type does not match returned value: expected `Self@take_block_columns`, found `Block` -pandas/core/internals/blocks.py:315:16: error[invalid-return-type] Return type does not match returned value: expected `Self@getitem_block_columns`, found `Block` -pandas/core/internals/blocks.py:649:16: error[invalid-return-type] Return type does not match returned value: expected `Self@copy`, found `Block` -pandas/core/internals/blocks.py:2089:16: error[invalid-return-type] Return type does not match returned value: expected `Self@slice_block_rows`, found `ExtensionBlock` pandas/core/internals/construction.py:286:39: error[invalid-argument-type] Argument to function `_check_values_indices_shape_match` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `Unknown | ndarray[tuple[Any, ...], dtype[Any]] | ExtensionArray` pandas/core/internals/construction.py:1021:46: error[invalid-argument-type] Argument to function `maybe_cast_to_datetime` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]] | list[Unknown]`, found `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]]` pandas/core/internals/managers.py:235:13: error[unresolved-attribute] Object of type `Self@blknos` has no attribute `_rebuild_blknos_and_blklocs` pandas/core/internals/managers.py:246:13: error[unresolved-attribute] Object of type `Self@blklocs` has no attribute `_rebuild_blknos_and_blklocs` -pandas/core/internals/managers.py:762:16: error[invalid-return-type] Return type does not match returned value: expected `Self@consolidate`, found `BaseBlockManager` pandas/core/internals/managers.py:1225:17: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown | BlockPlacement` and value of type `ndarray[tuple[Any, ...], dtype[Any]]` on object of type `list[Unknown | None]` -pandas/core/internals/managers.py:1695:16: error[invalid-return-type] Return type does not match returned value: expected `Self@quantile`, found `BlockManager` -pandas/core/internals/managers.py:2108:20: error[invalid-return-type] Return type does not match returned value: expected `Self@get_rows_with_mask`, found `SingleBlockManager` -pandas/core/internals/managers.py:2122:16: error[invalid-return-type] Return type does not match returned value: expected `Self@get_rows_with_mask`, found `SingleBlockManager` +pandas/core/internals/managers.py:1656:9: error[invalid-method-override] Invalid override of method `_equal_values`: Definition is incompatible with `BaseBlockManager._equal_values` +pandas/core/internals/managers.py:2231:9: error[invalid-method-override] Invalid override of method `_equal_values`: Definition is incompatible with `BaseBlockManager._equal_values` pandas/core/missing.py:608:19: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Literal["linear", "nearest", "nearest-up", "slinear", "zero", ... omitted 4 literals] | int`, found `Unknown | None | (str & ~Literal["polynomial"])` pandas/core/missing.py:613:28: error[unsupported-operator] Operator `<=` is not supported for types `None` and `int`, in comparing `Unknown | None` with `Literal[0]` pandas/core/missing.py:617:51: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Literal[1, 2, 3, 4, 5]`, found `Unknown | None` -pandas/core/nanops.py:82:26: error[unresolved-attribute] Object of type `F@__call__` has no attribute `__name__` -pandas/core/nanops.py:106:32: error[unresolved-attribute] Object of type `F@__call__` has no attribute `__name__` pandas/core/nanops.py:657:20: error[invalid-return-type] Return type does not match returned value: expected `ndarray[tuple[Any, ...], dtype[Any]] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | NaTType`, found `signedinteger[_64Bit]` pandas/core/nanops.py:908:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[int | float | ndarray[tuple[Any, ...], dtype[Any]], int | float | ndarray[tuple[Any, ...], dtype[Any]]]`, found `tuple[floating[Any] | @Todo | int | float | ndarray[tuple[Any, ...], dtype[Any]], Unknown | int | float]` pandas/core/nanops.py:1525:12: warning[possibly-missing-attribute] Attribute `astype` may be missing on object of type `@Todo | int` @@ -583,6 +596,8 @@ pandas/core/nanops.py:1563:30: error[no-matching-overload] No overload of bound pandas/core/nanops.py:1563:30: error[no-matching-overload] No overload of bound method `astype` matches arguments pandas/core/ops/array_ops.py:340:44: error[invalid-argument-type] Argument to function `invalid_comparison` is incorrect: Expected `ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]] | list[Unknown] | ... omitted 13 union elements`, found `~Top[list[Unknown]] | @Todo` pandas/core/resample.py:442:45: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `((...) -> Unknown) | str | list[((...) -> Unknown) | str] | MutableMapping[Hashable, ((...) -> Unknown) | str | list[((...) -> Unknown) | str]]`, found `Unknown | None` +pandas/core/resample.py:2110:9: error[invalid-method-override] Invalid override of method `_upsample`: Definition is incompatible with `Resampler._upsample` +pandas/core/resample.py:2242:9: error[invalid-method-override] Invalid override of method `_upsample`: Definition is incompatible with `Resampler._upsample` pandas/core/resample.py:2574:26: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | BaseOffset | _NoDefault`, found `Unknown | None` pandas/core/resample.py:2574:26: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | BaseOffset | _NoDefault`, found `Unknown | None` pandas/core/resample.py:2581:13: error[invalid-argument-type] Argument to function `_get_timestamp_range_edges` is incorrect: Expected `BaseOffset`, found `Unknown | None` @@ -605,8 +620,8 @@ pandas/core/reshape/merge.py:1649:25: warning[redundant-cast] Value is already o pandas/core/reshape/merge.py:1671:25: warning[redundant-cast] Value is already of type `Hashable` pandas/core/reshape/merge.py:1954:16: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Unknown | (Hashable & ~None)` pandas/core/reshape/merge.py:1954:33: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Unknown | (Hashable & ~None)` -pandas/core/reshape/merge.py:2434:41: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Unknown | None | list[Divergent]` -pandas/core/reshape/merge.py:2438:24: error[unsupported-operator] Operator `+` is unsupported between objects of type `Unknown | None | list[Divergent]` and `list[Unknown]` +pandas/core/reshape/merge.py:2434:41: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Unknown | None | list[Divergent] | list[Unknown | None | list[Divergent]]` +pandas/core/reshape/merge.py:2438:24: error[unsupported-operator] Operator `+` is unsupported between objects of type `Unknown | None | list[Divergent] | list[Unknown | None | list[Divergent]]` and `list[Unknown]` pandas/core/reshape/merge.py:2920:32: error[invalid-argument-type] Argument to bound method `factorize` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `ndarray[tuple[Any, ...], dtype[Any]] | Unknown | ExtensionArray` pandas/core/reshape/merge.py:2922:48: error[invalid-argument-type] Argument to bound method `hash_inner_join` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `ndarray[tuple[Any, ...], dtype[Any]] | Unknown | (ExtensionArray & ~BaseMaskedArray & ~ArrowExtensionArray)` pandas/core/reshape/merge.py:2925:36: error[invalid-argument-type] Argument to bound method `factorize` is incorrect: Expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `ndarray[tuple[Any, ...], dtype[Any]] | Unknown | (ExtensionArray & ~BaseMaskedArray & ~ArrowExtensionArray)` @@ -618,6 +633,7 @@ pandas/core/reshape/tile.py:542:18: error[no-matching-overload] No overload of f pandas/core/series.py:341:16: error[invalid-type-form] Invalid subscript of object of type `Accessor` in type expression pandas/core/series.py:341:21: error[invalid-type-form] Variable of type `Accessor` is not allowed in a type expression pandas/core/series.py:908:23: error[invalid-type-form] Invalid subscript of object of type `Accessor` in type expression +pandas/core/series.py:939:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `NDFrame.__getitem__` pandas/core/series.py:1432:27: error[invalid-type-form] Variable of type `Accessor` is not allowed in a type expression pandas/core/series.py:1444:17: error[invalid-type-form] Variable of type `Accessor` is not allowed in a type expression pandas/core/series.py:1445:23: error[invalid-type-form] Variable of type `Accessor` is not allowed in a type expression @@ -643,6 +659,7 @@ pandas/core/series.py:1608:10: error[invalid-type-form] Variable of type `Access pandas/core/series.py:2835:43: error[unresolved-attribute] Object of type `int` has no attribute `is_integer` pandas/core/series.py:4642:32: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `((...) -> Unknown) | str | list[((...) -> Unknown) | str] | MutableMapping[Hashable, ((...) -> Unknown) | str | list[((...) -> Unknown) | str]]`, found `(Unknown & ~None) | dict[str, Unknown]` pandas/core/series.py:5073:20: error[no-matching-overload] No overload of bound method `_rename` matches arguments +pandas/core/series.py:5391:9: error[invalid-method-override] Invalid override of method `rename_axis`: Definition is incompatible with `NDFrame.rename_axis` pandas/core/series.py:5461:16: error[invalid-return-type] Return type does not match returned value: expected `Self@rename_axis | None`, found `Series | None` pandas/core/series.py:5650:17: error[invalid-type-form] Variable of type `Accessor` is not allowed in a type expression pandas/core/series.py:5652:30: error[invalid-type-form] Variable of type `Accessor` is not allowed in a type expression @@ -651,12 +668,11 @@ pandas/core/series.py:6471:15: error[invalid-type-form] Variable of type `Access pandas/core/series.py:6535:19: error[invalid-type-form] Invalid subscript of object of type `Accessor` in type expression pandas/core/sorting.py:429:13: error[unknown-argument] Argument `ascending` does not match any known parameter of bound method `argsort` pandas/core/sorting.py:431:13: error[unknown-argument] Argument `na_position` does not match any known parameter of bound method `argsort` -pandas/core/strings/accessor.py:134:21: error[unresolved-attribute] Object of type `F@forbid_nonstring_types` has no attribute `__name__` -pandas/core/strings/accessor.py:310:33: error[unresolved-attribute] Module `pyarrow` has no member `compute` -pandas/core/strings/accessor.py:311:27: error[unresolved-attribute] Module `pyarrow` has no member `compute` -pandas/core/strings/accessor.py:312:27: error[unresolved-attribute] Module `pyarrow` has no member `compute` -pandas/core/strings/accessor.py:321:25: error[unresolved-attribute] Module `pyarrow` has no member `compute` -pandas/core/strings/accessor.py:331:21: error[unresolved-attribute] Module `pyarrow` has no member `compute` +pandas/core/strings/accessor.py:310:33: warning[possibly-missing-attribute] Submodule `compute` may not be available as an attribute on module `pyarrow` +pandas/core/strings/accessor.py:311:27: warning[possibly-missing-attribute] Submodule `compute` may not be available as an attribute on module `pyarrow` +pandas/core/strings/accessor.py:312:27: warning[possibly-missing-attribute] Submodule `compute` may not be available as an attribute on module `pyarrow` +pandas/core/strings/accessor.py:321:25: warning[possibly-missing-attribute] Submodule `compute` may not be available as an attribute on module `pyarrow` +pandas/core/strings/accessor.py:331:21: warning[possibly-missing-attribute] Submodule `compute` may not be available as an attribute on module `pyarrow` pandas/core/strings/accessor.py:396:30: warning[possibly-missing-attribute] Attribute `dtype` may be missing on object of type `(Unknown & & ) | dict[Unknown, ArrowExtensionArray | Unknown] | list[Unknown]` pandas/core/strings/accessor.py:1411:20: warning[possibly-missing-attribute] Attribute `flags` may be missing on object of type `str | Pattern[Unknown]` pandas/core/strings/accessor.py:1426:33: warning[possibly-missing-attribute] Attribute `flags` may be missing on object of type `str | Pattern[Unknown] | Pattern[str]` @@ -664,9 +680,9 @@ pandas/core/strings/accessor.py:1431:38: warning[possibly-missing-attribute] Att pandas/core/tools/datetimes.py:393:35: error[invalid-argument-type] Argument to function `is_supported_dtype` is incorrect: Expected `dtype[Any]`, found `(Any & ~DatetimeTZDtype) | None` pandas/core/tools/datetimes.py:1062:22: error[invalid-assignment] Object of type `bool` is not assignable to `Timestamp | NaTType | Series | Index` pandas/core/util/hashing.py:314:16: error[no-matching-overload] No overload of bound method `astype` matches arguments -pandas/core/util/numba_.py:79:8: error[unresolved-attribute] Module `numba` has no member `extending` +pandas/core/util/numba_.py:79:8: warning[possibly-missing-attribute] Submodule `extending` may not be available as an attribute on module `numba` pandas/core/util/numba_.py:82:22: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__` -pandas/core/util/numba_.py:89:22: error[unresolved-attribute] Module `numba` has no member `extending` +pandas/core/util/numba_.py:89:22: warning[possibly-missing-attribute] Submodule `extending` may not be available as an attribute on module `numba` pandas/core/window/ewm.py:913:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `BaseGrouper`, found `Unknown | None` pandas/core/window/numba_.py:67:18: error[not-iterable] Object of type `prange` is not iterable pandas/core/window/numba_.py:131:18: error[not-iterable] Object of type `prange` is not iterable @@ -743,7 +759,12 @@ pandas/io/excel/_base.py:852:17: error[invalid-assignment] Invalid subscript ass pandas/io/excel/_base.py:852:57: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Unknown, (s: slice[Any, Any, Any], /) -> list[Unknown]]` cannot be called with key of type `object` on object of type `list[Unknown]` pandas/io/excel/_base.py:855:54: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Unknown, (s: slice[Any, Any, Any], /) -> list[Unknown]]` cannot be called with key of type `object` on object of type `list[Unknown]` pandas/io/excel/_base.py:1366:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[int | float | str | date, str | None]`, found `tuple[Unknown | int | float | Decimal | str, None | Unknown | str]` +pandas/io/excel/_calamine.py:100:9: error[invalid-method-override] Invalid override of method `get_sheet_data`: Definition is incompatible with `BaseExcelReader.get_sheet_data` +pandas/io/excel/_odfreader.py:102:9: error[invalid-method-override] Invalid override of method `get_sheet_data`: Definition is incompatible with `BaseExcelReader.get_sheet_data` pandas/io/excel/_odswriter.py:68:23: error[invalid-type-form] Variable of type `def OpenDocumentSpreadsheet() -> Unknown` is not allowed in a type expression +pandas/io/excel/_openpyxl.py:614:9: error[invalid-method-override] Invalid override of method `get_sheet_data`: Definition is incompatible with `BaseExcelReader.get_sheet_data` +pandas/io/excel/_pyxlsb.py:97:9: error[invalid-method-override] Invalid override of method `get_sheet_data`: Definition is incompatible with `BaseExcelReader.get_sheet_data` +pandas/io/excel/_xlrd.py:79:9: error[invalid-method-override] Invalid override of method `get_sheet_data`: Definition is incompatible with `BaseExcelReader.get_sheet_data` pandas/io/formats/excel.py:252:21: error[invalid-argument-type] Argument to function `remove_none` is incorrect: Expected `dict[str, str | None]`, found `dict[Unknown | str, Unknown | dict[str, bool | str | None] | dict[str, dict[str, str | None]] | dict[str, int | float | str | None] | dict[str, str | None]]` pandas/io/formats/excel.py:253:16: error[invalid-return-type] Return type does not match returned value: expected `dict[str, dict[str, str]]`, found `dict[Unknown | str, Unknown | dict[str, bool | str | None] | dict[str, dict[str, str | None]] | dict[str, int | float | str | None] | dict[str, str | None]]` pandas/io/formats/format.py:572:22: error[invalid-assignment] Object of type `(Sequence[str | int] & Top[Mapping[Unknown, object]] & ~int & ~str) | (Mapping[Hashable, str | int] & ~int & ~str)` is not assignable to `Mapping[Hashable, str | int]` @@ -774,7 +795,7 @@ pandas/io/formats/style.py:2732:13: warning[possibly-missing-attribute] Attribut pandas/io/formats/style.py:2732:38: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[CSSDict]`, found `dict[Any, list[CSSDict]] | list[CSSDict] | None` pandas/io/formats/style.py:4022:41: error[invalid-argument-type] Argument to function `_validate_apply_axis_arg` is incorrect: Expected `NDFrame | Sequence[Unknown] | ndarray[tuple[Any, ...], dtype[Any]]`, found `bytes | (date & Iterable[object]) | (timedelta & Iterable[object]) | ... omitted 12 union elements` pandas/io/formats/style.py:4025:42: error[invalid-argument-type] Argument to function `_validate_apply_axis_arg` is incorrect: Expected `NDFrame | Sequence[Unknown] | ndarray[tuple[Any, ...], dtype[Any]]`, found `bytes | (date & Iterable[object]) | (timedelta & Iterable[object]) | ... omitted 12 union elements` -pandas/io/formats/style.py:4234:20: error[invalid-assignment] Object of type `tuple[floating[Any], Literal["zero"]]` is not assignable to `int | float` +pandas/io/formats/style.py:4234:20: error[invalid-assignment] Object of type `floating[Any]` is not assignable to `int | float` pandas/io/formats/style_render.py:1222:17: error[invalid-argument-type] Argument to function `_maybe_wrap_formatter` is incorrect: Expected `str | ((...) -> Unknown) | None`, found `object` pandas/io/formats/style_render.py:1402:25: error[invalid-assignment] Object of type `dict[int | Unknown, object]` is not assignable to `str | ((...) -> Unknown) | dict[Any, str | ((...) -> Unknown) | None] | None` pandas/io/formats/style_render.py:1409:17: warning[possibly-missing-attribute] Attribute `get` may be missing on object of type `dict[Any, str | ((...) -> Unknown) | None] | str | ((...) -> Unknown) | None` @@ -786,6 +807,9 @@ pandas/io/formats/style_render.py:1878:12: error[invalid-return-type] Return typ pandas/io/formats/xml.py:449:14: error[unresolved-import] Cannot resolve imported module `lxml.etree` pandas/io/formats/xml.py:511:14: error[unresolved-import] Cannot resolve imported module `lxml.etree` pandas/io/formats/xml.py:523:14: error[unresolved-import] Cannot resolve imported module `lxml.etree` +pandas/io/html.py:639:9: error[invalid-method-override] Invalid override of method `_parse_td`: Definition is incompatible with `_HtmlFrameParser._parse_td` +pandas/io/html.py:731:9: error[invalid-method-override] Invalid override of method `_parse_td`: Definition is incompatible with `_HtmlFrameParser._parse_td` +pandas/io/html.py:736:9: error[invalid-method-override] Invalid override of method `_parse_tables`: Definition is incompatible with `_HtmlFrameParser._parse_tables` pandas/io/html.py:784:14: error[unresolved-import] Cannot resolve imported module `lxml.etree` pandas/io/json/_json.py:792:19: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `JsonReader[FrameSeriesStrT@JsonReader]`, found `JsonReader[str]` pandas/io/json/_json.py:1025:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ExtensionDtype | str | dtype[Any] | ... omitted 3 union elements`, found `Unknown | bool | None | str | _NoDefault` @@ -883,48 +907,47 @@ pandas/io/xml.py:46:22: error[unresolved-import] Module `lxml` has no member `et pandas/io/xml.py:545:14: error[unresolved-import] Cannot resolve imported module `lxml.etree` pandas/io/xml.py:617:14: error[unresolved-import] Cannot resolve imported module `lxml.etree` pandas/io/xml.py:655:14: error[unresolved-import] Cannot resolve imported module `lxml.etree` -pandas/plotting/_matplotlib/boxplot.py:278:9: error[unresolved-attribute] Module `matplotlib` has no member `artist` -pandas/plotting/_matplotlib/boxplot.py:280:9: error[unresolved-attribute] Module `matplotlib` has no member `artist` -pandas/plotting/_matplotlib/boxplot.py:282:9: error[unresolved-attribute] Module `matplotlib` has no member `artist` -pandas/plotting/_matplotlib/boxplot.py:284:9: error[unresolved-attribute] Module `matplotlib` has no member `artist` +pandas/plotting/_matplotlib/boxplot.py:278:9: warning[possibly-missing-attribute] Submodule `artist` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/boxplot.py:280:9: warning[possibly-missing-attribute] Submodule `artist` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/boxplot.py:282:9: warning[possibly-missing-attribute] Submodule `artist` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/boxplot.py:284:9: warning[possibly-missing-attribute] Submodule `artist` may not be available as an attribute on module `matplotlib` pandas/plotting/_matplotlib/boxplot.py:338:14: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method pandas/plotting/_matplotlib/boxplot.py:338:27: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Unknown | None | list[Unknown | None]` pandas/plotting/_matplotlib/converter.py:78:12: error[invalid-return-type] Return type does not match returned value: expected `list[tuple[type, type[DateConverter]]]`, found `list[Unknown | tuple[, ] | tuple[, ] | ... omitted 4 union elements]` -pandas/plotting/_matplotlib/converter.py:172:18: error[unresolved-attribute] Module `matplotlib` has no member `ticker` -pandas/plotting/_matplotlib/converter.py:182:21: error[unresolved-attribute] Module `matplotlib` has no member `ticker` +pandas/plotting/_matplotlib/converter.py:157:9: error[invalid-method-override] Invalid override of method `convert`: Definition is incompatible with `ConversionInterface.convert` +pandas/plotting/_matplotlib/converter.py:172:18: warning[possibly-missing-attribute] Submodule `ticker` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/converter.py:182:21: warning[possibly-missing-attribute] Submodule `ticker` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/converter.py:227:9: error[invalid-method-override] Invalid override of method `convert`: Definition is incompatible with `DateConverter.convert` pandas/plotting/_matplotlib/converter.py:236:16: error[no-matching-overload] No overload of function `to_offset` matches arguments +pandas/plotting/_matplotlib/converter.py:291:9: error[invalid-method-override] Invalid override of method `convert`: Definition is incompatible with `DateConverter.convert` pandas/plotting/_matplotlib/converter.py:841:12: error[invalid-return-type] Return type does not match returned value: expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `ndarray[tuple[int], list[Unknown | tuple[str, ] | tuple[str, ] | tuple[str, str]]]` pandas/plotting/_matplotlib/converter.py:889:12: error[invalid-return-type] Return type does not match returned value: expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `ndarray[tuple[int], list[Unknown | tuple[str, ] | tuple[str, ] | tuple[str, str]]]` pandas/plotting/_matplotlib/converter.py:912:12: error[invalid-return-type] Return type does not match returned value: expected `ndarray[tuple[Any, ...], dtype[Any]]`, found `ndarray[tuple[int], list[Unknown | tuple[str, ] | tuple[str, ] | tuple[str, str]]]` -pandas/plotting/_matplotlib/converter.py:932:30: error[unresolved-attribute] Module `matplotlib` has no member `ticker` -pandas/plotting/_matplotlib/converter.py:1013:16: error[unresolved-attribute] Module `matplotlib` has no member `transforms` -pandas/plotting/_matplotlib/converter.py:1021:32: error[unresolved-attribute] Module `matplotlib` has no member `ticker` -pandas/plotting/_matplotlib/converter.py:1097:37: error[unresolved-attribute] Module `matplotlib` has no member `ticker` -pandas/plotting/_matplotlib/core.py:111:20: error[unresolved-attribute] Module `matplotlib` has no member `colors` +pandas/plotting/_matplotlib/converter.py:932:30: warning[possibly-missing-attribute] Submodule `ticker` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/converter.py:1013:16: warning[possibly-missing-attribute] Submodule `transforms` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/converter.py:1021:32: warning[possibly-missing-attribute] Submodule `ticker` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/converter.py:1097:37: warning[possibly-missing-attribute] Submodule `ticker` may not be available as an attribute on module `matplotlib` pandas/plotting/_matplotlib/core.py:541:20: error[invalid-return-type] Return type does not match returned value: expected `Axes`, found `object` pandas/plotting/_matplotlib/core.py:745:21: error[unresolved-attribute] Object of type `object` has no attribute `yaxis` pandas/plotting/_matplotlib/core.py:756:21: error[unresolved-attribute] Object of type `object` has no attribute `yaxis` pandas/plotting/_matplotlib/core.py:1063:35: error[invalid-return-type] Function can implicitly return `None`, which is not assignable to return type `bool` -pandas/plotting/_matplotlib/core.py:1240:32: error[unresolved-attribute] Module `matplotlib` has no member `axes` -pandas/plotting/_matplotlib/core.py:1383:21: error[unresolved-attribute] Module `matplotlib` has no member `patches` -pandas/plotting/_matplotlib/core.py:1445:17: error[unresolved-attribute] Module `matplotlib` has no member `colors` +pandas/plotting/_matplotlib/core.py:1240:32: warning[possibly-missing-attribute] Submodule `axes` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/core.py:1383:21: warning[possibly-missing-attribute] Submodule `patches` may not be available as an attribute on module `matplotlib` pandas/plotting/_matplotlib/core.py:1457:39: error[invalid-argument-type] Argument to bound method `get_cmap` is incorrect: Expected `str | Colormap`, found `Unknown | None` -pandas/plotting/_matplotlib/core.py:1477:20: error[unresolved-attribute] Module `matplotlib` has no member `colors` -pandas/plotting/_matplotlib/core.py:1479:20: error[unresolved-attribute] Module `matplotlib` has no member `colors` -pandas/plotting/_matplotlib/misc.py:131:22: error[unresolved-attribute] Module `matplotlib` has no member `lines` -pandas/plotting/_matplotlib/misc.py:192:18: error[unresolved-attribute] Module `matplotlib` has no member `patches` -pandas/plotting/_matplotlib/misc.py:195:22: error[unresolved-attribute] Module `matplotlib` has no member `patches` +pandas/plotting/_matplotlib/misc.py:131:22: warning[possibly-missing-attribute] Submodule `lines` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/misc.py:192:18: warning[possibly-missing-attribute] Submodule `patches` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/misc.py:195:22: warning[possibly-missing-attribute] Submodule `patches` may not be available as an attribute on module `matplotlib` pandas/plotting/_matplotlib/misc.py:416:27: error[invalid-argument-type] Argument to bound method `axvline` is incorrect: Expected `int | float`, found `Unknown | int | str` pandas/plotting/_matplotlib/misc.py:416:27: error[invalid-argument-type] Argument to bound method `axvline` is incorrect: Expected `int | float`, found `Unknown | int | str` pandas/plotting/_matplotlib/style.py:99:16: error[invalid-return-type] Return type does not match returned value: expected `dict[str, str | Sequence[int | float]] | list[str | Sequence[int | float]]`, found `dict[str, str | Sequence[int | float]] | (Sequence[str | Sequence[int | float]] & Top[dict[Unknown, Unknown]]) | (Sequence[int | float] & Top[dict[Unknown, Unknown]])` pandas/plotting/_matplotlib/timeseries.py:120:38: error[invalid-argument-type] Argument to function `_replot_ax` is incorrect: Expected `Axes`, found `~None` pandas/plotting/_matplotlib/timeseries.py:360:23: error[invalid-argument-type] Argument to function `decorate_axes` is incorrect: Expected `Axes`, found `object` pandas/plotting/_matplotlib/timeseries.py:362:23: error[invalid-argument-type] Argument to function `decorate_axes` is incorrect: Expected `Axes`, found `object` -pandas/plotting/_matplotlib/tools.py:82:12: error[unresolved-attribute] Module `matplotlib` has no member `table` -pandas/plotting/_matplotlib/tools.py:332:45: error[unresolved-attribute] Module `matplotlib` has no member `ticker` -pandas/plotting/_matplotlib/tools.py:333:32: error[unresolved-attribute] Module `matplotlib` has no member `ticker` -pandas/plotting/_matplotlib/tools.py:334:47: error[unresolved-attribute] Module `matplotlib` has no member `ticker` -pandas/plotting/_matplotlib/tools.py:335:34: error[unresolved-attribute] Module `matplotlib` has no member `ticker` +pandas/plotting/_matplotlib/tools.py:82:12: warning[possibly-missing-attribute] Submodule `table` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/tools.py:332:45: warning[possibly-missing-attribute] Submodule `ticker` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/tools.py:333:32: warning[possibly-missing-attribute] Submodule `ticker` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/tools.py:334:47: warning[possibly-missing-attribute] Submodule `ticker` may not be available as an attribute on module `matplotlib` +pandas/plotting/_matplotlib/tools.py:335:34: warning[possibly-missing-attribute] Submodule `ticker` may not be available as an attribute on module `matplotlib` pandas/plotting/_matplotlib/tools.py:477:18: error[unresolved-attribute] Object of type `object` has no attribute `get_lines` pandas/plotting/_matplotlib/tools.py:480:18: error[unresolved-attribute] Object of type `object` has no attribute `get_lines` pandas/tseries/holiday.py:325:48: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `SupportsIndex`, found `Unknown | None` @@ -940,7 +963,5 @@ pandas/util/_decorators.py:377:21: error[invalid-argument-type] Argument to boun pandas/util/_exceptions.py:45:15: error[no-matching-overload] No overload of function `dirname` matches arguments pandas/util/_print_versions.py:29:14: error[unresolved-import] Cannot resolve imported module `pandas._version_meson` pandas/util/_validators.py:388:33: error[invalid-argument-type] Argument to function `validate_bool_kwarg` is incorrect: Argument type `object` does not satisfy constraints (`bool`, `int`, `None`) of type variable `BoolishNoneT` -typings/numba.pyi:20:7: error[unresolved-attribute] Module `numba.core.types` has no member `abstract` -typings/numba.pyi:21:12: error[unresolved-attribute] Module `numba.core.types` has no member `abstract` typings/numba.pyi:24:21: error[unresolved-attribute] Module `numba` has no member `compiler` -Found 945 diagnostics +Found 966 diagnostics diff --git a/scripts/ty_benchmark/snapshots/prefect_ty.txt b/scripts/ty_benchmark/snapshots/prefect_ty.txt index 9cba4fde77..5cf646f825 100644 --- a/scripts/ty_benchmark/snapshots/prefect_ty.txt +++ b/scripts/ty_benchmark/snapshots/prefect_ty.txt @@ -26,6 +26,9 @@ src/prefect/events/utilities.py:96:27: error[invalid-argument-type] Argument is src/prefect/events/utilities.py:96:27: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Any | dict[str, Any] | None` src/prefect/events/utilities.py:96:27: error[invalid-argument-type] Argument is incorrect: Expected `UUID`, found `Any | dict[str, Any] | None` src/prefect/events/utilities.py:96:27: error[invalid-argument-type] Argument is incorrect: Expected `UUID | None`, found `Any | dict[str, Any] | None` +src/prefect/events/worker.py:74:9: error[invalid-method-override] Invalid override of method `_prepare_item`: Definition is incompatible with `QueueService._prepare_item` +src/prefect/events/worker.py:78:15: error[invalid-method-override] Invalid override of method `_handle`: Definition is incompatible with `QueueService._handle` +src/prefect/events/worker.py:100:9: error[invalid-method-override] Invalid override of method `instance`: Definition is incompatible with `_QueueServiceBase.instance` src/prefect/input/actions.py:46:49: warning[deprecated] The function `json` is deprecated: The `json` method is deprecated; use `model_dump_json` instead. src/prefect/server/models/artifacts.py:449:12: error[unresolved-attribute] Object of type `Result[Unknown]` has no attribute `rowcount` src/prefect/server/models/artifacts.py:449:39: error[unresolved-attribute] Object of type `Result[Unknown]` has no attribute `rowcount` @@ -87,34 +90,34 @@ src/prefect/server/models/variables.py:154:12: error[unresolved-attribute] Objec src/prefect/server/models/variables.py:168:12: error[unresolved-attribute] Object of type `Result[Any]` has no attribute `rowcount` src/prefect/server/models/work_queues.py:282:15: error[unresolved-attribute] Object of type `Result[Unknown]` has no attribute `rowcount` src/prefect/server/models/work_queues.py:311:12: error[unresolved-attribute] Object of type `Result[Any]` has no attribute `rowcount` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `Operator`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterId | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterName | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterTags | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterDeploymentId | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterWorkQueueName | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterFlowVersion | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterStartTime | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterEndTime | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterExpectedStartTime | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterNextScheduledStartTime | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterParentFlowRunId | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterParentTaskRunId | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterIdempotencyKey | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `Operator`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterId | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterName | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterTags | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterDeploymentId | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterWorkQueueName | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterFlowVersion | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterStartTime | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterEndTime | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterExpectedStartTime | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterNextScheduledStartTime | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterParentFlowRunId | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterParentTaskRunId | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:403:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterIdempotencyKey | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` src/prefect/server/models/work_queues.py:404:17: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterState | None`, found `dict[str, dict[str, list[Unknown | StateType]]]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `Operator`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterId | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterName | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterTags | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterDeploymentId | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterWorkQueueName | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterFlowVersion | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterStartTime | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterEndTime | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterExpectedStartTime | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterParentFlowRunId | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterParentTaskRunId | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` -src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterIdempotencyKey | None`, found `dict[str, Unknown] | dict[str, Unknown | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `Operator`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterId | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterName | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterTags | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterDeploymentId | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterWorkQueueName | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterFlowVersion | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterStartTime | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterEndTime | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterExpectedStartTime | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterParentFlowRunId | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterParentTaskRunId | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` +src/prefect/server/models/work_queues.py:421:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterIdempotencyKey | None`, found `dict[str, list[str] | None] | dict[str, list[UUID] | None | bool]` src/prefect/server/models/work_queues.py:422:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterState | None`, found `dict[str, dict[str, list[Unknown | StateType]]]` src/prefect/server/models/work_queues.py:423:13: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterNextScheduledStartTime | None`, found `dict[str, datetime | None]` src/prefect/server/models/work_queues.py:491:54: error[invalid-argument-type] Argument is incorrect: Expected `FlowRunFilterStateName | None`, found `dict[Unknown | str, Unknown | list[Unknown | str]]` @@ -124,8 +127,8 @@ src/prefect/server/models/work_queues.py:628:13: error[invalid-argument-type] Ar src/prefect/server/models/workers.py:253:15: error[unresolved-attribute] Object of type `Result[Unknown]` has no attribute `rowcount` src/prefect/server/models/workers.py:289:12: error[unresolved-attribute] Object of type `Result[Any]` has no attribute `rowcount` src/prefect/server/models/workers.py:626:15: error[unresolved-attribute] Object of type `Result[Unknown]` has no attribute `rowcount` -src/prefect/server/models/workers.py:672:12: error[unresolved-attribute] Module `sqlalchemy` has no member `exc` +src/prefect/server/models/workers.py:672:12: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `sqlalchemy` src/prefect/server/models/workers.py:755:9: error[invalid-assignment] Invalid subscript assignment with key of type `Literal["heartbeat_interval_seconds"]` and value of type `int` on object of type `dict[str, datetime | WorkerStatus]` src/prefect/server/models/workers.py:770:12: error[unresolved-attribute] Object of type `Result[Unknown]` has no attribute `rowcount` src/prefect/server/models/workers.py:799:12: error[unresolved-attribute] Object of type `Result[Any]` has no attribute `rowcount` -Found 130 diagnostics +Found 133 diagnostics diff --git a/scripts/ty_benchmark/snapshots/pytorch_Pyrefly.txt b/scripts/ty_benchmark/snapshots/pytorch_Pyrefly.txt index b1f7dbde41..f61afc16b2 100644 --- a/scripts/ty_benchmark/snapshots/pytorch_Pyrefly.txt +++ b/scripts/ty_benchmark/snapshots/pytorch_Pyrefly.txt @@ -987,6 +987,8 @@ ERROR torch/_dynamo/utils.py:2484:5-16: No attribute `iinfo` in module `torch` [ ERROR torch/_dynamo/utils.py:2490:12-18: Could not find import of `triton` [missing-import] ERROR torch/_dynamo/utils.py:2510:13-23: No attribute `Size` in module `torch` [missing-attribute] ERROR torch/_dynamo/utils.py:2532:21-54: Module `torch.nested._internal.nested_int` exists, but was not imported explicitly. You are relying on other modules to load it. [implicit-import] +ERROR torch/_dynamo/utils.py:2646:39-53: `type[Iterator]` is not assignable to `type[Iterator[Any]]` [bad-assignment] +ERROR torch/_dynamo/utils.py:2647:39-59: `type[Iterator]` is not assignable to `type[Iterator[Any]]` [bad-assignment] ERROR torch/_dynamo/utils.py:2981:12-22: No attribute `sqrt` in module `torch` [missing-attribute] ERROR torch/_dynamo/utils.py:2981:23-33: No attribute `mean` in module `torch` [missing-attribute] ERROR torch/_dynamo/utils.py:2981:34-46: No attribute `square` in module `torch` [missing-attribute] @@ -1275,6 +1277,7 @@ ERROR torch/_dynamo/variables/functions.py:628:18-44: Module `torch._dynamo.side ERROR torch/_dynamo/variables/functions.py:645:22-48: Module `torch._dynamo.side_effects` exists, but was not imported explicitly. You are relying on other modules to load it. [implicit-import] ERROR torch/_dynamo/variables/functions.py:1839:34-47: Module `torch._guards` exists, but was not imported explicitly. You are relying on other modules to load it. [implicit-import] WARN torch/_dynamo/variables/functions.py:1981:13-38: `torch.distributed.distributed_c10d._reduce_scatter_base` is deprecated [deprecated] +ERROR torch/_dynamo/variables/functions.py:2193:33-45: `(...) -> object` is not assignable to attribute `traceable_fn` with type `_F` [bad-assignment] ERROR torch/_dynamo/variables/functions.py:2446:9-17: Class member `DynamoTritonHOPifier.call_HOP` overrides parent class `TritonHOPifier` in an inconsistent manner [bad-param-name-override] ERROR torch/_dynamo/variables/higher_order_ops.py:98:24-57: Argument `list[bool] | None` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type] ERROR torch/_dynamo/variables/higher_order_ops.py:98:66-83: Argument `list[Any] | None` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type] @@ -4349,6 +4352,7 @@ ERROR torch/_inductor/codegen/simd_kernel_features.py:357:46-52: Argument `list[ ERROR torch/_inductor/codegen/subgraph.py:97:44-56: Object of class `Expr` has no attribute `name` [missing-attribute] ERROR torch/_inductor/codegen/subgraph.py:98:56-68: Object of class `Expr` has no attribute `name` [missing-attribute] ERROR torch/_inductor/codegen/subgraph.py:373:31-42: No attribute `empty` in module `torch` [missing-attribute] +ERROR torch/_inductor/codegen/triton_combo_kernel.py:619:26-44: Class `NoneType` has no class attribute `grid_expr` [missing-attribute] ERROR torch/_inductor/codegen/triton_split_scan.py:92:16-37: Could not find import of `triton.language` [missing-import] ERROR torch/_inductor/codegen/triton_split_scan.py:130:55-61: Argument `int` is not assignable to parameter `index` with type `Expr` in function `torch._inductor.codegen.simd.SIMDKernel.index_to_str` [bad-argument-type] ERROR torch/_inductor/codegen/triton_utils.py:39:25-44: No attribute `float8_e4m3fn` in module `torch` [missing-attribute] @@ -12393,11 +12397,7 @@ ERROR torch/_weights_only_unpickler.py:217:9-47: No attribute `per_channel_affin ERROR torch/accelerator/__init__.py:96:59-71: No attribute `device` in module `torch` [missing-attribute] ERROR torch/accelerator/__init__.py:122:16-52: No attribute `_accelerator_getAccelerator` in module `torch._C` [missing-attribute] ERROR torch/accelerator/__init__.py:134:12-48: No attribute `_accelerator_getDeviceIndex` in module `torch._C` [missing-attribute] - WARN torch/accelerator/__init__.py:137:22-140:24: `current_device_index` is deprecated [deprecated] - WARN torch/accelerator/__init__.py:142:1-19: `current_device_index` is deprecated [deprecated] ERROR torch/accelerator/__init__.py:165:5-41: No attribute `_accelerator_setDeviceIndex` in module `torch._C` [missing-attribute] - WARN torch/accelerator/__init__.py:168:18-171:20: `set_device_index` is deprecated [deprecated] - WARN torch/accelerator/__init__.py:173:1-15: `set_device_index` is deprecated [deprecated] ERROR torch/accelerator/__init__.py:187:52-64: No attribute `Stream` in module `torch` [missing-attribute] ERROR torch/accelerator/__init__.py:199:12-43: No attribute `_accelerator_getStream` in module `torch._C` [missing-attribute] ERROR torch/accelerator/__init__.py:202:24-36: No attribute `Stream` in module `torch` [missing-attribute] @@ -13115,6 +13115,12 @@ ERROR torch/ao/pruning/sparsifier/weight_norm_sparsifier.py:197:25-35: No attrib ERROR torch/ao/pruning/sparsifier/weight_norm_sparsifier.py:231:25-40: No attribute `ones_like` in module `torch` [missing-attribute] ERROR torch/ao/pruning/sparsifier/weight_norm_sparsifier.py:233:25-41: No attribute `zeros_like` in module `torch` [missing-attribute] ERROR torch/ao/pruning/sparsifier/weight_norm_sparsifier.py:249:31-47: No attribute `logical_or` in module `torch` [missing-attribute] + WARN torch/ao/quantization/__init__.py:33:23-24: `prepare` is deprecated [deprecated] + WARN torch/ao/quantization/__init__.py:33:23-24: `quantize` is deprecated [deprecated] + WARN torch/ao/quantization/__init__.py:33:23-24: `quantize_dynamic` is deprecated [deprecated] + WARN torch/ao/quantization/__init__.py:33:23-24: `prepare_qat` is deprecated [deprecated] + WARN torch/ao/quantization/__init__.py:33:23-24: `quantize_qat` is deprecated [deprecated] + WARN torch/ao/quantization/__init__.py:33:23-24: `convert` is deprecated [deprecated] ERROR torch/ao/quantization/__init__.py:217:16-27: No attribute `dtype` in module `torch` [missing-attribute] ERROR torch/ao/quantization/__init__.py:224:18-31: No attribute `qscheme` in module `torch` [missing-attribute] ERROR torch/ao/quantization/_correct_bias.py:147:30-40: No attribute `mean` in module `torch` [missing-attribute] @@ -13811,6 +13817,7 @@ ERROR torch/ao/quantization/fx/convert.py:768:19-31: No attribute `device` in mo ERROR torch/ao/quantization/fx/convert.py:1284:54-60: Cannot index into `Module` [bad-index] ERROR torch/ao/quantization/fx/graph_module.py:136:39-60: No attribute `ScriptObject` in module `torch._C` [missing-attribute] ERROR torch/ao/quantization/fx/graph_module.py:179:40-61: No attribute `ScriptObject` in module `torch._C` [missing-attribute] + WARN torch/ao/quantization/fx/lstm_utils.py:15:72-82: `prepare_fx` is deprecated [deprecated] WARN torch/ao/quantization/fx/lstm_utils.py:114:16-26: `torch.ao.quantization.quantize_fx.prepare_fx` is deprecated [deprecated] ERROR torch/ao/quantization/fx/lstm_utils.py:122:18-27: No attribute `add` in module `torch` [missing-attribute] ERROR torch/ao/quantization/fx/lstm_utils.py:123:18-27: No attribute `mul` in module `torch` [missing-attribute] @@ -13830,6 +13837,7 @@ ERROR torch/ao/quantization/fx/lstm_utils.py:144:29-38: No attribute `add` in mo ERROR torch/ao/quantization/fx/lstm_utils.py:146:33-42: No attribute `mul` in module `torch` [missing-attribute] ERROR torch/ao/quantization/fx/lstm_utils.py:147:29-38: No attribute `mul` in module `torch` [missing-attribute] ERROR torch/ao/quantization/fx/lstm_utils.py:211:31-56: No attribute `quantize_per_tensor` in module `torch` [missing-attribute] + WARN torch/ao/quantization/fx/prepare.py:30:44-51: `convert` is deprecated [deprecated] ERROR torch/ao/quantization/fx/prepare.py:90:39-49: No attribute `bool` in module `torch` [missing-attribute] ERROR torch/ao/quantization/fx/prepare.py:92:5-17: No attribute `quint8` in module `torch` [missing-attribute] ERROR torch/ao/quantization/fx/prepare.py:93:5-16: No attribute `qint8` in module `torch` [missing-attribute] @@ -16187,7 +16195,6 @@ ERROR torch/distributed/fsdp/sharded_grad_scaler.py:254:21-31: No attribute `ful ERROR torch/distributed/fsdp/sharded_grad_scaler.py:255:30-43: No attribute `float32` in module `torch` [missing-attribute] ERROR torch/distributed/fsdp/sharded_grad_scaler.py:286:13-33: No attribute `_foreach_copy_` in module `torch` [missing-attribute] ERROR torch/distributed/fsdp/sharded_grad_scaler.py:367:17-41: No attribute `_amp_update_scale_` in module `torch` [missing-attribute] - WARN torch/distributed/launch.py:207:5-9: `main` is deprecated [deprecated] ERROR torch/distributed/nn/__init__.py:6:4-25: Module `torch.distributed.rpc` exists, but was not imported explicitly. You are relying on other modules to load it. [implicit-import] ERROR torch/distributed/nn/api/remote_module.py:13:19-25: Could not import `device` from `torch` [missing-module-attribute] ERROR torch/distributed/nn/api/remote_module.py:13:27-32: Could not import `dtype` from `torch` [missing-module-attribute] @@ -20540,6 +20547,15 @@ ERROR torch/quantization/_quantized_conversions.py:115:23-32: No attribute `int` ERROR torch/quantization/_quantized_conversions.py:120:20-34: No attribute `quint4x2` in module `torch` [missing-attribute] ERROR torch/quantization/_quantized_conversions.py:130:18-32: No attribute `quint4x2` in module `torch` [missing-attribute] ERROR torch/quantization/_quantized_conversions.py:134:41-52: No attribute `uint8` in module `torch` [missing-attribute] + WARN torch/quantization/quantize.py:22:5-12: `convert` is deprecated [deprecated] + WARN torch/quantization/quantize.py:23:5-12: `prepare` is deprecated [deprecated] + WARN torch/quantization/quantize.py:24:5-16: `prepare_qat` is deprecated [deprecated] + WARN torch/quantization/quantize.py:26:5-13: `quantize` is deprecated [deprecated] + WARN torch/quantization/quantize.py:27:5-21: `quantize_dynamic` is deprecated [deprecated] + WARN torch/quantization/quantize.py:28:5-17: `quantize_qat` is deprecated [deprecated] + WARN torch/quantization/quantize_fx.py:19:5-15: `convert_fx` is deprecated [deprecated] + WARN torch/quantization/quantize_fx.py:21:5-15: `prepare_fx` is deprecated [deprecated] + WARN torch/quantization/quantize_fx.py:22:5-19: `prepare_qat_fx` is deprecated [deprecated] ERROR torch/quasirandom.py:62:15-27: No attribute `device` in module `torch` [missing-attribute] ERROR torch/quasirandom.py:64:27-38: No attribute `zeros` in module `torch` [missing-attribute] ERROR torch/quasirandom.py:65:55-65: No attribute `long` in module `torch` [missing-attribute] @@ -21391,8 +21407,8 @@ ERROR torch/utils/_sympy/printers.py:487:53-68: Object of class `Expr` has no at ERROR torch/utils/_sympy/printers.py:573:12-29: Object of class `Basic` has no attribute `is_integer` [missing-attribute] ERROR torch/utils/_sympy/printers.py:575:16-28: `>=` is not supported between `Basic` and `Literal[0]` [unsupported-operation] ERROR torch/utils/_sympy/printers.py:581:86-94: Unary `-` is not supported on `Basic` [unsupported-operation] -ERROR torch/utils/_sympy/reference.py:106:28-39: Argument `type[floor]` is not assignable to parameter `f` with type `(**tuple[*@_]) -> @_` in function `torch.utils._sympy.functions._keep_float` [bad-argument-type] -ERROR torch/utils/_sympy/reference.py:110:28-41: Argument `type[ceiling]` is not assignable to parameter `f` with type `(**tuple[*@_]) -> @_` in function `torch.utils._sympy.functions._keep_float` [bad-argument-type] +ERROR torch/utils/_sympy/reference.py:106:40-43: Unpacked argument `tuple[Unknown]` is not assignable to varargs type `tuple[()]` [bad-argument-type] +ERROR torch/utils/_sympy/reference.py:110:42-45: Unpacked argument `tuple[Unknown]` is not assignable to varargs type `tuple[()]` [bad-argument-type] ERROR torch/utils/_sympy/reference.py:114:21-34: No attribute `float64` in module `torch` [missing-attribute] ERROR torch/utils/_sympy/reference.py:222:21-32: No attribute `int64` in module `torch` [missing-attribute] ERROR torch/utils/_sympy/reference.py:224:23-35: No attribute `double` in module `torch` [missing-attribute] @@ -21597,6 +21613,7 @@ ERROR torch/utils/data/dataloader.py:650:26-41: No attribute `Generator` in modu ERROR torch/utils/data/dataloader.py:706:13-24: No attribute `empty` in module `torch` [missing-attribute] ERROR torch/utils/data/dataloader.py:706:35-46: No attribute `int64` in module `torch` [missing-attribute] ERROR torch/utils/data/dataloader.py:723:26-41: No attribute `Generator` in module `torch` [missing-attribute] +ERROR torch/utils/data/datapipes/datapipe.py:422:16-41: Returned type `_T_co` is not assignable to declared return type `_T_co` [bad-return] ERROR torch/utils/data/datapipes/datapipe.py:426:9-20: Class member `_MapDataPipeSerializationWrapper.__getitem__` overrides parent class `MapDataPipe` in an inconsistent manner [bad-param-name-override] WARN torch/utils/data/datapipes/gen_pyi.py:64:30-47: `materialize_lines` is deprecated [deprecated] ERROR torch/utils/data/datapipes/iter/callable.py:79:9-37: No attribute `_log_api_usage_once` in module `torch._C` [missing-attribute] @@ -21800,4 +21817,4 @@ ERROR torch/xpu/streams.py:103:13-35: No attribute `_XpuEventBase` in module `to ERROR torch/xpu/streams.py:167:32-47: Object of class `Event` has no attribute `sycl_event` [missing-attribute] ERROR torch/xpu/streams.py:170:12-27: Object of class `Event` has no attribute `sycl_event` [missing-attribute] INFO Checking project configured at `/pyrefly.toml` - INFO 21,677 errors (6,455 suppressed) + INFO 21,682 errors (6,437 suppressed) diff --git a/scripts/ty_benchmark/snapshots/pytorch_ty.txt b/scripts/ty_benchmark/snapshots/pytorch_ty.txt index 5814462426..2e07525401 100644 --- a/scripts/ty_benchmark/snapshots/pytorch_ty.txt +++ b/scripts/ty_benchmark/snapshots/pytorch_ty.txt @@ -123,6 +123,7 @@ torch/__init__.py:2980:16: error[unresolved-attribute] Module `torch` has no mem torch/__init__.py:2980:41: error[unresolved-attribute] Module `torch` has no member `int64` torch/__init__.py:2982:16: error[unresolved-attribute] Module `torch` has no member `as_tensor` torch/_awaits/__init__.py:14:14: error[unresolved-attribute] Module `torch._C` has no member `_Await` +torch/_classes.py:12:9: error[invalid-method-override] Invalid override of method `__getattr__`: Definition is incompatible with `ModuleType.__getattr__` torch/_classes.py:13:17: error[unresolved-attribute] Module `torch._C` has no member `_get_custom_class_python_wrapper` torch/_custom_op/autograd.py:53:12: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_custom_op/autograd.py:57:14: error[unresolved-attribute] Module `torch._C` has no member `_AutoDispatchBelowAutograd` @@ -131,7 +132,7 @@ torch/_custom_op/impl.py:113:9: error[unresolved-attribute] Module `torch._C` ha torch/_custom_op/impl.py:150:25: error[unresolved-attribute] Module `torch._C` has no member `_DispatchOperatorHandle` torch/_custom_op/impl.py:216:18: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_call_boxed` torch/_custom_op/impl.py:246:12: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_computed_kernel_for_dispatch_key` -torch/_custom_op/impl.py:290:22: error[unresolved-attribute] Module `torch._library` has no member `fake_impl` +torch/_custom_op/impl.py:290:22: warning[possibly-missing-attribute] Submodule `fake_impl` may not be available as an attribute on module `torch._library` torch/_custom_op/impl.py:341:12: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` torch/_custom_op/impl.py:356:16: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` torch/_custom_op/impl.py:374:12: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` @@ -141,9 +142,9 @@ torch/_custom_op/impl.py:396:12: error[unresolved-attribute] Module `torch._C` h torch/_custom_op/impl.py:414:13: error[unresolved-attribute] Object of type `Self@_register_autograd_kernel` has no attribute `_output_differentiability` torch/_custom_op/impl.py:467:13: error[unresolved-attribute] Unresolved attribute `_output_differentiability` on type `Self@impl_backward`. torch/_custom_op/impl.py:484:12: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_find_schema_or_throw` -torch/_custom_op/impl.py:503:12: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/_custom_op/impl.py:691:24: error[unresolved-attribute] Module `torch` has no member `_custom_op` -torch/_custom_op/impl.py:693:17: error[unresolved-attribute] Module `torch` has no member `_custom_op` +torch/_custom_op/impl.py:503:12: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/_custom_op/impl.py:691:24: warning[possibly-missing-attribute] Submodule `_custom_op` may not be available as an attribute on module `torch` +torch/_custom_op/impl.py:693:17: warning[possibly-missing-attribute] Submodule `_custom_op` may not be available as an attribute on module `torch` torch/_custom_op/impl.py:706:13: error[unresolved-attribute] Module `torch._C` has no member `Tag` torch/_custom_op/impl.py:713:5: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_set_report_error_callback` torch/_decomp/__init__.py:59:8: error[unresolved-attribute] Module `torch` has no member `Tag` @@ -264,7 +265,7 @@ torch/_decomp/decompositions.py:1368:16: error[unresolved-attribute] Module `tor torch/_decomp/decompositions.py:1370:9: error[unresolved-attribute] Module `torch` has no member `cat` torch/_decomp/decompositions.py:1386:39: error[unresolved-attribute] Module `torch` has no member `contiguous_format` torch/_decomp/decompositions.py:1433:48: error[unresolved-attribute] Module `torch` has no member `int64` -torch/_decomp/decompositions.py:1446:26: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_decomp/decompositions.py:1446:26: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_decomp/decompositions.py:1476:19: error[unresolved-attribute] Module `torch` has no member `mm` torch/_decomp/decompositions.py:1516:19: error[unresolved-attribute] Module `torch` has no member `mv` torch/_decomp/decompositions.py:1563:10: error[unresolved-attribute] Module `torch` has no member `mul` @@ -554,51 +555,51 @@ torch/_dispatch/python.py:58:9: error[unresolved-attribute] Module `torch._C` ha torch/_dispatch/python.py:60:12: error[unresolved-attribute] Module `torch._C` has no member `_functionalization_reapply_views_tls` torch/_dispatch/python.py:62:9: error[unresolved-attribute] Module `torch` has no member `_disable_functionalization` torch/_dispatch/python.py:67:13: error[unresolved-attribute] Module `torch` has no member `_enable_functionalization` -torch/_dispatch/python.py:74:25: error[unresolved-attribute] Module `torch` has no member `_prims_common` +torch/_dispatch/python.py:74:25: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` torch/_dispatch/python.py:126:20: error[unresolved-attribute] Module `torch` has no member `_is_functional_tensor` torch/_dispatch/python.py:127:25: error[unresolved-attribute] Module `torch` has no member `_from_functional_tensor` torch/_dispatch/python.py:183:30: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/_dispatch/python.py:192:34: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/_dynamo/__init__.py:61:29: warning[deprecated] The function `is_compiling` is deprecated: `torch._dynamo.external_utils.is_compiling` is deprecated. Use `torch.compiler.is_compiling` instead. torch/_dynamo/__init__.py:122:5: error[invalid-assignment] Implicit shadowing of function `manual_seed` -torch/_dynamo/__init__.py:153:9: error[unresolved-attribute] Module `torch._dynamo` has no member `compiled_autograd` -torch/_dynamo/__init__.py:160:9: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/_dynamo/__init__.py:153:9: warning[possibly-missing-attribute] Submodule `compiled_autograd` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/__init__.py:160:9: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/_dynamo/_trace_wrapped_higher_order_op.py:35:22: error[unresolved-import] Module `torch._C` has no member `DispatchKey` torch/_dynamo/_trace_wrapped_higher_order_op.py:59:12: error[unresolved-attribute] Module `torch` has no member `zeros` -torch/_dynamo/_trace_wrapped_higher_order_op.py:121:6: error[unresolved-attribute] Module `torch` has no member `_export` +torch/_dynamo/_trace_wrapped_higher_order_op.py:121:6: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` torch/_dynamo/_trace_wrapped_higher_order_op.py:139:22: error[unresolved-attribute] Module `torch._C` has no member `_TensorMeta` torch/_dynamo/_trace_wrapped_higher_order_op.py:171:12: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_dynamo/_trace_wrapped_higher_order_op.py:215:40: error[unresolved-attribute] Module `torch` has no member `empty_like` torch/_dynamo/_trace_wrapped_higher_order_op.py:247:17: error[invalid-assignment] Object of type `list[Any]` is not assignable to `tuple[Any, ...]` torch/_dynamo/aot_compile.py:112:17: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__globals__` -torch/_dynamo/aot_compile.py:226:13: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_dynamo/aot_compile.py:227:13: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/aot_compile_types.py:49:14: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_dynamo/aot_compile.py:226:13: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_dynamo/aot_compile.py:227:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/aot_compile_types.py:49:14: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_dynamo/backends/common.py:166:58: error[unresolved-attribute] Module `torch` has no member `device` torch/_dynamo/backends/common.py:170:12: error[unresolved-attribute] Module `torch` has no member `device` torch/_dynamo/backends/common.py:173:57: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_dynamo/backends/common.py:177:12: error[unresolved-attribute] Module `torch` has no member `float32` torch/_dynamo/backends/cudagraphs.py:95:11: error[unresolved-attribute] Module `torch` has no member `device` torch/_dynamo/backends/cudagraphs.py:96:31: error[unresolved-attribute] Module `torch` has no member `device` -torch/_dynamo/backends/cudagraphs.py:203:23: error[unresolved-attribute] Module `torch._inductor` has no member `cudagraph_trees` +torch/_dynamo/backends/cudagraphs.py:203:23: warning[possibly-missing-attribute] Submodule `cudagraph_trees` may not be available as an attribute on module `torch._inductor` torch/_dynamo/backends/cudagraphs.py:267:26: error[unresolved-attribute] Module `torch` has no member `zeros_like` -torch/_dynamo/backends/debugging.py:101:19: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` -torch/_dynamo/backends/debugging.py:224:12: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/backends/debugging.py:226:10: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/backends/debugging.py:229:16: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_dynamo/backends/debugging.py:101:19: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/backends/debugging.py:224:12: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/backends/debugging.py:226:10: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/backends/debugging.py:229:16: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_dynamo/backends/debugging.py:372:27: error[unresolved-attribute] Module `torch` has no member `relu` torch/_dynamo/backends/debugging.py:382:27: error[unresolved-attribute] Module `torch` has no member `relu` torch/_dynamo/backends/debugging.py:394:27: error[unresolved-attribute] Module `torch` has no member `relu` torch/_dynamo/backends/debugging.py:395:27: error[unresolved-attribute] Module `torch` has no member `add` torch/_dynamo/backends/distributed.py:30:58: warning[possibly-missing-import] Member `detect_fake_mode` of module `torch._dynamo.utils` may be missing -torch/_dynamo/backends/distributed.py:191:15: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_dynamo/backends/distributed.py:191:15: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_dynamo/backends/distributed.py:210:17: error[unresolved-attribute] Cannot assign object of type `(...) -> Any` to attribute `submod` on type `Self@__init__` with custom `__setattr__` method. torch/_dynamo/backends/distributed.py:211:17: error[unresolved-attribute] Cannot assign object of type `bool` to attribute `unwrap_singleton_tuple` on type `Self@__init__` with custom `__setattr__` method. -torch/_dynamo/backends/distributed.py:311:31: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_dynamo/backends/distributed.py:319:35: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_dynamo/backends/distributed.py:346:35: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_dynamo/backends/distributed.py:311:31: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_dynamo/backends/distributed.py:319:35: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_dynamo/backends/distributed.py:346:35: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_dynamo/backends/distributed.py:441:37: warning[possibly-missing-attribute] Member `_DEFAULT_FIRST_BUCKET_BYTES` may be missing on module `torch.distributed` -torch/_dynamo/backends/distributed.py:576:20: error[unresolved-attribute] Module `torch.fx` has no member `passes` +torch/_dynamo/backends/distributed.py:576:20: warning[possibly-missing-attribute] Submodule `passes` may not be available as an attribute on module `torch.fx` torch/_dynamo/backends/registry.py:104:20: error[unresolved-attribute] Object of type `((GraphModule, list[Tensor], /) -> CompiledFn) & (() -> object)` has no attribute `__name__` torch/_dynamo/backends/torchxla.py:33:16: error[unresolved-import] Cannot resolve imported module `torch_xla.core.dynamo_bridge` torch/_dynamo/backends/tvm.py:83:14: error[unresolved-import] Cannot resolve imported module `tvm` @@ -608,33 +609,33 @@ torch/_dynamo/backends/tvm.py:106:43: error[invalid-argument-type] Argument to f torch/_dynamo/backends/tvm.py:108:39: error[invalid-argument-type] Argument to function `unlink` is incorrect: Expected `str | bytes | PathLike[str] | PathLike[bytes]`, found `_TemporaryFileWrapper[bytes]` torch/_dynamo/backends/tvm.py:118:14: error[unresolved-import] Cannot resolve imported module `tvm` torch/_dynamo/backends/tvm.py:164:20: error[unresolved-attribute] Module `torch` has no member `from_numpy` -torch/_dynamo/backends/tvm.py:165:16: error[unresolved-attribute] Module `torch.utils` has no member `dlpack` +torch/_dynamo/backends/tvm.py:165:16: warning[possibly-missing-attribute] Submodule `dlpack` may not be available as an attribute on module `torch.utils` torch/_dynamo/backends/tvm.py:169:34: error[unresolved-attribute] Module `torch` has no member `bool` -torch/_dynamo/bytecode_transformation.py:1364:21: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` +torch/_dynamo/bytecode_transformation.py:1364:21: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` torch/_dynamo/bytecode_transformation.py:1783:34: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__code__` torch/_dynamo/codegen.py:311:42: error[unresolved-attribute] Module `torch` has no member `float64` torch/_dynamo/compiled_autograd.py:167:28: error[unresolved-attribute] Module `torch` has no member `isnan` torch/_dynamo/compiled_autograd.py:192:20: error[unresolved-attribute] Module `torch` has no member `isnan` -torch/_dynamo/compiled_autograd.py:420:13: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` +torch/_dynamo/compiled_autograd.py:420:13: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` torch/_dynamo/compiled_autograd.py:422:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[str, list[Tensor], list[int | SymInt], list[int | float | SymFloat]]`, found `tuple[str, list[Tensor], list[Unknown], list[int | float]]` torch/_dynamo/compiled_autograd.py:473:12: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` -torch/_dynamo/compiled_autograd.py:486:19: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_dynamo/compiled_autograd.py:486:19: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_dynamo/compiled_autograd.py:604:28: error[unresolved-attribute] Module `torch` has no member `zeros` -torch/_dynamo/compiled_autograd.py:634:19: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_dynamo/compiled_autograd.py:634:19: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_dynamo/compiled_autograd.py:689:21: error[unresolved-attribute] Module `torch` has no member `empty` torch/_dynamo/compiled_autograd.py:731:20: error[unresolved-attribute] Module `torch` has no member `zeros` torch/_dynamo/compiled_autograd.py:783:30: error[unresolved-attribute] Module `torch` has no member `add` -torch/_dynamo/compiled_autograd.py:849:13: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` +torch/_dynamo/compiled_autograd.py:849:13: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` torch/_dynamo/compiled_autograd.py:869:16: error[invalid-return-type] Return type does not match returned value: expected `list[Tensor]`, found `list[Tensor | None | Unknown]` torch/_dynamo/compiled_autograd.py:1123:51: error[unresolved-attribute] Module `torch` has no member `empty` -torch/_dynamo/compiled_autograd.py:1398:41: error[unresolved-attribute] Module `torch.fx.experimental` has no member `proxy_tensor` -torch/_dynamo/compiled_autograd.py:1521:17: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` -torch/_dynamo/compiled_autograd.py:1537:17: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` -torch/_dynamo/compiled_autograd.py:1551:9: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` -torch/_dynamo/compiled_autograd.py:1563:9: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` -torch/_dynamo/compiled_autograd.py:1573:5: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` -torch/_dynamo/compiled_autograd.py:1574:5: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` -torch/_dynamo/compiled_autograd.py:1575:5: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` +torch/_dynamo/compiled_autograd.py:1398:41: warning[possibly-missing-attribute] Submodule `proxy_tensor` may not be available as an attribute on module `torch.fx.experimental` +torch/_dynamo/compiled_autograd.py:1521:17: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` +torch/_dynamo/compiled_autograd.py:1537:17: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` +torch/_dynamo/compiled_autograd.py:1551:9: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` +torch/_dynamo/compiled_autograd.py:1563:9: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` +torch/_dynamo/compiled_autograd.py:1573:5: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` +torch/_dynamo/compiled_autograd.py:1574:5: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` +torch/_dynamo/compiled_autograd.py:1575:5: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` torch/_dynamo/compiled_autograd.py:1597:64: error[unresolved-attribute] Module `torch` has no member `contiguous_format` torch/_dynamo/convert_frame.py:159:5: warning[possibly-missing-import] Member `LazyString` of module `torch._dynamo.utils` may be missing torch/_dynamo/convert_frame.py:176:5: error[conflicting-declarations] Conflicting declared types for `np`: `ModuleType | None` and `` @@ -680,6 +681,8 @@ torch/_dynamo/debug_utils.py:850:65: error[unresolved-attribute] Module `torch` torch/_dynamo/debug_utils.py:864:23: error[unresolved-attribute] Module `torch` has no member `randn` torch/_dynamo/debug_utils.py:864:67: error[unresolved-attribute] Module `torch` has no member `zeros` torch/_dynamo/decorators.py:121:15: error[unresolved-attribute] Object of type `((...) -> Any) & (() -> object)` has no attribute `__code__` +torch/_dynamo/decorators.py:148:9: error[invalid-method-override] Invalid override of method `__call__`: Definition is incompatible with `_DecoratorContextManager.__call__` +torch/_dynamo/decorators.py:158:9: error[invalid-method-override] Invalid override of method `__exit__`: Definition is incompatible with `_DecoratorContextManager.__exit__` torch/_dynamo/decorators.py:823:12: error[unresolved-import] Cannot resolve imported module `einops` torch/_dynamo/device_interface.py:30:26: error[unresolved-import] Module `torch._C` has no member `_cuda_getCurrentRawStream` torch/_dynamo/device_interface.py:106:24: error[unresolved-attribute] Module `torch` has no member `Stream` @@ -695,6 +698,7 @@ torch/_dynamo/device_interface.py:295:26: error[unresolved-import] Module `torch torch/_dynamo/device_interface.py:321:30: error[unresolved-attribute] Module `torch` has no member `device` torch/_dynamo/device_interface.py:323:39: error[unresolved-attribute] Module `torch` has no member `device` torch/_dynamo/device_interface.py:335:20: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | Unknown, (s: slice[Any, Any, Any], /) -> list[dict[str, Any] | Unknown]]` cannot be called with key of type `(Unknown & ~None) | str | int` on object of type `list[dict[str, Any] | Unknown]` +torch/_dynamo/device_interface.py:369:9: error[invalid-method-override] Invalid override of method `raise_if_triton_unavailable`: Definition is incompatible with `DeviceInterface.raise_if_triton_unavailable` torch/_dynamo/device_interface.py:370:16: error[unresolved-import] Cannot resolve imported module `triton.backends` torch/_dynamo/device_interface.py:378:26: error[unresolved-import] Module `torch._C` has no member `_xpu_getCurrentRawStream` torch/_dynamo/device_interface.py:404:30: error[unresolved-attribute] Module `torch` has no member `device` @@ -721,13 +725,14 @@ torch/_dynamo/distributed.py:48:32: warning[possibly-missing-attribute] Member ` torch/_dynamo/distributed.py:51:25: warning[possibly-missing-attribute] Member `distributed_c10d` may be missing on module `torch.distributed` torch/_dynamo/eval_frame.py:337:13: error[call-non-callable] Object of type `object` is not callable torch/_dynamo/eval_frame.py:356:16: error[unresolved-attribute] Object of type `((...) -> Any) & (() -> object)` has no attribute `__code__` -torch/_dynamo/eval_frame.py:357:12: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` +torch/_dynamo/eval_frame.py:357:12: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` torch/_dynamo/eval_frame.py:520:13: error[invalid-assignment] Object of type `bool` is not assignable to attribute `training` on type `Unknown | Module` +torch/_dynamo/eval_frame.py:527:9: error[invalid-method-override] Invalid override of method `__setattr__`: Definition is incompatible with `Module.__setattr__` torch/_dynamo/eval_frame.py:657:13: warning[possibly-missing-attribute] Member `all_gather_object` may be missing on module `torch.distributed` torch/_dynamo/eval_frame.py:811:38: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__code__` torch/_dynamo/eval_frame.py:868:26: error[unresolved-attribute] Module `torch._C` has no member `_is_tracing` -torch/_dynamo/eval_frame.py:876:39: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_dynamo/eval_frame.py:914:21: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_dynamo/eval_frame.py:876:39: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_dynamo/eval_frame.py:914:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_dynamo/eval_frame.py:917:61: error[invalid-argument-type] Argument to function `_callback_from_stance` is incorrect: Expected `DynamoCallbackFn | None | bool`, found `(def do_nothing(...) -> None) | ((...) -> Any)` torch/_dynamo/eval_frame.py:1121:13: error[invalid-assignment] Object of type `(...) -> Any` is not assignable to attribute `__call__` on type `((...) -> Any) & type & ~Module` torch/_dynamo/eval_frame.py:1125:17: error[invalid-assignment] Object of type `(...) -> Any` is not assignable to attribute `_call_impl` on type `((...) -> Any) & type[Module] & ~Module` @@ -736,7 +741,7 @@ torch/_dynamo/eval_frame.py:1429:5: error[unresolved-attribute] Module `torch._C torch/_dynamo/eval_frame.py:1475:13: error[call-non-callable] Object of type `object` is not callable torch/_dynamo/eval_frame.py:1739:9: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` torch/_dynamo/eval_frame.py:1954:9: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` -torch/_dynamo/eval_frame.py:2228:22: error[unresolved-attribute] Module `torch.fx` has no member `traceback` +torch/_dynamo/eval_frame.py:2228:22: warning[possibly-missing-attribute] Submodule `traceback` may not be available as an attribute on module `torch.fx` torch/_dynamo/external_utils.py:103:59: error[unresolved-attribute] Module `torch` has no member `as_tensor` torch/_dynamo/functional_export.py:372:16: error[unsupported-operator] Operator `in` is not supported for types `str` and `Module`, in comparing `Literal["dynamo_flat_name_to_original_fqn"]` with `Unknown | Tensor | Module` torch/_dynamo/functional_export.py:374:70: error[non-subscriptable] Cannot subscript object of type `Module` with no `__getitem__` method @@ -755,7 +760,7 @@ torch/_dynamo/functional_export.py:644:13: error[unresolved-attribute] Cannot as torch/_dynamo/functional_export.py:647:13: error[unresolved-attribute] Cannot assign object of type `set[str]` to attribute `_non_persistent_buffers_set` on type `GraphModule` with custom `__setattr__` method. torch/_dynamo/functional_export.py:654:9: error[unresolved-attribute] Cannot assign object of type `TreeSpec` to attribute `_in_spec` on type `GraphModule` with custom `__setattr__` method. torch/_dynamo/functional_export.py:655:9: error[unresolved-attribute] Cannot assign object of type `TreeSpec` to attribute `_out_spec` on type `GraphModule` with custom `__setattr__` method. -torch/_dynamo/functional_export.py:800:43: error[unresolved-attribute] Module `torch._dynamo` has no member `source` +torch/_dynamo/functional_export.py:800:43: warning[possibly-missing-attribute] Submodule `source` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/graph_region_tracker.py:55:5: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_dynamo/graph_region_tracker.py:155:9: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_dynamo/graph_region_tracker.py:156:9: error[unresolved-attribute] Module `torch` has no member `is_inference_mode_enabled` @@ -768,24 +773,24 @@ torch/_dynamo/graph_utils.py:87:26: error[unresolved-attribute] Module `torch` h torch/_dynamo/guards.py:220:26: error[unresolved-import] Module `torch._C` has no member `DispatchKeySet` torch/_dynamo/guards.py:726:16: error[unresolved-attribute] Module `torch` has no member `as_tensor` torch/_dynamo/guards.py:770:23: error[unresolved-attribute] Module `torch` has no member `device` -torch/_dynamo/guards.py:783:23: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` +torch/_dynamo/guards.py:783:23: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` torch/_dynamo/guards.py:852:25: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_local_include_set` torch/_dynamo/guards.py:853:9: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_local_exclude_set` -torch/_dynamo/guards.py:1011:14: error[unresolved-attribute] Module `torch` has no member `package` -torch/_dynamo/guards.py:1818:24: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` +torch/_dynamo/guards.py:1011:14: warning[possibly-missing-attribute] Submodule `package` may not be available as an attribute on module `torch` +torch/_dynamo/guards.py:1818:24: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` torch/_dynamo/guards.py:2074:32: error[unresolved-attribute] Module `torch._C` has no member `DispatchKeySet` -torch/_dynamo/guards.py:2102:22: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/guards.py:2112:21: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/guards.py:2114:13: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_dynamo/guards.py:2102:22: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/guards.py:2112:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/guards.py:2114:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_dynamo/guards.py:2205:17: error[unresolved-attribute] Module `torch` has no member `Size` torch/_dynamo/guards.py:2206:17: error[unresolved-attribute] Module `torch` has no member `Stream` torch/_dynamo/guards.py:2214:55: warning[possibly-missing-import] Member `DeviceMesh` of module `torch.distributed.device_mesh` may be missing -torch/_dynamo/guards.py:2771:20: error[unresolved-attribute] Module `torch._inductor` has no member `exc` +torch/_dynamo/guards.py:2771:20: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._inductor` torch/_dynamo/guards.py:2810:29: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_keys` torch/_dynamo/guards.py:2861:44: error[unresolved-attribute] Module `torch` has no member `device` torch/_dynamo/guards.py:2861:58: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_dynamo/guards.py:3195:9: error[unresolved-attribute] Module `torch._C` has no member `Stream` -torch/_dynamo/guards.py:3199:17: error[unresolved-attribute] Module `torch._C` has no member `_distributed_c10d` +torch/_dynamo/guards.py:3199:17: warning[possibly-missing-attribute] Submodule `_distributed_c10d` may not be available as an attribute on module `torch._C` torch/_dynamo/guards.py:3231:17: error[unresolved-attribute] Module `torch` has no member `device` torch/_dynamo/guards.py:3242:13: error[invalid-argument-type] Argument to bound method `from_meta_and_device` is incorrect: Expected `type[Tensor] | None`, found `type` torch/_dynamo/guards.py:3243:13: error[unresolved-attribute] Module `torch._C` has no member `DispatchKeySet` @@ -793,39 +798,39 @@ torch/_dynamo/guards.py:3252:17: error[unresolved-attribute] Module `torch` has torch/_dynamo/guards.py:3268:29: error[unresolved-attribute] Module `torch._C` has no member `DispatchKeySet` torch/_dynamo/guards.py:3276:59: error[unresolved-attribute] Module `torch._C` has no member `DispatchKeySet` torch/_dynamo/guards.py:3277:16: error[unresolved-attribute] Module `torch._C` has no member `DispatchKeySet` -torch/_dynamo/guards.py:3282:10: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/guards.py:3283:16: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/guards.py:3299:16: error[unresolved-attribute] Module `torch.distributed` has no member `fsdp` +torch/_dynamo/guards.py:3282:10: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/guards.py:3283:16: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/guards.py:3299:16: warning[possibly-missing-attribute] Submodule `fsdp` may not be available as an attribute on module `torch.distributed` torch/_dynamo/guards.py:3361:21: error[unresolved-attribute] Module `torch` has no member `empty_like` torch/_dynamo/guards.py:3364:21: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_keys` torch/_dynamo/guards.py:3370:17: error[unresolved-attribute] Module `torch` has no member `empty_like` torch/_dynamo/guards.py:3373:17: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_keys` torch/_dynamo/guards.py:3395:30: error[unresolved-attribute] Module `torch._C` has no member `DispatchKeySet` -torch/_dynamo/guards.py:3398:30: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/guards.py:3461:19: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` -torch/_dynamo/guards.py:3507:15: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` +torch/_dynamo/guards.py:3398:30: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/guards.py:3461:19: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/guards.py:3507:15: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/guards.py:3538:37: error[unresolved-reference] Name `OutputGraphCommon` used when not defined -torch/_dynamo/guards.py:3553:37: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` -torch/_dynamo/guards.py:3776:23: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` -torch/_dynamo/guards.py:3788:23: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` -torch/_dynamo/guards.py:3855:21: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_dynamo/guards.py:3553:37: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` +torch/_dynamo/guards.py:3776:23: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/guards.py:3788:23: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/guards.py:3855:21: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_dynamo/metrics_context.py:124:35: error[invalid-type-form] Invalid subscript of object of type `def set(self, metric: str, value: Any, overwrite: bool = Literal[False]) -> None` in type expression torch/_dynamo/output_graph.py:144:5: warning[possibly-missing-import] Member `LazyString` of module `torch._dynamo.utils` may be missing -torch/_dynamo/output_graph.py:335:28: error[unresolved-attribute] Module `torch._functorch` has no member `pyfunctorch` +torch/_dynamo/output_graph.py:335:28: warning[possibly-missing-attribute] Submodule `pyfunctorch` may not be available as an attribute on module `torch._functorch` torch/_dynamo/output_graph.py:336:30: error[unresolved-attribute] Module `torch` has no member `device` -torch/_dynamo/output_graph.py:337:25: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` +torch/_dynamo/output_graph.py:337:25: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` torch/_dynamo/output_graph.py:411:71: warning[deprecated] The class `LeafSpec` is deprecated: `isinstance(treespec, LeafSpec)` is deprecated, use `isinstance(treespec, TreeSpec) and treespec.is_leaf()` instead. torch/_dynamo/output_graph.py:416:75: warning[deprecated] The class `LeafSpec` is deprecated: `isinstance(treespec, LeafSpec)` is deprecated, use `isinstance(treespec, TreeSpec) and treespec.is_leaf()` instead. torch/_dynamo/output_graph.py:437:12: error[invalid-return-type] Return type does not match returned value: expected `dict[str, Any]`, found `Top[dict[Unknown, Unknown]]` -torch/_dynamo/output_graph.py:549:30: error[unresolved-attribute] Module `torch._functorch` has no member `pyfunctorch` -torch/_dynamo/output_graph.py:550:28: error[unresolved-attribute] Module `torch.utils` has no member `_device` -torch/_dynamo/output_graph.py:553:16: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` +torch/_dynamo/output_graph.py:549:30: warning[possibly-missing-attribute] Submodule `pyfunctorch` may not be available as an attribute on module `torch._functorch` +torch/_dynamo/output_graph.py:550:28: warning[possibly-missing-attribute] Submodule `_device` may not be available as an attribute on module `torch.utils` +torch/_dynamo/output_graph.py:553:16: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` torch/_dynamo/output_graph.py:671:44: error[unresolved-attribute] Module `torch._C` has no member `_is_torch_function_mode_enabled` -torch/_dynamo/output_graph.py:802:14: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/output_graph.py:807:16: error[unresolved-attribute] Module `torch._dynamo` has no member `compiled_autograd` -torch/_dynamo/output_graph.py:815:12: error[unresolved-attribute] Module `torch._dynamo` has no member `compiled_autograd` -torch/_dynamo/output_graph.py:818:21: error[unresolved-attribute] Module `torch._functorch` has no member `_aot_autograd` -torch/_dynamo/output_graph.py:820:13: error[unresolved-attribute] Module `torch._functorch` has no member `_aot_autograd` +torch/_dynamo/output_graph.py:802:14: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/output_graph.py:807:16: warning[possibly-missing-attribute] Submodule `compiled_autograd` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/output_graph.py:815:12: warning[possibly-missing-attribute] Submodule `compiled_autograd` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/output_graph.py:818:21: warning[possibly-missing-attribute] Submodule `_aot_autograd` may not be available as an attribute on module `torch._functorch` +torch/_dynamo/output_graph.py:820:13: warning[possibly-missing-attribute] Submodule `_aot_autograd` may not be available as an attribute on module `torch._functorch` torch/_dynamo/output_graph.py:851:24: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `InstructionTranslatorBase`, found `Unknown | InstructionTranslatorBase | None` torch/_dynamo/output_graph.py:855:17: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__name__` torch/_dynamo/output_graph.py:995:65: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` @@ -843,9 +848,9 @@ torch/_dynamo/output_graph.py:1026:16: error[invalid-return-type] Return type do torch/_dynamo/output_graph.py:1942:24: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_dynamo/output_graph.py:1945:33: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` torch/_dynamo/output_graph.py:1951:37: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` -torch/_dynamo/output_graph.py:1966:19: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` +torch/_dynamo/output_graph.py:1966:19: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/output_graph.py:2064:17: warning[possibly-missing-attribute] Member `all_gather_object` may be missing on module `torch.distributed` -torch/_dynamo/output_graph.py:2323:25: error[unresolved-attribute] Module `torch._dynamo` has no member `graph_bytecode_inputs` +torch/_dynamo/output_graph.py:2323:25: warning[possibly-missing-attribute] Submodule `graph_bytecode_inputs` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/output_graph.py:2416:17: warning[possibly-missing-attribute] Attribute `f_code` may be missing on object of type `Unknown | InstructionTranslatorBase | None` torch/_dynamo/output_graph.py:2418:77: warning[possibly-missing-attribute] Attribute `format_frame_summary` may be missing on object of type `Unknown | InstructionTranslatorBase | None` torch/_dynamo/output_graph.py:2591:66: error[unresolved-attribute] Module `torch` has no member `ScriptObject` @@ -866,17 +871,19 @@ torch/_dynamo/output_graph.py:3724:43: error[unresolved-attribute] Module `torch torch/_dynamo/output_graph.py:3724:61: error[unresolved-attribute] Module `torch` has no member `sparse_bsr` torch/_dynamo/output_graph.py:3727:43: error[unresolved-attribute] Module `torch` has no member `sparse_csc` torch/_dynamo/output_graph.py:3727:61: error[unresolved-attribute] Module `torch` has no member `sparse_bsc` -torch/_dynamo/package.py:123:12: error[unresolved-attribute] Module `torch._dynamo` has no member `guards` +torch/_dynamo/package.py:123:12: warning[possibly-missing-attribute] Submodule `guards` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/package.py:323:35: warning[possibly-missing-attribute] Attribute `strip` may be missing on object of type `str | None` torch/_dynamo/package.py:619:28: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__code__` torch/_dynamo/package.py:624:17: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__code__` torch/_dynamo/package.py:756:43: warning[possibly-missing-attribute] Attribute `__code__` may be missing on object of type `(Unknown & ~None) | ((...) -> Any)` torch/_dynamo/package.py:773:35: warning[possibly-missing-attribute] Attribute `__code__` may be missing on object of type `(Unknown & ~None) | ((...) -> Any)` -torch/_dynamo/package.py:849:53: error[unresolved-attribute] Module `torch._dynamo` has no member `guards` +torch/_dynamo/package.py:849:53: warning[possibly-missing-attribute] Submodule `guards` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/package.py:867:21: warning[possibly-missing-attribute] Attribute `__qualname__` may be missing on object of type `(Unknown & ~None) | ((...) -> Any)` torch/_dynamo/package.py:868:29: warning[possibly-missing-attribute] Attribute `__code__` may be missing on object of type `(Unknown & ~None) | ((...) -> Any)` torch/_dynamo/package.py:878:28: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__qualname__` torch/_dynamo/package.py:879:32: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__code__` +torch/_dynamo/package.py:1014:9: error[invalid-method-override] Invalid override of method `write`: Definition is incompatible with `DynamoStore.write` +torch/_dynamo/package.py:1058:9: error[invalid-method-override] Invalid override of method `write`: Definition is incompatible with `DynamoStore.write` torch/_dynamo/pgo.py:529:32: warning[possibly-missing-attribute] Member `is_initialized` may be missing on module `torch.distributed` torch/_dynamo/pgo.py:530:16: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/_dynamo/pgo.py:598:14: error[unresolved-import] Cannot resolve imported module `torch._inductor.fb.remote_cache` @@ -900,23 +907,23 @@ torch/_dynamo/repro/after_aot.py:376:31: warning[possibly-missing-attribute] Att torch/_dynamo/repro/after_aot.py:383:38: warning[possibly-missing-attribute] Attribute `configs` may be missing on object of type `Unknown | (Autotuner & Autotuner) | (JITFunction & Autotuner)` torch/_dynamo/repro/after_aot.py:403:24: warning[possibly-missing-attribute] Attribute `src` may be missing on object of type `Unknown | (Autotuner & JITFunction) | (JITFunction & JITFunction)` torch/_dynamo/repro/after_aot.py:406:17: warning[possibly-missing-attribute] Attribute `_fn_name` may be missing on object of type `Unknown | (Autotuner & JITFunction) | (JITFunction & JITFunction)` -torch/_dynamo/repro/after_aot.py:507:25: error[unresolved-attribute] Module `torch.fx` has no member `experimental` +torch/_dynamo/repro/after_aot.py:507:25: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` torch/_dynamo/repro/after_aot.py:792:5: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `generate_intermediate_hooks` of type `Literal[False]` -torch/_dynamo/repro/after_aot.py:883:14: error[unresolved-attribute] Module `torch.utils` has no member `_content_store` -torch/_dynamo/repro/after_aot.py:886:14: error[unresolved-attribute] Module `torch.utils` has no member `_content_store` +torch/_dynamo/repro/after_aot.py:883:14: warning[possibly-missing-attribute] Submodule `_content_store` may not be available as an attribute on module `torch.utils` +torch/_dynamo/repro/after_aot.py:886:14: warning[possibly-missing-attribute] Submodule `_content_store` may not be available as an attribute on module `torch.utils` torch/_dynamo/repro/after_dynamo.py:231:42: error[unresolved-attribute] Module `torch` has no member `is_autocast_enabled` torch/_dynamo/repro/aoti.py:305:5: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `generate_intermediate_hooks` of type `Literal[False]` torch/_dynamo/repro/aoti.py:427:14: error[invalid-assignment] Object of type `Module | None` is not assignable to `GraphModule` torch/_dynamo/resume_execution.py:106:12: warning[unresolved-global] Invalid global declaration of `__import_torch_dot__dynamo_dot_utils`: `__import_torch_dot__dynamo_dot_utils` has no declarations or bindings in the global scope torch/_dynamo/side_effects.py:502:19: error[no-matching-overload] No overload of function `__new__` matches arguments -torch/_dynamo/side_effects.py:724:26: error[unresolved-attribute] Module `torch._dynamo.variables` has no member `torch_function` -torch/_dynamo/side_effects.py:958:22: error[unresolved-attribute] Module `torch._dynamo.variables` has no member `torch_function` -torch/_dynamo/side_effects.py:967:24: error[unresolved-attribute] Module `torch._dynamo.variables` has no member `torch_function` +torch/_dynamo/side_effects.py:724:26: warning[possibly-missing-attribute] Submodule `torch_function` may not be available as an attribute on module `torch._dynamo.variables` +torch/_dynamo/side_effects.py:958:22: warning[possibly-missing-attribute] Submodule `torch_function` may not be available as an attribute on module `torch._dynamo.variables` +torch/_dynamo/side_effects.py:967:24: warning[possibly-missing-attribute] Submodule `torch_function` may not be available as an attribute on module `torch._dynamo.variables` torch/_dynamo/source.py:26:19: error[unresolved-import] Module `torch` has no member `device` torch/_dynamo/symbolic_convert.py:134:5: warning[possibly-missing-import] Member `LazyString` of module `torch._dynamo.utils` may be missing torch/_dynamo/symbolic_convert.py:434:45: error[invalid-argument-type] Argument to class `tuple` is incorrect: Expected `Iterable[object]`, found `~AlwaysFalsy` torch/_dynamo/symbolic_convert.py:686:21: error[unresolved-attribute] Module `torch` has no member `_assert_async` -torch/_dynamo/symbolic_convert.py:699:26: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` +torch/_dynamo/symbolic_convert.py:699:26: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` torch/_dynamo/symbolic_convert.py:711:34: error[unresolved-attribute] Module `torch` has no member `scalar_tensor` torch/_dynamo/symbolic_convert.py:722:17: error[unresolved-attribute] Module `torch` has no member `_assert_async` torch/_dynamo/symbolic_convert.py:921:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `InstructionTranslatorBase`, found `Unknown | InstructionTranslatorBase | None` @@ -924,25 +931,27 @@ torch/_dynamo/symbolic_convert.py:1004:9: error[unresolved-attribute] Unresolved torch/_dynamo/symbolic_convert.py:1292:17: error[missing-argument] No argument provided for required parameter `self` of function `is_non_empty_graph` torch/_dynamo/symbolic_convert.py:1602:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `InstructionTranslatorBase`, found `Unknown | InstructionTranslatorBase | None` torch/_dynamo/symbolic_convert.py:1654:42: error[unsupported-operator] Operator `in` is not supported for types `str` and `object`, in comparing `Literal["Data-dependent"]` with `object` -torch/_dynamo/symbolic_convert.py:1843:21: error[unresolved-attribute] Module `torch` has no member `package` +torch/_dynamo/symbolic_convert.py:1843:21: warning[possibly-missing-attribute] Submodule `package` may not be available as an attribute on module `torch` torch/_dynamo/symbolic_convert.py:1988:17: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `str | None` torch/_dynamo/symbolic_convert.py:2228:60: error[invalid-argument-type] Argument to function `get_dynamo_observed_exception` is incorrect: Expected `type[Exception]`, found `Unknown | type` torch/_dynamo/symbolic_convert.py:2469:17: warning[possibly-missing-attribute] Attribute `fn` may be missing on object of type `VariableTracker | Unknown` torch/_dynamo/symbolic_convert.py:2558:22: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `keys_as_python_constant` torch/_dynamo/symbolic_convert.py:2560:32: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `items` torch/_dynamo/symbolic_convert.py:2951:24: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `InstructionTranslatorBase`, found `Unknown | InstructionTranslatorBase | None` -torch/_dynamo/symbolic_convert.py:4176:26: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_dynamo/symbolic_convert.py:4176:26: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_dynamo/symbolic_convert.py:4196:49: error[invalid-argument-type] Argument to function `collapse_resume_frames` is incorrect: Expected `StackSummary`, found `StackSummary | None` -torch/_dynamo/symbolic_convert.py:4562:14: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/symbolic_convert.py:4564:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/symbolic_convert.py:4565:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/symbolic_convert.py:4566:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/symbolic_convert.py:5075:21: error[unresolved-attribute] Module `torch` has no member `package` -torch/_dynamo/tensor_version_op.py:53:15: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/_dynamo/tensor_version_op.py:70:5: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/_dynamo/symbolic_convert.py:4562:14: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/symbolic_convert.py:4564:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/symbolic_convert.py:4565:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/symbolic_convert.py:4566:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/symbolic_convert.py:5075:21: warning[possibly-missing-attribute] Submodule `package` may not be available as an attribute on module `torch` +torch/_dynamo/tensor_version_op.py:53:15: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/_dynamo/tensor_version_op.py:70:5: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/_dynamo/test_case.py:87:39: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_dynamo/test_case.py:101:47: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_dynamo/test_case.py:125:9: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `nested_graph_breaks` of type `Literal[False]` +torch/_dynamo/test_case.py:173:5: error[invalid-method-override] Invalid override of method `assertRaises`: Definition is incompatible with `TestCase.assertRaises` +torch/_dynamo/test_case.py:175:5: error[invalid-method-override] Invalid override of method `assertRaisesRegex`: Definition is incompatible with `TestCase.assertRaisesRegex` torch/_dynamo/testing.py:52:5: error[conflicting-declarations] Conflicting declared types for `np`: `ModuleType | None` and `` torch/_dynamo/testing.py:116:20: error[unresolved-attribute] Module `torch` has no member `zeros_like` torch/_dynamo/testing.py:383:14: error[unresolved-attribute] Module `torch` has no member `randn` @@ -960,15 +969,15 @@ torch/_dynamo/testing.py:558:16: error[unresolved-import] Cannot resolve importe torch/_dynamo/trace_rules.py:56:5: warning[possibly-missing-import] Member `NP_SUPPORTED_MODULES` of module `torch._dynamo.utils` may be missing torch/_dynamo/trace_rules.py:3011:27: warning[possibly-missing-attribute] Attribute `__wrapped__` may be missing on object of type `(Any & ~None) | str` torch/_dynamo/trace_rules.py:3616:20: error[invalid-argument-type] Argument to function `_as_posix_path` is incorrect: Expected `str`, found `str | None` -torch/_dynamo/trace_rules.py:4036:5: error[unresolved-attribute] Module `torch._dynamo` has no member `trace_rules` -torch/_dynamo/trace_rules.py:4037:5: error[unresolved-attribute] Module `torch._dynamo` has no member `trace_rules` -torch/_dynamo/trace_rules.py:4038:5: error[unresolved-attribute] Module `torch._dynamo` has no member `trace_rules` -torch/_dynamo/trace_rules.py:4039:5: error[unresolved-attribute] Module `torch._dynamo` has no member `trace_rules` -torch/_dynamo/trace_rules.py:4040:5: error[unresolved-attribute] Module `torch._dynamo` has no member `trace_rules` +torch/_dynamo/trace_rules.py:4036:5: warning[possibly-missing-attribute] Submodule `trace_rules` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/trace_rules.py:4037:5: warning[possibly-missing-attribute] Submodule `trace_rules` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/trace_rules.py:4038:5: warning[possibly-missing-attribute] Submodule `trace_rules` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/trace_rules.py:4039:5: warning[possibly-missing-attribute] Submodule `trace_rules` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/trace_rules.py:4040:5: warning[possibly-missing-attribute] Submodule `trace_rules` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/utils.py:74:5: error[unresolved-import] Module `torch._C` has no member `_len_torch_function_stack` torch/_dynamo/utils.py:75:5: error[unresolved-import] Module `torch._C` has no member `_pop_torch_function_stack` torch/_dynamo/utils.py:76:5: error[unresolved-import] Module `torch._C` has no member `_push_on_torch_function_stack` -torch/_dynamo/utils.py:740:23: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_dynamo/utils.py:740:23: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_dynamo/utils.py:857:5: error[unresolved-attribute] Module `torch` has no member `FloatTensor` torch/_dynamo/utils.py:857:25: error[unresolved-attribute] Module `torch` has no member `float32` torch/_dynamo/utils.py:857:40: error[unresolved-attribute] Module `torch` has no member `float` @@ -995,11 +1004,12 @@ torch/_dynamo/utils.py:865:25: error[unresolved-attribute] Module `torch` has no torch/_dynamo/utils.py:865:38: error[unresolved-attribute] Module `torch` has no member `short` torch/_dynamo/utils.py:866:5: error[unresolved-attribute] Module `torch` has no member `BoolTensor` torch/_dynamo/utils.py:866:24: error[unresolved-attribute] Module `torch` has no member `bool` +torch/_dynamo/utils.py:1038:68: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2 torch/_dynamo/utils.py:1665:18: error[unresolved-import] Cannot resolve imported module `torch._inductor.fb.remote_cache` -torch/_dynamo/utils.py:1680:22: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_dynamo/utils.py:1901:36: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_dynamo/utils.py:1944:36: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_dynamo/utils.py:2044:26: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_dynamo/utils.py:1680:22: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_dynamo/utils.py:1901:36: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_dynamo/utils.py:1944:36: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_dynamo/utils.py:2044:26: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_dynamo/utils.py:2161:41: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_dynamo/utils.py:2170:13: error[unresolved-attribute] Module `torch` has no member `clone` torch/_dynamo/utils.py:2185:24: error[unresolved-attribute] Module `torch` has no member `sparse_coo` @@ -1010,10 +1020,10 @@ torch/_dynamo/utils.py:2199:20: error[unresolved-attribute] Module `torch` has n torch/_dynamo/utils.py:2215:22: error[unresolved-attribute] Module `torch` has no member `empty_quantized` torch/_dynamo/utils.py:2217:22: error[unresolved-attribute] Module `torch` has no member `empty` torch/_dynamo/utils.py:2287:25: error[unresolved-attribute] Module `torch._C` has no member `_DisableFuncTorch` -torch/_dynamo/utils.py:2288:29: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_dynamo/utils.py:2288:29: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_dynamo/utils.py:2290:21: error[unresolved-attribute] Module `torch` has no member `clone` torch/_dynamo/utils.py:2293:30: error[unresolved-attribute] Module `torch` has no member `clone` -torch/_dynamo/utils.py:2297:14: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_dynamo/utils.py:2297:14: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_dynamo/utils.py:2394:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[str, ...]`, found `object` torch/_dynamo/utils.py:2413:21: error[unresolved-attribute] Module `torch` has no member `clone` torch/_dynamo/utils.py:2415:30: error[unresolved-attribute] Module `torch` has no member `clone` @@ -1026,7 +1036,7 @@ torch/_dynamo/utils.py:2483:5: error[unresolved-attribute] Module `torch` has no torch/_dynamo/utils.py:2484:5: error[unresolved-attribute] Module `torch` has no member `iinfo` torch/_dynamo/utils.py:2490:12: error[unresolved-import] Cannot resolve imported module `triton` torch/_dynamo/utils.py:2510:13: error[unresolved-attribute] Module `torch` has no member `Size` -torch/_dynamo/utils.py:2532:21: error[unresolved-attribute] Module `torch.nested._internal` has no member `nested_int` +torch/_dynamo/utils.py:2532:21: warning[possibly-missing-attribute] Submodule `nested_int` may not be available as an attribute on module `torch.nested._internal` torch/_dynamo/utils.py:2742:50: error[invalid-argument-type] Argument to function `keys` is incorrect: Argument type `dict[Any, Any]` does not satisfy upper bound `OrderedDict[_KT@OrderedDict, _VT@OrderedDict]` of type variable `Self` torch/_dynamo/utils.py:2981:12: error[unresolved-attribute] Module `torch` has no member `sqrt` torch/_dynamo/utils.py:2981:23: error[unresolved-attribute] Module `torch` has no member `mean` @@ -1050,7 +1060,7 @@ torch/_dynamo/utils.py:3251:13: error[unresolved-attribute] Module `torch` has n torch/_dynamo/utils.py:3252:13: error[unresolved-attribute] Module `torch` has no member `as_tensor` torch/_dynamo/utils.py:3306:5: error[invalid-assignment] Object of type `int` is not assignable to attribute `recompile_limit` of type `Literal[8]` torch/_dynamo/utils.py:3309:5: error[invalid-assignment] Object of type `int` is not assignable to attribute `accumulated_recompile_limit` of type `Literal[256]` -torch/_dynamo/utils.py:3325:27: error[unresolved-attribute] Module `torch._dynamo` has no member `output_graph` +torch/_dynamo/utils.py:3325:27: warning[possibly-missing-attribute] Submodule `output_graph` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/utils.py:3542:32: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_pystub` torch/_dynamo/utils.py:3880:44: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__code__` torch/_dynamo/utils.py:3980:16: error[unresolved-attribute] Module `torch` has no member `as_tensor` @@ -1058,8 +1068,8 @@ torch/_dynamo/utils.py:3992:38: error[unresolved-attribute] Object of type `(... torch/_dynamo/utils.py:3995:47: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | ((...) -> R@numpy_to_tensor_wrapper)` torch/_dynamo/utils.py:4035:36: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__name__` torch/_dynamo/utils.py:4044:16: error[invalid-assignment] Object of type `GeneratorType[ndarray | (@Todo & ~Tensor), None, None]` is not assignable to `tuple[@Todo, ...]` -torch/_dynamo/utils.py:4054:11: error[unresolved-attribute] Module `torch` has no member `_prims_common` -torch/_dynamo/utils.py:4055:13: error[unresolved-attribute] Module `torch` has no member `_prims_common` +torch/_dynamo/utils.py:4054:11: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` +torch/_dynamo/utils.py:4055:13: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` torch/_dynamo/utils.py:4072:9: error[unresolved-attribute] Module `torch` has no member `empty_strided` torch/_dynamo/utils.py:4133:12: error[unresolved-attribute] Module `torch` has no member `device` torch/_dynamo/utils.py:4438:9: error[unresolved-attribute] Module `torch._C` has no member `Generator` @@ -1068,12 +1078,12 @@ torch/_dynamo/utils.py:4444:9: error[unresolved-attribute] Module `torch._C` has torch/_dynamo/utils.py:4445:9: error[unresolved-attribute] Module `torch` has no member `default_generator` torch/_dynamo/utils.py:4487:47: error[call-non-callable] Object of type `object` is not callable torch/_dynamo/utils.py:4496:35: error[unresolved-attribute] Module `torch._C` has no member `_disabled_torch_function_impl` -torch/_dynamo/utils.py:4507:27: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_dynamo/utils.py:4557:14: error[unresolved-attribute] Module `torch._dynamo` has no member `compiled_autograd` +torch/_dynamo/utils.py:4507:27: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_dynamo/utils.py:4557:14: warning[possibly-missing-attribute] Submodule `compiled_autograd` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/utils.py:4590:9: error[unresolved-attribute] Cannot assign object of type `(list[Any], /) -> Any` to attribute `unflatten_fn` on type `Self@__init__` with custom `__setattr__` method. -torch/_dynamo/utils.py:4612:8: error[unresolved-attribute] Module `torch._dynamo` has no member `compiled_autograd` -torch/_dynamo/utils.py:4690:17: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/_dynamo/utils.py:4693:9: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/_dynamo/utils.py:4612:8: warning[possibly-missing-attribute] Submodule `compiled_autograd` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/utils.py:4690:17: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/_dynamo/utils.py:4693:9: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/_dynamo/utils.py:4697:52: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_dynamo/utils.py:4708:12: error[unresolved-attribute] Module `torch._C` has no member `_get_function_stack_at` torch/_dynamo/utils.py:4724:32: error[unresolved-attribute] Module `torch` has no member `device` @@ -1083,48 +1093,51 @@ torch/_dynamo/utils.py:4793:12: error[unresolved-attribute] Module `torch._C` ha torch/_dynamo/utils.py:4796:62: error[unresolved-attribute] Module `torch` has no member `Event` torch/_dynamo/utils.py:4797:12: error[unresolved-attribute] Module `torch._C` has no member `Event` torch/_dynamo/utils.py:4890:55: error[unresolved-attribute] Module `torch` has no member `is_inference_mode_enabled` -torch/_dynamo/utils.py:4910:14: error[unresolved-attribute] Module `torch._subclasses` has no member `meta_utils` -torch/_dynamo/utils.py:4936:9: error[unresolved-attribute] Module `torch._C` has no member `_profiler` +torch/_dynamo/utils.py:4910:14: warning[possibly-missing-attribute] Submodule `meta_utils` may not be available as an attribute on module `torch._subclasses` +torch/_dynamo/utils.py:4936:9: warning[possibly-missing-attribute] Submodule `_profiler` may not be available as an attribute on module `torch._C` torch/_dynamo/variables/builder.py:301:10: error[invalid-assignment] Object of type `None` is not assignable to `` torch/_dynamo/variables/builder.py:398:13: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `None` torch/_dynamo/variables/builder.py:399:13: error[invalid-argument-type] Argument is incorrect: Expected `TensorWeakRef | SymInt`, found `BackwardState` -torch/_dynamo/variables/builder.py:534:21: error[unresolved-attribute] Module `torch._subclasses` has no member `functional_tensor` +torch/_dynamo/variables/builder.py:534:21: warning[possibly-missing-attribute] Submodule `functional_tensor` may not be available as an attribute on module `torch._subclasses` torch/_dynamo/variables/builder.py:539:64: error[unresolved-attribute] Module `torch` has no member `Size` torch/_dynamo/variables/builder.py:667:18: error[unresolved-import] Cannot resolve imported module `triton.runtime.autotuner` torch/_dynamo/variables/builder.py:668:18: error[unresolved-import] Cannot resolve imported module `triton.runtime.jit` torch/_dynamo/variables/builder.py:690:18: error[unresolved-import] Cannot resolve imported module `triton.tools.experimental_descriptor` torch/_dynamo/variables/builder.py:695:18: error[unresolved-import] Cannot resolve imported module `triton.tools.tensor_descriptor` -torch/_dynamo/variables/builder.py:854:22: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` +torch/_dynamo/variables/builder.py:854:22: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` torch/_dynamo/variables/builder.py:866:32: error[unresolved-attribute] Module `torch` has no member `DispatchKey` -torch/_dynamo/variables/builder.py:866:51: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_dynamo/variables/builder.py:866:51: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_dynamo/variables/builder.py:1019:32: error[unresolved-attribute] Module `torch._C` has no member `_ImperativeEngine` torch/_dynamo/variables/builder.py:1043:20: error[unresolved-attribute] Object of type `type[VariableTracker] | None` has no attribute `create_with_source` torch/_dynamo/variables/builder.py:1063:32: error[unresolved-attribute] Module `torch` has no member `Stream` torch/_dynamo/variables/builder.py:1075:33: error[unresolved-attribute] Module `torch._C` has no member `_SDPAParams` -torch/_dynamo/variables/builder.py:1078:32: error[unresolved-attribute] Module `torch._functorch` has no member `pyfunctorch` +torch/_dynamo/variables/builder.py:1078:32: warning[possibly-missing-attribute] Submodule `pyfunctorch` may not be available as an attribute on module `torch._functorch` torch/_dynamo/variables/builder.py:1081:32: error[unresolved-attribute] Module `torch` has no member `Event` torch/_dynamo/variables/builder.py:1112:32: error[unresolved-attribute] Module `torch` has no member `DispatchKeySet` torch/_dynamo/variables/builder.py:1322:20: error[unresolved-attribute] Object of type `type[VariableTracker] | None` has no attribute `create_with_source` -torch/_dynamo/variables/builder.py:1347:47: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` +torch/_dynamo/variables/builder.py:1347:47: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` torch/_dynamo/variables/builder.py:1396:24: error[unresolved-attribute] Object of type `type[VariableTracker] | None` has no attribute `create_with_source` torch/_dynamo/variables/builder.py:1498:57: error[invalid-argument-type] Argument is incorrect: Expected `Tensor | None`, found `FakeScriptObject | Unknown` -torch/_dynamo/variables/builder.py:1765:17: error[invalid-argument-type] Argument is incorrect: Expected `TensorWeakRef | SymInt`, found `list[Unknown] | (@Todo & Top[list[Unknown]])` -torch/_dynamo/variables/builder.py:1924:34: error[unresolved-attribute] Module `torch.fx.experimental` has no member `proxy_tensor` -torch/_dynamo/variables/builder.py:2159:39: error[unresolved-attribute] Module `torch.nested._internal` has no member `nested_tensor` +torch/_dynamo/variables/builder.py:1678:55: error[invalid-type-form] Variable of type `type[ValuesView[Any]]` is not allowed in a type expression +torch/_dynamo/variables/builder.py:1765:17: error[invalid-argument-type] Argument is incorrect: Expected `TensorWeakRef | SymInt`, found `list[Unknown] | (Unknown & Top[list[Unknown]])` +torch/_dynamo/variables/builder.py:1798:42: error[invalid-type-form] Variable of type `type[@Todo]` is not allowed in a type expression +torch/_dynamo/variables/builder.py:1809:42: error[invalid-type-form] Variable of type `type[@Todo]` is not allowed in a type expression +torch/_dynamo/variables/builder.py:1924:34: warning[possibly-missing-attribute] Submodule `proxy_tensor` may not be available as an attribute on module `torch.fx.experimental` +torch/_dynamo/variables/builder.py:2159:39: warning[possibly-missing-attribute] Submodule `nested_tensor` may not be available as an attribute on module `torch.nested._internal` torch/_dynamo/variables/builder.py:2187:32: warning[possibly-missing-attribute] Attribute `dtype` may be missing on object of type `Tensor | None` torch/_dynamo/variables/builder.py:2191:69: warning[possibly-missing-attribute] Attribute `dtype` may be missing on object of type `Tensor | None` -torch/_dynamo/variables/builder.py:2244:20: error[unresolved-attribute] Module `torch.distributed` has no member `tensor` +torch/_dynamo/variables/builder.py:2244:20: warning[possibly-missing-attribute] Submodule `tensor` may not be available as an attribute on module `torch.distributed` torch/_dynamo/variables/builder.py:2321:29: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `proxy` torch/_dynamo/variables/builder.py:2472:21: error[no-matching-overload] No overload of bound method `__init__` matches arguments torch/_dynamo/variables/builder.py:2575:25: error[unresolved-attribute] Module `torch` has no member `tensor` torch/_dynamo/variables/builder.py:2575:51: error[unresolved-attribute] Module `torch` has no member `float64` -torch/_dynamo/variables/builder.py:2580:12: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_dynamo/variables/builder.py:2580:12: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_dynamo/variables/builder.py:2664:57: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `sym_num` torch/_dynamo/variables/builder.py:2674:25: error[unresolved-attribute] Module `torch` has no member `tensor` torch/_dynamo/variables/builder.py:2757:17: error[unresolved-attribute] Module `torch` has no member `_is_functional_tensor` torch/_dynamo/variables/builder.py:2791:14: error[unresolved-attribute] Module `torch._C` has no member `DisableTorchFunctionSubclass` -torch/_dynamo/variables/builder.py:2864:17: error[unresolved-attribute] Module `torch._dynamo` has no member `variables` -torch/_dynamo/variables/builder.py:2865:17: error[unresolved-attribute] Module `torch._dynamo` has no member `variables` +torch/_dynamo/variables/builder.py:2864:17: warning[possibly-missing-attribute] Submodule `variables` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/builder.py:2865:17: warning[possibly-missing-attribute] Submodule `variables` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/variables/builder.py:2910:22: error[unresolved-attribute] Module `torch._C` has no member `DisableTorchFunctionSubclass` torch/_dynamo/variables/builder.py:2924:68: error[invalid-argument-type] Argument to function `wrap_to_fake_tensor_and_record` is incorrect: Expected `Source | None`, found `Unknown | bool` torch/_dynamo/variables/builder.py:3001:52: error[unresolved-attribute] Module `torch._C` has no member `Generator` @@ -1135,17 +1148,17 @@ torch/_dynamo/variables/builder.py:3078:35: error[unresolved-attribute] Module ` torch/_dynamo/variables/builder.py:3090:35: error[unresolved-attribute] Module `torch` has no member `Event` torch/_dynamo/variables/builder.py:3103:43: error[unresolved-attribute] Module `torch` has no member `Event` torch/_dynamo/variables/builder.py:3115:39: error[unresolved-attribute] Module `torch` has no member `Event` -torch/_dynamo/variables/builder.py:3131:13: error[unresolved-attribute] Module `torch._functorch` has no member `predispatch` -torch/_dynamo/variables/builder.py:3132:13: error[unresolved-attribute] Module `torch._functorch` has no member `predispatch` +torch/_dynamo/variables/builder.py:3131:13: warning[possibly-missing-attribute] Submodule `predispatch` may not be available as an attribute on module `torch._functorch` +torch/_dynamo/variables/builder.py:3132:13: warning[possibly-missing-attribute] Submodule `predispatch` may not be available as an attribute on module `torch._functorch` torch/_dynamo/variables/builder.py:3155:13: error[unresolved-attribute] Module `torch._C` has no member `_are_functorch_transforms_active` -torch/_dynamo/variables/builder.py:3156:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_dynamo/variables/builder.py:3156:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_dynamo/variables/builder.py:3160:13: error[unresolved-attribute] Module `torch._C` has no member `_get_cudnn_sdp_enabled` torch/_dynamo/variables/builder.py:3161:13: error[unresolved-attribute] Module `torch._C` has no member `_get_flash_sdp_enabled` torch/_dynamo/variables/builder.py:3162:13: error[unresolved-attribute] Module `torch._C` has no member `_get_mem_efficient_sdp_enabled` torch/_dynamo/variables/builder.py:3163:13: error[unresolved-attribute] Module `torch._C` has no member `_get_math_sdp_enabled` torch/_dynamo/variables/builder.py:3164:13: error[unresolved-attribute] Module `torch._C` has no member `_get_overrideable_sdp_enabled` -torch/_dynamo/variables/builder.py:3195:9: error[unresolved-attribute] Module `torch._subclasses` has no member `functional_tensor` -torch/_dynamo/variables/builder.py:3380:12: error[unresolved-attribute] Module `torch.nested._internal` has no member `nested_tensor` +torch/_dynamo/variables/builder.py:3195:9: warning[possibly-missing-attribute] Submodule `functional_tensor` may not be available as an attribute on module `torch._subclasses` +torch/_dynamo/variables/builder.py:3380:12: warning[possibly-missing-attribute] Submodule `nested_tensor` may not be available as an attribute on module `torch.nested._internal` torch/_dynamo/variables/builder.py:3418:27: error[unresolved-attribute] Object of type `SymbolicContext` has no attribute `dynamic_sizes` torch/_dynamo/variables/builder.py:3419:29: error[unresolved-attribute] Object of type `SymbolicContext` has no attribute `dynamic_strides` torch/_dynamo/variables/builder.py:3420:30: error[unresolved-attribute] Object of type `SymbolicContext` has no attribute `constraint_sizes` @@ -1161,16 +1174,16 @@ torch/_dynamo/variables/builder.py:3782:20: error[call-non-callable] Object of t torch/_dynamo/variables/builder.py:3787:19: error[call-non-callable] Object of type `None` is not callable torch/_dynamo/variables/builder.py:3790:20: error[call-non-callable] Object of type `None` is not callable torch/_dynamo/variables/builder.py:3792:32: error[unresolved-attribute] Module `torch` has no member `DispatchKey` -torch/_dynamo/variables/builder.py:3792:51: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/builder.py:3814:32: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` -torch/_dynamo/variables/builder.py:3824:32: error[unresolved-attribute] Module `torch._dynamo` has no member `variables` -torch/_dynamo/variables/builder.py:3827:20: error[unresolved-attribute] Module `torch._dynamo` has no member `variables` +torch/_dynamo/variables/builder.py:3792:51: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/builder.py:3814:32: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` +torch/_dynamo/variables/builder.py:3824:32: warning[possibly-missing-attribute] Submodule `variables` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/builder.py:3827:20: warning[possibly-missing-attribute] Submodule `variables` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/variables/builder.py:3876:18: error[unresolved-attribute] Module `torch` has no member `Size` torch/_dynamo/variables/builder.py:3885:18: error[unresolved-attribute] Module `torch` has no member `DispatchKeySet` -torch/_dynamo/variables/builder.py:3888:18: error[unresolved-attribute] Module `torch._functorch` has no member `pyfunctorch` -torch/_dynamo/variables/builder.py:3894:18: error[unresolved-attribute] Module `torch.distributions` has no member `constraints` -torch/_dynamo/variables/builder.py:3899:18: error[unresolved-attribute] Module `torch.distributions` has no member `constraints` -torch/_dynamo/variables/builder.py:3904:18: error[unresolved-attribute] Module `torch.distributions` has no member `constraints` +torch/_dynamo/variables/builder.py:3888:18: warning[possibly-missing-attribute] Submodule `pyfunctorch` may not be available as an attribute on module `torch._functorch` +torch/_dynamo/variables/builder.py:3894:18: warning[possibly-missing-attribute] Submodule `constraints` may not be available as an attribute on module `torch.distributions` +torch/_dynamo/variables/builder.py:3899:18: warning[possibly-missing-attribute] Submodule `constraints` may not be available as an attribute on module `torch.distributions` +torch/_dynamo/variables/builder.py:3904:18: warning[possibly-missing-attribute] Submodule `constraints` may not be available as an attribute on module `torch.distributions` torch/_dynamo/variables/builder.py:3918:1: error[unresolved-attribute] Unresolved attribute `_type_handlers` on type ``. torch/_dynamo/variables/builtin.py:245:12: error[unresolved-attribute] Module `torch` has no member `ones` torch/_dynamo/variables/builtin.py:246:12: error[unresolved-attribute] Module `torch` has no member `ones` @@ -1197,24 +1210,24 @@ torch/_dynamo/variables/builtin.py:1724:60: error[unresolved-attribute] Module ` torch/_dynamo/variables/builtin.py:1750:65: error[unresolved-attribute] Module `torch` has no member `clamp` torch/_dynamo/variables/builtin.py:1760:38: error[unresolved-attribute] Module `torch` has no member `maximum` torch/_dynamo/variables/builtin.py:1760:58: error[unresolved-attribute] Module `torch` has no member `minimum` -torch/_dynamo/variables/builtin.py:2652:19: error[unresolved-attribute] Module `torch._dynamo` has no member `trace_rules` -torch/_dynamo/variables/builtin.py:2774:25: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/_dynamo/variables/builtin.py:2652:19: warning[possibly-missing-attribute] Submodule `trace_rules` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/builtin.py:2774:25: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/_dynamo/variables/constant.py:127:55: error[unresolved-attribute] Module `torch` has no member `Size` torch/_dynamo/variables/ctx_manager.py:78:13: error[call-non-callable] Object of type `object` is not callable torch/_dynamo/variables/ctx_manager.py:89:21: error[call-non-callable] Object of type `object` is not callable -torch/_dynamo/variables/ctx_manager.py:253:27: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:254:9: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:257:21: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:263:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:275:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:296:22: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:299:21: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:303:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:315:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:345:21: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:347:25: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:351:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:362:30: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_dynamo/variables/ctx_manager.py:253:27: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:254:9: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:257:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:263:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:275:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:296:22: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:299:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:303:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:315:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:345:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/variables/ctx_manager.py:347:25: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/variables/ctx_manager.py:351:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:362:30: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_dynamo/variables/ctx_manager.py:382:27: error[unresolved-attribute] Module `torch._C` has no member `_is_fwd_grad_enabled` torch/_dynamo/variables/ctx_manager.py:383:9: error[unresolved-attribute] Module `torch._C` has no member `_set_fwd_grad_enabled` torch/_dynamo/variables/ctx_manager.py:386:21: error[unresolved-attribute] Module `torch._C` has no member `_set_fwd_grad_enabled` @@ -1222,14 +1235,15 @@ torch/_dynamo/variables/ctx_manager.py:390:13: error[unresolved-attribute] Modul torch/_dynamo/variables/ctx_manager.py:402:13: error[unresolved-attribute] Module `torch._C` has no member `_set_fwd_grad_enabled` torch/_dynamo/variables/ctx_manager.py:430:13: error[unresolved-attribute] Module `torch._C` has no member `_enter_dual_level` torch/_dynamo/variables/ctx_manager.py:442:13: error[unresolved-attribute] Module `torch._C` has no member `_exit_dual_level` -torch/_dynamo/variables/ctx_manager.py:472:22: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:473:43: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:476:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:487:30: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:564:22: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:567:43: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:570:13: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/variables/ctx_manager.py:582:13: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_dynamo/variables/ctx_manager.py:472:22: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:473:43: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:476:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:487:30: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:526:9: error[invalid-method-override] Invalid override of method `reconstruct`: Definition is incompatible with `ContextWrappingVariable.reconstruct` +torch/_dynamo/variables/ctx_manager.py:564:22: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:567:43: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:570:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/variables/ctx_manager.py:582:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_dynamo/variables/ctx_manager.py:603:29: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_dynamo/variables/ctx_manager.py:645:12: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_dynamo/variables/ctx_manager.py:647:34: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` @@ -1239,28 +1253,30 @@ torch/_dynamo/variables/ctx_manager.py:676:30: error[unresolved-attribute] Modul torch/_dynamo/variables/ctx_manager.py:703:21: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_dynamo/variables/ctx_manager.py:704:13: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` torch/_dynamo/variables/ctx_manager.py:710:17: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` +torch/_dynamo/variables/ctx_manager.py:825:9: error[invalid-method-override] Invalid override of method `set_cleanup_hook`: Definition is incompatible with `ContextWrappingVariable.set_cleanup_hook` torch/_dynamo/variables/ctx_manager.py:898:30: error[unresolved-attribute] Module `torch._C` has no member `_set_deterministic_algorithms` torch/_dynamo/variables/ctx_manager.py:900:9: error[unresolved-attribute] Module `torch._C` has no member `_set_deterministic_algorithms` -torch/_dynamo/variables/ctx_manager.py:919:17: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/_dynamo/variables/ctx_manager.py:951:17: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/_dynamo/variables/ctx_manager.py:955:13: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/_dynamo/variables/ctx_manager.py:959:34: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/_dynamo/variables/ctx_manager.py:961:13: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/_dynamo/variables/ctx_manager.py:919:17: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:951:17: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:955:13: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:959:34: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/ctx_manager.py:961:13: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/_dynamo/variables/ctx_manager.py:979:28: warning[deprecated] The class `autocast` is deprecated: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead. torch/_dynamo/variables/ctx_manager.py:980:27: warning[deprecated] The class `autocast` is deprecated: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead. torch/_dynamo/variables/ctx_manager.py:993:32: warning[deprecated] The class `autocast` is deprecated: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead. torch/_dynamo/variables/ctx_manager.py:994:31: warning[deprecated] The class `autocast` is deprecated: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead. torch/_dynamo/variables/ctx_manager.py:996:56: warning[deprecated] The class `autocast` is deprecated: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead. -torch/_dynamo/variables/ctx_manager.py:1367:29: error[unresolved-attribute] Module `torch.fx` has no member `traceback` -torch/_dynamo/variables/ctx_manager.py:1368:29: error[unresolved-attribute] Module `torch.fx` has no member `traceback` +torch/_dynamo/variables/ctx_manager.py:1091:9: error[invalid-method-override] Invalid override of method `reconstruct`: Definition is incompatible with `ContextWrappingVariable.reconstruct` +torch/_dynamo/variables/ctx_manager.py:1367:29: warning[possibly-missing-attribute] Submodule `traceback` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/ctx_manager.py:1368:29: warning[possibly-missing-attribute] Submodule `traceback` may not be available as an attribute on module `torch.fx` torch/_dynamo/variables/dicts.py:1022:17: error[invalid-assignment] Object of type `dict[VariableTracker, VariableTracker]` is not assignable to `list[VariableTracker]` torch/_dynamo/variables/dicts.py:1024:26: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[VariableTracker, VariableTracker]`, found `list[VariableTracker]` torch/_dynamo/variables/distributed.py:273:51: warning[possibly-missing-import] Member `DeviceMesh` of module `torch.distributed.device_mesh` may be missing torch/_dynamo/variables/distributed.py:367:68: error[invalid-argument-type] Argument to bound method `call_method` is incorrect: Expected `list[VariableTracker]`, found `tuple[Unknown, ...]` -torch/_dynamo/variables/functions.py:628:18: error[unresolved-attribute] Module `torch._dynamo` has no member `side_effects` -torch/_dynamo/variables/functions.py:645:22: error[unresolved-attribute] Module `torch._dynamo` has no member `side_effects` +torch/_dynamo/variables/functions.py:628:18: warning[possibly-missing-attribute] Submodule `side_effects` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/functions.py:645:22: warning[possibly-missing-attribute] Submodule `side_effects` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/variables/functions.py:1011:50: error[invalid-argument-type] Argument to function `get_dynamo_observed_exception` is incorrect: Expected `type[Exception]`, found `type` -torch/_dynamo/variables/functions.py:1839:34: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_dynamo/variables/functions.py:1839:34: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_dynamo/variables/functions.py:1895:18: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__name__` torch/_dynamo/variables/functions.py:1979:13: warning[possibly-missing-attribute] Member `all_reduce` may be missing on module `torch.distributed` torch/_dynamo/variables/functions.py:1980:13: warning[possibly-missing-attribute] Member `reduce_scatter_tensor` may be missing on module `torch.distributed` @@ -1270,6 +1286,7 @@ torch/_dynamo/variables/functions.py:2108:44: error[invalid-argument-type] Argum torch/_dynamo/variables/functions.py:2124:43: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `list[VariableTracker]`, found `Unknown | (Sequence[VariableTracker] & Top[list[Unknown]])` torch/_dynamo/variables/functions.py:2276:65: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `Any | None` does not satisfy upper bound `(...) -> Any` of type variable `_F` torch/_dynamo/variables/functions.py:2290:10: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `VariableTracker` +torch/_dynamo/variables/functions.py:2446:9: error[invalid-method-override] Invalid override of method `call_HOP`: Definition is incompatible with `TritonHOPifier.call_HOP` torch/_dynamo/variables/higher_order_ops.py:98:24: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `list[bool] | None` torch/_dynamo/variables/higher_order_ops.py:98:66: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `list[Any] | None` torch/_dynamo/variables/higher_order_ops.py:189:17: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` @@ -1286,41 +1303,65 @@ torch/_dynamo/variables/higher_order_ops.py:605:23: error[unresolved-attribute] torch/_dynamo/variables/higher_order_ops.py:669:9: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `value` torch/_dynamo/variables/higher_order_ops.py:1029:50: error[unresolved-attribute] Object of type `tuple[Node]` has no attribute `values` torch/_dynamo/variables/higher_order_ops.py:1065:32: error[unresolved-attribute] Object of type `tuple[Node]` has no attribute `values` -torch/_dynamo/variables/higher_order_ops.py:1210:23: error[unresolved-attribute] Module `torch._dynamo` has no member `output_graph` +torch/_dynamo/variables/higher_order_ops.py:1210:23: warning[possibly-missing-attribute] Submodule `output_graph` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/variables/higher_order_ops.py:1361:21: warning[possibly-missing-attribute] Attribute `append` may be missing on object of type `list[Unknown] | tuple[Unknown, ...]` torch/_dynamo/variables/higher_order_ops.py:1410:44: error[invalid-argument-type] Argument to function `validate_subgraph_output_types` is incorrect: Expected `VariableTracker`, found `tuple[Unknown, ...]` torch/_dynamo/variables/higher_order_ops.py:1603:29: error[invalid-argument-type] Argument is incorrect: Expected `TreeSpec`, found `None | Unknown` torch/_dynamo/variables/higher_order_ops.py:1648:29: error[invalid-argument-type] Argument is incorrect: Expected `TreeSpec`, found `None | Unknown` -torch/_dynamo/variables/higher_order_ops.py:1753:16: error[unresolved-attribute] Module `torch._dynamo` has no member `variables` -torch/_dynamo/variables/higher_order_ops.py:1755:13: error[unresolved-attribute] Module `torch._dynamo` has no member `variables` +torch/_dynamo/variables/higher_order_ops.py:1747:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` +torch/_dynamo/variables/higher_order_ops.py:1753:16: warning[possibly-missing-attribute] Submodule `variables` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/higher_order_ops.py:1755:13: warning[possibly-missing-attribute] Submodule `variables` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/variables/higher_order_ops.py:1758:31: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | Source | None` torch/_dynamo/variables/higher_order_ops.py:1892:13: warning[possibly-missing-attribute] Attribute `epoch` may be missing on object of type `FakeTensorMode | None` +torch/_dynamo/variables/higher_order_ops.py:1993:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` torch/_dynamo/variables/higher_order_ops.py:2261:14: error[invalid-context-manager] Object of type `FakeTensorMode | None` cannot be used with `with` because the methods `__enter__` and `__exit__` are possibly missing +torch/_dynamo/variables/higher_order_ops.py:2677:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` +torch/_dynamo/variables/higher_order_ops.py:2701:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` torch/_dynamo/variables/higher_order_ops.py:2738:14: error[invalid-context-manager] Object of type `FakeTensorMode | None` cannot be used with `with` because the methods `__enter__` and `__exit__` are possibly missing torch/_dynamo/variables/higher_order_ops.py:2739:29: error[unresolved-attribute] Object of type `object` has no attribute `original_module` +torch/_dynamo/variables/higher_order_ops.py:2762:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `UserFunctionVariable.call_function` +torch/_dynamo/variables/higher_order_ops.py:2775:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `UserFunctionVariable.call_function` +torch/_dynamo/variables/higher_order_ops.py:2794:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `UserFunctionVariable.call_function` torch/_dynamo/variables/higher_order_ops.py:2798:53: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ContextWrappingVariable`, found `VariableTracker` +torch/_dynamo/variables/higher_order_ops.py:2880:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` torch/_dynamo/variables/higher_order_ops.py:2907:16: error[invalid-return-type] Return type does not match returned value: expected `VariableTracker`, found `VariableTracker | None` +torch/_dynamo/variables/higher_order_ops.py:2924:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable.call_function` +torch/_dynamo/variables/higher_order_ops.py:3011:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable.call_function` torch/_dynamo/variables/higher_order_ops.py:3168:16: error[invalid-return-type] Return type does not match returned value: expected `VariableTracker`, found `VariableTracker | None` -torch/_dynamo/variables/higher_order_ops.py:3319:32: error[unresolved-attribute] Module `torch._dynamo` has no member `variables` -torch/_dynamo/variables/higher_order_ops.py:3322:22: error[unresolved-attribute] Module `torch._dynamo` has no member `variables` +torch/_dynamo/variables/higher_order_ops.py:3180:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` +torch/_dynamo/variables/higher_order_ops.py:3307:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` +torch/_dynamo/variables/higher_order_ops.py:3319:32: warning[possibly-missing-attribute] Submodule `variables` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/higher_order_ops.py:3322:22: warning[possibly-missing-attribute] Submodule `variables` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/variables/higher_order_ops.py:3355:16: error[invalid-return-type] Return type does not match returned value: expected `VariableTracker`, found `VariableTracker | None` -torch/_dynamo/variables/higher_order_ops.py:3378:33: error[unresolved-attribute] Module `torch._dynamo` has no member `variables` -torch/_dynamo/variables/higher_order_ops.py:3381:23: error[unresolved-attribute] Module `torch._dynamo` has no member `variables` +torch/_dynamo/variables/higher_order_ops.py:3370:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` +torch/_dynamo/variables/higher_order_ops.py:3378:33: warning[possibly-missing-attribute] Submodule `variables` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/higher_order_ops.py:3381:23: warning[possibly-missing-attribute] Submodule `variables` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/variables/higher_order_ops.py:3409:16: error[invalid-return-type] Return type does not match returned value: expected `VariableTracker`, found `VariableTracker | None` +torch/_dynamo/variables/higher_order_ops.py:3421:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable.call_function` +torch/_dynamo/variables/higher_order_ops.py:3444:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` +torch/_dynamo/variables/higher_order_ops.py:3467:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` +torch/_dynamo/variables/higher_order_ops.py:3504:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` +torch/_dynamo/variables/higher_order_ops.py:3542:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` torch/_dynamo/variables/higher_order_ops.py:3578:17: error[invalid-argument-type] Argument to bound method `call_method` is incorrect: Expected `list[VariableTracker]`, found `tuple[Any]` torch/_dynamo/variables/higher_order_ops.py:3580:56: error[unresolved-attribute] Module `torch` has no member `int32` torch/_dynamo/variables/higher_order_ops.py:3587:45: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `requires_grad` torch/_dynamo/variables/higher_order_ops.py:3591:21: error[invalid-argument-type] Argument to bound method `call_method` is incorrect: Expected `list[VariableTracker]`, found `tuple[Any]` +torch/_dynamo/variables/higher_order_ops.py:3631:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` torch/_dynamo/variables/higher_order_ops.py:3654:44: error[unresolved-attribute] Module `torch.nn.attention` has no member `_flex_attention` -torch/_dynamo/variables/higher_order_ops.py:3679:14: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/higher_order_ops.py:3754:22: error[unresolved-attribute] Module `torch._dynamo` has no member `output_graph` -torch/_dynamo/variables/higher_order_ops.py:3814:22: error[unresolved-attribute] Module `torch._dynamo` has no member `output_graph` -torch/_dynamo/variables/higher_order_ops.py:3869:20: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` -torch/_dynamo/variables/higher_order_ops.py:3871:24: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` -torch/_dynamo/variables/higher_order_ops.py:3875:34: error[unresolved-attribute] Module `torch._dynamo` has no member `output_graph` -torch/_dynamo/variables/higher_order_ops.py:4056:18: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | list[Unknown | bool] | list[Unknown]]` is not assignable to `dict[str, VariableTracker]` +torch/_dynamo/variables/higher_order_ops.py:3679:14: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/higher_order_ops.py:3708:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` +torch/_dynamo/variables/higher_order_ops.py:3754:22: warning[possibly-missing-attribute] Submodule `output_graph` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/higher_order_ops.py:3814:22: warning[possibly-missing-attribute] Submodule `output_graph` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/higher_order_ops.py:3869:20: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/higher_order_ops.py:3871:24: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/higher_order_ops.py:3875:34: warning[possibly-missing-attribute] Submodule `output_graph` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/higher_order_ops.py:4056:18: error[invalid-assignment] Object of type `dict[str, VariableTracker | list[Unknown | bool] | list[Unknown]]` is not assignable to `dict[str, VariableTracker]` +torch/_dynamo/variables/higher_order_ops.py:4136:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` torch/_dynamo/variables/higher_order_ops.py:4156:16: error[invalid-return-type] Return type does not match returned value: expected `VariableTracker`, found `VariableTracker | None` +torch/_dynamo/variables/higher_order_ops.py:4172:9: error[invalid-method-override] Invalid override of method `install_subgraph_in_output_graph`: Definition is incompatible with `WrapHigherOrderVariable.install_subgraph_in_output_graph` torch/_dynamo/variables/higher_order_ops.py:4267:16: error[invalid-return-type] Return type does not match returned value: expected `VariableTracker`, found `VariableTracker | None` +torch/_dynamo/variables/higher_order_ops.py:4319:9: error[invalid-method-override] Invalid override of method `build`: Definition is incompatible with `VariableTracker.build` +torch/_dynamo/variables/higher_order_ops.py:4328:9: error[invalid-method-override] Invalid override of method `_call_function`: Definition is incompatible with `TorchHigherOrderOperatorVariable._call_function` torch/_dynamo/variables/higher_order_ops.py:4364:50: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `value` torch/_dynamo/variables/higher_order_ops.py:4365:50: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `value` torch/_dynamo/variables/higher_order_ops.py:4368:31: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `value` @@ -1341,13 +1382,16 @@ torch/_dynamo/variables/higher_order_ops.py:4535:36: error[unresolved-attribute] torch/_dynamo/variables/higher_order_ops.py:4536:35: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `value` torch/_dynamo/variables/higher_order_ops.py:4537:28: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `value` torch/_dynamo/variables/higher_order_ops.py:4540:16: error[invalid-return-type] Return type does not match returned value: expected `VariableTracker`, found `VariableTracker | None` +torch/_dynamo/variables/iter.py:509:9: error[invalid-method-override] Invalid override of method `python_type`: Definition is incompatible with `ZipVariable.python_type` torch/_dynamo/variables/lazy.py:76:16: error[invalid-return-type] Return type does not match returned value: expected `VariableTracker`, found `Unknown | VariableTracker | None` torch/_dynamo/variables/lists.py:71:13: error[unresolved-attribute] Module `torch` has no member `Size` +torch/_dynamo/variables/lists.py:1159:9: error[invalid-method-override] Invalid override of method `python_type`: Definition is incompatible with `TupleVariable.python_type` torch/_dynamo/variables/lists.py:1160:16: error[unresolved-attribute] Module `torch` has no member `Size` torch/_dynamo/variables/lists.py:1195:20: error[unresolved-attribute] Module `torch` has no member `Size` torch/_dynamo/variables/lists.py:1197:54: error[unresolved-attribute] Module `torch` has no member `Size` torch/_dynamo/variables/lists.py:1200:13: error[unresolved-attribute] Module `torch` has no member `Size` torch/_dynamo/variables/lists.py:1296:58: error[unresolved-attribute] Module `torch` has no member `Size` +torch/_dynamo/variables/lists.py:1335:9: error[invalid-method-override] Invalid override of method `python_type`: Definition is incompatible with `TupleVariable.python_type` torch/_dynamo/variables/misc.py:131:23: warning[possibly-missing-attribute] Attribute `python_type` may be missing on object of type `Unknown | None` torch/_dynamo/variables/misc.py:133:24: warning[possibly-missing-attribute] Attribute `source` may be missing on object of type `Unknown | None` torch/_dynamo/variables/misc.py:133:47: warning[possibly-missing-attribute] Attribute `source` may be missing on object of type `Unknown | None` @@ -1372,8 +1416,10 @@ torch/_dynamo/variables/misc.py:367:26: error[unresolved-attribute] Module `torc torch/_dynamo/variables/misc.py:374:23: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `items` torch/_dynamo/variables/misc.py:375:42: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `items` torch/_dynamo/variables/misc.py:475:30: error[invalid-argument-type] Argument to bound method `set_context` is incorrect: Expected `ExceptionVariable`, found `VariableTracker` +torch/_dynamo/variables/misc.py:565:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` torch/_dynamo/variables/misc.py:575:30: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Unknown | Source | None` torch/_dynamo/variables/misc.py:594:60: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | Source | None` +torch/_dynamo/variables/misc.py:597:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` torch/_dynamo/variables/misc.py:629:23: warning[possibly-missing-attribute] Attribute `items` may be missing on object of type `(Unknown & ~AlwaysFalsy) | (VariableTracker & ~AlwaysFalsy)` torch/_dynamo/variables/misc.py:673:5: error[unresolved-attribute] Unresolved attribute `_origin` on type `def trampoline_autograd_apply(...) -> Unknown`. torch/_dynamo/variables/misc.py:791:37: error[unresolved-attribute] Object of type `Signature` has no attribute `_parameters` @@ -1388,22 +1434,29 @@ torch/_dynamo/variables/misc.py:1003:13: error[invalid-assignment] Object of typ torch/_dynamo/variables/misc.py:1005:13: warning[possibly-missing-attribute] Attribute `tensors` may be missing on object of type `Unknown | None` torch/_dynamo/variables/misc.py:1011:68: error[invalid-argument-type] Argument to bound method `call_method` is incorrect: Expected `list[VariableTracker]`, found `tuple[Unknown, ...]` torch/_dynamo/variables/misc.py:1020:50: error[unresolved-attribute] Object of type `object` has no attribute `needs_input_grad` -torch/_dynamo/variables/misc.py:1046:16: error[unresolved-attribute] Module `torch._dynamo` has no member `compiled_autograd` +torch/_dynamo/variables/misc.py:1046:16: warning[possibly-missing-attribute] Submodule `compiled_autograd` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/misc.py:1083:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` +torch/_dynamo/variables/misc.py:1145:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` +torch/_dynamo/variables/misc.py:1237:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` torch/_dynamo/variables/misc.py:1403:20: error[unresolved-attribute] Object of type `InstructionTranslator` has no attribute `side_effects` torch/_dynamo/variables/misc.py:1450:25: warning[possibly-missing-import] Member `NP_TO_TNP_MODULE` of module `torch._dynamo.utils` may be missing +torch/_dynamo/variables/misc.py:1498:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` torch/_dynamo/variables/misc.py:1734:16: warning[possibly-missing-attribute] Attribute `reconstruct` may be missing on object of type `Unknown | Source | None` torch/_dynamo/variables/misc.py:1737:47: error[invalid-type-form] Boolean literals are not allowed in this context in a type expression torch/_dynamo/variables/misc.py:1775:13: error[invalid-return-type] Return type does not match returned value: expected `VariableTracker`, found `None` torch/_dynamo/variables/misc.py:1801:23: error[invalid-assignment] Implicit shadowing of class `floating` torch/_dynamo/variables/misc.py:1802:20: error[invalid-assignment] Implicit shadowing of class `dtype` torch/_dynamo/variables/misc.py:1854:60: warning[possibly-missing-attribute] Attribute `np_generic` may be missing on object of type `Self@var_getattr` +torch/_dynamo/variables/misc.py:2071:9: error[invalid-method-override] Invalid override of method `build`: Definition is incompatible with `VariableTracker.build` +torch/_dynamo/variables/misc.py:2087:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` torch/_dynamo/variables/nn_module.py:210:57: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | Source | None` torch/_dynamo/variables/nn_module.py:237:39: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | Source | None` torch/_dynamo/variables/nn_module.py:319:63: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `((...) -> Any) | None`, found `Unknown | AttrSource` torch/_dynamo/variables/nn_module.py:383:68: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `(Unknown & ~AlwaysTruthy) | (Source & ~AlwaysTruthy) | None | AttrSource` torch/_dynamo/variables/nn_module.py:419:73: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `(Unknown & ~AlwaysTruthy) | (Source & ~AlwaysTruthy) | None | AttrSource` +torch/_dynamo/variables/nn_module.py:435:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` torch/_dynamo/variables/nn_module.py:476:62: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | Source | None` -torch/_dynamo/variables/nn_module.py:508:26: error[unresolved-attribute] Module `torch.ao.quantization.pt2e` has no member `export_utils` +torch/_dynamo/variables/nn_module.py:508:26: warning[possibly-missing-attribute] Submodule `export_utils` may not be available as an attribute on module `torch.ao.quantization.pt2e` torch/_dynamo/variables/nn_module.py:621:23: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `items` torch/_dynamo/variables/nn_module.py:621:37: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `value` torch/_dynamo/variables/nn_module.py:630:53: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | Source | None` @@ -1417,6 +1470,7 @@ torch/_dynamo/variables/nn_module.py:747:57: error[invalid-argument-type] Argume torch/_dynamo/variables/nn_module.py:750:57: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | Source | None` torch/_dynamo/variables/nn_module.py:841:45: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | Source | None` torch/_dynamo/variables/nn_module.py:919:47: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | Source | None` +torch/_dynamo/variables/nn_module.py:1035:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` torch/_dynamo/variables/nn_module.py:1044:16: error[unresolved-attribute] Object of type `object` has no attribute `cls_to_become` torch/_dynamo/variables/nn_module.py:1045:35: error[unresolved-attribute] Object of type `object` has no attribute `cls_to_become` torch/_dynamo/variables/nn_module.py:1058:20: error[unresolved-attribute] Object of type `object` has no attribute `__call__` @@ -1450,13 +1504,13 @@ torch/_dynamo/variables/streams.py:83:30: error[unresolved-attribute] Module `to torch/_dynamo/variables/streams.py:202:43: error[unresolved-attribute] Module `torch` has no member `device` torch/_dynamo/variables/streams.py:266:16: error[unresolved-attribute] Module `torch` has no member `Stream` torch/_dynamo/variables/streams.py:284:16: error[unresolved-attribute] Module `torch` has no member `Stream` -torch/_dynamo/variables/streams.py:356:21: error[unresolved-attribute] Module `torch._dynamo` has no member `graph_bytecode_inputs` +torch/_dynamo/variables/streams.py:356:21: warning[possibly-missing-attribute] Submodule `graph_bytecode_inputs` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/variables/streams.py:399:16: error[unresolved-attribute] Module `torch` has no member `Event` torch/_dynamo/variables/tensor.py:79:10: error[invalid-assignment] Object of type `None` is not assignable to `` torch/_dynamo/variables/tensor.py:133:20: error[unresolved-attribute] Module `torch._C` has no member `TensorBase` -torch/_dynamo/variables/tensor.py:268:16: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/tensor.py:275:30: error[unresolved-attribute] Module `torch` has no member `_prims_common` -torch/_dynamo/variables/tensor.py:402:13: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/_dynamo/variables/tensor.py:268:16: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/tensor.py:275:30: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` +torch/_dynamo/variables/tensor.py:402:13: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/_dynamo/variables/tensor.py:495:21: error[unresolved-attribute] Module `torch` has no member `Tag` torch/_dynamo/variables/tensor.py:554:49: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Unknown | Source | None` torch/_dynamo/variables/tensor.py:573:23: warning[possibly-missing-attribute] Attribute `make_guard` may be missing on object of type `Unknown | Source | None` @@ -1469,23 +1523,25 @@ torch/_dynamo/variables/tensor.py:969:17: error[unresolved-attribute] Module `to torch/_dynamo/variables/tensor.py:970:17: error[unresolved-attribute] Module `torch` has no member `int32` torch/_dynamo/variables/tensor.py:971:17: error[unresolved-attribute] Module `torch` has no member `int64` torch/_dynamo/variables/tensor.py:1039:17: error[unresolved-attribute] Module `torch` has no member `select` -torch/_dynamo/variables/tensor.py:1059:22: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_dynamo/variables/tensor.py:1059:22: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_dynamo/variables/tensor.py:1202:61: error[unresolved-attribute] Module `torch` has no member `mul` torch/_dynamo/variables/tensor.py:1212:61: error[unresolved-attribute] Module `torch` has no member `div` torch/_dynamo/variables/tensor.py:1215:61: error[unresolved-attribute] Module `torch` has no member `mul` torch/_dynamo/variables/tensor.py:1229:57: error[unresolved-attribute] Module `torch` has no member `eq` torch/_dynamo/variables/tensor.py:1232:57: error[unresolved-attribute] Module `torch` has no member `any` torch/_dynamo/variables/tensor.py:1459:21: error[unresolved-attribute] Module `torch` has no member `scalar_tensor` -torch/_dynamo/variables/tensor.py:1467:16: error[unresolved-attribute] Module `torch.fx` has no member `experimental` +torch/_dynamo/variables/tensor.py:1467:16: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/tensor.py:1590:9: error[invalid-method-override] Invalid override of method `call_method`: Definition is incompatible with `TensorVariable.call_method` +torch/_dynamo/variables/tensor.py:1696:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` torch/_dynamo/variables/torch.py:115:9: error[unresolved-attribute] Module `torch._C` has no member `DisableTorchFunctionSubclass` torch/_dynamo/variables/torch.py:116:9: error[unresolved-attribute] Module `torch._C` has no member `DisableTorchFunction` -torch/_dynamo/variables/torch.py:117:9: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/variables/torch.py:118:9: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/variables/torch.py:119:9: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/variables/torch.py:120:9: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_dynamo/variables/torch.py:117:9: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/variables/torch.py:118:9: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/variables/torch.py:119:9: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/variables/torch.py:120:9: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_dynamo/variables/torch.py:127:37: warning[deprecated] The class `autocast` is deprecated: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead. torch/_dynamo/variables/torch.py:128:38: warning[deprecated] The class `autocast` is deprecated: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead. -torch/_dynamo/variables/torch.py:129:9: error[unresolved-attribute] Module `torch.fx` has no member `traceback` +torch/_dynamo/variables/torch.py:129:9: warning[possibly-missing-attribute] Submodule `traceback` may not be available as an attribute on module `torch.fx` torch/_dynamo/variables/torch.py:145:9: error[unresolved-attribute] Module `torch` has no member `_shape_as_tensor` torch/_dynamo/variables/torch.py:161:5: error[unresolved-attribute] Module `torch._C` has no member `_get_cublas_allow_tf32` torch/_dynamo/variables/torch.py:162:5: error[unresolved-attribute] Module `torch._C` has no member `_is_any_autocast_enabled` @@ -1514,18 +1570,18 @@ torch/_dynamo/variables/torch.py:235:9: error[unresolved-attribute] Module `torc torch/_dynamo/variables/torch.py:236:9: error[unresolved-attribute] Module `torch` has no member `zeros_like` torch/_dynamo/variables/torch.py:237:9: error[unresolved-attribute] Module `torch` has no member `empty` torch/_dynamo/variables/torch.py:238:9: error[unresolved-attribute] Module `torch` has no member `full` -torch/_dynamo/variables/torch.py:260:20: error[unresolved-attribute] Module `torch._dynamo` has no member `compiled_autograd` -torch/_dynamo/variables/torch.py:386:13: error[unresolved-attribute] Module `torch.fx` has no member `traceback` +torch/_dynamo/variables/torch.py:260:20: warning[possibly-missing-attribute] Submodule `compiled_autograd` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/torch.py:386:13: warning[possibly-missing-attribute] Submodule `traceback` may not be available as an attribute on module `torch.fx` torch/_dynamo/variables/torch.py:393:69: error[unresolved-attribute] Module `torch` has no member `Stream` torch/_dynamo/variables/torch.py:408:28: warning[deprecated] The class `autocast` is deprecated: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead. torch/_dynamo/variables/torch.py:409:27: warning[deprecated] The class `autocast` is deprecated: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead. torch/_dynamo/variables/torch.py:424:27: error[unresolved-attribute] Module `torch._C` has no member `DisableTorchFunctionSubclass` torch/_dynamo/variables/torch.py:425:30: error[unresolved-attribute] Module `torch._C` has no member `DisableTorchFunction` torch/_dynamo/variables/torch.py:429:49: error[unresolved-attribute] Module `torch._C` has no member `DisableTorchFunctionSubclass` -torch/_dynamo/variables/torch.py:431:28: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/variables/torch.py:437:28: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/variables/torch.py:449:28: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/variables/torch.py:453:27: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_dynamo/variables/torch.py:431:28: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/variables/torch.py:437:28: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/variables/torch.py:449:28: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/variables/torch.py:453:27: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_dynamo/variables/torch.py:543:30: warning[deprecated] The function `is_compiling` is deprecated: `torch._utils.is_compiling` is deprecated. Use `torch.compiler.is_compiling` instead. torch/_dynamo/variables/torch.py:544:46: warning[deprecated] The function `is_compiling` is deprecated: `torch._dynamo.external_utils.is_compiling` is deprecated. Use `torch.compiler.is_compiling` instead. torch/_dynamo/variables/torch.py:557:30: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_keys` @@ -1540,11 +1596,11 @@ torch/_dynamo/variables/torch.py:646:13: error[unresolved-attribute] Module `tor torch/_dynamo/variables/torch.py:651:34: error[unresolved-attribute] Module `torch` has no member `is_floating_point` torch/_dynamo/variables/torch.py:653:36: error[unresolved-attribute] Module `torch` has no member `is_complex` torch/_dynamo/variables/torch.py:658:19: error[unresolved-attribute] Module `torch` has no member `numel` -torch/_dynamo/variables/torch.py:688:13: error[unresolved-attribute] Module `torch.nn.modules` has no member `utils` -torch/_dynamo/variables/torch.py:689:13: error[unresolved-attribute] Module `torch.nn.modules` has no member `utils` -torch/_dynamo/variables/torch.py:690:13: error[unresolved-attribute] Module `torch.nn.modules` has no member `utils` -torch/_dynamo/variables/torch.py:691:13: error[unresolved-attribute] Module `torch.nn.modules` has no member `utils` -torch/_dynamo/variables/torch.py:692:13: error[unresolved-attribute] Module `torch.nn.modules` has no member `utils` +torch/_dynamo/variables/torch.py:688:13: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch.nn.modules` +torch/_dynamo/variables/torch.py:689:13: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch.nn.modules` +torch/_dynamo/variables/torch.py:690:13: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch.nn.modules` +torch/_dynamo/variables/torch.py:691:13: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch.nn.modules` +torch/_dynamo/variables/torch.py:692:13: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch.nn.modules` torch/_dynamo/variables/torch.py:697:19: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_dynamo/variables/torch.py:700:44: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_dynamo/variables/torch.py:724:19: error[unresolved-attribute] Module `torch._C` has no member `_is_torch_function_enabled` @@ -1562,29 +1618,29 @@ torch/_dynamo/variables/torch.py:866:19: error[unresolved-attribute] Module `tor torch/_dynamo/variables/torch.py:877:19: error[unresolved-attribute] Module `torch` has no member `_foreach_pow` torch/_dynamo/variables/torch.py:902:21: error[unresolved-attribute] Module `torch._C` has no member `_SDPAParams` torch/_dynamo/variables/torch.py:999:58: error[unresolved-attribute] Module `torch` has no member `strided` -torch/_dynamo/variables/torch.py:1037:19: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1043:21: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1050:19: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1056:21: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1061:19: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1067:21: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1072:19: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1076:21: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1083:19: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1098:17: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1101:19: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1105:21: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1112:19: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1117:21: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1123:19: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1128:21: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1134:19: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1145:17: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_dynamo/variables/torch.py:1148:19: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/_dynamo/variables/torch.py:1158:19: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/torch.py:1165:17: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_dynamo/variables/torch.py:1168:19: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_dynamo/variables/torch.py:1174:17: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_dynamo/variables/torch.py:1037:19: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1043:21: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1050:19: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1056:21: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1061:19: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1067:21: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1072:19: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1076:21: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1083:19: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1098:17: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1101:19: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1105:21: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1112:19: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1117:21: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1123:19: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1128:21: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1134:19: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1145:17: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_dynamo/variables/torch.py:1148:19: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/torch.py:1158:19: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/torch.py:1165:17: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_dynamo/variables/torch.py:1168:19: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_dynamo/variables/torch.py:1174:17: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_dynamo/variables/torch.py:1177:19: error[unresolved-attribute] Module `torch` has no member `tensor` torch/_dynamo/variables/torch.py:1204:19: error[unresolved-attribute] Module `torch._C` has no member `_pop_torch_function_stack` torch/_dynamo/variables/torch.py:1222:19: error[unresolved-attribute] Module `torch._C` has no member `_push_on_torch_function_stack` @@ -1592,14 +1648,14 @@ torch/_dynamo/variables/torch.py:1235:19: error[unresolved-attribute] Module `to torch/_dynamo/variables/torch.py:1245:19: error[unresolved-attribute] Module `torch._C` has no member `_get_function_stack_at` torch/_dynamo/variables/torch.py:1311:30: error[unresolved-attribute] Module `torch` has no member `device` torch/_dynamo/variables/torch.py:1313:30: error[unresolved-attribute] Module `torch` has no member `device` -torch/_dynamo/variables/torch.py:1579:17: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` -torch/_dynamo/variables/torch.py:1581:17: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` +torch/_dynamo/variables/torch.py:1579:17: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` +torch/_dynamo/variables/torch.py:1581:17: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` torch/_dynamo/variables/torch.py:1632:29: error[unresolved-attribute] Module `torch` has no member `Tag` -torch/_dynamo/variables/torch.py:1789:28: error[unresolved-attribute] Module `torch` has no member `_prims_common` -torch/_dynamo/variables/torch.py:1818:24: error[unresolved-attribute] Module `torch` has no member `_prims_common` -torch/_dynamo/variables/torch.py:1834:26: error[unresolved-attribute] Module `torch.nn.modules` has no member `utils` -torch/_dynamo/variables/torch.py:1849:21: error[unresolved-attribute] Module `torch.nn.modules` has no member `utils` -torch/_dynamo/variables/torch.py:1861:26: error[unresolved-attribute] Module `torch.nn.modules` has no member `utils` +torch/_dynamo/variables/torch.py:1789:28: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` +torch/_dynamo/variables/torch.py:1818:24: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` +torch/_dynamo/variables/torch.py:1834:26: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch.nn.modules` +torch/_dynamo/variables/torch.py:1849:21: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch.nn.modules` +torch/_dynamo/variables/torch.py:1861:26: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch.nn.modules` torch/_dynamo/variables/torch.py:1907:12: warning[possibly-missing-attribute] Attribute `source` may be missing on object of type `Unknown | None` torch/_dynamo/variables/torch.py:2057:53: error[unresolved-attribute] Module `torch._C` has no member `TensorBase` torch/_dynamo/variables/torch_function.py:209:13: error[unresolved-attribute] Module `torch._C` has no member `_push_on_torch_function_stack` @@ -1626,6 +1682,7 @@ torch/_dynamo/variables/user_defined.py:198:13: error[unresolved-attribute] Modu torch/_dynamo/variables/user_defined.py:199:13: error[unresolved-attribute] Module `torch.cuda` has no member `LongTensor` torch/_dynamo/variables/user_defined.py:200:13: error[unresolved-attribute] Module `torch` has no member `Stream` torch/_dynamo/variables/user_defined.py:201:13: error[unresolved-attribute] Module `torch` has no member `Event` +torch/_dynamo/variables/user_defined.py:470:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` torch/_dynamo/variables/user_defined.py:511:17: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `items` torch/_dynamo/variables/user_defined.py:517:16: error[unresolved-attribute] Object of type `type & ~ & ~ & ~ & ~` has no attribute `__optional_keys__` torch/_dynamo/variables/user_defined.py:681:33: error[unresolved-attribute] Object of type `VariableTracker` has no attribute `items` @@ -1642,11 +1699,13 @@ torch/_dynamo/variables/user_defined.py:842:41: error[unresolved-attribute] Modu torch/_dynamo/variables/user_defined.py:1147:45: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `~_local` torch/_dynamo/variables/user_defined.py:1208:21: error[non-subscriptable] Cannot subscript object of type `object` with no `__getitem__` method torch/_dynamo/variables/user_defined.py:1211:36: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `object` -torch/_dynamo/variables/user_defined.py:1262:25: error[unresolved-attribute] Module `torch.utils` has no member `_contextlib` +torch/_dynamo/variables/user_defined.py:1246:9: error[invalid-method-override] Invalid override of method `call_function`: Definition is incompatible with `VariableTracker.call_function` +torch/_dynamo/variables/user_defined.py:1262:25: warning[possibly-missing-attribute] Submodule `_contextlib` may not be available as an attribute on module `torch.utils` +torch/_dynamo/variables/user_defined.py:1277:50: error[unresolved-attribute] Object of type `object` has no attribute `mode` torch/_dynamo/variables/user_defined.py:1291:35: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | Source | None` torch/_dynamo/variables/user_defined.py:1293:34: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | Source | None` torch/_dynamo/variables/user_defined.py:1298:37: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | None | TypeSource` -torch/_dynamo/variables/user_defined.py:1317:14: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` +torch/_dynamo/variables/user_defined.py:1317:14: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` torch/_dynamo/variables/user_defined.py:1334:56: error[invalid-argument-type] Argument to bound method `__getattribute__` is incorrect: Expected `str`, found `object` torch/_dynamo/variables/user_defined.py:1334:68: error[too-many-positional-arguments] Too many positional arguments to bound method `__getattribute__`: expected 2, got 3 torch/_dynamo/variables/user_defined.py:1402:25: error[unsupported-operator] Operator `not in` is not supported for types `Unknown` and `object` @@ -1658,12 +1717,15 @@ torch/_dynamo/variables/user_defined.py:1532:17: error[unsupported-operator] Ope torch/_dynamo/variables/user_defined.py:1551:20: warning[possibly-missing-attribute] Attribute `items` may be missing on object of type `Unknown | None | TupleVariable` torch/_dynamo/variables/user_defined.py:1573:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `((...) -> Any) | None`, found `None | AttrSource` torch/_dynamo/variables/user_defined.py:1689:57: error[invalid-argument-type] Argument is incorrect: Expected `Source`, found `Unknown | Source | None` -torch/_dynamo/variables/user_defined.py:1695:20: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` +torch/_dynamo/variables/user_defined.py:1695:20: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` torch/_dynamo/variables/user_defined.py:1795:50: warning[deprecated] The class `LeafSpec` is deprecated: `isinstance(treespec, LeafSpec)` is deprecated, use `isinstance(treespec, TreeSpec) and treespec.is_leaf()` instead. +torch/_dynamo/variables/user_defined.py:1804:29: error[invalid-argument-type] Argument to function `fields` is incorrect: Expected `DataclassInstance | type[@Todo]`, found `object` torch/_dynamo/variables/user_defined.py:1822:29: error[invalid-argument-type] Argument to function `fields` is incorrect: Expected `DataclassInstance | type[@Todo]`, found `object` +torch/_dynamo/variables/user_defined.py:1854:9: error[invalid-method-override] Invalid override of method `method_setattr_standard`: Definition is incompatible with `UserDefinedObjectVariable.method_setattr_standard` torch/_dynamo/variables/user_defined.py:1877:49: error[unresolved-attribute] Object of type `object` has no attribute `forward` torch/_dynamo/variables/user_defined.py:1903:13: error[unresolved-attribute] Unresolved attribute `args` on type `object`. torch/_dynamo/variables/user_defined.py:1940:14: error[unresolved-import] Cannot resolve imported module `torchrec.sparse.jagged_tensor` +torch/_dynamo/variables/user_defined.py:1985:9: error[invalid-method-override] Invalid override of method `call_method`: Definition is incompatible with `VariableTracker.call_method` torch/_dynamo/variables/user_defined.py:1988:52: error[invalid-argument-type] Argument to bound method `remove_hook` is incorrect: Expected `int`, found `Unknown | None | Literal[-1]` torch/_dynamo/variables/user_defined.py:2046:24: warning[possibly-missing-attribute] Attribute `call_method` may be missing on object of type `Unknown | None | ConstDictVariable` torch/_dynamo/variables/user_defined.py:2059:12: error[unresolved-attribute] Object of type `type` has no attribute `__iter__` @@ -1685,12 +1747,11 @@ torch/_dynamo/variables/user_defined.py:2194:12: error[unresolved-attribute] Obj torch/_dynamo/variables/user_defined.py:2227:21: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method torch/_dynamo/variables/user_defined.py:2247:12: error[unresolved-attribute] Object of type `type` has no attribute `__iter__` torch/_dynamo/variables/user_defined.py:2267:30: error[unresolved-attribute] Object of type `type` has no attribute `get` -torch/_dynamo/variables/user_defined.py:2268:13: error[unresolved-attribute] Module `collections` has no member `abc` -torch/_export/__init__.py:137:14: error[unresolved-attribute] Module `torch` has no member `_export` -torch/_export/__init__.py:169:44: error[unresolved-attribute] Module `torch._C` has no member `_aoti` -torch/_export/__init__.py:171:18: error[unresolved-attribute] Module `torch._C` has no member `_aoti` -torch/_export/__init__.py:173:18: error[unresolved-attribute] Module `torch._C` has no member `_aoti` -torch/_export/__init__.py:175:18: error[unresolved-attribute] Module `torch._C` has no member `_aoti` +torch/_export/__init__.py:137:14: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` +torch/_export/__init__.py:169:44: warning[possibly-missing-attribute] Submodule `_aoti` may not be available as an attribute on module `torch._C` +torch/_export/__init__.py:171:18: warning[possibly-missing-attribute] Submodule `_aoti` may not be available as an attribute on module `torch._C` +torch/_export/__init__.py:173:18: warning[possibly-missing-attribute] Submodule `_aoti` may not be available as an attribute on module `torch._C` +torch/_export/__init__.py:175:18: warning[possibly-missing-attribute] Submodule `_aoti` may not be available as an attribute on module `torch._C` torch/_export/converter.py:54:35: error[unresolved-attribute] Module `torch` has no member `is_autocast_cache_enabled` torch/_export/converter.py:55:5: error[unresolved-attribute] Module `torch` has no member `set_autocast_cache_enabled` torch/_export/converter.py:63:5: error[unresolved-attribute] Module `torch` has no member `set_autocast_cache_enabled` @@ -1744,7 +1805,7 @@ torch/_export/converter.py:660:40: error[unresolved-attribute] Module `torch._C` torch/_export/converter.py:662:31: error[unresolved-attribute] Module `torch` has no member `float` torch/_export/converter.py:671:41: error[unresolved-attribute] Module `torch._C` has no member `Node` torch/_export/converter.py:680:13: error[unresolved-attribute] Module `torch` has no member `tensor` -torch/_export/converter.py:682:18: error[unresolved-attribute] Module `torch` has no member `_refs` +torch/_export/converter.py:682:18: warning[possibly-missing-attribute] Submodule `_refs` may not be available as an attribute on module `torch` torch/_export/converter.py:699:41: error[unresolved-attribute] Module `torch._C` has no member `Node` torch/_export/converter.py:722:43: error[unresolved-attribute] Module `torch._C` has no member `Node` torch/_export/converter.py:750:45: error[unresolved-attribute] Module `torch._C` has no member `Node` @@ -1871,19 +1932,19 @@ torch/_export/non_strict_utils.py:362:5: error[invalid-assignment] Implicit shad torch/_export/non_strict_utils.py:363:70: error[unresolved-attribute] Module `torch` has no member `maximum` torch/_export/non_strict_utils.py:367:5: error[invalid-assignment] Implicit shadowing of function `min` torch/_export/non_strict_utils.py:368:70: error[unresolved-attribute] Module `torch` has no member `minimum` -torch/_export/non_strict_utils.py:415:15: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_export/non_strict_utils.py:647:25: error[unresolved-attribute] Module `torch.fx.experimental` has no member `_config` -torch/_export/non_strict_utils.py:660:12: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` +torch/_export/non_strict_utils.py:415:15: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_export/non_strict_utils.py:647:25: warning[possibly-missing-attribute] Submodule `_config` may not be available as an attribute on module `torch.fx.experimental` +torch/_export/non_strict_utils.py:660:12: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` torch/_export/non_strict_utils.py:822:21: error[unresolved-attribute] Module `torch` has no member `ScriptObject` -torch/_export/non_strict_utils.py:855:9: error[unresolved-attribute] Module `torch` has no member `_export` -torch/_export/non_strict_utils.py:862:9: error[unresolved-attribute] Module `torch` has no member `_export` +torch/_export/non_strict_utils.py:855:9: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` +torch/_export/non_strict_utils.py:862:9: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` torch/_export/non_strict_utils.py:974:13: error[unresolved-attribute] Module `torch` has no member `ScriptObject` torch/_export/non_strict_utils.py:1028:21: warning[possibly-missing-attribute] Member `all_reduce` may be missing on module `torch.distributed` torch/_export/non_strict_utils.py:1029:21: warning[possibly-missing-attribute] Member `reduce_scatter_tensor` may be missing on module `torch.distributed` torch/_export/non_strict_utils.py:1030:21: warning[possibly-missing-attribute] Member `_reduce_scatter_base` may be missing on module `torch.distributed` torch/_export/non_strict_utils.py:1030:39: warning[deprecated] The function `_reduce_scatter_base` is deprecated: `torch.distributed._reduce_scatter_base` is a private function and will be deprecated. Please use `torch.distributed.reduce_scatter_tensor` instead. torch/_export/non_strict_utils.py:1035:20: error[unresolved-attribute] Module `torch` has no member `tensor` -torch/_export/non_strict_utils.py:1044:24: error[unresolved-attribute] Module `torch` has no member `_refs` +torch/_export/non_strict_utils.py:1044:24: warning[possibly-missing-attribute] Submodule `_refs` may not be available as an attribute on module `torch` torch/_export/non_strict_utils.py:1050:38: error[unresolved-attribute] Module `torch` has no member `unsqueeze` torch/_export/non_strict_utils.py:1052:34: error[unresolved-attribute] Module `torch` has no member `select` torch/_export/pass_base.py:123:29: error[unresolved-attribute] Module `torch` has no member `dequantize` @@ -1895,18 +1956,18 @@ torch/_export/passes/_node_metadata_hook.py:44:17: error[unresolved-attribute] O torch/_export/passes/_node_metadata_hook.py:52:14: error[invalid-context-manager] Object of type `FakeTensorMode | None` cannot be used with `with` because the methods `__enter__` and `__exit__` are possibly missing torch/_export/passes/_node_metadata_hook.py:86:16: error[unresolved-attribute] Object of type `(((...) -> Any) & (() -> object)) | (str & (() -> object))` has no attribute `__name__` torch/_export/passes/_node_metadata_hook.py:88:49: error[unresolved-attribute] Object of type `(((...) -> Any) & (() -> object)) | (str & (() -> object))` has no attribute `__name__` +torch/_export/passes/collect_tracepoints_pass.py:32:9: error[invalid-method-override] Invalid override of method `call`: Definition is incompatible with `PassBase.call` torch/_export/passes/constant_folding.py:71:33: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_export/passes/constant_folding.py:162:17: error[unresolved-attribute] Module `torch` has no member `Tag` -torch/_export/passes/constant_folding.py:211:10: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` -torch/_export/passes/constant_folding.py:251:10: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` -torch/_export/passes/lift_constants_pass.py:26:23: error[unresolved-attribute] Module `collections` has no member `abc` -torch/_export/passes/lift_constants_pass.py:37:56: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` +torch/_export/passes/constant_folding.py:211:10: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` +torch/_export/passes/constant_folding.py:251:10: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` +torch/_export/passes/lift_constants_pass.py:37:56: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` torch/_export/passes/lift_constants_pass.py:43:44: error[unresolved-attribute] Module `torch` has no member `ScriptObject` torch/_export/passes/lift_constants_pass.py:46:49: error[unresolved-attribute] Module `torch` has no member `ScriptObject` torch/_export/passes/lift_constants_pass.py:58:28: error[unresolved-attribute] Module `torch` has no member `ScriptObject` torch/_export/passes/lift_constants_pass.py:73:49: error[unresolved-attribute] Module `torch` has no member `ScriptObject` torch/_export/passes/lift_constants_pass.py:88:49: error[unresolved-attribute] Module `torch` has no member `ScriptObject` -torch/_export/passes/lift_constants_pass.py:234:41: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` +torch/_export/passes/lift_constants_pass.py:234:41: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` torch/_export/passes/lift_constants_pass.py:256:42: error[unresolved-attribute] Module `torch` has no member `ScriptObject` torch/_export/passes/lift_constants_pass.py:322:47: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` torch/_export/passes/lift_constants_pass.py:392:33: error[unresolved-attribute] Module `torch` has no member `ScriptObject` @@ -1989,12 +2050,12 @@ torch/_export/serde/serialize.py:259:12: error[unresolved-attribute] Module `tor torch/_export/serde/serialize.py:278:48: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_export/serde/serialize.py:340:73: error[invalid-argument-type] Argument to function `_print_sympy` is incorrect: Expected `SymInt | SymBool | SymFloat | Expr`, found `SymBool | bool` torch/_export/serde/serialize.py:472:16: error[invalid-return-type] Return type does not match returned value: expected `Expr`, found `int` -torch/_export/serde/serialize.py:537:12: error[unresolved-attribute] Module `torch._higher_order_ops` has no member `triton_kernel_wrap` +torch/_export/serde/serialize.py:537:12: warning[possibly-missing-attribute] Submodule `triton_kernel_wrap` may not be available as an attribute on module `torch._higher_order_ops` torch/_export/serde/serialize.py:541:10: error[unresolved-import] Cannot resolve imported module `triton.runtime.autotuner` torch/_export/serde/serialize.py:542:10: error[unresolved-import] Cannot resolve imported module `triton.runtime.jit` -torch/_export/serde/serialize.py:545:14: error[unresolved-attribute] Module `torch._higher_order_ops` has no member `triton_kernel_wrap` +torch/_export/serde/serialize.py:545:14: warning[possibly-missing-attribute] Submodule `triton_kernel_wrap` may not be available as an attribute on module `torch._higher_order_ops` torch/_export/serde/serialize.py:662:37: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` -torch/_export/serde/serialize.py:816:20: error[unresolved-attribute] Module `torch._higher_order_ops` has no member `triton_kernel_wrap` +torch/_export/serde/serialize.py:816:20: warning[possibly-missing-attribute] Submodule `triton_kernel_wrap` may not be available as an attribute on module `torch._higher_order_ops` torch/_export/serde/serialize.py:1201:45: error[unresolved-attribute] Module `torch` has no member `OptionalType` torch/_export/serde/serialize.py:1203:49: error[unresolved-attribute] Module `torch` has no member `ListType` torch/_export/serde/serialize.py:1205:46: error[unresolved-attribute] Module `torch` has no member `OptionalType` @@ -2021,46 +2082,47 @@ torch/_export/serde/serialize.py:2040:42: error[invalid-argument-type] Argument torch/_export/serde/serialize.py:2045:21: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `Expr` on object of type `dict[str, Symbol]` torch/_export/serde/serialize.py:2124:17: error[unresolved-attribute] Module `torch` has no member `empty_strided` torch/_export/serde/serialize.py:2285:39: error[unresolved-attribute] Module `torch` has no member `TensorType` -torch/_export/serde/serialize.py:2300:16: error[unresolved-attribute] Module `torch._higher_order_ops` has no member `triton_kernel_wrap` -torch/_export/serde/serialize.py:2537:29: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2538:36: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2539:26: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2540:30: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2541:24: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2542:29: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2543:30: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2544:31: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2545:28: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2546:27: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2547:27: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2548:33: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2549:29: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2550:33: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2551:31: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2552:54: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2553:33: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2554:31: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2555:31: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2556:33: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2557:28: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/_export/serde/serialize.py:2558:29: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` +torch/_export/serde/serialize.py:2300:16: warning[possibly-missing-attribute] Submodule `triton_kernel_wrap` may not be available as an attribute on module `torch._higher_order_ops` +torch/_export/serde/serialize.py:2537:29: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2538:36: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2539:26: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2540:30: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2541:24: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2542:29: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2543:30: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2544:31: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2545:28: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2546:27: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2547:27: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2548:33: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2549:29: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2550:33: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2551:31: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2552:54: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2553:33: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2554:31: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2555:31: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2556:33: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2557:28: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/_export/serde/serialize.py:2558:29: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` torch/_export/serde/serialize.py:3101:51: error[unresolved-attribute] Module `torch._C` has no member `_get_max_operator_version` +torch/_export/serde/serialize.py:3180:9: error[invalid-method-override] Invalid override of method `default`: Definition is incompatible with `JSONEncoder.default` torch/_export/serde/serialize.py:3865:31: error[unresolved-attribute] Module `torch` has no member `FunctionSchema` torch/_export/serde/union.py:49:12: error[call-non-callable] Object of type `` is not callable torch/_export/verifier.py:49:19: error[unresolved-attribute] Module `torch` has no member `memory_format` torch/_export/verifier.py:49:40: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_export/verifier.py:49:53: error[unresolved-attribute] Module `torch` has no member `device` torch/_export/verifier.py:49:67: error[unresolved-attribute] Module `torch` has no member `layout` -torch/_export/verifier.py:162:39: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` -torch/_export/verifier.py:170:13: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` -torch/_export/verifier.py:219:17: error[unresolved-attribute] Module `torch.export` has no member `custom_ops` +torch/_export/verifier.py:162:39: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` +torch/_export/verifier.py:170:13: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` +torch/_export/verifier.py:219:17: warning[possibly-missing-attribute] Submodule `custom_ops` may not be available as an attribute on module `torch.export` torch/_export/verifier.py:223:17: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` -torch/_export/verifier.py:226:17: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` -torch/_export/verifier.py:227:17: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_export/verifier.py:228:17: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_export/verifier.py:229:17: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_export/verifier.py:230:17: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_export/verifier.py:231:17: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_export/verifier.py:226:17: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` +torch/_export/verifier.py:227:17: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_export/verifier.py:228:17: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_export/verifier.py:229:17: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_export/verifier.py:230:17: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_export/verifier.py:231:17: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_export/wrappers.py:8:22: error[unresolved-import] Module `torch._C` has no member `DispatchKey` torch/_export/wrappers.py:296:48: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` torch/_export/wrappers.py:302:26: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_local_include_set` @@ -2080,20 +2142,22 @@ torch/_functorch/_activation_checkpointing/knapsack.py:85:10: error[unresolved-a torch/_functorch/_activation_checkpointing/knapsack.py:86:50: error[unresolved-attribute] Module `torch` has no member `float32` torch/_functorch/_activation_checkpointing/knapsack.py:100:38: error[unresolved-attribute] Module `torch` has no member `maximum` torch/_functorch/_activation_checkpointing/knapsack_evaluator.py:5:8: error[unresolved-import] Cannot resolve imported module `networkx` -torch/_functorch/_aot_autograd/aot_autograd_result.py:163:9: error[unresolved-attribute] Module `torch._inductor` has no member `async_compile` +torch/_functorch/_aot_autograd/aot_autograd_result.py:163:9: warning[possibly-missing-attribute] Submodule `async_compile` may not be available as an attribute on module `torch._inductor` torch/_functorch/_aot_autograd/aot_autograd_result.py:312:5: error[unresolved-attribute] Cannot assign object of type `dict[Unknown, Unknown]` to attribute `meta` on type `GraphModule` with custom `__setattr__` method. torch/_functorch/_aot_autograd/aot_autograd_result.py:515:23: error[unresolved-attribute] Module `torch._C` has no member `_is_any_autocast_enabled` -torch/_functorch/_aot_autograd/aot_autograd_result.py:643:15: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_functorch/_aot_autograd/aot_autograd_result.py:647:19: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_functorch/_aot_autograd/aot_autograd_result.py:648:10: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_functorch/_aot_autograd/aot_autograd_result.py:643:15: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/aot_autograd_result.py:647:19: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/aot_autograd_result.py:648:10: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_functorch/_aot_autograd/autograd_cache.py:105:14: error[unresolved-import] Cannot resolve imported module `torch._inductor.fb.remote_cache` -torch/_functorch/_aot_autograd/autograd_cache.py:171:17: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_functorch/_aot_autograd/autograd_cache.py:264:23: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_functorch/_aot_autograd/autograd_cache.py:171:17: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/autograd_cache.py:264:23: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_functorch/_aot_autograd/autograd_cache.py:319:18: error[unresolved-import] Cannot resolve imported module `triton.runtime.autotuner` torch/_functorch/_aot_autograd/autograd_cache.py:340:29: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_functorch/_aot_autograd/autograd_cache.py:341:28: error[unresolved-attribute] Module `torch._C` has no member `_is_any_autocast_enabled` torch/_functorch/_aot_autograd/autograd_cache.py:383:9: warning[possibly-missing-attribute] Attribute `update` may be missing on object of type `Mapping[type, (Any, /) -> str | tuple[(...) -> Any, tuple[Any, ...]] | tuple[(...) -> Any, tuple[Any, ...], Any] | tuple[(...) -> Any, tuple[Any, ...], Any, Iterator[Any] | None] | tuple[(...) -> Any, tuple[Any, ...], Any, Iterator[Any] | None, Iterator[Any] | None]] | dict[Unknown, Unknown]` +torch/_functorch/_aot_autograd/autograd_cache.py:408:9: error[invalid-method-override] Invalid override of method `_reduce_tensor`: Definition is incompatible with `FxGraphCachePickler._reduce_tensor` torch/_functorch/_aot_autograd/autograd_cache.py:486:16: error[unresolved-import] Cannot resolve imported module `triton` +torch/_functorch/_aot_autograd/autograd_cache.py:769:9: error[invalid-method-override] Invalid override of method `_get_tmp_dir_for_key`: Definition is incompatible with `GuardedCache._get_tmp_dir_for_key` torch/_functorch/_aot_autograd/collect_metadata_analysis.py:90:8: warning[possibly-missing-attribute] Attribute `memory_format` may be missing on object of type `MemoryFormatMeta | None` torch/_functorch/_aot_autograd/collect_metadata_analysis.py:93:44: warning[possibly-missing-attribute] Attribute `memory_format` may be missing on object of type `MemoryFormatMeta | None` torch/_functorch/_aot_autograd/collect_metadata_analysis.py:133:13: warning[possibly-missing-attribute] Attribute `append` may be missing on object of type `list[Unknown | MemoryFormatMeta | None] | MemoryFormatMeta | None` @@ -2103,14 +2167,14 @@ torch/_functorch/_aot_autograd/collect_metadata_analysis.py:195:13: error[unreso torch/_functorch/_aot_autograd/collect_metadata_analysis.py:195:37: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/_functorch/_aot_autograd/collect_metadata_analysis.py:705:18: error[invalid-context-manager] Object of type `FakeTensorMode | None` cannot be used with `with` because the methods `__enter__` and `__exit__` are possibly missing torch/_functorch/_aot_autograd/collect_metadata_analysis.py:706:24: error[unresolved-attribute] Module `torch` has no member `empty` -torch/_functorch/_aot_autograd/collect_metadata_analysis.py:712:33: error[unresolved-attribute] Module `torch.nested._internal` has no member `nested_tensor` -torch/_functorch/_aot_autograd/collect_metadata_analysis.py:713:20: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_functorch/_aot_autograd/collect_metadata_analysis.py:802:12: error[unresolved-attribute] Module `torch._dynamo` has no member `compiled_autograd` +torch/_functorch/_aot_autograd/collect_metadata_analysis.py:712:33: warning[possibly-missing-attribute] Submodule `nested_tensor` may not be available as an attribute on module `torch.nested._internal` +torch/_functorch/_aot_autograd/collect_metadata_analysis.py:713:20: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/collect_metadata_analysis.py:802:12: warning[possibly-missing-attribute] Submodule `compiled_autograd` may not be available as an attribute on module `torch._dynamo` torch/_functorch/_aot_autograd/collect_metadata_analysis.py:841:12: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_functorch/_aot_autograd/collect_metadata_analysis.py:842:37: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_functorch/_aot_autograd/frontend_utils.py:50:30: error[unresolved-attribute] Module `torch` has no member `ScriptObject` -torch/_functorch/_aot_autograd/frontend_utils.py:71:35: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_functorch/_aot_autograd/frontend_utils.py:116:26: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_functorch/_aot_autograd/frontend_utils.py:71:35: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/frontend_utils.py:116:26: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_functorch/_aot_autograd/frontend_utils.py:156:16: error[unsupported-operator] Operator `in` is not supported for types `str` and `Module`, in comparing `str` with `Tensor | Module` torch/_functorch/_aot_autograd/frontend_utils.py:157:18: error[non-subscriptable] Cannot subscript object of type `Module` with no `__getitem__` method torch/_functorch/_aot_autograd/functional_utils.py:75:12: error[unresolved-attribute] Module `torch` has no member `_from_functional_tensor` @@ -2124,9 +2188,9 @@ torch/_functorch/_aot_autograd/functional_utils.py:336:13: error[unresolved-attr torch/_functorch/_aot_autograd/functional_utils.py:376:16: error[unresolved-attribute] Module `torch` has no member `_is_functional_tensor` torch/_functorch/_aot_autograd/graph_capture.py:15:33: warning[possibly-missing-import] Member `detect_fake_mode` of module `torch._dynamo.utils` may be missing torch/_functorch/_aot_autograd/graph_capture_wrappers.py:138:36: error[unresolved-attribute] Module `torch._C` has no member `_autocast_supported_devices` -torch/_functorch/_aot_autograd/graph_capture_wrappers.py:354:38: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_functorch/_aot_autograd/graph_capture_wrappers.py:354:38: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_functorch/_aot_autograd/graph_capture_wrappers.py:355:17: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` -torch/_functorch/_aot_autograd/graph_capture_wrappers.py:376:42: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_functorch/_aot_autograd/graph_capture_wrappers.py:376:42: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_functorch/_aot_autograd/graph_capture_wrappers.py:455:56: error[unresolved-attribute] Module `torch` has no member `device` torch/_functorch/_aot_autograd/graph_capture_wrappers.py:459:59: error[unresolved-attribute] Module `torch` has no member `device` torch/_functorch/_aot_autograd/graph_capture_wrappers.py:777:29: error[unresolved-attribute] Module `torch._C` has no member `_ExcludeDispatchKeyGuard` @@ -2135,75 +2199,78 @@ torch/_functorch/_aot_autograd/graph_capture_wrappers.py:778:41: error[unresolve torch/_functorch/_aot_autograd/graph_capture_wrappers.py:1074:25: error[unresolved-attribute] Module `torch._C` has no member `_ExcludeDispatchKeyGuard` torch/_functorch/_aot_autograd/graph_capture_wrappers.py:1075:13: error[unresolved-attribute] Module `torch._C` has no member `DispatchKeySet` torch/_functorch/_aot_autograd/graph_capture_wrappers.py:1075:37: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` -torch/_functorch/_aot_autograd/graph_capture_wrappers.py:1092:38: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_functorch/_aot_autograd/graph_capture_wrappers.py:1092:38: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_functorch/_aot_autograd/graph_capture_wrappers.py:1093:17: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` torch/_functorch/_aot_autograd/graph_capture_wrappers.py:1140:36: error[unresolved-attribute] Module `torch` has no member `tensor` torch/_functorch/_aot_autograd/graph_capture_wrappers.py:1317:9: error[invalid-argument-type] Argument to function `run_functionalized_fw_and_collect_metadata` is incorrect: Expected `list[AOTInput]`, found `list[Unknown] | AOTInput | tuple[list[Unknown], list[Unknown]] | list[AOTInput]` torch/_functorch/_aot_autograd/graph_compile.py:37:5: warning[possibly-missing-import] Member `detect_fake_mode` of module `torch._dynamo.utils` may be missing -torch/_functorch/_aot_autograd/graph_compile.py:368:32: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_functorch/_aot_autograd/graph_compile.py:368:32: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_functorch/_aot_autograd/graph_compile.py:510:19: error[unresolved-attribute] Module `torch._C` has no member `_is_any_autocast_enabled` torch/_functorch/_aot_autograd/graph_compile.py:1027:29: error[unresolved-attribute] Module `torch._C` has no member `_ExcludeDispatchKeyGuard` torch/_functorch/_aot_autograd/graph_compile.py:1028:17: error[unresolved-attribute] Module `torch._C` has no member `DispatchKeySet` torch/_functorch/_aot_autograd/graph_compile.py:1028:41: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` -torch/_functorch/_aot_autograd/graph_compile.py:1062:8: error[unresolved-attribute] Module `torch._dynamo` has no member `compiled_autograd` -torch/_functorch/_aot_autograd/graph_compile.py:1065:17: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_functorch/_aot_autograd/graph_compile.py:1067:9: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_functorch/_aot_autograd/graph_compile.py:1124:12: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_functorch/_aot_autograd/graph_compile.py:1487:32: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_functorch/_aot_autograd/graph_compile.py:1062:8: warning[possibly-missing-attribute] Submodule `compiled_autograd` may not be available as an attribute on module `torch._dynamo` +torch/_functorch/_aot_autograd/graph_compile.py:1065:17: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/graph_compile.py:1067:9: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/graph_compile.py:1124:12: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/graph_compile.py:1487:32: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_functorch/_aot_autograd/graph_compile.py:1574:19: error[unresolved-attribute] Module `torch._C` has no member `_is_any_autocast_enabled` torch/_functorch/_aot_autograd/graph_compile.py:1578:19: error[unresolved-attribute] Module `torch._C` has no member `_DisableAutocast` -torch/_functorch/_aot_autograd/graph_compile.py:1599:25: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_functorch/_aot_autograd/graph_compile.py:1601:24: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_functorch/_aot_autograd/graph_compile.py:1669:16: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_functorch/_aot_autograd/graph_compile.py:1599:25: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/graph_compile.py:1601:24: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/graph_compile.py:1669:16: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_functorch/_aot_autograd/graph_compile.py:1819:61: error[unresolved-attribute] Module `torch._C` has no member `_DisableAutocast` -torch/_functorch/_aot_autograd/graph_compile.py:1943:16: error[unresolved-attribute] Module `torch._dynamo` has no member `compiled_autograd` +torch/_functorch/_aot_autograd/graph_compile.py:1943:16: warning[possibly-missing-attribute] Submodule `compiled_autograd` may not be available as an attribute on module `torch._dynamo` torch/_functorch/_aot_autograd/graph_compile.py:2069:19: error[unresolved-attribute] Module `torch._C` has no member `_is_any_autocast_enabled` torch/_functorch/_aot_autograd/graph_compile.py:2199:36: error[invalid-assignment] Implicit shadowing of function `try_save_cache_entry` torch/_functorch/_aot_autograd/graph_compile.py:2248:13: error[unresolved-attribute] Module `torch._C` has no member `_DisableAutocast` torch/_functorch/_aot_autograd/graph_compile.py:2249:16: error[unresolved-attribute] Module `torch._C` has no member `_is_any_autocast_enabled` torch/_functorch/_aot_autograd/graph_compile.py:2256:24: error[unresolved-attribute] Module `torch._C` has no member `_DisableAutocast` -torch/_functorch/_aot_autograd/graph_compile.py:2287:31: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_functorch/_aot_autograd/graph_compile.py:2287:31: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_functorch/_aot_autograd/graph_compile.py:2293:32: error[call-non-callable] Object of type `None` is not callable torch/_functorch/_aot_autograd/input_output_analysis.py:77:61: error[unresolved-attribute] Module `torch` has no member `contiguous_format` -torch/_functorch/_aot_autograd/input_output_analysis.py:306:23: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_functorch/_aot_autograd/logging_utils.py:51:27: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_functorch/_aot_autograd/logging_utils.py:64:35: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_functorch/_aot_autograd/runtime_wrappers.py:236:8: error[unresolved-attribute] Module `torch._dynamo` has no member `compiled_autograd` -torch/_functorch/_aot_autograd/runtime_wrappers.py:239:17: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_functorch/_aot_autograd/runtime_wrappers.py:241:9: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_functorch/_aot_autograd/runtime_wrappers.py:300:18: error[unresolved-attribute] Module `torch._C` has no member `_profiler` +torch/_functorch/_aot_autograd/input_output_analysis.py:306:23: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/logging_utils.py:51:27: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/logging_utils.py:64:35: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/runtime_wrappers.py:236:8: warning[possibly-missing-attribute] Submodule `compiled_autograd` may not be available as an attribute on module `torch._dynamo` +torch/_functorch/_aot_autograd/runtime_wrappers.py:239:17: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/runtime_wrappers.py:241:9: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/runtime_wrappers.py:300:18: warning[possibly-missing-attribute] Submodule `_profiler` may not be available as an attribute on module `torch._C` torch/_functorch/_aot_autograd/runtime_wrappers.py:352:28: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_functorch/_aot_autograd/runtime_wrappers.py:355:21: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` torch/_functorch/_aot_autograd/runtime_wrappers.py:362:21: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` torch/_functorch/_aot_autograd/runtime_wrappers.py:465:13: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` -torch/_functorch/_aot_autograd/runtime_wrappers.py:574:27: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_functorch/_aot_autograd/runtime_wrappers.py:492:9: error[invalid-method-override] Invalid override of method `pre_compile`: Definition is incompatible with `InductorWrapper.pre_compile` +torch/_functorch/_aot_autograd/runtime_wrappers.py:574:27: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/runtime_wrappers.py:674:9: error[invalid-method-override] Invalid override of method `post_compile`: Definition is incompatible with `CompilerWrapper.post_compile` +torch/_functorch/_aot_autograd/runtime_wrappers.py:712:9: error[invalid-method-override] Invalid override of method `post_compile`: Definition is incompatible with `CompilerWrapper.post_compile` torch/_functorch/_aot_autograd/runtime_wrappers.py:966:39: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method torch/_functorch/_aot_autograd/runtime_wrappers.py:969:39: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method torch/_functorch/_aot_autograd/runtime_wrappers.py:1487:30: error[unresolved-attribute] Module `torch` has no member `empty` -torch/_functorch/_aot_autograd/runtime_wrappers.py:1592:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_functorch/_aot_autograd/runtime_wrappers.py:1592:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_functorch/_aot_autograd/runtime_wrappers.py:1798:9: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_functorch/_aot_autograd/runtime_wrappers.py:1811:26: error[unresolved-attribute] Module `torch` has no member `Generator` torch/_functorch/_aot_autograd/runtime_wrappers.py:1812:26: error[unresolved-attribute] Module `torch` has no member `Generator` -torch/_functorch/_aot_autograd/runtime_wrappers.py:1827:10: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_functorch/_aot_autograd/runtime_wrappers.py:1827:10: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_functorch/_aot_autograd/runtime_wrappers.py:1828:17: error[unresolved-attribute] Module `torch` has no member `randint` torch/_functorch/_aot_autograd/runtime_wrappers.py:1828:34: error[unresolved-attribute] Module `torch` has no member `iinfo` torch/_functorch/_aot_autograd/runtime_wrappers.py:1828:46: error[unresolved-attribute] Module `torch` has no member `int64` torch/_functorch/_aot_autograd/runtime_wrappers.py:1897:17: error[unresolved-attribute] Module `torch` has no member `empty_strided` -torch/_functorch/_aot_autograd/runtime_wrappers.py:1923:13: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/_functorch/_aot_autograd/runtime_wrappers.py:1925:9: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/_functorch/_aot_autograd/runtime_wrappers.py:1931:13: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/_functorch/_aot_autograd/runtime_wrappers.py:1933:13: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/_functorch/_aot_autograd/runtime_wrappers.py:1988:26: error[unresolved-attribute] Module `torch._subclasses` has no member `functional_tensor` +torch/_functorch/_aot_autograd/runtime_wrappers.py:1923:13: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/_functorch/_aot_autograd/runtime_wrappers.py:1925:9: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/_functorch/_aot_autograd/runtime_wrappers.py:1931:13: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/_functorch/_aot_autograd/runtime_wrappers.py:1933:13: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/_functorch/_aot_autograd/runtime_wrappers.py:1988:26: warning[possibly-missing-attribute] Submodule `functional_tensor` may not be available as an attribute on module `torch._subclasses` torch/_functorch/_aot_autograd/runtime_wrappers.py:2096:30: error[unresolved-attribute] Module `torch` has no member `Generator` torch/_functorch/_aot_autograd/runtime_wrappers.py:2097:30: error[unresolved-attribute] Module `torch` has no member `Generator` -torch/_functorch/_aot_autograd/runtime_wrappers.py:2288:25: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/_functorch/_aot_autograd/runtime_wrappers.py:2288:25: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/_functorch/_aot_autograd/runtime_wrappers.py:2331:30: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` -torch/_functorch/_aot_autograd/runtime_wrappers.py:2375:25: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/_functorch/_aot_autograd/runtime_wrappers.py:2375:25: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/_functorch/_aot_autograd/runtime_wrappers.py:2442:31: error[unresolved-attribute] Module `torch._C` has no member `_DisableAutocast` -torch/_functorch/_aot_autograd/runtime_wrappers.py:2478:21: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_functorch/_aot_autograd/runtime_wrappers.py:2478:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_functorch/_aot_autograd/schemas.py:175:29: error[unresolved-attribute] Module `torch` has no member `memory_format` -torch/_functorch/_aot_autograd/schemas.py:185:17: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_functorch/_aot_autograd/schemas.py:200:31: error[unresolved-attribute] Module `torch` has no member `_prims_common` +torch/_functorch/_aot_autograd/schemas.py:185:17: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_functorch/_aot_autograd/schemas.py:200:31: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` torch/_functorch/_aot_autograd/streams.py:20:31: error[unresolved-attribute] Module `torch` has no member `device` torch/_functorch/_aot_autograd/subclass_utils.py:243:44: error[invalid-argument-type] Argument to function `flatten_subclass` is incorrect: Expected `AOTDescriptor@unwrap_tensor_subclasses`, found `SubclassGetAttrAOTInput | SubclassGetAttrAOTOutput` torch/_functorch/_aot_autograd/subclass_utils.py:287:26: warning[possibly-missing-attribute] Attribute `attrs` may be missing on object of type `SubclassCreationMeta | None` @@ -2217,11 +2284,11 @@ torch/_functorch/_aot_autograd/utils.py:101:9: error[unresolved-attribute] Modul torch/_functorch/_aot_autograd/utils.py:131:15: error[unresolved-attribute] Module `torch._C` has no member `_DisableAutocast` torch/_functorch/_aot_autograd/utils.py:288:42: error[unresolved-attribute] Module `torch` has no member `tensor` torch/_functorch/_aot_autograd/utils.py:289:50: error[unresolved-attribute] Module `torch` has no member `tensor` -torch/_functorch/_aot_autograd/utils.py:523:26: error[unresolved-attribute] Module `torch.fx.experimental` has no member `proxy_tensor` -torch/_functorch/_aot_autograd/utils.py:525:21: error[unresolved-attribute] Module `torch.fx.experimental` has no member `proxy_tensor` +torch/_functorch/_aot_autograd/utils.py:523:26: warning[possibly-missing-attribute] Submodule `proxy_tensor` may not be available as an attribute on module `torch.fx.experimental` +torch/_functorch/_aot_autograd/utils.py:525:21: warning[possibly-missing-attribute] Submodule `proxy_tensor` may not be available as an attribute on module `torch.fx.experimental` torch/_functorch/_aot_autograd/utils.py:545:17: error[unresolved-attribute] Module `torch` has no member `Tag` -torch/_functorch/_aot_autograd/utils.py:563:12: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/_functorch/aot_autograd.py:564:16: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_functorch/_aot_autograd/utils.py:563:12: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/_functorch/aot_autograd.py:564:16: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_functorch/aot_autograd.py:598:25: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> InputAliasInfo, (s: slice[Any, Any, Any], /) -> list[InputAliasInfo]]` cannot be called with key of type `int | None` on object of type `list[InputAliasInfo]` torch/_functorch/aot_autograd.py:785:9: error[invalid-argument-type] Argument is incorrect: Expected `(...) -> Unknown`, found `None` torch/_functorch/aot_autograd.py:786:9: error[invalid-argument-type] Argument is incorrect: Expected `(...) -> Unknown`, found `None` @@ -2229,7 +2296,7 @@ torch/_functorch/aot_autograd.py:788:9: error[invalid-argument-type] Argument is torch/_functorch/aot_autograd.py:789:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[OpOverload[Unknown, Any], (...) -> Unknown]`, found `dict[Unknown, Unknown] | None` torch/_functorch/aot_autograd.py:871:58: error[invalid-argument-type] Argument to function `assert_no_fake_params_or_buffers` is incorrect: Expected `GraphModule`, found `Module` torch/_functorch/aot_autograd.py:881:33: error[parameter-already-assigned] Multiple values provided for parameter `num_params_buffers` of function `aot_function` -torch/_functorch/aot_autograd.py:970:27: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_functorch/aot_autograd.py:970:27: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_functorch/aot_autograd.py:994:9: error[invalid-argument-type] Argument is incorrect: Expected `(...) -> Unknown`, found `None` torch/_functorch/aot_autograd.py:995:9: error[invalid-argument-type] Argument is incorrect: Expected `(...) -> Unknown`, found `None` torch/_functorch/aot_autograd.py:997:9: error[invalid-argument-type] Argument is incorrect: Expected `(...) -> Unknown`, found `None` @@ -2240,7 +2307,7 @@ torch/_functorch/aot_autograd.py:1155:5: error[unresolved-attribute] Unresolved torch/_functorch/aot_autograd.py:1156:5: error[unresolved-attribute] Unresolved attribute `named_parameters` on type `(...) -> Unknown`. torch/_functorch/aot_autograd.py:1157:5: error[unresolved-attribute] Unresolved attribute `named_buffers` on type `(...) -> Unknown`. torch/_functorch/aot_autograd.py:1169:12: error[invalid-return-type] Return type does not match returned value: expected `Module`, found `(...) -> Unknown` -torch/_functorch/aot_autograd.py:1174:14: error[unresolved-attribute] Module `torch.fx` has no member `traceback` +torch/_functorch/aot_autograd.py:1174:14: warning[possibly-missing-attribute] Submodule `traceback` may not be available as an attribute on module `torch.fx` torch/_functorch/aot_autograd.py:1177:5: error[unresolved-attribute] Unresolved attribute `_boxed_call` on type `def run(args) -> Unknown`. torch/_functorch/aot_autograd.py:1270:9: error[invalid-argument-type] Argument to function `prepare_aot_module_simplified` is incorrect: Expected `dict[Unknown, Unknown]`, found `dict[Unknown, Unknown] | None` torch/_functorch/aot_autograd.py:1272:9: error[invalid-argument-type] Argument to function `prepare_aot_module_simplified` is incorrect: Expected `BoxedDeviceIndex`, found `None` @@ -2302,7 +2369,7 @@ torch/_functorch/eager_transforms.py:24:5: error[unresolved-import] Module `torc torch/_functorch/eager_transforms.py:87:40: error[invalid-argument-type] Argument to function `_unwrap_for_grad` is incorrect: Expected `int`, found `Unknown | None` torch/_functorch/eager_transforms.py:104:20: error[missing-argument] No argument provided for required parameter `treespec` of function `tree_unflatten` torch/_functorch/eager_transforms.py:141:22: error[unresolved-attribute] Module `torch` has no member `zeros_like` -torch/_functorch/eager_transforms.py:142:10: error[unresolved-attribute] Module `torch._dynamo` has no member `compiled_autograd` +torch/_functorch/eager_transforms.py:142:10: warning[possibly-missing-attribute] Submodule `compiled_autograd` may not be available as an attribute on module `torch._dynamo` torch/_functorch/eager_transforms.py:152:9: error[unresolved-attribute] Module `torch` has no member `zeros_like` torch/_functorch/eager_transforms.py:387:32: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_functorch/eager_transforms.py:603:35: error[unresolved-attribute] Module `torch` has no member `squeeze` @@ -2346,33 +2413,33 @@ torch/_functorch/partitioners.py:450:17: error[unresolved-attribute] Module `tor torch/_functorch/partitioners.py:458:25: error[unresolved-attribute] Module `torch` has no member `float32` torch/_functorch/partitioners.py:461:31: error[unresolved-attribute] Module `torch` has no member `float32` torch/_functorch/partitioners.py:533:34: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/_functorch/partitioners.py:534:22: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_functorch/partitioners.py:547:22: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_functorch/partitioners.py:552:12: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_functorch/partitioners.py:558:12: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_functorch/partitioners.py:534:22: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_functorch/partitioners.py:547:22: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_functorch/partitioners.py:552:12: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_functorch/partitioners.py:558:12: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_functorch/partitioners.py:569:25: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/_functorch/partitioners.py:570:18: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_functorch/partitioners.py:570:18: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_functorch/partitioners.py:577:28: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_functorch/partitioners.py:585:12: error[unresolved-attribute] Module `torch` has no member `finfo` -torch/_functorch/partitioners.py:600:16: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_functorch/partitioners.py:661:16: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_functorch/partitioners.py:789:8: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_functorch/partitioners.py:843:8: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_functorch/partitioners.py:985:18: error[unresolved-attribute] Module `torch.fx` has no member `_lazy_graph_module` -torch/_functorch/partitioners.py:986:18: error[unresolved-attribute] Module `torch.fx` has no member `_lazy_graph_module` +torch/_functorch/partitioners.py:600:16: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_functorch/partitioners.py:661:16: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_functorch/partitioners.py:789:8: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_functorch/partitioners.py:843:8: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_functorch/partitioners.py:985:18: warning[possibly-missing-attribute] Submodule `_lazy_graph_module` may not be available as an attribute on module `torch.fx` +torch/_functorch/partitioners.py:986:18: warning[possibly-missing-attribute] Submodule `_lazy_graph_module` may not be available as an attribute on module `torch.fx` torch/_functorch/partitioners.py:1187:16: error[unresolved-attribute] Module `torch` has no member `Tag` torch/_functorch/partitioners.py:1248:28: error[invalid-assignment] Object of type `list[Node]` is not assignable to `OrderedSet[Node]` torch/_functorch/partitioners.py:1285:13: error[unresolved-attribute] Module `torch` has no member `device` -torch/_functorch/partitioners.py:1325:36: error[unresolved-attribute] Module `torch` has no member `_prims` +torch/_functorch/partitioners.py:1325:36: warning[possibly-missing-attribute] Submodule `_prims` may not be available as an attribute on module `torch` torch/_functorch/partitioners.py:1406:21: error[unresolved-attribute] Module `torch` has no member `Tag` torch/_functorch/partitioners.py:1411:38: error[unresolved-attribute] Module `torch` has no member `device` torch/_functorch/partitioners.py:1427:16: error[unresolved-attribute] Module `torch` has no member `device` torch/_functorch/partitioners.py:1429:47: error[unresolved-attribute] Module `torch` has no member `device` torch/_functorch/partitioners.py:1448:17: error[unresolved-attribute] Module `torch` has no member `Tag` -torch/_functorch/partitioners.py:1455:24: error[unresolved-attribute] Module `torch` has no member `_prims` -torch/_functorch/partitioners.py:1456:26: error[unresolved-attribute] Module `torch` has no member `_prims` +torch/_functorch/partitioners.py:1455:24: warning[possibly-missing-attribute] Submodule `_prims` may not be available as an attribute on module `torch` +torch/_functorch/partitioners.py:1456:26: warning[possibly-missing-attribute] Submodule `_prims` may not be available as an attribute on module `torch` torch/_functorch/partitioners.py:1477:21: error[unresolved-attribute] Module `torch` has no member `device` -torch/_functorch/partitioners.py:1484:18: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_functorch/partitioners.py:1484:18: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_functorch/partitioners.py:1732:16: error[unresolved-import] Cannot resolve imported module `networkx` torch/_functorch/partitioners.py:2071:12: error[unresolved-import] Cannot resolve imported module `networkx` torch/_functorch/partitioners.py:2072:12: error[unresolved-import] Cannot resolve imported module `pydot` @@ -2392,22 +2459,24 @@ torch/_functorch/partitioners.py:2666:13: warning[possibly-missing-attribute] Me torch/_functorch/partitioners.py:2667:40: warning[possibly-missing-attribute] Member `distributed_c10d` may be missing on module `torch.distributed` torch/_functorch/partitioners.py:2670:35: error[unresolved-attribute] Module `torch` has no member `argmin` torch/_functorch/predispatch.py:17:5: error[unresolved-import] Module `torch._C._functorch` has no member `_remove_batch_dim` -torch/_functorch/pyfunctorch.py:102:15: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_functorch/pyfunctorch.py:278:19: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_functorch/pyfunctorch.py:284:11: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_functorch/pyfunctorch.py:296:12: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_functorch/pyfunctorch.py:314:23: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_functorch/pyfunctorch.py:102:15: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_functorch/pyfunctorch.py:278:19: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_functorch/pyfunctorch.py:284:11: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_functorch/pyfunctorch.py:296:12: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_functorch/pyfunctorch.py:314:23: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_functorch/vmap.py:225:66: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Unknown]`, found `list[Unknown | int] | tuple[int, ...] | list[Any] | None` torch/_functorch/vmap.py:349:16: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `list[Any] | None` torch/_functorch/vmap.py:351:35: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Any]`, found `list[Any] | None` torch/_functorch/vmap.py:352:28: error[unresolved-attribute] Module `torch` has no member `cat` -torch/_functorch/vmap.py:481:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_guards.py:279:40: error[unresolved-attribute] Module `torch._dynamo` has no member `guards` +torch/_functorch/vmap.py:481:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_guards.py:279:40: warning[possibly-missing-attribute] Submodule `guards` may not be available as an attribute on module `torch._dynamo` torch/_guards.py:286:13: error[unresolved-attribute] Object of type `(GuardBuilderBase, Guard, /) -> Any` has no attribute `__code__` torch/_guards.py:294:20: error[invalid-return-type] Return type does not match returned value: expected `(GuardBuilderBase, Guard, /) -> Any`, found `() -> object` torch/_guards.py:333:78: error[unresolved-attribute] Object of type `(GuardBuilderBase, Guard, /) -> Any` has no attribute `__name__` torch/_guards.py:347:43: error[unresolved-attribute] Object of type `(GuardBuilderBase, Guard, /) -> Any` has no attribute `__name__` torch/_guards.py:377:16: error[unresolved-attribute] Object of type `(() -> object) | (((GuardBuilderBase, Guard, /) -> None) & ~Top[partial[Unknown]])` has no attribute `__name__` +torch/_higher_order_ops/_invoke_quant.py:15:9: error[invalid-method-override] Invalid override of method `__call__`: Definition is incompatible with `BaseHOP.__call__` +torch/_higher_order_ops/_invoke_quant.py:29:9: error[invalid-method-override] Invalid override of method `__call__`: Definition is incompatible with `BaseHOP.__call__` torch/_higher_order_ops/aoti_call_delegate.py:57:32: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/_higher_order_ops/aoti_call_delegate.py:58:32: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/_higher_order_ops/aoti_call_delegate.py:59:32: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` @@ -2446,28 +2515,28 @@ torch/_higher_order_ops/auto_functionalize.py:454:12: error[unresolved-attribute torch/_higher_order_ops/auto_functionalize.py:460:13: error[unresolved-attribute] Module `torch` has no member `FunctionSchema` torch/_higher_order_ops/auto_functionalize.py:461:28: error[unresolved-attribute] Module `torch` has no member `Type` torch/_higher_order_ops/auto_functionalize.py:480:63: error[unresolved-attribute] Module `torch` has no member `Type` -torch/_higher_order_ops/auto_functionalize.py:485:12: error[unresolved-attribute] Module `torch._subclasses` has no member `functional_tensor` -torch/_higher_order_ops/auto_functionalize.py:599:12: error[unresolved-attribute] Module `torch._subclasses` has no member `functional_tensor` +torch/_higher_order_ops/auto_functionalize.py:485:12: warning[possibly-missing-attribute] Submodule `functional_tensor` may not be available as an attribute on module `torch._subclasses` +torch/_higher_order_ops/auto_functionalize.py:599:12: warning[possibly-missing-attribute] Submodule `functional_tensor` may not be available as an attribute on module `torch._subclasses` torch/_higher_order_ops/auto_functionalize.py:614:10: error[invalid-assignment] Object of type `Unknown | HigherOrderOperator | (OpOverload[Unknown, Any] & ~HopInstance)` is not assignable to `OpOverload[Unknown, Any] | HopInstance` torch/_higher_order_ops/auto_functionalize.py:854:17: error[unresolved-attribute] Module `torch._C` has no member `FunctionSchema` torch/_higher_order_ops/base_hop.py:7:22: error[unresolved-import] Module `torch._C` has no member `DispatchKey` torch/_higher_order_ops/base_hop.py:226:14: error[unresolved-attribute] Module `torch._C` has no member `_AutoDispatchBelowAutograd` torch/_higher_order_ops/cond.py:12:22: error[unresolved-import] Module `torch._C` has no member `DispatchKey` -torch/_higher_order_ops/cond.py:247:15: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` +torch/_higher_order_ops/cond.py:247:15: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` torch/_higher_order_ops/cond.py:308:35: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_local_include_set` torch/_higher_order_ops/cond.py:309:35: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_local_exclude_set` torch/_higher_order_ops/cond.py:312:14: error[unresolved-attribute] Module `torch._C` has no member `_AutoDispatchBelowAutograd` -torch/_higher_order_ops/cond.py:442:17: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` +torch/_higher_order_ops/cond.py:442:17: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` torch/_higher_order_ops/cond.py:567:20: error[unresolved-attribute] Module `torch` has no member `Size` torch/_higher_order_ops/cond.py:568:20: error[unresolved-attribute] Module `torch` has no member `Size` torch/_higher_order_ops/cond.py:654:16: error[unresolved-attribute] Module `torch` has no member `empty_strided` -torch/_higher_order_ops/cond.py:680:18: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_higher_order_ops/cond.py:680:18: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_higher_order_ops/cond.py:708:20: error[unresolved-attribute] Module `torch` has no member `where` torch/_higher_order_ops/effects.py:6:22: error[unresolved-import] Module `torch._C` has no member `DispatchKey` -torch/_higher_order_ops/effects.py:24:6: error[unresolved-attribute] Module `torch._library` has no member `custom_ops` +torch/_higher_order_ops/effects.py:24:6: warning[possibly-missing-attribute] Submodule `custom_ops` may not be available as an attribute on module `torch._library` torch/_higher_order_ops/effects.py:35:16: error[invalid-return-type] Return type does not match returned value: expected `str`, found `object` -torch/_higher_order_ops/effects.py:50:13: error[unresolved-attribute] Module `torch._library` has no member `simple_registry` -torch/_higher_order_ops/effects.py:57:13: error[unresolved-attribute] Module `torch._library` has no member `simple_registry` +torch/_higher_order_ops/effects.py:50:13: warning[possibly-missing-attribute] Submodule `simple_registry` may not be available as an attribute on module `torch._library` +torch/_higher_order_ops/effects.py:57:13: warning[possibly-missing-attribute] Submodule `simple_registry` may not be available as an attribute on module `torch._library` torch/_higher_order_ops/effects.py:130:12: error[unresolved-attribute] Module `torch` has no member `tensor` torch/_higher_order_ops/effects.py:201:61: error[unresolved-attribute] Module `torch` has no member `FunctionSchema` torch/_higher_order_ops/effects.py:243:29: error[unresolved-attribute] Module `torch._C` has no member `_get_dispatch_mode` @@ -2502,8 +2571,8 @@ torch/_higher_order_ops/flex_attention.py:258:23: error[unresolved-attribute] Mo torch/_higher_order_ops/flex_attention.py:329:35: error[unresolved-attribute] Module `torch` has no member `int` torch/_higher_order_ops/flex_attention.py:331:52: error[unresolved-attribute] Module `torch` has no member `int` torch/_higher_order_ops/flex_attention.py:358:34: warning[possibly-missing-attribute] Attribute `unwrap_proxy` may be missing on object of type `(Unknown & Tracer) | PythonKeyTracer | (_GraphAppendingTracerEx & Tracer)` -torch/_higher_order_ops/flex_attention.py:359:10: error[unresolved-attribute] Module `torch.fx.experimental` has no member `proxy_tensor` -torch/_higher_order_ops/flex_attention.py:402:10: error[unresolved-attribute] Module `torch._subclasses` has no member `functional_tensor` +torch/_higher_order_ops/flex_attention.py:359:10: warning[possibly-missing-attribute] Submodule `proxy_tensor` may not be available as an attribute on module `torch.fx.experimental` +torch/_higher_order_ops/flex_attention.py:402:10: warning[possibly-missing-attribute] Submodule `functional_tensor` may not be available as an attribute on module `torch._subclasses` torch/_higher_order_ops/flex_attention.py:454:48: error[unresolved-attribute] Module `torch` has no member `int` torch/_higher_order_ops/flex_attention.py:516:73: error[unresolved-attribute] Module `torch` has no member `float32` torch/_higher_order_ops/flex_attention.py:517:74: error[unresolved-attribute] Module `torch` has no member `float32` @@ -2534,8 +2603,8 @@ torch/_higher_order_ops/flex_attention.py:979:29: error[unresolved-attribute] Mo torch/_higher_order_ops/flex_attention.py:1037:35: error[unresolved-attribute] Module `torch` has no member `int` torch/_higher_order_ops/flex_attention.py:1040:52: error[unresolved-attribute] Module `torch` has no member `int` torch/_higher_order_ops/flex_attention.py:1080:34: warning[possibly-missing-attribute] Attribute `unwrap_proxy` may be missing on object of type `(Unknown & Tracer) | PythonKeyTracer | (_GraphAppendingTracerEx & Tracer)` -torch/_higher_order_ops/flex_attention.py:1118:10: error[unresolved-attribute] Module `torch.fx.experimental` has no member `proxy_tensor` -torch/_higher_order_ops/flex_attention.py:1142:10: error[unresolved-attribute] Module `torch._subclasses` has no member `functional_tensor` +torch/_higher_order_ops/flex_attention.py:1118:10: warning[possibly-missing-attribute] Submodule `proxy_tensor` may not be available as an attribute on module `torch.fx.experimental` +torch/_higher_order_ops/flex_attention.py:1142:10: warning[possibly-missing-attribute] Submodule `functional_tensor` may not be available as an attribute on module `torch._subclasses` torch/_higher_order_ops/flex_attention.py:1277:18: error[unresolved-attribute] Module `torch` has no member `empty_like` torch/_higher_order_ops/flex_attention.py:1281:13: error[unresolved-attribute] Module `torch` has no member `empty_like` torch/_higher_order_ops/flex_attention.py:1281:52: error[unresolved-attribute] Module `torch` has no member `contiguous_format` @@ -2544,8 +2613,8 @@ torch/_higher_order_ops/flex_attention.py:1296:22: error[unresolved-attribute] M torch/_higher_order_ops/hints_wrap.py:4:22: error[unresolved-import] Module `torch._C` has no member `DispatchKey` torch/_higher_order_ops/invoke_subgraph.py:10:22: error[unresolved-import] Module `torch._C` has no member `DispatchKey` torch/_higher_order_ops/invoke_subgraph.py:81:61: error[unresolved-attribute] Module `torch` has no member `Generator` -torch/_higher_order_ops/invoke_subgraph.py:187:23: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_higher_order_ops/invoke_subgraph.py:410:18: error[unresolved-attribute] Module `torch.fx` has no member `traceback` +torch/_higher_order_ops/invoke_subgraph.py:187:23: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_higher_order_ops/invoke_subgraph.py:410:18: warning[possibly-missing-attribute] Submodule `traceback` may not be available as an attribute on module `torch.fx` torch/_higher_order_ops/invoke_subgraph.py:443:21: error[unresolved-attribute] Module `torch._C` has no member `_ForceDispatchKeyGuard` torch/_higher_order_ops/invoke_subgraph.py:474:35: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_local_include_set` torch/_higher_order_ops/invoke_subgraph.py:475:35: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_local_exclude_set` @@ -2553,12 +2622,12 @@ torch/_higher_order_ops/invoke_subgraph.py:479:14: error[unresolved-attribute] M torch/_higher_order_ops/invoke_subgraph.py:536:28: error[invalid-assignment] Object of type `tuple[object, ...]` is not assignable to `list[object]` torch/_higher_order_ops/local_map.py:16:22: error[unresolved-import] Module `torch._C` has no member `DispatchKey` torch/_higher_order_ops/local_map.py:59:16: error[unresolved-attribute] Module `torch` has no member `empty_strided` -torch/_higher_order_ops/local_map.py:124:9: error[unresolved-attribute] Module `torch.distributed` has no member `tensor` +torch/_higher_order_ops/local_map.py:124:9: warning[possibly-missing-attribute] Submodule `tensor` may not be available as an attribute on module `torch.distributed` torch/_higher_order_ops/local_map.py:135:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[Tensor, int, SymInt, None]`, found `tuple[@Todo, @Todo]` -torch/_higher_order_ops/local_map.py:140:13: error[unresolved-attribute] Module `torch.distributed` has no member `tensor` -torch/_higher_order_ops/local_map.py:156:9: error[unresolved-attribute] Module `torch.distributed` has no member `tensor` +torch/_higher_order_ops/local_map.py:140:13: warning[possibly-missing-attribute] Submodule `tensor` may not be available as an attribute on module `torch.distributed` +torch/_higher_order_ops/local_map.py:156:9: warning[possibly-missing-attribute] Submodule `tensor` may not be available as an attribute on module `torch.distributed` torch/_higher_order_ops/local_map.py:158:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[Tensor, int, SymInt, None]`, found `tuple[@Todo, @Todo]` -torch/_higher_order_ops/local_map.py:172:9: error[unresolved-attribute] Module `torch.distributed` has no member `tensor` +torch/_higher_order_ops/local_map.py:172:9: warning[possibly-missing-attribute] Submodule `tensor` may not be available as an attribute on module `torch.distributed` torch/_higher_order_ops/local_map.py:407:14: error[unresolved-attribute] Module `torch._C` has no member `_AutoDispatchBelowAutograd` torch/_higher_order_ops/local_map.py:434:14: error[unresolved-attribute] Module `torch._C` has no member `_AutoDispatchBelowAutograd` torch/_higher_order_ops/local_map.py:454:24: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` @@ -2593,7 +2662,7 @@ torch/_higher_order_ops/scan.py:329:38: error[unresolved-attribute] Module `torc torch/_higher_order_ops/scan.py:467:14: error[unresolved-attribute] Module `torch._C` has no member `_AutoDispatchBelowAutograd` torch/_higher_order_ops/scan.py:683:13: error[unresolved-attribute] Module `torch` has no member `zeros_like` torch/_higher_order_ops/scan.py:773:14: error[unresolved-attribute] Module `torch` has no member `flip` -torch/_higher_order_ops/scan.py:869:18: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_higher_order_ops/scan.py:869:18: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_higher_order_ops/scan.py:959:9: error[unresolved-attribute] Module `torch` has no member `stack` torch/_higher_order_ops/schema.py:53:14: error[unresolved-attribute] Module `torch._C` has no member `IntType` torch/_higher_order_ops/schema.py:54:16: error[unresolved-attribute] Module `torch._C` has no member `FloatType` @@ -2613,7 +2682,7 @@ torch/_higher_order_ops/schema.py:286:11: error[unresolved-attribute] Module `to torch/_higher_order_ops/strict_mode.py:7:22: error[unresolved-import] Module `torch._C` has no member `DispatchKey` torch/_higher_order_ops/torchbind.py:6:22: error[unresolved-import] Module `torch._C` has no member `DispatchKey` torch/_higher_order_ops/torchbind.py:37:32: error[unresolved-attribute] Module `torch` has no member `FunctionSchema` -torch/_higher_order_ops/torchbind.py:41:32: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_higher_order_ops/torchbind.py:41:32: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_higher_order_ops/torchbind.py:51:22: error[unresolved-attribute] Module `torch._C` has no member `parse_schema` torch/_higher_order_ops/torchbind.py:64:27: error[unresolved-attribute] Module `torch` has no member `ScriptMethod` torch/_higher_order_ops/torchbind.py:80:28: error[unresolved-attribute] Module `torch` has no member `ScriptObject` @@ -2658,28 +2727,28 @@ torch/_higher_order_ops/triton_kernel_wrap.py:1140:5: error[non-subscriptable] C torch/_higher_order_ops/triton_kernel_wrap.py:1186:14: error[unresolved-attribute] Object of type `(...) -> Any` has no attribute `__name__` torch/_higher_order_ops/triton_kernel_wrap.py:1536:14: error[unresolved-import] Cannot resolve imported module `triton.runtime.autotuner` torch/_higher_order_ops/triton_kernel_wrap.py:1546:9: error[invalid-assignment] Object of type `tuple[int | Expr | SymInt, ...] | ((dict[str, int], /) -> tuple[int, ...]) | None` is not assignable to attribute `grid` on type `TraceableTritonKernelWrapper | TritonKernelVariable` -torch/_higher_order_ops/triton_kernel_wrap.py:1569:21: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_higher_order_ops/triton_kernel_wrap.py:1580:21: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_higher_order_ops/triton_kernel_wrap.py:1569:21: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_higher_order_ops/triton_kernel_wrap.py:1580:21: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_higher_order_ops/triton_kernel_wrap.py:1650:14: error[unresolved-import] Cannot resolve imported module `triton` torch/_higher_order_ops/triton_kernel_wrap.py:1651:14: error[unresolved-import] Cannot resolve imported module `triton.runtime.autotuner` torch/_higher_order_ops/triton_kernel_wrap.py:1887:41: warning[possibly-missing-attribute] Attribute `arg_names` may be missing on object of type `Unknown | Autotuner | JITFunction` -torch/_higher_order_ops/triton_kernel_wrap.py:2014:33: error[unresolved-attribute] Module `collections` has no member `abc` +torch/_higher_order_ops/triton_kernel_wrap.py:2019:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[int | Expr | SymInt, ...]`, found `tuple[object, ...]` torch/_higher_order_ops/triton_kernel_wrap.py:2097:20: warning[possibly-missing-attribute] Attribute `run` may be missing on object of type `(Unknown & ~None) | Autotuner | JITFunction` torch/_higher_order_ops/triton_kernel_wrap.py:2109:20: error[non-subscriptable] Cannot subscript object of type `Autotuner` with no `__getitem__` method torch/_higher_order_ops/triton_kernel_wrap.py:2109:20: error[non-subscriptable] Cannot subscript object of type `JITFunction` with no `__getitem__` method torch/_higher_order_ops/utils.py:52:10: error[unresolved-attribute] Module `torch._C` has no member `_AutoDispatchBelowAutograd` torch/_higher_order_ops/utils.py:55:12: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` -torch/_higher_order_ops/utils.py:59:26: error[unresolved-attribute] Module `torch._C` has no member `_functions` +torch/_higher_order_ops/utils.py:59:26: warning[possibly-missing-attribute] Submodule `_functions` may not be available as an attribute on module `torch._C` torch/_higher_order_ops/utils.py:65:24: error[unresolved-attribute] Module `torch` has no member `is_floating_point` torch/_higher_order_ops/utils.py:65:59: error[unresolved-attribute] Module `torch` has no member `is_complex` -torch/_higher_order_ops/utils.py:206:19: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` -torch/_higher_order_ops/utils.py:223:15: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` +torch/_higher_order_ops/utils.py:206:19: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` +torch/_higher_order_ops/utils.py:223:15: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` torch/_higher_order_ops/utils.py:274:9: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `allow_empty_graphs` of type `Literal[False]` -torch/_higher_order_ops/utils.py:394:24: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_higher_order_ops/utils.py:396:26: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_higher_order_ops/utils.py:399:31: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_higher_order_ops/utils.py:401:30: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_higher_order_ops/utils.py:402:35: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_higher_order_ops/utils.py:394:24: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_higher_order_ops/utils.py:396:26: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_higher_order_ops/utils.py:399:31: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_higher_order_ops/utils.py:401:30: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_higher_order_ops/utils.py:402:35: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_higher_order_ops/utils.py:458:23: error[unresolved-attribute] Module `torch` has no member `bool` torch/_higher_order_ops/utils.py:459:20: error[unresolved-attribute] Module `torch` has no member `empty_strided` torch/_higher_order_ops/utils.py:473:18: error[unresolved-attribute] Module `torch` has no member `_is_functional_tensor` @@ -2695,14 +2764,14 @@ torch/_higher_order_ops/utils.py:1144:31: error[unresolved-attribute] Module `to torch/_higher_order_ops/utils.py:1145:31: error[unresolved-attribute] Module `torch._C` has no member `DispatchKeySet` torch/_higher_order_ops/utils.py:1149:27: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_local_include_set` torch/_higher_order_ops/utils.py:1151:27: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_local_exclude_set` -torch/_higher_order_ops/utils.py:1161:21: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_higher_order_ops/utils.py:1161:21: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_higher_order_ops/utils.py:1164:21: error[unresolved-attribute] Module `torch._C` has no member `_ForceDispatchKeyGuard` torch/_higher_order_ops/utils.py:1194:31: error[unresolved-attribute] Module `torch._C` has no member `FunctionSchema` torch/_higher_order_ops/while_loop.py:9:22: error[unresolved-import] Module `torch._C` has no member `DispatchKey` torch/_higher_order_ops/while_loop.py:269:32: error[unresolved-attribute] Module `torch` has no member `Size` torch/_higher_order_ops/while_loop.py:270:31: error[unresolved-attribute] Module `torch` has no member `bool` torch/_higher_order_ops/while_loop.py:320:25: error[unresolved-attribute] Module `torch` has no member `stack` -torch/_higher_order_ops/while_loop.py:341:17: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_higher_order_ops/while_loop.py:341:17: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_higher_order_ops/while_loop.py:716:14: error[unresolved-attribute] Module `torch._C` has no member `_AutoDispatchBelowAutograd` torch/_higher_order_ops/while_loop.py:756:35: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_local_include_set` torch/_higher_order_ops/while_loop.py:757:35: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_local_exclude_set` @@ -2830,40 +2899,42 @@ torch/_inductor/aoti_eager.py:197:17: error[unresolved-attribute] Module `torch` torch/_inductor/aoti_eager.py:253:40: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/aoti_eager.py:255:40: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/aoti_eager.py:257:40: error[unresolved-attribute] Module `torch` has no member `layout` -torch/_inductor/async_compile.py:285:13: error[unresolved-attribute] Module `multiprocessing` has no member `util` -torch/_inductor/async_compile.py:375:17: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` -torch/_inductor/async_compile.py:381:22: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/async_compile.py:585:25: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` -torch/_inductor/async_compile.py:586:19: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` -torch/_inductor/async_compile.py:621:25: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` -torch/_inductor/async_compile.py:622:19: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` -torch/_inductor/augmented_graph_helper.py:94:16: error[unresolved-attribute] Module `torch._dynamo` has no member `graph_deduplication` +torch/_inductor/async_compile.py:285:13: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `multiprocessing` +torch/_inductor/async_compile.py:375:17: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` +torch/_inductor/async_compile.py:381:22: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/async_compile.py:585:25: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` +torch/_inductor/async_compile.py:586:19: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` +torch/_inductor/async_compile.py:621:25: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` +torch/_inductor/async_compile.py:622:19: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` +torch/_inductor/augmented_graph_helper.py:94:16: warning[possibly-missing-attribute] Submodule `graph_deduplication` may not be available as an attribute on module `torch._dynamo` torch/_inductor/autoheuristic/autoheuristic_utils.py:336:55: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/autoheuristic/autoheuristic_utils.py:338:17: error[unresolved-attribute] Module `torch` has no member `float32` torch/_inductor/autotune_process.py:362:13: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/autotune_process.py:363:12: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/_inductor/autotune_process.py:364:12: error[unresolved-attribute] Module `torch` has no member `_prims_common` -torch/_inductor/autotune_process.py:365:14: error[unresolved-attribute] Module `torch` has no member `_prims_common` -torch/_inductor/autotune_process.py:654:13: error[unresolved-attribute] Module `torch._inductor` has no member `runtime` +torch/_inductor/autotune_process.py:364:12: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` +torch/_inductor/autotune_process.py:365:14: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` +torch/_inductor/autotune_process.py:654:13: warning[possibly-missing-attribute] Submodule `runtime` may not be available as an attribute on module `torch._inductor` torch/_inductor/autotune_process.py:751:30: error[unresolved-attribute] Module `torch` has no member `zeros` torch/_inductor/autotune_process.py:753:23: error[unresolved-attribute] Module `torch` has no member `float64` -torch/_inductor/await_utils.py:25:14: error[unresolved-attribute] Module `asyncio` has no member `futures` -torch/_inductor/await_utils.py:62:28: error[unresolved-attribute] Module `asyncio` has no member `events` -torch/_inductor/await_utils.py:63:9: error[unresolved-attribute] Module `asyncio` has no member `events` -torch/_inductor/await_utils.py:67:13: error[unresolved-attribute] Module `asyncio` has no member `events` torch/_inductor/bounds.py:185:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/bounds.py:186:20: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/bounds.py:193:9: error[invalid-method-override] Invalid override of method `index_expr`: Definition is incompatible with `OpsHandler.index_expr` torch/_inductor/bounds.py:193:44: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/bounds.py:198:9: error[invalid-method-override] Invalid override of method `to_dtype`: Definition is incompatible with `SymPyValueRangeAnalysis.to_dtype` torch/_inductor/bounds.py:200:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/bounds.py:201:29: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/bounds.py:206:21: error[unresolved-attribute] Module `torch` has no member `bool` torch/_inductor/bounds.py:214:24: error[no-matching-overload] No overload of bound method `__init__` matches arguments torch/_inductor/bounds.py:216:33: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/bounds.py:240:9: error[invalid-method-override] Invalid override of method `square`: Definition is incompatible with `OpsHandler.square` +torch/_inductor/bounds.py:244:9: error[invalid-method-override] Invalid override of method `neg`: Definition is incompatible with `OpsHandler.neg` +torch/_inductor/bounds.py:251:9: error[invalid-method-override] Invalid override of method `truncdiv`: Definition is incompatible with `OpsHandler.truncdiv` +torch/_inductor/bounds.py:259:9: error[invalid-method-override] Invalid override of method `sub`: Definition is incompatible with `OpsHandler.sub` torch/_inductor/choices.py:38:10: error[unresolved-import] Cannot resolve imported module `triton` torch/_inductor/choices.py:95:37: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/choices.py:101:37: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/choices.py:107:37: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/_inductor/choices.py:352:34: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` +torch/_inductor/choices.py:352:34: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` torch/_inductor/choices.py:391:17: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/choices.py:608:16: error[invalid-return-type] Return type does not match returned value: expected `Sortable`, found `tuple[int, bool, int, Unknown]` torch/_inductor/codegen/common.py:183:13: error[unresolved-attribute] Module `torch` has no member `device` @@ -2927,6 +2998,15 @@ torch/_inductor/codegen/common.py:928:40: error[unresolved-attribute] Module `to torch/_inductor/codegen/common.py:935:39: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/codegen/common.py:941:40: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/common.py:977:57: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/codegen/common.py:981:9: error[invalid-method-override] Invalid override of method `bitwise_not`: Definition is incompatible with `OpsHandler.bitwise_not` +torch/_inductor/codegen/common.py:985:9: error[invalid-method-override] Invalid override of method `logical_not`: Definition is incompatible with `OpsHandler.logical_not` +torch/_inductor/codegen/common.py:989:9: error[invalid-method-override] Invalid override of method `bitwise_and`: Definition is incompatible with `OpsHandler.bitwise_and` +torch/_inductor/codegen/common.py:993:9: error[invalid-method-override] Invalid override of method `bitwise_or`: Definition is incompatible with `OpsHandler.bitwise_or` +torch/_inductor/codegen/common.py:997:9: error[invalid-method-override] Invalid override of method `bitwise_xor`: Definition is incompatible with `OpsHandler.bitwise_xor` +torch/_inductor/codegen/common.py:1001:9: error[invalid-method-override] Invalid override of method `bitwise_left_shift`: Definition is incompatible with `OpsHandler.bitwise_left_shift` +torch/_inductor/codegen/common.py:1005:9: error[invalid-method-override] Invalid override of method `bitwise_right_shift`: Definition is incompatible with `OpsHandler.bitwise_right_shift` +torch/_inductor/codegen/common.py:1009:9: error[invalid-method-override] Invalid override of method `int_truediv`: Definition is incompatible with `OpsHandler.int_truediv` +torch/_inductor/codegen/common.py:1019:9: error[invalid-method-override] Invalid override of method `indirect_indexing`: Definition is incompatible with `OpsHandler.indirect_indexing` torch/_inductor/codegen/common.py:1059:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/common.py:1060:20: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/common.py:1070:23: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -2946,12 +3026,9 @@ torch/_inductor/codegen/common.py:1674:16: error[invalid-return-type] Return typ torch/_inductor/codegen/common.py:1690:45: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/common.py:1697:48: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/common.py:1744:49: error[invalid-argument-type] Argument to bound method `wrap_size_arg` is incorrect: Expected `str | Symbol`, found `Expr` -torch/_inductor/codegen/common.py:1746:59: error[invalid-argument-type] Argument to bound method `ensure_size_computed` is incorrect: Expected `Symbol`, found `Expr` torch/_inductor/codegen/common.py:1789:30: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `str`, found `Expr` -torch/_inductor/codegen/common.py:1793:59: error[invalid-argument-type] Argument to bound method `ensure_size_computed` is incorrect: Expected `Symbol`, found `Expr` torch/_inductor/codegen/common.py:1848:25: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/common.py:1880:9: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/_inductor/codegen/common.py:1924:16: error[invalid-return-type] Return type does not match returned value: expected `Self@clone`, found `CSE[CSEVariableType@CSE, AugmentedKeyT@CSE]` torch/_inductor/codegen/common.py:1966:25: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/common.py:2038:25: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/common.py:2050:25: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -2968,6 +3045,7 @@ torch/_inductor/codegen/common.py:2472:23: error[unresolved-attribute] Object of torch/_inductor/codegen/common.py:2472:39: error[unresolved-attribute] Object of type `object` has no attribute `get_dtype` torch/_inductor/codegen/common.py:2476:37: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/common.py:2604:33: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/codegen/common.py:2701:9: error[invalid-method-override] Invalid override of method `indirect_indexing`: Definition is incompatible with `OpsHandler.indirect_indexing` torch/_inductor/codegen/common.py:2715:57: error[unresolved-attribute] Module `torch` has no member `long` torch/_inductor/codegen/common.py:2754:16: error[invalid-return-type] Return type does not match returned value: expected `Symbol`, found `Unknown | Expr` torch/_inductor/codegen/common.py:2812:16: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -3006,19 +3084,152 @@ torch/_inductor/codegen/cpp.py:213:40: error[unresolved-attribute] Module `torch torch/_inductor/codegen/cpp.py:226:28: error[unresolved-attribute] Module `torch` has no member `bool` torch/_inductor/codegen/cpp.py:255:37: error[unresolved-attribute] Module `torch` has no member `bool` torch/_inductor/codegen/cpp.py:331:12: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/codegen/cpp.py:704:9: error[invalid-method-override] Invalid override of method `add`: Definition is incompatible with `OpsHandler.add` +torch/_inductor/codegen/cpp.py:708:9: error[invalid-method-override] Invalid override of method `sub`: Definition is incompatible with `OpsHandler.sub` +torch/_inductor/codegen/cpp.py:712:9: error[invalid-method-override] Invalid override of method `mul`: Definition is incompatible with `OpsHandler.mul` torch/_inductor/codegen/cpp.py:723:52: error[unresolved-attribute] Module `torch` has no member `float` +torch/_inductor/codegen/cpp.py:764:9: error[invalid-method-override] Invalid override of method `abs`: Definition is incompatible with `OpsHandler.abs` +torch/_inductor/codegen/cpp.py:768:9: error[invalid-method-override] Invalid override of method `sin`: Definition is incompatible with `OpsHandler.sin` +torch/_inductor/codegen/cpp.py:772:9: error[invalid-method-override] Invalid override of method `cos`: Definition is incompatible with `OpsHandler.cos` +torch/_inductor/codegen/cpp.py:776:9: error[invalid-method-override] Invalid override of method `neg`: Definition is incompatible with `BasicMathOpsMixin.neg` +torch/_inductor/codegen/cpp.py:780:9: error[invalid-method-override] Invalid override of method `exp`: Definition is incompatible with `OpsHandler.exp` +torch/_inductor/codegen/cpp.py:785:9: error[invalid-method-override] Invalid override of method `exp2`: Definition is incompatible with `OpsHandler.exp2` +torch/_inductor/codegen/cpp.py:789:9: error[invalid-method-override] Invalid override of method `expm1`: Definition is incompatible with `OpsHandler.expm1` +torch/_inductor/codegen/cpp.py:793:9: error[invalid-method-override] Invalid override of method `erf`: Definition is incompatible with `OpsHandler.erf` +torch/_inductor/codegen/cpp.py:797:9: error[invalid-method-override] Invalid override of method `erfc`: Definition is incompatible with `OpsHandler.erfc` +torch/_inductor/codegen/cpp.py:801:9: error[invalid-method-override] Invalid override of method `erfinv`: Definition is incompatible with `OpsHandler.erfinv` +torch/_inductor/codegen/cpp.py:805:9: error[invalid-method-override] Invalid override of method `sqrt`: Definition is incompatible with `OpsHandler.sqrt` +torch/_inductor/codegen/cpp.py:809:9: error[invalid-method-override] Invalid override of method `rsqrt`: Definition is incompatible with `OpsHandler.rsqrt` +torch/_inductor/codegen/cpp.py:813:9: error[invalid-method-override] Invalid override of method `log1p`: Definition is incompatible with `OpsHandler.log1p` +torch/_inductor/codegen/cpp.py:825:9: error[invalid-method-override] Invalid override of method `tan`: Definition is incompatible with `OpsHandler.tan` +torch/_inductor/codegen/cpp.py:829:9: error[invalid-method-override] Invalid override of method `tanh`: Definition is incompatible with `OpsHandler.tanh` +torch/_inductor/codegen/cpp.py:833:9: error[invalid-method-override] Invalid override of method `signbit`: Definition is incompatible with `OpsHandler.signbit` +torch/_inductor/codegen/cpp.py:845:9: error[invalid-method-override] Invalid override of method `pow`: Definition is incompatible with `OpsHandler.pow` +torch/_inductor/codegen/cpp.py:849:9: error[invalid-method-override] Invalid override of method `log`: Definition is incompatible with `OpsHandler.log` +torch/_inductor/codegen/cpp.py:853:9: error[invalid-method-override] Invalid override of method `round`: Definition is incompatible with `OpsHandler.round` +torch/_inductor/codegen/cpp.py:857:9: error[invalid-method-override] Invalid override of method `floor`: Definition is incompatible with `OpsHandler.floor` +torch/_inductor/codegen/cpp.py:861:9: error[invalid-method-override] Invalid override of method `floordiv`: Definition is incompatible with `OpsHandler.floordiv` +torch/_inductor/codegen/cpp.py:868:9: error[invalid-method-override] Invalid override of method `ceil`: Definition is incompatible with `OpsHandler.ceil` +torch/_inductor/codegen/cpp.py:872:9: error[invalid-method-override] Invalid override of method `trunc`: Definition is incompatible with `OpsHandler.trunc` +torch/_inductor/codegen/cpp.py:876:9: error[invalid-method-override] Invalid override of method `truncdiv`: Definition is incompatible with `OpsHandler.truncdiv` +torch/_inductor/codegen/cpp.py:881:9: error[invalid-method-override] Invalid override of method `fmod`: Definition is incompatible with `OpsHandler.fmod` +torch/_inductor/codegen/cpp.py:885:9: error[invalid-method-override] Invalid override of method `isinf`: Definition is incompatible with `OpsHandler.isinf` +torch/_inductor/codegen/cpp.py:889:9: error[invalid-method-override] Invalid override of method `isnan`: Definition is incompatible with `OpsHandler.isnan` +torch/_inductor/codegen/cpp.py:893:9: error[invalid-method-override] Invalid override of method `lgamma`: Definition is incompatible with `OpsHandler.lgamma` +torch/_inductor/codegen/cpp.py:897:9: error[invalid-method-override] Invalid override of method `acos`: Definition is incompatible with `OpsHandler.acos` +torch/_inductor/codegen/cpp.py:901:9: error[invalid-method-override] Invalid override of method `acosh`: Definition is incompatible with `OpsHandler.acosh` +torch/_inductor/codegen/cpp.py:905:9: error[invalid-method-override] Invalid override of method `cosh`: Definition is incompatible with `OpsHandler.cosh` +torch/_inductor/codegen/cpp.py:909:9: error[invalid-method-override] Invalid override of method `sinh`: Definition is incompatible with `OpsHandler.sinh` +torch/_inductor/codegen/cpp.py:913:9: error[invalid-method-override] Invalid override of method `asin`: Definition is incompatible with `OpsHandler.asin` +torch/_inductor/codegen/cpp.py:917:9: error[invalid-method-override] Invalid override of method `asinh`: Definition is incompatible with `OpsHandler.asinh` +torch/_inductor/codegen/cpp.py:921:9: error[invalid-method-override] Invalid override of method `atan2`: Definition is incompatible with `OpsHandler.atan2` +torch/_inductor/codegen/cpp.py:925:9: error[invalid-method-override] Invalid override of method `atan`: Definition is incompatible with `OpsHandler.atan` +torch/_inductor/codegen/cpp.py:929:9: error[invalid-method-override] Invalid override of method `atanh`: Definition is incompatible with `OpsHandler.atanh` +torch/_inductor/codegen/cpp.py:933:9: error[invalid-method-override] Invalid override of method `copysign`: Definition is incompatible with `OpsHandler.copysign` +torch/_inductor/codegen/cpp.py:937:9: error[invalid-method-override] Invalid override of method `frexp`: Definition is incompatible with `OpsHandler.frexp` torch/_inductor/codegen/cpp.py:943:46: error[unresolved-attribute] Module `torch` has no member `int32` +torch/_inductor/codegen/cpp.py:954:9: error[invalid-method-override] Invalid override of method `hypot`: Definition is incompatible with `OpsHandler.hypot` +torch/_inductor/codegen/cpp.py:958:9: error[invalid-method-override] Invalid override of method `log10`: Definition is incompatible with `OpsHandler.log10` +torch/_inductor/codegen/cpp.py:962:9: error[invalid-method-override] Invalid override of method `log2`: Definition is incompatible with `OpsHandler.log2` +torch/_inductor/codegen/cpp.py:966:9: error[invalid-method-override] Invalid override of method `nextafter`: Definition is incompatible with `OpsHandler.nextafter` +torch/_inductor/codegen/cpp.py:970:9: error[invalid-method-override] Invalid override of method `relu`: Definition is incompatible with `OpsHandler.relu` +torch/_inductor/codegen/cpp.py:986:9: error[invalid-method-override] Invalid override of method `minimum`: Definition is incompatible with `OpsHandler.minimum` +torch/_inductor/codegen/cpp.py:990:9: error[invalid-method-override] Invalid override of method `maximum`: Definition is incompatible with `OpsHandler.maximum` +torch/_inductor/codegen/cpp.py:994:9: error[invalid-method-override] Invalid override of method `where`: Definition is incompatible with `OpsHandler.where` +torch/_inductor/codegen/cpp.py:998:9: error[invalid-method-override] Invalid override of method `mod`: Definition is incompatible with `OpsHandler.mod` +torch/_inductor/codegen/cpp.py:1002:9: error[invalid-method-override] Invalid override of method `constant`: Definition is incompatible with `OpOverrides.constant` +torch/_inductor/codegen/cpp.py:1031:9: error[invalid-method-override] Invalid override of method `logical_and`: Definition is incompatible with `OpsHandler.logical_and` +torch/_inductor/codegen/cpp.py:1035:9: error[invalid-method-override] Invalid override of method `logical_not`: Definition is incompatible with `OpsHandler.logical_not` +torch/_inductor/codegen/cpp.py:1039:9: error[invalid-method-override] Invalid override of method `logical_or`: Definition is incompatible with `OpsHandler.logical_or` +torch/_inductor/codegen/cpp.py:1043:9: error[invalid-method-override] Invalid override of method `logical_xor`: Definition is incompatible with `OpsHandler.logical_xor` +torch/_inductor/codegen/cpp.py:1047:9: error[invalid-method-override] Invalid override of method `bitwise_and`: Definition is incompatible with `OpOverrides.bitwise_and` +torch/_inductor/codegen/cpp.py:1051:9: error[invalid-method-override] Invalid override of method `bitwise_not`: Definition is incompatible with `OpOverrides.bitwise_not` +torch/_inductor/codegen/cpp.py:1055:9: error[invalid-method-override] Invalid override of method `bitwise_or`: Definition is incompatible with `OpOverrides.bitwise_or` +torch/_inductor/codegen/cpp.py:1059:9: error[invalid-method-override] Invalid override of method `bitwise_xor`: Definition is incompatible with `OpOverrides.bitwise_xor` +torch/_inductor/codegen/cpp.py:1063:9: error[invalid-method-override] Invalid override of method `bitwise_left_shift`: Definition is incompatible with `OpOverrides.bitwise_left_shift` +torch/_inductor/codegen/cpp.py:1083:9: error[invalid-method-override] Invalid override of method `bitwise_right_shift`: Definition is incompatible with `OpOverrides.bitwise_right_shift` +torch/_inductor/codegen/cpp.py:1113:9: error[invalid-method-override] Invalid override of method `sigmoid`: Definition is incompatible with `OpsHandler.sigmoid` +torch/_inductor/codegen/cpp.py:1117:9: error[invalid-method-override] Invalid override of method `sign`: Definition is incompatible with `OpsHandler.sign` torch/_inductor/codegen/cpp.py:1179:59: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/codegen/cpp.py:1181:57: error[unresolved-attribute] Module `torch` has no member `int64` +torch/_inductor/codegen/cpp.py:1239:9: error[invalid-method-override] Invalid override of method `add`: Definition is incompatible with `OpsHandler.add` +torch/_inductor/codegen/cpp.py:1243:9: error[invalid-method-override] Invalid override of method `sub`: Definition is incompatible with `OpsHandler.sub` +torch/_inductor/codegen/cpp.py:1247:9: error[invalid-method-override] Invalid override of method `mul`: Definition is incompatible with `OpsHandler.mul` +torch/_inductor/codegen/cpp.py:1251:9: error[invalid-method-override] Invalid override of method `truediv`: Definition is incompatible with `OpsHandler.truediv` +torch/_inductor/codegen/cpp.py:1255:9: error[invalid-method-override] Invalid override of method `abs`: Definition is incompatible with `OpsHandler.abs` +torch/_inductor/codegen/cpp.py:1259:9: error[invalid-method-override] Invalid override of method `sin`: Definition is incompatible with `OpsHandler.sin` +torch/_inductor/codegen/cpp.py:1263:9: error[invalid-method-override] Invalid override of method `cos`: Definition is incompatible with `OpsHandler.cos` +torch/_inductor/codegen/cpp.py:1267:9: error[invalid-method-override] Invalid override of method `exp`: Definition is incompatible with `OpsHandler.exp` +torch/_inductor/codegen/cpp.py:1271:9: error[invalid-method-override] Invalid override of method `exp2`: Definition is incompatible with `OpsHandler.exp2` +torch/_inductor/codegen/cpp.py:1275:9: error[invalid-method-override] Invalid override of method `expm1`: Definition is incompatible with `OpsHandler.expm1` +torch/_inductor/codegen/cpp.py:1281:9: error[invalid-method-override] Invalid override of method `erf`: Definition is incompatible with `OpsHandler.erf` +torch/_inductor/codegen/cpp.py:1285:9: error[invalid-method-override] Invalid override of method `erfc`: Definition is incompatible with `OpsHandler.erfc` +torch/_inductor/codegen/cpp.py:1289:9: error[invalid-method-override] Invalid override of method `erfinv`: Definition is incompatible with `OpsHandler.erfinv` +torch/_inductor/codegen/cpp.py:1293:9: error[invalid-method-override] Invalid override of method `sqrt`: Definition is incompatible with `OpsHandler.sqrt` +torch/_inductor/codegen/cpp.py:1297:9: error[invalid-method-override] Invalid override of method `eq`: Definition is incompatible with `BasicMathOpsMixin.eq` +torch/_inductor/codegen/cpp.py:1304:9: error[invalid-method-override] Invalid override of method `ne`: Definition is incompatible with `BasicMathOpsMixin.ne` torch/_inductor/codegen/cpp.py:1307:23: error[unresolved-attribute] Module `torch` has no member `bool` torch/_inductor/codegen/cpp.py:1308:31: error[unresolved-attribute] Module `torch` has no member `bool` +torch/_inductor/codegen/cpp.py:1316:9: error[invalid-method-override] Invalid override of method `lt`: Definition is incompatible with `BasicMathOpsMixin.lt` +torch/_inductor/codegen/cpp.py:1323:9: error[invalid-method-override] Invalid override of method `gt`: Definition is incompatible with `BasicMathOpsMixin.gt` +torch/_inductor/codegen/cpp.py:1330:9: error[invalid-method-override] Invalid override of method `le`: Definition is incompatible with `BasicMathOpsMixin.le` +torch/_inductor/codegen/cpp.py:1337:9: error[invalid-method-override] Invalid override of method `ge`: Definition is incompatible with `BasicMathOpsMixin.ge` +torch/_inductor/codegen/cpp.py:1344:9: error[invalid-method-override] Invalid override of method `and_`: Definition is incompatible with `BasicMathOpsMixin.and_` +torch/_inductor/codegen/cpp.py:1348:9: error[invalid-method-override] Invalid override of method `rsqrt`: Definition is incompatible with `OpsHandler.rsqrt` +torch/_inductor/codegen/cpp.py:1352:9: error[invalid-method-override] Invalid override of method `pow`: Definition is incompatible with `OpsHandler.pow` +torch/_inductor/codegen/cpp.py:1356:9: error[invalid-method-override] Invalid override of method `log`: Definition is incompatible with `OpsHandler.log` +torch/_inductor/codegen/cpp.py:1360:9: error[invalid-method-override] Invalid override of method `round`: Definition is incompatible with `OpsHandler.round` +torch/_inductor/codegen/cpp.py:1364:9: error[invalid-method-override] Invalid override of method `floor`: Definition is incompatible with `OpsHandler.floor` +torch/_inductor/codegen/cpp.py:1368:9: error[invalid-method-override] Invalid override of method `ceil`: Definition is incompatible with `OpsHandler.ceil` +torch/_inductor/codegen/cpp.py:1372:9: error[invalid-method-override] Invalid override of method `trunc`: Definition is incompatible with `OpsHandler.trunc` +torch/_inductor/codegen/cpp.py:1376:9: error[invalid-method-override] Invalid override of method `fmod`: Definition is incompatible with `OpsHandler.fmod` +torch/_inductor/codegen/cpp.py:1380:9: error[invalid-method-override] Invalid override of method `lgamma`: Definition is incompatible with `OpsHandler.lgamma` +torch/_inductor/codegen/cpp.py:1384:9: error[invalid-method-override] Invalid override of method `logical_and`: Definition is incompatible with `OpsHandler.logical_and` +torch/_inductor/codegen/cpp.py:1389:9: error[invalid-method-override] Invalid override of method `logical_not`: Definition is incompatible with `OpsHandler.logical_not` +torch/_inductor/codegen/cpp.py:1393:9: error[invalid-method-override] Invalid override of method `logical_or`: Definition is incompatible with `OpsHandler.logical_or` +torch/_inductor/codegen/cpp.py:1398:9: error[invalid-method-override] Invalid override of method `logical_xor`: Definition is incompatible with `OpsHandler.logical_xor` +torch/_inductor/codegen/cpp.py:1403:9: error[invalid-method-override] Invalid override of method `bitwise_and`: Definition is incompatible with `OpOverrides.bitwise_and` +torch/_inductor/codegen/cpp.py:1408:9: error[invalid-method-override] Invalid override of method `bitwise_not`: Definition is incompatible with `OpOverrides.bitwise_not` +torch/_inductor/codegen/cpp.py:1412:9: error[invalid-method-override] Invalid override of method `bitwise_or`: Definition is incompatible with `OpOverrides.bitwise_or` +torch/_inductor/codegen/cpp.py:1417:9: error[invalid-method-override] Invalid override of method `bitwise_xor`: Definition is incompatible with `OpOverrides.bitwise_xor` +torch/_inductor/codegen/cpp.py:1422:9: error[invalid-method-override] Invalid override of method `bitwise_left_shift`: Definition is incompatible with `OpOverrides.bitwise_left_shift` +torch/_inductor/codegen/cpp.py:1426:9: error[invalid-method-override] Invalid override of method `bitwise_right_shift`: Definition is incompatible with `OpOverrides.bitwise_right_shift` torch/_inductor/codegen/cpp.py:1455:58: error[unresolved-attribute] Module `torch` has no member `int64` +torch/_inductor/codegen/cpp.py:1458:9: error[invalid-method-override] Invalid override of method `remainder`: Definition is incompatible with `OpsHandler.remainder` +torch/_inductor/codegen/cpp.py:1465:9: error[invalid-method-override] Invalid override of method `tan`: Definition is incompatible with `CppOverrides.tan` +torch/_inductor/codegen/cpp.py:1469:9: error[invalid-method-override] Invalid override of method `tanh`: Definition is incompatible with `CppOverrides.tanh` +torch/_inductor/codegen/cpp.py:1481:9: error[invalid-method-override] Invalid override of method `reciprocal`: Definition is incompatible with `OpDecompositions.reciprocal` +torch/_inductor/codegen/cpp.py:1485:9: error[invalid-method-override] Invalid override of method `atan`: Definition is incompatible with `OpsHandler.atan` +torch/_inductor/codegen/cpp.py:1489:9: error[invalid-method-override] Invalid override of method `acos`: Definition is incompatible with `OpsHandler.acos` +torch/_inductor/codegen/cpp.py:1493:9: error[invalid-method-override] Invalid override of method `asin`: Definition is incompatible with `OpsHandler.asin` +torch/_inductor/codegen/cpp.py:1497:9: error[invalid-method-override] Invalid override of method `cosh`: Definition is incompatible with `OpsHandler.cosh` +torch/_inductor/codegen/cpp.py:1501:9: error[invalid-method-override] Invalid override of method `sinh`: Definition is incompatible with `OpsHandler.sinh` +torch/_inductor/codegen/cpp.py:1505:9: error[invalid-method-override] Invalid override of method `log10`: Definition is incompatible with `OpsHandler.log10` +torch/_inductor/codegen/cpp.py:1509:9: error[invalid-method-override] Invalid override of method `log2`: Definition is incompatible with `OpsHandler.log2` +torch/_inductor/codegen/cpp.py:1513:9: error[invalid-method-override] Invalid override of method `nextafter`: Definition is incompatible with `OpsHandler.nextafter` +torch/_inductor/codegen/cpp.py:1517:9: error[invalid-method-override] Invalid override of method `copysign`: Definition is incompatible with `CppOverrides.copysign` +torch/_inductor/codegen/cpp.py:1521:9: error[invalid-method-override] Invalid override of method `atan2`: Definition is incompatible with `CppOverrides.atan2` +torch/_inductor/codegen/cpp.py:1525:9: error[invalid-method-override] Invalid override of method `hypot`: Definition is incompatible with `CppOverrides.hypot` +torch/_inductor/codegen/cpp.py:1529:9: error[invalid-method-override] Invalid override of method `atanh`: Definition is incompatible with `OpsHandler.atanh` +torch/_inductor/codegen/cpp.py:1536:9: error[invalid-method-override] Invalid override of method `asinh`: Definition is incompatible with `OpsHandler.asinh` +torch/_inductor/codegen/cpp.py:1540:9: error[invalid-method-override] Invalid override of method `acosh`: Definition is incompatible with `OpsHandler.acosh` +torch/_inductor/codegen/cpp.py:1544:9: error[invalid-method-override] Invalid override of method `relu`: Definition is incompatible with `OpsHandler.relu` +torch/_inductor/codegen/cpp.py:1561:9: error[invalid-method-override] Invalid override of method `sigmoid`: Definition is incompatible with `OpsHandler.sigmoid` +torch/_inductor/codegen/cpp.py:1565:9: error[invalid-method-override] Invalid override of method `neg`: Definition is incompatible with `BasicMathOpsMixin.neg` +torch/_inductor/codegen/cpp.py:1569:9: error[invalid-method-override] Invalid override of method `floordiv`: Definition is incompatible with `OpsHandler.floordiv` +torch/_inductor/codegen/cpp.py:1588:9: error[invalid-method-override] Invalid override of method `truncdiv`: Definition is incompatible with `OpsHandler.truncdiv` +torch/_inductor/codegen/cpp.py:1597:9: error[invalid-method-override] Invalid override of method `minimum`: Definition is incompatible with `OpsHandler.minimum` torch/_inductor/codegen/cpp.py:1598:23: error[unresolved-attribute] Module `torch` has no member `bool` torch/_inductor/codegen/cpp.py:1599:31: error[unresolved-attribute] Module `torch` has no member `bool` +torch/_inductor/codegen/cpp.py:1606:9: error[invalid-method-override] Invalid override of method `maximum`: Definition is incompatible with `OpsHandler.maximum` torch/_inductor/codegen/cpp.py:1607:23: error[unresolved-attribute] Module `torch` has no member `bool` torch/_inductor/codegen/cpp.py:1608:31: error[unresolved-attribute] Module `torch` has no member `bool` +torch/_inductor/codegen/cpp.py:1615:9: error[invalid-method-override] Invalid override of method `square`: Definition is incompatible with `OpDecompositions.square` +torch/_inductor/codegen/cpp.py:1619:9: error[invalid-method-override] Invalid override of method `where`: Definition is incompatible with `OpsHandler.where` torch/_inductor/codegen/cpp.py:1621:23: error[unresolved-attribute] Module `torch` has no member `bool` torch/_inductor/codegen/cpp.py:1622:31: error[unresolved-attribute] Module `torch` has no member `bool` +torch/_inductor/codegen/cpp.py:1631:9: error[invalid-method-override] Invalid override of method `sign`: Definition is incompatible with `OpsHandler.sign` +torch/_inductor/codegen/cpp.py:1646:9: error[invalid-method-override] Invalid override of method `to_dtype`: Definition is incompatible with `CppOverrides.to_dtype` torch/_inductor/codegen/cpp.py:1648:13: error[unresolved-attribute] Module `torch` has no member `bool` torch/_inductor/codegen/cpp.py:1649:13: error[unresolved-attribute] Module `torch` has no member `float64` torch/_inductor/codegen/cpp.py:1650:13: error[unresolved-attribute] Module `torch` has no member `float` @@ -3031,7 +3242,9 @@ torch/_inductor/codegen/cpp.py:1656:13: error[unresolved-attribute] Module `torc torch/_inductor/codegen/cpp.py:1657:13: error[unresolved-attribute] Module `torch` has no member `float8_e4m3fn` torch/_inductor/codegen/cpp.py:1658:13: error[unresolved-attribute] Module `torch` has no member `float8_e5m2` torch/_inductor/codegen/cpp.py:1665:52: error[unresolved-attribute] Module `torch` has no member `float` +torch/_inductor/codegen/cpp.py:1670:9: error[invalid-method-override] Invalid override of method `log1p`: Definition is incompatible with `OpsHandler.log1p` torch/_inductor/codegen/cpp.py:1700:29: error[unresolved-attribute] Module `torch` has no member `bool` +torch/_inductor/codegen/cpp.py:1784:9: error[invalid-method-override] Invalid override of method `frexp`: Definition is incompatible with `OpsHandler.frexp` torch/_inductor/codegen/cpp.py:1792:46: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/codegen/cpp.py:2022:30: error[invalid-argument-type] Argument to function `replace_acc_name` is incorrect: Expected `IndentedBuffer`, found `Unknown | IndentedBuffer | None` torch/_inductor/codegen/cpp.py:2030:17: error[call-non-callable] Object of type `object` is not callable @@ -3106,6 +3319,7 @@ torch/_inductor/codegen/cpp.py:3690:17: error[unresolved-attribute] Module `torc torch/_inductor/codegen/cpp.py:3691:17: error[unresolved-attribute] Module `torch` has no member `float8_e4m3fn` torch/_inductor/codegen/cpp.py:3692:17: error[unresolved-attribute] Module `torch` has no member `float8_e5m2` torch/_inductor/codegen/cpp.py:3697:13: warning[possibly-missing-attribute] Attribute `writeline` may be missing on object of type `Unknown | IndentedBuffer | None` +torch/_inductor/codegen/cpp.py:3713:9: error[invalid-method-override] Invalid override of method `set_ranges`: Definition is incompatible with `CppKernel.set_ranges` torch/_inductor/codegen/cpp.py:3739:62: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/cpp.py:3747:29: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/cpp.py:3803:17: error[unresolved-attribute] Module `torch` has no member `float` @@ -3153,8 +3367,8 @@ torch/_inductor/codegen/cpp_gemm_template.py:605:33: error[unresolved-attribute] torch/_inductor/codegen/cpp_gemm_template.py:605:46: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/codegen/cpp_gemm_template.py:605:62: error[unresolved-attribute] Module `torch` has no member `half` torch/_inductor/codegen/cpp_gemm_template.py:605:74: error[unresolved-attribute] Module `torch` has no member `uint8` -torch/_inductor/codegen/cpp_gemm_template.py:772:17: error[unresolved-attribute] Module `torch._C` has no member `_cpu` -torch/_inductor/codegen/cpp_gemm_template.py:780:17: error[unresolved-attribute] Module `torch._C` has no member `_cpu` +torch/_inductor/codegen/cpp_gemm_template.py:772:17: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` +torch/_inductor/codegen/cpp_gemm_template.py:780:17: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` torch/_inductor/codegen/cpp_gemm_template.py:788:24: error[unresolved-attribute] Module `torch` has no member `tensor` torch/_inductor/codegen/cpp_gemm_template.py:794:27: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/codegen/cpp_gemm_template.py:794:57: error[unresolved-attribute] Module `torch` has no member `int8` @@ -3169,8 +3383,8 @@ torch/_inductor/codegen/cpp_gemm_template.py:1484:24: warning[possibly-missing-a torch/_inductor/codegen/cpp_gemm_template.py:1496:32: warning[possibly-missing-attribute] Attribute `layout` may be missing on object of type `Buffer | (list[Buffer] & IRNode)` torch/_inductor/codegen/cpp_gemm_template.py:1507:32: warning[possibly-missing-attribute] Attribute `layout` may be missing on object of type `Buffer | (list[Buffer] & IRNode)` torch/_inductor/codegen/cpp_gemm_template.py:1539:26: warning[possibly-missing-attribute] Attribute `get_dtype` may be missing on object of type `Unknown | IRNode | Sequence[IRNode]` -torch/_inductor/codegen/cpp_gemm_template.py:1556:25: error[unresolved-attribute] Module `torch._C` has no member `_cpu` -torch/_inductor/codegen/cpp_gemm_template.py:1559:25: error[unresolved-attribute] Module `torch._C` has no member `_cpu` +torch/_inductor/codegen/cpp_gemm_template.py:1556:25: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` +torch/_inductor/codegen/cpp_gemm_template.py:1559:25: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` torch/_inductor/codegen/cpp_gemm_template.py:1589:27: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/codegen/cpp_gemm_template.py:1589:57: error[unresolved-attribute] Module `torch` has no member `float` torch/_inductor/codegen/cpp_gemm_template.py:1615:34: error[unresolved-attribute] Module `torch` has no member `bfloat16` @@ -3184,8 +3398,8 @@ torch/_inductor/codegen/cpp_grouped_gemm_template.py:302:20: error[invalid-retur torch/_inductor/codegen/cpp_grouped_gemm_template.py:303:71: error[invalid-argument-type] Argument to function `reorder_and_filter` is incorrect: Expected `list[IRNode]`, found `list[_T@preprocessor]` torch/_inductor/codegen/cpp_grouped_gemm_template.py:374:16: error[non-subscriptable] Cannot subscript object of type `Literal[False]` with no `__getitem__` method torch/_inductor/codegen/cpp_grouped_gemm_template.py:403:26: warning[possibly-missing-attribute] Attribute `get_dtype` may be missing on object of type `Unknown | IRNode | Sequence[IRNode]` -torch/_inductor/codegen/cpp_grouped_gemm_template.py:415:25: error[unresolved-attribute] Module `torch._C` has no member `_cpu` -torch/_inductor/codegen/cpp_grouped_gemm_template.py:418:25: error[unresolved-attribute] Module `torch._C` has no member `_cpu` +torch/_inductor/codegen/cpp_grouped_gemm_template.py:415:25: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` +torch/_inductor/codegen/cpp_grouped_gemm_template.py:418:25: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` torch/_inductor/codegen/cpp_grouped_gemm_template.py:441:13: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `Unknown | IRNode | Sequence[IRNode]` on object of type `dict[str, IRNode | None]` torch/_inductor/codegen/cpp_grouped_gemm_template.py:491:27: error[unresolved-attribute] Module `torch` has no member `float` torch/_inductor/codegen/cpp_micro_gemm.py:96:33: error[unresolved-attribute] Module `torch` has no member `uint8` @@ -3476,6 +3690,7 @@ torch/_inductor/codegen/cpp_wrapper_cpu.py:2009:9: error[missing-argument] No ar torch/_inductor/codegen/cpp_wrapper_cpu.py:2009:24: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `ExitSubgraphLine` torch/_inductor/codegen/cpp_wrapper_cpu.py:2010:9: error[missing-argument] No argument provided for required parameter `line` of function `writeline` torch/_inductor/codegen/cpp_wrapper_cpu.py:2010:24: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `Literal["}"]` +torch/_inductor/codegen/cpp_wrapper_cpu.py:2012:9: error[invalid-method-override] Invalid override of method `codegen_subgraph`: Definition is incompatible with `PythonWrapperCodegen.codegen_subgraph` torch/_inductor/codegen/cpp_wrapper_cpu.py:2020:13: error[missing-argument] No argument provided for required parameter `line` of function `writeline` torch/_inductor/codegen/cpp_wrapper_cpu.py:2020:28: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` torch/_inductor/codegen/cpp_wrapper_cpu.py:2046:13: error[missing-argument] No argument provided for required parameter `line` of function `writeline` @@ -3581,6 +3796,7 @@ torch/_inductor/codegen/cpp_wrapper_cpu.py:2810:30: error[unresolved-attribute] torch/_inductor/codegen/cpp_wrapper_cpu.py:2812:30: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/cpp_wrapper_cpu.py:2814:30: error[unresolved-attribute] Module `torch` has no member `layout` torch/_inductor/codegen/cpp_wrapper_cpu.py:2816:30: error[unresolved-attribute] Module `torch` has no member `memory_format` +torch/_inductor/codegen/cpp_wrapper_cpu.py:2830:9: error[invalid-method-override] Invalid override of method `val_to_arg_str`: Definition is incompatible with `PythonWrapperCodegen.val_to_arg_str` torch/_inductor/codegen/cpp_wrapper_cpu.py:2833:51: error[unresolved-attribute] Module `torch` has no member `OptionalType` torch/_inductor/codegen/cpp_wrapper_cpu.py:2837:25: error[unresolved-attribute] Module `torch` has no member `DeviceObjType` torch/_inductor/codegen/cpp_wrapper_cpu.py:2838:25: error[unresolved-attribute] Module `torch` has no member `ListType` @@ -3619,11 +3835,13 @@ torch/_inductor/codegen/cpp_wrapper_cpu.py:2994:24: error[invalid-argument-type] torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:137:17: error[missing-argument] No argument provided for required parameter `line` of function `writeline` torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:137:32: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:152:13: error[missing-argument] No argument provided for required parameter `line` of function `writeline` +torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:571:9: error[invalid-method-override] Invalid override of method `make_allocation`: Definition is incompatible with `CppWrapperCpu.make_allocation` torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:739:9: error[missing-argument] No argument provided for required parameter `line` of function `writeline` torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:739:24: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:766:9: error[missing-argument] No argument provided for required parameter `line` of function `writeline` torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:788:9: error[missing-argument] No argument provided for required parameter `line` of function `writeline` torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:789:13: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` +torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:855:9: error[invalid-method-override] Invalid override of method `val_to_arg_str`: Definition is incompatible with `PythonWrapperCodegen.val_to_arg_str` torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:858:35: error[unresolved-attribute] Module `torch` has no member `OptionalType` torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:859:52: error[unresolved-attribute] Module `torch` has no member `TensorType` torch/_inductor/codegen/cpp_wrapper_cpu_array_ref.py:862:52: error[unresolved-attribute] Module `torch` has no member `TensorType` @@ -3861,6 +4079,7 @@ torch/_inductor/codegen/cuda/gemm_template.py:1321:23: error[unresolved-attribut torch/_inductor/codegen/cuda/gemm_template.py:1322:28: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/cuda/gemm_template.py:1372:16: error[unresolved-import] Cannot resolve imported module `cutlass_library.library` torch/_inductor/codegen/cuda/gemm_template.py:1391:16: error[unresolved-import] Cannot resolve imported module `cutlass_library.library` +torch/_inductor/codegen/cuda/gemm_template.py:1477:9: error[invalid-method-override] Invalid override of method `_render_evt`: Definition is incompatible with `CUTLASSGemmTemplate._render_evt` torch/_inductor/codegen/cuda/gemm_template.py:1483:23: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/cuda/gemm_template.py:1484:28: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/cuda/gemm_template.py:1486:60: warning[possibly-missing-import] Member `create_example_tensors` of module `torch._inductor.codegen.cuda.cutlass_lib_extensions.evt_extensions` may be missing @@ -3885,6 +4104,7 @@ torch/_inductor/codegen/cuda/serialization.py:361:14: error[unresolved-import] C torch/_inductor/codegen/cuda/serialization.py:444:14: error[unresolved-import] Cannot resolve imported module `cutlass_library` torch/_inductor/codegen/cuda/serialization.py:445:14: error[unresolved-import] Cannot resolve imported module `cutlass_library.library` torch/_inductor/codegen/cuda_combined_scheduling.py:50:44: error[unresolved-attribute] Module `torch` has no member `device` +torch/_inductor/codegen/cuda_combined_scheduling.py:92:9: error[invalid-method-override] Invalid override of method `group_fn`: Definition is incompatible with `BaseScheduling.group_fn` torch/_inductor/codegen/cutedsl/_cutedsl_utils.py:3:8: error[unresolved-import] Cannot resolve imported module `cutlass.cute` torch/_inductor/codegen/cutedsl/cutedsl_kernel.py:411:46: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/cutedsl/cutedsl_kernel.py:416:16: error[unresolved-attribute] Module `torch` has no member `float32` @@ -3912,27 +4132,38 @@ torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:48:9: error[unresolved-a torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:49:9: error[unresolved-attribute] Module `torch` has no member `float8_e5m2` torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:81:25: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:147:57: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:158:9: error[invalid-method-override] Invalid override of method `add`: Definition is incompatible with `OpsHandler.add` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:162:9: error[invalid-method-override] Invalid override of method `mul`: Definition is incompatible with `OpsHandler.mul` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:166:9: error[invalid-method-override] Invalid override of method `sub`: Definition is incompatible with `OpsHandler.sub` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:170:9: error[invalid-method-override] Invalid override of method `truediv`: Definition is incompatible with `OpsHandler.truediv` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:174:9: error[invalid-method-override] Invalid override of method `mod`: Definition is incompatible with `OpsHandler.mod` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:178:9: error[invalid-method-override] Invalid override of method `remainder`: Definition is incompatible with `OpsHandler.remainder` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:182:9: error[invalid-method-override] Invalid override of method `exp`: Definition is incompatible with `OpsHandler.exp` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:189:9: error[invalid-method-override] Invalid override of method `sqrt`: Definition is incompatible with `OpsHandler.sqrt` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:194:9: error[invalid-method-override] Invalid override of method `log`: Definition is incompatible with `OpsHandler.log` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:199:9: error[invalid-method-override] Invalid override of method `cos`: Definition is incompatible with `OpsHandler.cos` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:204:9: error[invalid-method-override] Invalid override of method `sin`: Definition is incompatible with `OpsHandler.sin` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:209:9: error[invalid-method-override] Invalid override of method `erf`: Definition is incompatible with `OpsHandler.erf` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:214:9: error[invalid-method-override] Invalid override of method `maximum`: Definition is incompatible with `OpsHandler.maximum` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:218:9: error[invalid-method-override] Invalid override of method `minimum`: Definition is incompatible with `OpsHandler.minimum` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:222:9: error[invalid-method-override] Invalid override of method `where`: Definition is incompatible with `OpsHandler.where` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:258:9: error[invalid-method-override] Invalid override of method `pow`: Definition is incompatible with `OpsHandler.pow` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:262:9: error[invalid-method-override] Invalid override of method `abs`: Definition is incompatible with `OpsHandler.abs` torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:269:23: error[unresolved-attribute] Module `torch` has no member `float32` torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:273:28: error[unresolved-attribute] Module `torch` has no member `float16` torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:273:43: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:273:59: error[unresolved-attribute] Module `torch` has no member `float32` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:283:9: error[invalid-method-override] Invalid override of method `neg`: Definition is incompatible with `BasicMathOpsMixin.neg` torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:292:31: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:333:9: error[invalid-method-override] Invalid override of method `logical_not`: Definition is incompatible with `OpsHandler.logical_not` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:339:9: error[invalid-method-override] Invalid override of method `eq`: Definition is incompatible with `OpsHandler.eq` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:343:9: error[invalid-method-override] Invalid override of method `ne`: Definition is incompatible with `OpsHandler.ne` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:347:9: error[invalid-method-override] Invalid override of method `lt`: Definition is incompatible with `OpsHandler.lt` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:351:9: error[invalid-method-override] Invalid override of method `le`: Definition is incompatible with `OpsHandler.le` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:355:9: error[invalid-method-override] Invalid override of method `gt`: Definition is incompatible with `OpsHandler.gt` +torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py:359:9: error[invalid-method-override] Invalid override of method `ge`: Definition is incompatible with `OpsHandler.ge` torch/_inductor/codegen/debug_utils.py:11:19: error[unresolved-import] Module `torch` has no member `dtype` -torch/_inductor/codegen/debug_utils.py:207:17: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/debug_utils.py:208:21: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` -torch/_inductor/codegen/debug_utils.py:227:17: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/debug_utils.py:227:48: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` -torch/_inductor/codegen/debug_utils.py:245:17: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/debug_utils.py:246:21: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` -torch/_inductor/codegen/debug_utils.py:265:21: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/debug_utils.py:266:25: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` -torch/_inductor/codegen/debug_utils.py:271:30: error[unresolved-attribute] Module `torch._inductor` has no member `codegen` -torch/_inductor/codegen/debug_utils.py:277:21: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/debug_utils.py:278:25: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` -torch/_inductor/codegen/debug_utils.py:282:25: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/debug_utils.py:283:29: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` -torch/_inductor/codegen/debug_utils.py:286:17: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/debug_utils.py:287:21: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` +torch/_inductor/codegen/debug_utils.py:271:30: warning[possibly-missing-attribute] Submodule `codegen` may not be available as an attribute on module `torch._inductor` torch/_inductor/codegen/halide.py:64:16: error[unresolved-attribute] Module `torch` has no member `iinfo` torch/_inductor/codegen/halide.py:64:28: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/codegen/halide.py:215:5: error[unresolved-attribute] Module `torch` has no member `bool` @@ -3962,11 +4193,65 @@ torch/_inductor/codegen/halide.py:257:26: error[unresolved-attribute] Module `to torch/_inductor/codegen/halide.py:257:41: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/codegen/halide.py:260:22: error[unresolved-attribute] Module `torch` has no member `float16` torch/_inductor/codegen/halide.py:260:37: error[unresolved-attribute] Module `torch` has no member `bfloat16` +torch/_inductor/codegen/halide.py:269:9: error[invalid-method-override] Invalid override of method `abs`: Definition is incompatible with `OpsHandler.abs` +torch/_inductor/codegen/halide.py:273:9: error[invalid-method-override] Invalid override of method `exp`: Definition is incompatible with `OpsHandler.exp` +torch/_inductor/codegen/halide.py:279:9: error[invalid-method-override] Invalid override of method `sqrt`: Definition is incompatible with `OpsHandler.sqrt` +torch/_inductor/codegen/halide.py:283:9: error[invalid-method-override] Invalid override of method `minimum`: Definition is incompatible with `OpsHandler.minimum` +torch/_inductor/codegen/halide.py:291:9: error[invalid-method-override] Invalid override of method `maximum`: Definition is incompatible with `OpsHandler.maximum` +torch/_inductor/codegen/halide.py:299:9: error[invalid-method-override] Invalid override of method `where`: Definition is incompatible with `OpsHandler.where` +torch/_inductor/codegen/halide.py:305:9: error[invalid-method-override] Invalid override of method `cos`: Definition is incompatible with `OpsHandler.cos` +torch/_inductor/codegen/halide.py:309:9: error[invalid-method-override] Invalid override of method `sin`: Definition is incompatible with `OpsHandler.sin` +torch/_inductor/codegen/halide.py:313:9: error[invalid-method-override] Invalid override of method `lgamma`: Definition is incompatible with `OpsHandler.lgamma` +torch/_inductor/codegen/halide.py:317:9: error[invalid-method-override] Invalid override of method `erf`: Definition is incompatible with `OpsHandler.erf` +torch/_inductor/codegen/halide.py:321:9: error[invalid-method-override] Invalid override of method `cosh`: Definition is incompatible with `OpsHandler.cosh` +torch/_inductor/codegen/halide.py:325:9: error[invalid-method-override] Invalid override of method `sinh`: Definition is incompatible with `OpsHandler.sinh` +torch/_inductor/codegen/halide.py:329:9: error[invalid-method-override] Invalid override of method `acos`: Definition is incompatible with `OpsHandler.acos` +torch/_inductor/codegen/halide.py:333:9: error[invalid-method-override] Invalid override of method `acosh`: Definition is incompatible with `OpsHandler.acosh` +torch/_inductor/codegen/halide.py:337:9: error[invalid-method-override] Invalid override of method `asin`: Definition is incompatible with `OpsHandler.asin` +torch/_inductor/codegen/halide.py:341:9: error[invalid-method-override] Invalid override of method `asinh`: Definition is incompatible with `OpsHandler.asinh` +torch/_inductor/codegen/halide.py:345:9: error[invalid-method-override] Invalid override of method `atan2`: Definition is incompatible with `OpsHandler.atan2` +torch/_inductor/codegen/halide.py:349:9: error[invalid-method-override] Invalid override of method `atan`: Definition is incompatible with `OpsHandler.atan` +torch/_inductor/codegen/halide.py:353:9: error[invalid-method-override] Invalid override of method `atanh`: Definition is incompatible with `OpsHandler.atanh` +torch/_inductor/codegen/halide.py:357:9: error[invalid-method-override] Invalid override of method `copysign`: Definition is incompatible with `OpsHandler.copysign` +torch/_inductor/codegen/halide.py:361:9: error[invalid-method-override] Invalid override of method `erfinv`: Definition is incompatible with `OpsHandler.erfinv` +torch/_inductor/codegen/halide.py:365:9: error[invalid-method-override] Invalid override of method `hypot`: Definition is incompatible with `OpsHandler.hypot` +torch/_inductor/codegen/halide.py:369:9: error[invalid-method-override] Invalid override of method `nextafter`: Definition is incompatible with `OpsHandler.nextafter` +torch/_inductor/codegen/halide.py:373:9: error[invalid-method-override] Invalid override of method `logical_and`: Definition is incompatible with `OpsHandler.logical_and` +torch/_inductor/codegen/halide.py:377:9: error[invalid-method-override] Invalid override of method `logical_not`: Definition is incompatible with `OpsHandler.logical_not` +torch/_inductor/codegen/halide.py:381:9: error[invalid-method-override] Invalid override of method `logical_or`: Definition is incompatible with `OpsHandler.logical_or` +torch/_inductor/codegen/halide.py:385:9: error[invalid-method-override] Invalid override of method `logical_xor`: Definition is incompatible with `OpsHandler.logical_xor` +torch/_inductor/codegen/halide.py:389:9: error[invalid-method-override] Invalid override of method `bitwise_and`: Definition is incompatible with `OpOverrides.bitwise_and` +torch/_inductor/codegen/halide.py:393:9: error[invalid-method-override] Invalid override of method `bitwise_not`: Definition is incompatible with `OpOverrides.bitwise_not` +torch/_inductor/codegen/halide.py:397:9: error[invalid-method-override] Invalid override of method `bitwise_or`: Definition is incompatible with `OpOverrides.bitwise_or` +torch/_inductor/codegen/halide.py:401:9: error[invalid-method-override] Invalid override of method `bitwise_xor`: Definition is incompatible with `OpOverrides.bitwise_xor` +torch/_inductor/codegen/halide.py:405:9: error[invalid-method-override] Invalid override of method `bitwise_left_shift`: Definition is incompatible with `OpOverrides.bitwise_left_shift` +torch/_inductor/codegen/halide.py:409:9: error[invalid-method-override] Invalid override of method `bitwise_right_shift`: Definition is incompatible with `OpOverrides.bitwise_right_shift` +torch/_inductor/codegen/halide.py:429:9: error[invalid-method-override] Invalid override of method `rsqrt`: Definition is incompatible with `OpsHandler.rsqrt` +torch/_inductor/codegen/halide.py:434:9: error[invalid-method-override] Invalid override of method `tan`: Definition is incompatible with `OpsHandler.tan` +torch/_inductor/codegen/halide.py:438:9: error[invalid-method-override] Invalid override of method `tanh`: Definition is incompatible with `OpsHandler.tanh` +torch/_inductor/codegen/halide.py:442:9: error[invalid-method-override] Invalid override of method `signbit`: Definition is incompatible with `OpsHandler.signbit` +torch/_inductor/codegen/halide.py:446:9: error[invalid-method-override] Invalid override of method `fmod`: Definition is incompatible with `OpsHandler.fmod` +torch/_inductor/codegen/halide.py:451:9: error[invalid-method-override] Invalid override of method `pow`: Definition is incompatible with `OpsHandler.pow` +torch/_inductor/codegen/halide.py:455:9: error[invalid-method-override] Invalid override of method `log`: Definition is incompatible with `OpsHandler.log` +torch/_inductor/codegen/halide.py:459:9: error[invalid-method-override] Invalid override of method `log2`: Definition is incompatible with `OpsHandler.log2` +torch/_inductor/codegen/halide.py:463:9: error[invalid-method-override] Invalid override of method `isinf`: Definition is incompatible with `OpsHandler.isinf` +torch/_inductor/codegen/halide.py:468:9: error[invalid-method-override] Invalid override of method `isnan`: Definition is incompatible with `OpsHandler.isnan` +torch/_inductor/codegen/halide.py:473:9: error[invalid-method-override] Invalid override of method `round`: Definition is incompatible with `OpsHandler.round` +torch/_inductor/codegen/halide.py:477:9: error[invalid-method-override] Invalid override of method `floor`: Definition is incompatible with `OpsHandler.floor` +torch/_inductor/codegen/halide.py:481:9: error[invalid-method-override] Invalid override of method `int_truediv`: Definition is incompatible with `OpsHandler.int_truediv` +torch/_inductor/codegen/halide.py:485:9: error[invalid-method-override] Invalid override of method `floordiv`: Definition is incompatible with `OpsHandler.floordiv` +torch/_inductor/codegen/halide.py:492:9: error[invalid-method-override] Invalid override of method `sign`: Definition is incompatible with `OpsHandler.sign` torch/_inductor/codegen/halide.py:493:45: error[unresolved-attribute] Module `torch` has no member `int8` torch/_inductor/codegen/halide.py:494:46: error[unresolved-attribute] Module `torch` has no member `int8` +torch/_inductor/codegen/halide.py:499:9: error[invalid-method-override] Invalid override of method `trunc`: Definition is incompatible with `OpsHandler.trunc` +torch/_inductor/codegen/halide.py:503:9: error[invalid-method-override] Invalid override of method `truncdiv`: Definition is incompatible with `OpsHandler.truncdiv` +torch/_inductor/codegen/halide.py:511:9: error[invalid-method-override] Invalid override of method `ceil`: Definition is incompatible with `OpsHandler.ceil` +torch/_inductor/codegen/halide.py:515:9: error[invalid-method-override] Invalid override of method `relu`: Definition is incompatible with `OpsHandler.relu` torch/_inductor/codegen/halide.py:526:26: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/codegen/halide.py:526:39: error[unresolved-attribute] Module `torch` has no member `int64` +torch/_inductor/codegen/halide.py:531:9: error[invalid-method-override] Invalid override of method `indirect_indexing`: Definition is incompatible with `OpOverrides.indirect_indexing` torch/_inductor/codegen/halide.py:533:45: error[unresolved-attribute] Module `torch` has no member `int32` +torch/_inductor/codegen/halide.py:566:9: error[invalid-method-override] Invalid override of method `frexp`: Definition is incompatible with `OpsHandler.frexp` torch/_inductor/codegen/halide.py:594:25: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/halide.py:720:35: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/halide.py:727:40: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `ValueRanges[Any]`, found `Unknown | None` @@ -3977,10 +4262,8 @@ torch/_inductor/codegen/halide.py:1133:37: error[unresolved-attribute] Module `t torch/_inductor/codegen/halide.py:1134:21: error[unresolved-attribute] Module `torch` has no member `float32` torch/_inductor/codegen/halide.py:1199:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/halide.py:1200:20: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/codegen/halide.py:1299:9: error[invalid-method-override] Invalid override of method `scan`: Definition is incompatible with `Kernel.scan` torch/_inductor/codegen/halide.py:1301:23: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/_inductor/codegen/halide.py:1669:27: error[missing-argument] No argument provided for required parameter `graph_name` of function `write_get_raw_stream` -torch/_inductor/codegen/halide.py:1670:39: error[invalid-argument-type] Argument to bound method `write_get_raw_stream` is incorrect: Expected `str`, found `Unknown | str | None` -torch/_inductor/codegen/halide.py:1670:39: error[invalid-argument-type] Argument to function `write_get_raw_stream` is incorrect: Expected `int`, found `Unknown | str | None` torch/_inductor/codegen/halide.py:1693:43: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/codegen/memory_planning.py:228:35: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `tuple[()]`? torch/_inductor/codegen/memory_planning.py:229:33: error[invalid-type-form] List literals are not allowed in this context in a type expression: Did you mean `tuple[()]`? @@ -4008,9 +4291,44 @@ torch/_inductor/codegen/mps.py:178:29: error[unresolved-attribute] Module `torch torch/_inductor/codegen/mps.py:181:21: error[unresolved-attribute] Module `torch` has no member `double` torch/_inductor/codegen/mps.py:190:32: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/mps.py:190:56: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/codegen/mps.py:195:9: error[invalid-method-override] Invalid override of method `constant`: Definition is incompatible with `OpOverrides.constant` torch/_inductor/codegen/mps.py:195:55: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/mps.py:199:45: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/codegen/mps.py:207:9: error[invalid-method-override] Invalid override of method `masked`: Definition is incompatible with `OpsHandler.masked` torch/_inductor/codegen/mps.py:210:22: error[call-non-callable] Object of type `Expr` is not callable +torch/_inductor/codegen/mps.py:218:9: error[invalid-method-override] Invalid override of method `where`: Definition is incompatible with `OpsHandler.where` +torch/_inductor/codegen/mps.py:222:9: error[invalid-method-override] Invalid override of method `remainder`: Definition is incompatible with `OpsHandler.remainder` +torch/_inductor/codegen/mps.py:226:9: error[invalid-method-override] Invalid override of method `maximum`: Definition is incompatible with `OpsHandler.maximum` +torch/_inductor/codegen/mps.py:232:9: error[invalid-method-override] Invalid override of method `minimum`: Definition is incompatible with `OpsHandler.minimum` +torch/_inductor/codegen/mps.py:238:9: error[invalid-method-override] Invalid override of method `logical_or`: Definition is incompatible with `OpsHandler.logical_or` +torch/_inductor/codegen/mps.py:242:9: error[invalid-method-override] Invalid override of method `logical_and`: Definition is incompatible with `OpsHandler.logical_and` +torch/_inductor/codegen/mps.py:246:9: error[invalid-method-override] Invalid override of method `isnan`: Definition is incompatible with `OpsHandler.isnan` +torch/_inductor/codegen/mps.py:250:9: error[invalid-method-override] Invalid override of method `isinf`: Definition is incompatible with `OpsHandler.isinf` +torch/_inductor/codegen/mps.py:254:9: error[invalid-method-override] Invalid override of method `log`: Definition is incompatible with `OpsHandler.log` +torch/_inductor/codegen/mps.py:258:9: error[invalid-method-override] Invalid override of method `exp`: Definition is incompatible with `OpsHandler.exp` +torch/_inductor/codegen/mps.py:262:9: error[invalid-method-override] Invalid override of method `abs`: Definition is incompatible with `OpsHandler.abs` +torch/_inductor/codegen/mps.py:266:9: error[invalid-method-override] Invalid override of method `signbit`: Definition is incompatible with `OpsHandler.signbit` +torch/_inductor/codegen/mps.py:270:9: error[invalid-method-override] Invalid override of method `sin`: Definition is incompatible with `OpsHandler.sin` +torch/_inductor/codegen/mps.py:278:9: error[invalid-method-override] Invalid override of method `cos`: Definition is incompatible with `OpsHandler.cos` +torch/_inductor/codegen/mps.py:282:9: error[invalid-method-override] Invalid override of method `tan`: Definition is incompatible with `OpsHandler.tan` +torch/_inductor/codegen/mps.py:286:9: error[invalid-method-override] Invalid override of method `asin`: Definition is incompatible with `OpsHandler.asin` +torch/_inductor/codegen/mps.py:290:9: error[invalid-method-override] Invalid override of method `acos`: Definition is incompatible with `OpsHandler.acos` +torch/_inductor/codegen/mps.py:294:9: error[invalid-method-override] Invalid override of method `atan`: Definition is incompatible with `OpsHandler.atan` +torch/_inductor/codegen/mps.py:298:9: error[invalid-method-override] Invalid override of method `atan2`: Definition is incompatible with `OpsHandler.atan2` +torch/_inductor/codegen/mps.py:302:9: error[invalid-method-override] Invalid override of method `sqrt`: Definition is incompatible with `OpsHandler.sqrt` +torch/_inductor/codegen/mps.py:306:9: error[invalid-method-override] Invalid override of method `neg`: Definition is incompatible with `BasicMathOpsMixin.neg` +torch/_inductor/codegen/mps.py:312:9: error[invalid-method-override] Invalid override of method `rsqrt`: Definition is incompatible with `OpsHandler.rsqrt` +torch/_inductor/codegen/mps.py:316:9: error[invalid-method-override] Invalid override of method `tanh`: Definition is incompatible with `OpsHandler.tanh` +torch/_inductor/codegen/mps.py:320:9: error[invalid-method-override] Invalid override of method `atanh`: Definition is incompatible with `OpsHandler.atanh` +torch/_inductor/codegen/mps.py:324:9: error[invalid-method-override] Invalid override of method `floordiv`: Definition is incompatible with `OpsHandler.floordiv` +torch/_inductor/codegen/mps.py:329:9: error[invalid-method-override] Invalid override of method `floor`: Definition is incompatible with `OpsHandler.floor` +torch/_inductor/codegen/mps.py:333:9: error[invalid-method-override] Invalid override of method `sign`: Definition is incompatible with `OpsHandler.sign` +torch/_inductor/codegen/mps.py:337:9: error[invalid-method-override] Invalid override of method `fmod`: Definition is incompatible with `OpsHandler.fmod` +torch/_inductor/codegen/mps.py:343:9: error[invalid-method-override] Invalid override of method `trunc`: Definition is incompatible with `OpsHandler.trunc` +torch/_inductor/codegen/mps.py:347:9: error[invalid-method-override] Invalid override of method `truncdiv`: Definition is incompatible with `OpsHandler.truncdiv` +torch/_inductor/codegen/mps.py:356:9: error[invalid-method-override] Invalid override of method `ceil`: Definition is incompatible with `OpsHandler.ceil` +torch/_inductor/codegen/mps.py:377:9: error[invalid-method-override] Invalid override of method `round`: Definition is incompatible with `OpsHandler.round` +torch/_inductor/codegen/mps.py:381:9: error[invalid-method-override] Invalid override of method `pow`: Definition is incompatible with `OpsHandler.pow` torch/_inductor/codegen/mps.py:486:35: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/mps.py:495:22: error[unresolved-attribute] Module `torch` has no member `float16` torch/_inductor/codegen/mps.py:495:37: error[unresolved-attribute] Module `torch` has no member `bfloat16` @@ -4025,42 +4343,90 @@ torch/_inductor/codegen/mps.py:575:16: error[unresolved-attribute] Module `torch torch/_inductor/codegen/mps.py:576:20: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/mps.py:630:13: warning[possibly-missing-attribute] Attribute `writeline` may be missing on object of type `Unknown | IndentedBuffer | None` torch/_inductor/codegen/mps.py:639:51: error[invalid-argument-type] Argument to bound method `_new_idxvar` is incorrect: Expected `int | None`, found `int | Expr | Unknown` -torch/_inductor/codegen/mps.py:652:17: error[invalid-argument-type] Argument to bound method `generate` is incorrect: Expected `IndentedBuffer`, found `Unknown | IndentedBuffer | None` torch/_inductor/codegen/mps.py:657:51: error[invalid-argument-type] Argument to bound method `_new_idxvar` is incorrect: Expected `int | None`, found `int | Expr | Unknown` -torch/_inductor/codegen/mps.py:672:17: error[invalid-argument-type] Argument to bound method `generate` is incorrect: Expected `IndentedBuffer`, found `Unknown | IndentedBuffer | None` torch/_inductor/codegen/mps.py:677:56: error[invalid-argument-type] Argument to bound method `_new_idxvar` is incorrect: Expected `int | None`, found `int | Expr | Unknown` torch/_inductor/codegen/mps.py:678:51: error[invalid-argument-type] Argument to bound method `_new_idxvar` is incorrect: Expected `int | None`, found `int | Expr | Unknown` -torch/_inductor/codegen/mps.py:710:17: error[invalid-argument-type] Argument to bound method `generate` is incorrect: Expected `IndentedBuffer`, found `Unknown | IndentedBuffer | None` torch/_inductor/codegen/mps.py:717:55: error[invalid-argument-type] Argument to bound method `_new_idxvar` is incorrect: Expected `int | None`, found `Min` torch/_inductor/codegen/mps.py:722:27: error[unresolved-attribute] Module `torch` has no member `float32` torch/_inductor/codegen/mps.py:725:50: error[invalid-argument-type] Argument to bound method `_new_idxvar` is incorrect: Expected `int | None`, found `Min` -torch/_inductor/codegen/mps.py:732:17: error[invalid-argument-type] Argument to bound method `generate` is incorrect: Expected `IndentedBuffer`, found `Unknown | IndentedBuffer | None` torch/_inductor/codegen/mps.py:734:23: error[unresolved-attribute] Module `torch` has no member `float32` torch/_inductor/codegen/mps.py:739:50: error[invalid-argument-type] Argument to bound method `_new_idxvar` is incorrect: Expected `int | None`, found `Min` -torch/_inductor/codegen/mps.py:751:17: error[invalid-argument-type] Argument to bound method `generate` is incorrect: Expected `IndentedBuffer`, found `Unknown | IndentedBuffer | None` torch/_inductor/codegen/mps.py:753:23: error[unresolved-attribute] Module `torch` has no member `float32` -torch/_inductor/codegen/mps.py:829:17: error[invalid-argument-type] Argument to bound method `invalidate` is incorrect: Expected `OrderedSet[CSEVariable]`, found `OrderedSet[object]` torch/_inductor/codegen/mps.py:841:26: error[invalid-argument-type] Argument to bound method `splice` is incorrect: Expected `IndentedBuffer | str`, found `Unknown | IndentedBuffer | None` torch/_inductor/codegen/mps.py:844:9: warning[possibly-missing-attribute] Attribute `clear` may be missing on object of type `Unknown | IndentedBuffer | None` torch/_inductor/codegen/mps.py:899:33: error[unresolved-attribute] Module `torch` has no member `float64` -torch/_inductor/codegen/mps.py:959:42: error[invalid-argument-type] Argument to bound method `ensure_size_computed` is incorrect: Expected `Symbol`, found `Unknown | Expr` torch/_inductor/codegen/mps.py:1034:20: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/codegen/multi_kernel.py:263:21: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/multi_kernel.py:263:39: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` -torch/_inductor/codegen/multi_kernel.py:265:21: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/multi_kernel.py:265:39: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` +torch/_inductor/codegen/pallas.py:73:9: error[invalid-method-override] Invalid override of method `sin`: Definition is incompatible with `OpsHandler.sin` +torch/_inductor/codegen/pallas.py:77:9: error[invalid-method-override] Invalid override of method `cos`: Definition is incompatible with `OpsHandler.cos` +torch/_inductor/codegen/pallas.py:81:9: error[invalid-method-override] Invalid override of method `tan`: Definition is incompatible with `OpsHandler.tan` +torch/_inductor/codegen/pallas.py:85:9: error[invalid-method-override] Invalid override of method `sinh`: Definition is incompatible with `OpsHandler.sinh` +torch/_inductor/codegen/pallas.py:89:9: error[invalid-method-override] Invalid override of method `cosh`: Definition is incompatible with `OpsHandler.cosh` +torch/_inductor/codegen/pallas.py:93:9: error[invalid-method-override] Invalid override of method `tanh`: Definition is incompatible with `OpsHandler.tanh` +torch/_inductor/codegen/pallas.py:97:9: error[invalid-method-override] Invalid override of method `asin`: Definition is incompatible with `OpsHandler.asin` +torch/_inductor/codegen/pallas.py:101:9: error[invalid-method-override] Invalid override of method `acos`: Definition is incompatible with `OpsHandler.acos` +torch/_inductor/codegen/pallas.py:105:9: error[invalid-method-override] Invalid override of method `atan`: Definition is incompatible with `OpsHandler.atan` +torch/_inductor/codegen/pallas.py:109:9: error[invalid-method-override] Invalid override of method `exp`: Definition is incompatible with `OpsHandler.exp` +torch/_inductor/codegen/pallas.py:113:9: error[invalid-method-override] Invalid override of method `exp2`: Definition is incompatible with `OpsHandler.exp2` +torch/_inductor/codegen/pallas.py:117:9: error[invalid-method-override] Invalid override of method `expm1`: Definition is incompatible with `OpsHandler.expm1` +torch/_inductor/codegen/pallas.py:121:9: error[invalid-method-override] Invalid override of method `log`: Definition is incompatible with `OpsHandler.log` +torch/_inductor/codegen/pallas.py:125:9: error[invalid-method-override] Invalid override of method `log10`: Definition is incompatible with `OpsHandler.log10` +torch/_inductor/codegen/pallas.py:129:9: error[invalid-method-override] Invalid override of method `log2`: Definition is incompatible with `OpsHandler.log2` +torch/_inductor/codegen/pallas.py:133:9: error[invalid-method-override] Invalid override of method `log1p`: Definition is incompatible with `OpsHandler.log1p` +torch/_inductor/codegen/pallas.py:137:9: error[invalid-method-override] Invalid override of method `sqrt`: Definition is incompatible with `OpsHandler.sqrt` +torch/_inductor/codegen/pallas.py:141:9: error[invalid-method-override] Invalid override of method `rsqrt`: Definition is incompatible with `OpsHandler.rsqrt` +torch/_inductor/codegen/pallas.py:145:9: error[invalid-method-override] Invalid override of method `abs`: Definition is incompatible with `OpsHandler.abs` +torch/_inductor/codegen/pallas.py:149:9: error[invalid-method-override] Invalid override of method `neg`: Definition is incompatible with `BasicMathOpsMixin.neg` +torch/_inductor/codegen/pallas.py:153:9: error[invalid-method-override] Invalid override of method `floor`: Definition is incompatible with `OpsHandler.floor` +torch/_inductor/codegen/pallas.py:157:9: error[invalid-method-override] Invalid override of method `ceil`: Definition is incompatible with `OpsHandler.ceil` +torch/_inductor/codegen/pallas.py:161:9: error[invalid-method-override] Invalid override of method `trunc`: Definition is incompatible with `OpsHandler.trunc` +torch/_inductor/codegen/pallas.py:165:9: error[invalid-method-override] Invalid override of method `round`: Definition is incompatible with `OpsHandler.round` +torch/_inductor/codegen/pallas.py:169:9: error[invalid-method-override] Invalid override of method `sigmoid`: Definition is incompatible with `OpsHandler.sigmoid` +torch/_inductor/codegen/pallas.py:173:9: error[invalid-method-override] Invalid override of method `relu`: Definition is incompatible with `OpsHandler.relu` +torch/_inductor/codegen/pallas.py:177:9: error[invalid-method-override] Invalid override of method `pow`: Definition is incompatible with `OpsHandler.pow` +torch/_inductor/codegen/pallas.py:181:9: error[invalid-method-override] Invalid override of method `maximum`: Definition is incompatible with `OpsHandler.maximum` +torch/_inductor/codegen/pallas.py:185:9: error[invalid-method-override] Invalid override of method `minimum`: Definition is incompatible with `OpsHandler.minimum` +torch/_inductor/codegen/pallas.py:189:9: error[invalid-method-override] Invalid override of method `where`: Definition is incompatible with `OpsHandler.where` torch/_inductor/codegen/pallas.py:195:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/pallas.py:196:29: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/pallas.py:204:45: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/codegen/pallas.py:215:9: error[invalid-method-override] Invalid override of method `constant`: Definition is incompatible with `OpOverrides.constant` torch/_inductor/codegen/pallas.py:215:30: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/pallas.py:218:21: error[unresolved-attribute] Module `torch` has no member `bool` +torch/_inductor/codegen/pallas.py:250:9: error[invalid-method-override] Invalid override of method `eq`: Definition is incompatible with `OpsHandler.eq` +torch/_inductor/codegen/pallas.py:254:9: error[invalid-method-override] Invalid override of method `ne`: Definition is incompatible with `OpsHandler.ne` +torch/_inductor/codegen/pallas.py:258:9: error[invalid-method-override] Invalid override of method `lt`: Definition is incompatible with `OpsHandler.lt` +torch/_inductor/codegen/pallas.py:262:9: error[invalid-method-override] Invalid override of method `le`: Definition is incompatible with `OpsHandler.le` +torch/_inductor/codegen/pallas.py:266:9: error[invalid-method-override] Invalid override of method `gt`: Definition is incompatible with `OpsHandler.gt` +torch/_inductor/codegen/pallas.py:270:9: error[invalid-method-override] Invalid override of method `ge`: Definition is incompatible with `OpsHandler.ge` +torch/_inductor/codegen/pallas.py:275:9: error[invalid-method-override] Invalid override of method `logical_and`: Definition is incompatible with `OpsHandler.logical_and` +torch/_inductor/codegen/pallas.py:279:9: error[invalid-method-override] Invalid override of method `logical_or`: Definition is incompatible with `OpsHandler.logical_or` +torch/_inductor/codegen/pallas.py:283:9: error[invalid-method-override] Invalid override of method `logical_not`: Definition is incompatible with `OpOverrides.logical_not` +torch/_inductor/codegen/pallas.py:287:9: error[invalid-method-override] Invalid override of method `logical_xor`: Definition is incompatible with `OpsHandler.logical_xor` +torch/_inductor/codegen/pallas.py:292:9: error[invalid-method-override] Invalid override of method `atan2`: Definition is incompatible with `OpsHandler.atan2` +torch/_inductor/codegen/pallas.py:296:9: error[invalid-method-override] Invalid override of method `hypot`: Definition is incompatible with `OpsHandler.hypot` +torch/_inductor/codegen/pallas.py:300:9: error[invalid-method-override] Invalid override of method `fmod`: Definition is incompatible with `OpsHandler.fmod` +torch/_inductor/codegen/pallas.py:304:9: error[invalid-method-override] Invalid override of method `remainder`: Definition is incompatible with `OpsHandler.remainder` +torch/_inductor/codegen/pallas.py:317:9: error[invalid-method-override] Invalid override of method `sign`: Definition is incompatible with `OpsHandler.sign` +torch/_inductor/codegen/pallas.py:321:9: error[invalid-method-override] Invalid override of method `signbit`: Definition is incompatible with `OpsHandler.signbit` +torch/_inductor/codegen/pallas.py:326:9: error[invalid-method-override] Invalid override of method `erf`: Definition is incompatible with `OpsHandler.erf` +torch/_inductor/codegen/pallas.py:330:9: error[invalid-method-override] Invalid override of method `erfc`: Definition is incompatible with `OpsHandler.erfc` +torch/_inductor/codegen/pallas.py:334:9: error[invalid-method-override] Invalid override of method `erfinv`: Definition is incompatible with `OpsHandler.erfinv` +torch/_inductor/codegen/pallas.py:338:9: error[invalid-method-override] Invalid override of method `lgamma`: Definition is incompatible with `OpsHandler.lgamma` +torch/_inductor/codegen/pallas.py:347:9: error[invalid-method-override] Invalid override of method `reciprocal`: Definition is incompatible with `OpsHandler.reciprocal` +torch/_inductor/codegen/pallas.py:351:9: error[invalid-method-override] Invalid override of method `square`: Definition is incompatible with `OpsHandler.square` +torch/_inductor/codegen/pallas.py:356:9: error[invalid-method-override] Invalid override of method `fma`: Definition is incompatible with `OpDecompositions.fma` +torch/_inductor/codegen/pallas.py:361:9: error[invalid-method-override] Invalid override of method `copysign`: Definition is incompatible with `OpsHandler.copysign` +torch/_inductor/codegen/pallas.py:365:9: error[invalid-method-override] Invalid override of method `nextafter`: Definition is incompatible with `OpsHandler.nextafter` +torch/_inductor/codegen/pallas.py:373:9: error[invalid-method-override] Invalid override of method `frexp`: Definition is incompatible with `OpsHandler.frexp` +torch/_inductor/codegen/pallas.py:382:9: error[invalid-method-override] Invalid override of method `bitwise_and`: Definition is incompatible with `OpOverrides.bitwise_and` +torch/_inductor/codegen/pallas.py:386:9: error[invalid-method-override] Invalid override of method `bitwise_or`: Definition is incompatible with `OpOverrides.bitwise_or` +torch/_inductor/codegen/pallas.py:390:9: error[invalid-method-override] Invalid override of method `bitwise_xor`: Definition is incompatible with `OpOverrides.bitwise_xor` +torch/_inductor/codegen/pallas.py:394:9: error[invalid-method-override] Invalid override of method `bitwise_not`: Definition is incompatible with `OpsHandler.bitwise_not` torch/_inductor/codegen/pallas.py:724:31: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[Symbol, IterationRangesEntry].__getitem__(key: Symbol, /) -> IterationRangesEntry` cannot be called with key of type `Basic` on object of type `dict[Symbol, IterationRangesEntry]` torch/_inductor/codegen/pallas.py:779:9: warning[possibly-missing-attribute] Attribute `writeline` may be missing on object of type `Unknown | IndentedBuffer | None` torch/_inductor/codegen/pallas.py:783:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/pallas.py:784:20: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/pallas.py:981:25: warning[possibly-missing-attribute] Attribute `_lines` may be missing on object of type `Unknown | IndentedBuffer | None` -torch/_inductor/codegen/pallas.py:1143:9: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/pallas.py:1143:27: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` torch/_inductor/codegen/pallas.py:1150:43: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/codegen/rocm/ck_template.py:18:9: error[unresolved-attribute] Module `torch` has no member `float32` torch/_inductor/codegen/rocm/ck_template.py:19:9: error[unresolved-attribute] Module `torch` has no member `float64` @@ -4100,17 +4466,12 @@ torch/_inductor/codegen/simd.py:448:66: error[invalid-argument-type] Argument is torch/_inductor/codegen/simd.py:473:35: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/simd.py:476:49: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/codegen/simd.py:616:52: error[invalid-argument-type] Argument to bound method `get` is incorrect: Expected `Symbol`, found `Basic` -torch/_inductor/codegen/simd.py:618:39: error[invalid-argument-type] Argument to function `sympy_subs` is incorrect: Expected `dict[Expr, Any]`, found `dict[Unknown | Basic, Unknown]` +torch/_inductor/codegen/simd.py:618:39: error[invalid-argument-type] Argument to function `sympy_subs` is incorrect: Expected `dict[Expr, Any]`, found `dict[Basic, Any]` torch/_inductor/codegen/simd.py:1003:60: error[invalid-argument-type] Argument is incorrect: Expected `dict[Expr, Expr]`, found `dict[Symbol, Expr]` torch/_inductor/codegen/simd.py:1585:19: error[unresolved-attribute] Module `torch` has no member `float` -torch/_inductor/codegen/simd.py:1751:13: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/simd.py:1752:17: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` +torch/_inductor/codegen/simd.py:1605:9: error[invalid-method-override] Invalid override of method `benchmark_codegened_module`: Definition is incompatible with `BaseScheduling.benchmark_codegened_module` torch/_inductor/codegen/simd.py:1817:19: error[unresolved-attribute] Module `torch` has no member `iinfo` torch/_inductor/codegen/simd.py:1817:31: error[unresolved-attribute] Module `torch` has no member `int32` -torch/_inductor/codegen/simd.py:1926:21: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/simd.py:1927:25: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` -torch/_inductor/codegen/simd.py:2266:9: error[missing-argument] No argument provided for required parameter `line` of function `writeline` -torch/_inductor/codegen/simd.py:2266:40: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` torch/_inductor/codegen/simd.py:2673:27: error[invalid-argument-type] Argument to function `sympy_product` is incorrect: Expected `Iterable[Expr]`, found `list[int | Unknown]` torch/_inductor/codegen/simd.py:2678:27: error[invalid-argument-type] Argument to function `sympy_product` is incorrect: Expected `Iterable[Expr]`, found `list[int | Unknown]` torch/_inductor/codegen/simd.py:2703:28: error[invalid-return-type] Return type does not match returned value: expected `tuple[list[int], list[int]]`, found `tuple[list[int | (Expr & ~AlwaysFalsy)], list[int]]` @@ -4136,7 +4497,7 @@ torch/_inductor/codegen/triton_utils.py:43:27: error[unresolved-attribute] Modul torch/_inductor/codegen/triton_utils.py:45:27: error[unresolved-attribute] Module `torch` has no member `float8_e5m2fnuz` torch/_inductor/codegen/triton_utils.py:89:23: error[unresolved-attribute] Module `torch` has no member `iinfo` torch/_inductor/codegen/triton_utils.py:89:35: error[unresolved-attribute] Module `torch` has no member `int32` -torch/_inductor/codegen/triton_utils.py:187:27: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/codegen/triton_utils.py:187:27: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/codegen/wrapper.py:25:19: error[unresolved-import] Module `torch` has no member `dtype` torch/_inductor/codegen/wrapper.py:78:12: error[unresolved-import] Cannot resolve imported module `triton` torch/_inductor/codegen/wrapper.py:91:18: error[unresolved-attribute] Module `torch` has no member `device` @@ -4144,7 +4505,7 @@ torch/_inductor/codegen/wrapper.py:91:32: error[unresolved-attribute] Module `to torch/_inductor/codegen/wrapper.py:174:63: error[not-iterable] Object of type `(tuple[int | Expr, ...] & ~(() -> object)) | (((dict[str, int], /) -> tuple[int, ...]) & ~(() -> object))` may not be iterable torch/_inductor/codegen/wrapper.py:267:12: error[unresolved-import] Cannot resolve imported module `triton` torch/_inductor/codegen/wrapper.py:568:13: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/codegen/wrapper.py:1148:19: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_inductor/codegen/wrapper.py:1148:19: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_inductor/codegen/wrapper.py:1233:34: error[unresolved-import] Module `torch._C` has no member `_cuda_getCurrentRawStream` torch/_inductor/codegen/wrapper.py:1279:16: error[invalid-assignment] Object of type `str` is not assignable to `dict[str, int]` torch/_inductor/codegen/wrapper.py:1283:13: error[invalid-assignment] Invalid subscript assignment with key of type `dict[str, int]` and value of type `str` on object of type `dict[str, str]` @@ -4357,7 +4718,9 @@ torch/_inductor/codegen/wrapper.py:3659:17: error[missing-argument] No argument torch/_inductor/codegen/wrapper.py:3660:21: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` torch/_inductor/codegen/wrapper.py:3662:17: error[missing-argument] No argument provided for required parameter `line` of function `writeline` torch/_inductor/codegen/wrapper.py:3662:32: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `ExitSubgraphLine` +torch/_inductor/codegen/wrapper.py:3796:9: error[invalid-method-override] Invalid override of method `get_graph_inputs`: Definition is incompatible with `PythonWrapperCodegen.get_graph_inputs` torch/_inductor/codegen/wrapper.py:3805:16: error[invalid-return-type] Return type does not match returned value: expected `dict[str, TensorBox | TorchBindObject | Expr | None]`, found `Unknown | dict[str, TensorBox | TorchBindObject | Expr]` +torch/_inductor/codegen/wrapper_fxir.py:99:9: error[invalid-method-override] Invalid override of method `get_example`: Definition is incompatible with `CodegenSymbol.get_example` torch/_inductor/codegen/wrapper_fxir.py:166:9: error[missing-argument] No argument provided for required parameter `line` of function `writeline` torch/_inductor/codegen/wrapper_fxir.py:166:24: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `ConditionalLine` torch/_inductor/codegen/wrapper_fxir.py:198:16: error[invalid-return-type] Return type does not match returned value: expected `dict[str, TensorBox | TorchBindObject | Expr | None]`, found `dict[str, TensorBox | TorchBindObject | Expr]` @@ -4388,103 +4751,105 @@ torch/_inductor/comms.py:63:18: warning[possibly-missing-attribute] Member `get_ torch/_inductor/comms.py:66:5: warning[possibly-missing-attribute] Member `all_gather_object` may be missing on module `torch.distributed` torch/_inductor/comms.py:69:34: error[unresolved-attribute] Module `torch` has no member `median` torch/_inductor/comms.py:70:9: error[unresolved-attribute] Module `torch` has no member `tensor` -torch/_inductor/comms.py:776:8: error[unresolved-attribute] Module `importlib` has no member `util` -torch/_inductor/comms.py:1614:8: error[unresolved-attribute] Module `importlib` has no member `util` +torch/_inductor/comms.py:776:8: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` +torch/_inductor/comms.py:1614:8: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` torch/_inductor/comms.py:2138:12: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/_inductor/comms.py:2149:12: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/_inductor/comms.py:2427:9: error[invalid-argument-type] Argument to function `register_graph_pattern` is incorrect: Expected `_PassDictsType`, found `PatternMatcherPass` -torch/_inductor/comms.py:2471:13: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/comms.py:2472:13: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/comms.py:2479:18: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/comms.py:2480:28: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/comms.py:2482:11: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` +torch/_inductor/comms.py:2471:13: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/comms.py:2472:13: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/comms.py:2479:18: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/comms.py:2480:28: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/comms.py:2482:11: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` torch/_inductor/compile_fx.py:44:5: warning[possibly-missing-import] Member `detect_fake_mode` of module `torch._dynamo.utils` may be missing -torch/_inductor/compile_fx.py:252:15: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_inductor/compile_fx.py:252:15: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_inductor/compile_fx.py:384:21: error[unresolved-attribute] Module `torch` has no member `equal` torch/_inductor/compile_fx.py:649:47: error[unresolved-attribute] Module `torch` has no member `float32` -torch/_inductor/compile_fx.py:785:29: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` -torch/_inductor/compile_fx.py:835:22: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/compile_fx.py:886:21: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_inductor/compile_fx.py:785:29: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` +torch/_inductor/compile_fx.py:835:22: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/compile_fx.py:886:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_inductor/compile_fx.py:922:37: error[invalid-argument-type] Argument to function `prepare_key` is incorrect: Expected `_CompileFxKwargs`, found `dict[str, @Todo]` -torch/_inductor/compile_fx.py:944:12: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_inductor/compile_fx.py:944:12: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_inductor/compile_fx.py:1091:64: error[invalid-argument-type] Argument to bound method `post_compile` is incorrect: Expected `_CompileFxKwargs`, found `dict[str, @Todo]` -torch/_inductor/compile_fx.py:1238:13: error[unresolved-attribute] Module `torch._dynamo` has no member `repro` -torch/_inductor/compile_fx.py:1342:25: error[unresolved-attribute] Module `torch.fx` has no member `traceback` -torch/_inductor/compile_fx.py:1344:21: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/compile_fx.py:1346:29: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/compile_fx.py:1545:29: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/compile_fx.py:1548:29: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/compile_fx.py:1593:25: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/compile_fx.py:1596:21: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/compile_fx.py:1666:25: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/compile_fx.py:1668:29: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/compile_fx.py:1672:29: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/compile_fx.py:1677:29: error[unresolved-attribute] Module `torch._inductor` has no member `debug` +torch/_inductor/compile_fx.py:1238:13: warning[possibly-missing-attribute] Submodule `repro` may not be available as an attribute on module `torch._dynamo` +torch/_inductor/compile_fx.py:1342:25: warning[possibly-missing-attribute] Submodule `traceback` may not be available as an attribute on module `torch.fx` +torch/_inductor/compile_fx.py:1344:21: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/compile_fx.py:1346:29: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/compile_fx.py:1545:29: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/compile_fx.py:1548:29: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/compile_fx.py:1593:25: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/compile_fx.py:1596:21: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/compile_fx.py:1666:25: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/compile_fx.py:1668:29: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/compile_fx.py:1672:29: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/compile_fx.py:1677:29: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` torch/_inductor/compile_fx.py:1683:25: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `((...) -> Any) | None`, found `Unknown | list[str | Weights] | str | (bound method FileBackedGraphModule.call(args: list[Any]) -> Any)` torch/_inductor/compile_fx.py:1754:76: error[invalid-argument-type] Argument to bound method `codegen_and_compile` is incorrect: Expected `_CompileFxKwargs`, found `dict[str, @Todo]` torch/_inductor/compile_fx.py:1754:76: error[invalid-argument-type] Argument to bound method `codegen_and_compile` is incorrect: Expected `_CompileFxKwargs`, found `dict[str, @Todo]` torch/_inductor/compile_fx.py:1754:76: error[invalid-argument-type] Argument to bound method `codegen_and_compile` is incorrect: Expected `_CompileFxKwargs`, found `dict[str, @Todo]` torch/_inductor/compile_fx.py:1754:76: error[invalid-argument-type] Argument to bound method `codegen_and_compile` is incorrect: Expected `_CompileFxKwargs`, found `dict[str, @Todo]` torch/_inductor/compile_fx.py:1754:76: error[invalid-argument-type] Argument to bound method `codegen_and_compile` is incorrect: Expected `_CompileFxKwargs`, found `dict[str, @Todo]` -torch/_inductor/compile_fx.py:1819:24: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_inductor/compile_fx.py:1819:24: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_inductor/compile_fx.py:1840:12: error[unresolved-attribute] Module `torch` has no member `empty_strided` torch/_inductor/compile_fx.py:1931:20: error[invalid-return-type] Return type does not match returned value: expected `(list[Tensor | int | SymInt | None], /) -> Any`, found `(Any & Top[list[Unknown]]) | (Any & tuple[object, ...]) | tuple[Any & ~Top[list[Unknown]] & ~tuple[object, ...]]` torch/_inductor/compile_fx.py:1947:20: error[invalid-return-type] Return type does not match returned value: expected `(list[Tensor | int | SymInt | None], /) -> Any`, found `(Any & Top[list[Unknown]]) | (Any & tuple[object, ...]) | tuple[Any & ~Top[list[Unknown]] & ~tuple[object, ...]]` -torch/_inductor/compile_fx.py:1993:29: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/compile_fx.py:1996:9: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/compile_fx.py:2062:23: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_inductor/compile_fx.py:1993:29: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/compile_fx.py:1996:9: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/compile_fx.py:2062:23: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_inductor/compile_fx.py:2150:30: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/compile_fx.py:2296:19: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/compile_fx.py:2421:5: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/compile_fx.py:2426:17: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/compile_fx.py:2633:9: error[unresolved-attribute] Module `torch.fx` has no member `traceback` -torch/_inductor/compile_fx.py:2636:9: error[unresolved-attribute] Module `torch._inductor` has no member `debug` +torch/_inductor/compile_fx.py:2296:19: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/compile_fx.py:2421:5: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/compile_fx.py:2426:17: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/compile_fx.py:2633:9: warning[possibly-missing-attribute] Submodule `traceback` may not be available as an attribute on module `torch.fx` +torch/_inductor/compile_fx.py:2636:9: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` torch/_inductor/compile_fx.py:2681:36: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` -torch/_inductor/compile_fx.py:2717:13: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/compile_fx.py:2718:16: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_inductor/compile_fx.py:2717:13: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/compile_fx.py:2718:16: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_inductor/compile_fx.py:2754:49: error[unresolved-attribute] Module `torch` has no member `ScriptObject` torch/_inductor/compile_fx.py:2780:27: error[unresolved-attribute] Module `torch._C` has no member `_is_any_autocast_enabled` torch/_inductor/compile_fx.py:2782:17: error[unresolved-attribute] Module `torch._C` has no member `_DisableAutocast` -torch/_inductor/compile_fx.py:2789:13: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_inductor/compile_fx.py:2789:13: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_inductor/compile_fx.py:2824:17: error[unresolved-attribute] Object of type `object` has no attribute `returns` torch/_inductor/compile_fx.py:2825:54: error[unresolved-attribute] Object of type `object` has no attribute `returns` torch/_inductor/compile_fx.py:2881:40: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/compile_fx.py:2900:36: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/compile_fx.py:2923:29: error[unresolved-import] Module `torch._inductor.compile_fx` has no member `graph_returns_tuple` torch/_inductor/compile_fx.py:2959:29: error[unresolved-attribute] Module `torch` has no member `ScriptObject` -torch/_inductor/compile_fx_ext.py:105:25: error[unresolved-attribute] Module `torch._inductor` has no member `virtualized` -torch/_inductor/compile_fx_ext.py:193:31: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/compile_fx_ext.py:197:9: error[unresolved-attribute] Module `torch.testing` has no member `_internal` -torch/_inductor/compile_fx_ext.py:215:19: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/compile_fx_ext.py:220:17: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/_inductor/compile_fx_ext.py:251:25: error[unresolved-attribute] Module `torch.fx` has no member `experimental` +torch/_inductor/compile_fx_async.py:261:9: error[invalid-method-override] Invalid override of method `__call__`: Definition is incompatible with `OutputCode.__call__` +torch/_inductor/compile_fx_ext.py:105:25: warning[possibly-missing-attribute] Submodule `virtualized` may not be available as an attribute on module `torch._inductor` +torch/_inductor/compile_fx_ext.py:193:31: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/compile_fx_ext.py:197:9: warning[possibly-missing-attribute] Submodule `_internal` may not be available as an attribute on module `torch.testing` +torch/_inductor/compile_fx_ext.py:215:19: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/compile_fx_ext.py:220:17: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/_inductor/compile_fx_ext.py:251:25: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` torch/_inductor/compile_fx_ext.py:320:38: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Logger | PlaceHolder` torch/_inductor/compile_fx_ext.py:320:53: warning[possibly-missing-attribute] Attribute `level` may be missing on object of type `Logger | PlaceHolder` -torch/_inductor/compile_fx_ext.py:451:19: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/compile_fx_ext.py:459:13: error[unresolved-attribute] Module `torch.testing` has no member `_internal` -torch/_inductor/compile_fx_ext.py:520:37: error[unresolved-attribute] Module `unittest` has no member `mock` -torch/_inductor/compile_fx_ext.py:537:33: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/compile_fx_subproc.py:88:9: error[unresolved-attribute] Module `torch._inductor` has no member `metrics` +torch/_inductor/compile_fx_ext.py:451:19: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/compile_fx_ext.py:459:13: warning[possibly-missing-attribute] Submodule `_internal` may not be available as an attribute on module `torch.testing` +torch/_inductor/compile_fx_ext.py:520:37: warning[possibly-missing-attribute] Submodule `mock` may not be available as an attribute on module `unittest` +torch/_inductor/compile_fx_ext.py:537:33: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/compile_fx_subproc.py:34:9: error[invalid-method-override] Invalid override of method `_send_to_child_async`: Definition is incompatible with `_OutOfProcessFxCompile._send_to_child_async` +torch/_inductor/compile_fx_subproc.py:88:9: warning[possibly-missing-attribute] Submodule `metrics` may not be available as an attribute on module `torch._inductor` torch/_inductor/compile_worker/__main__.py:30:12: error[unresolved-import] Cannot resolve imported module `triton` -torch/_inductor/compile_worker/subproc_pool.py:446:9: error[unresolved-attribute] Module `multiprocessing` has no member `util` +torch/_inductor/compile_worker/subproc_pool.py:446:9: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `multiprocessing` torch/_inductor/compile_worker/subproc_pool.py:483:9: error[call-non-callable] Object of type `object` is not callable -torch/_inductor/compile_worker/tracked_process_pool.py:81:24: error[unresolved-attribute] Module `concurrent` has no member `futures` +torch/_inductor/compile_worker/tracked_process_pool.py:81:24: warning[possibly-missing-attribute] Submodule `futures` may not be available as an attribute on module `concurrent` torch/_inductor/compile_worker/utils.py:42:5: error[unresolved-attribute] Module `torch._C` has no member `_initCrashHandler` -torch/_inductor/config.py:291:16: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/config.py:292:15: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/config.py:301:16: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/config.py:302:15: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/config.py:393:20: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/config.py:394:19: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/config.py:639:20: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_inductor/config.py:643:20: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_inductor/config.py:291:16: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/config.py:292:15: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/config.py:301:16: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/config.py:302:15: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/config.py:393:20: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/config.py:394:19: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/config.py:639:20: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_inductor/config.py:643:20: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_inductor/config.py:1040:14: error[unresolved-import] Cannot resolve imported module `libfb.py` torch/_inductor/config.py:1853:26: error[no-matching-overload] No overload of function `dirname` matches arguments torch/_inductor/constant_folding.py:130:37: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/constant_folding.py:242:17: error[unresolved-attribute] Module `torch` has no member `Tag` torch/_inductor/constant_folding.py:253:28: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` -torch/_inductor/constant_folding.py:312:10: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` -torch/_inductor/constant_folding.py:342:10: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_inductor/constant_folding.py:312:10: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` +torch/_inductor/constant_folding.py:342:10: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_inductor/cpp_builder.py:37:10: error[unresolved-import] Cannot resolve imported module `triton.fb.build` torch/_inductor/cpp_builder.py:39:10: error[unresolved-import] Cannot resolve imported module `torch._inductor.fb.utils` torch/_inductor/cpu_vec_isa.py:40:28: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -4537,7 +4902,7 @@ torch/_inductor/cudagraph_trees.py:1728:16: error[unresolved-attribute] Module ` torch/_inductor/cudagraph_trees.py:1753:21: error[unresolved-attribute] Module `torch._C` has no member `_tensors_data_ptrs_at_indices_equal` torch/_inductor/cudagraph_trees.py:1831:8: error[unresolved-attribute] Module `torch._C` has no member `_cuda_checkPoolLiveAllocations` torch/_inductor/cudagraph_trees.py:1932:9: error[unresolved-attribute] Module `torch._C` has no member `_set_cached_tensors_enabled` -torch/_inductor/cudagraph_trees.py:2023:20: error[unresolved-attribute] Module `torch` has no member `_environment` +torch/_inductor/cudagraph_trees.py:2023:20: warning[possibly-missing-attribute] Submodule `_environment` may not be available as an attribute on module `torch` torch/_inductor/cudagraph_trees.py:2503:17: error[unresolved-attribute] Module `torch._C` has no member `_set_storage_access_error_msg` torch/_inductor/cudagraph_trees.py:2531:17: error[unresolved-attribute] Module `torch._C` has no member `_free_And_Remove_DeleterFn` torch/_inductor/cudagraph_trees.py:2536:17: error[unresolved-attribute] Module `torch._C` has no member `_set_storage_data_ptr_access_error_msg` @@ -4555,7 +4920,7 @@ torch/_inductor/debug.py:855:13: error[unresolved-attribute] Module `torch` has torch/_inductor/debug.py:1146:24: error[unresolved-attribute] Object of type `object` has no attribute `node` torch/_inductor/debug.py:1153:49: error[unresolved-attribute] Object of type `object` has no attribute `node` torch/_inductor/debug.py:1157:43: error[unresolved-attribute] Object of type `object` has no attribute `node` -torch/_inductor/debug.py:1232:20: error[unresolved-attribute] Module `torch._dynamo` has no member `testing` +torch/_inductor/debug.py:1232:20: warning[possibly-missing-attribute] Submodule `testing` may not be available as an attribute on module `torch._dynamo` torch/_inductor/decomposition.py:195:16: error[unresolved-attribute] Module `torch` has no member `full` torch/_inductor/decomposition.py:211:39: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/decomposition.py:230:12: error[unresolved-attribute] Module `torch` has no member `empty` @@ -4631,7 +4996,7 @@ torch/_inductor/decomposition.py:1050:19: error[invalid-assignment] Object of ty torch/_inductor/decomposition.py:1052:16: error[invalid-assignment] Object of type `Sequence[int]` is not assignable to `int | list[int]` torch/_inductor/decomposition.py:1054:15: error[invalid-assignment] Object of type `Sequence[int]` is not assignable to `int | list[int]` torch/_inductor/decomposition.py:1056:14: error[invalid-assignment] Object of type `Sequence[int]` is not assignable to `int | list[int] | None` -torch/_inductor/decomposition.py:1061:9: error[unresolved-attribute] Module `torch._inductor` has no member `lowering` +torch/_inductor/decomposition.py:1061:9: warning[possibly-missing-attribute] Submodule `lowering` may not be available as an attribute on module `torch._inductor` torch/_inductor/decomposition.py:1064:26: error[unresolved-attribute] Module `torch` has no member `iinfo` torch/_inductor/decomposition.py:1064:38: error[unresolved-attribute] Module `torch` has no member `int8` torch/_inductor/decomposition.py:1124:63: error[unresolved-attribute] Module `torch` has no member `int64` @@ -4667,26 +5032,28 @@ torch/_inductor/dependencies.py:585:25: error[unresolved-attribute] Module `torc torch/_inductor/dependencies.py:635:26: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `Sequence[Expr]`, found `list[int]` torch/_inductor/dependencies.py:636:38: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `(int, /) -> Unknown`, found `(Expr, /) -> Symbol` torch/_inductor/dependencies.py:721:13: error[invalid-argument-type] Argument to bound method `bucketize` is incorrect: Expected `tuple[str, Expr, Expr, Expr]`, found `tuple[Any, None, None, None]` -torch/_inductor/dependencies.py:731:18: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/dependencies.py:731:18: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` +torch/_inductor/dependencies.py:814:9: error[invalid-method-override] Invalid override of method `indirect_indexing`: Definition is incompatible with `OpsHandler.indirect_indexing` +torch/_inductor/dependencies.py:825:9: error[invalid-method-override] Invalid override of method `frexp`: Definition is incompatible with `OpsHandler.frexp` torch/_inductor/dependencies.py:840:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/dependencies.py:841:20: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/distributed_autotune.py:37:15: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` torch/_inductor/distributed_autotune.py:61:26: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` torch/_inductor/distributed_autotune.py:62:32: warning[possibly-missing-attribute] Member `is_initialized` may be missing on module `torch.distributed` torch/_inductor/distributed_autotune.py:65:28: warning[possibly-missing-attribute] Member `distributed_c10d` may be missing on module `torch.distributed` -torch/_inductor/distributed_autotune.py:73:25: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/distributed_autotune.py:129:12: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/distributed_autotune.py:73:25: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/distributed_autotune.py:129:12: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/distributed_autotune.py:200:5: warning[possibly-missing-attribute] Member `all_gather_object` may be missing on module `torch.distributed` -torch/_inductor/distributed_autotune.py:312:16: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/distributed_autotune.py:363:16: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` +torch/_inductor/distributed_autotune.py:312:16: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/distributed_autotune.py:363:16: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` torch/_inductor/dtype_propagation.py:22:24: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/dtype_propagation.py:34:27: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/dtype_propagation.py:39:20: error[unresolved-attribute] Module `torch` has no member `empty` torch/_inductor/dtype_propagation.py:41:20: error[unresolved-attribute] Module `torch` has no member `empty` -torch/_inductor/dtype_propagation.py:44:16: error[unresolved-attribute] Module `torch` has no member `_prims_common` -torch/_inductor/dtype_propagation.py:66:36: error[unresolved-attribute] Module `torch` has no member `_prims_common` -torch/_inductor/dtype_propagation.py:68:28: error[unresolved-attribute] Module `torch` has no member `_prims_common` -torch/_inductor/dtype_propagation.py:110:19: error[unresolved-attribute] Module `torch._inductor` has no member `codegen` +torch/_inductor/dtype_propagation.py:44:16: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` +torch/_inductor/dtype_propagation.py:66:36: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` +torch/_inductor/dtype_propagation.py:68:28: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` +torch/_inductor/dtype_propagation.py:110:19: warning[possibly-missing-attribute] Submodule `codegen` may not be available as an attribute on module `torch._inductor` torch/_inductor/dtype_propagation.py:124:74: error[unresolved-attribute] Module `torch` has no member `bool` torch/_inductor/dtype_propagation.py:138:10: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/dtype_propagation.py:142:46: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -4756,15 +5123,15 @@ torch/_inductor/dtype_propagation.py:368:47: error[unresolved-attribute] Module torch/_inductor/dtype_propagation.py:373:45: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/dtype_propagation.py:387:42: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/exc.py:136:23: error[invalid-type-form] Variable of type `type` is not allowed in a type expression -torch/_inductor/freezing.py:31:18: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_inductor/freezing.py:108:27: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_inductor/freezing.py:31:18: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_inductor/freezing.py:108:27: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_inductor/freezing.py:157:52: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `Unknown | None` -torch/_inductor/freezing.py:171:10: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` -torch/_inductor/freezing.py:174:14: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/freezing.py:185:22: error[unresolved-attribute] Module `torch` has no member `_dispatch` -torch/_inductor/freezing.py:194:10: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` -torch/_inductor/freezing.py:202:18: error[unresolved-attribute] Module `torch` has no member `_dispatch` -torch/_inductor/freezing.py:223:22: error[unresolved-attribute] Module `torch` has no member `_prims_common` +torch/_inductor/freezing.py:171:10: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` +torch/_inductor/freezing.py:174:14: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/freezing.py:185:22: warning[possibly-missing-attribute] Submodule `_dispatch` may not be available as an attribute on module `torch` +torch/_inductor/freezing.py:194:10: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` +torch/_inductor/freezing.py:202:18: warning[possibly-missing-attribute] Submodule `_dispatch` may not be available as an attribute on module `torch` +torch/_inductor/freezing.py:223:22: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` torch/_inductor/freezing.py:279:43: error[unresolved-attribute] Module `torch` has no member `channels_last` torch/_inductor/freezing.py:287:39: error[unresolved-attribute] Module `torch` has no member `channels_last` torch/_inductor/fx_passes/b2b_gemm.py:447:9: error[unresolved-attribute] Module `torch` has no member `mm` @@ -4773,10 +5140,10 @@ torch/_inductor/fx_passes/b2b_gemm.py:449:9: error[unresolved-attribute] Module torch/_inductor/fx_passes/b2b_gemm.py:449:43: error[unresolved-attribute] Module `torch` has no member `mm` torch/_inductor/fx_passes/b2b_gemm.py:515:23: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/fx_passes/b2b_gemm.py:515:44: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/fx_passes/b2b_gemm.py:527:8: error[unresolved-attribute] Module `torch._inductor` has no member `ir` -torch/_inductor/fx_passes/b2b_gemm.py:528:8: error[unresolved-attribute] Module `torch._inductor` has no member `ir` -torch/_inductor/fx_passes/b2b_gemm.py:529:8: error[unresolved-attribute] Module `torch._inductor` has no member `ir` -torch/_inductor/fx_passes/b2b_gemm.py:532:6: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/fx_passes/b2b_gemm.py:527:8: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/b2b_gemm.py:528:8: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/b2b_gemm.py:529:8: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/b2b_gemm.py:532:6: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/fx_passes/b2b_gemm.py:581:5: error[invalid-argument-type] Argument to function `register_graph_pattern` is incorrect: Expected `_PassDictsType`, found `PatternMatcherPass` torch/_inductor/fx_passes/b2b_gemm.py:590:18: error[unresolved-attribute] Module `torch` has no member `Tag` torch/_inductor/fx_passes/binary_folding.py:19:39: error[unresolved-attribute] Module `torch` has no member `float16` @@ -4792,7 +5159,7 @@ torch/_inductor/fx_passes/binary_folding.py:214:57: error[unresolved-attribute] torch/_inductor/fx_passes/binary_folding.py:214:72: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/fx_passes/binary_folding.py:268:57: error[unresolved-attribute] Module `torch` has no member `float16` torch/_inductor/fx_passes/binary_folding.py:268:72: error[unresolved-attribute] Module `torch` has no member `bfloat16` -torch/_inductor/fx_passes/binary_folding.py:310:18: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_inductor/fx_passes/binary_folding.py:310:18: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_inductor/fx_passes/binary_folding.py:311:32: error[unresolved-attribute] Module `torch` has no member `tensor` torch/_inductor/fx_passes/ddp_fusion.py:65:12: error[unresolved-attribute] Module `torch` has no member `Size` torch/_inductor/fx_passes/ddp_fusion.py:65:30: error[unresolved-attribute] Module `torch` has no member `Size` @@ -4818,8 +5185,8 @@ torch/_inductor/fx_passes/efficient_conv_bn_eval.py:169:9: error[unresolved-attr torch/_inductor/fx_passes/efficient_conv_bn_eval.py:170:9: error[unresolved-attribute] Module `torch` has no member `conv_transpose1d` torch/_inductor/fx_passes/efficient_conv_bn_eval.py:171:9: error[unresolved-attribute] Module `torch` has no member `conv_transpose2d` torch/_inductor/fx_passes/efficient_conv_bn_eval.py:172:9: error[unresolved-attribute] Module `torch` has no member `conv_transpose3d` -torch/_inductor/fx_passes/freezing_patterns.py:51:5: error[unresolved-attribute] Module `torch._inductor` has no member `fx_passes` -torch/_inductor/fx_passes/freezing_patterns.py:65:5: error[unresolved-attribute] Module `torch._inductor` has no member `fx_passes` +torch/_inductor/fx_passes/freezing_patterns.py:51:5: warning[possibly-missing-attribute] Submodule `fx_passes` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/freezing_patterns.py:65:5: warning[possibly-missing-attribute] Submodule `fx_passes` may not be available as an attribute on module `torch._inductor` torch/_inductor/fx_passes/freezing_patterns.py:78:9: error[unresolved-attribute] Module `torch._C` has no member `_has_mkldnn` torch/_inductor/fx_passes/freezing_patterns.py:82:36: warning[possibly-missing-import] Member `_eliminate_duplicate_packed_nodes` of module `torch._inductor.fx_passes.mkldnn_fusion` may be missing torch/_inductor/fx_passes/freezing_patterns.py:93:8: error[unresolved-attribute] Module `torch._C` has no member `_has_mkldnn` @@ -4984,19 +5351,20 @@ torch/_inductor/fx_passes/group_batch_fusion.py:1122:26: error[unresolved-attrib torch/_inductor/fx_passes/group_batch_fusion.py:1134:26: error[unresolved-attribute] Module `torch` has no member `detach` torch/_inductor/fx_passes/group_batch_fusion.py:1140:26: error[unresolved-attribute] Module `torch` has no member `nan_to_num` torch/_inductor/fx_passes/group_batch_fusion.py:1146:26: error[unresolved-attribute] Module `torch` has no member `clamp` -torch/_inductor/fx_passes/joint_graph.py:73:10: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` -torch/_inductor/fx_passes/joint_graph.py:170:10: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_inductor/fx_passes/joint_graph.py:73:10: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` +torch/_inductor/fx_passes/joint_graph.py:170:10: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_inductor/fx_passes/joint_graph.py:172:41: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/fx_passes/joint_graph.py:278:17: error[unresolved-attribute] Module `torch` has no member `full` +torch/_inductor/fx_passes/joint_graph.py:290:9: error[invalid-method-override] Invalid override of method `insertable_tensor_check`: Definition is incompatible with `ConstantFolder.insertable_tensor_check` torch/_inductor/fx_passes/joint_graph.py:363:13: error[unresolved-attribute] Module `torch` has no member `Tag` -torch/_inductor/fx_passes/joint_graph.py:382:10: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_inductor/fx_passes/joint_graph.py:382:10: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_inductor/fx_passes/joint_graph.py:422:60: error[unresolved-attribute] Module `torch` has no member `contiguous_format` torch/_inductor/fx_passes/joint_graph.py:427:17: error[unresolved-attribute] Module `torch` has no member `uint8` torch/_inductor/fx_passes/joint_graph.py:428:17: error[unresolved-attribute] Module `torch` has no member `uint16` torch/_inductor/fx_passes/joint_graph.py:429:17: error[unresolved-attribute] Module `torch` has no member `uint32` torch/_inductor/fx_passes/joint_graph.py:430:17: error[unresolved-attribute] Module `torch` has no member `uint64` torch/_inductor/fx_passes/joint_graph.py:472:35: error[unresolved-attribute] Module `torch` has no member `strided` -torch/_inductor/fx_passes/joint_graph.py:572:9: error[unresolved-attribute] Module `torch.fx` has no member `passes` +torch/_inductor/fx_passes/joint_graph.py:572:9: warning[possibly-missing-attribute] Submodule `passes` may not be available as an attribute on module `torch.fx` torch/_inductor/fx_passes/joint_graph.py:645:31: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/fx_passes/joint_graph.py:689:50: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/fx_passes/joint_graph.py:689:71: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -5028,7 +5396,7 @@ torch/_inductor/fx_passes/misc_patterns.py:59:17: error[unresolved-attribute] Mo torch/_inductor/fx_passes/misc_patterns.py:63:17: error[unresolved-attribute] Module `torch` has no member `randperm` torch/_inductor/fx_passes/misc_patterns.py:71:10: error[unresolved-attribute] Module `torch` has no member `empty` torch/_inductor/fx_passes/misc_patterns.py:73:9: error[invalid-argument-type] Argument to function `register_replacement` is incorrect: Expected `TraceFn`, found `def fwd_only(fn: (...) -> Any, args: Sequence[Any], *, run_functional_passes: bool = Literal[True], get_decomp_fn: ((...) -> Any) | None = None) -> GraphModule` -torch/_inductor/fx_passes/misc_patterns.py:110:30: error[unresolved-attribute] Module `torch.fx` has no member `operator_schemas` +torch/_inductor/fx_passes/misc_patterns.py:110:30: warning[possibly-missing-attribute] Submodule `operator_schemas` may not be available as an attribute on module `torch.fx` torch/_inductor/fx_passes/mkldnn_fusion.py:42:4: error[unresolved-attribute] Module `torch._C` has no member `_has_mkldnn` torch/_inductor/fx_passes/mkldnn_fusion.py:293:26: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/fx_passes/mkldnn_fusion.py:295:28: error[unresolved-attribute] Module `torch` has no member `float16` @@ -5072,19 +5440,19 @@ torch/_inductor/fx_passes/node_runtime_estimation.py:51:12: warning[possibly-mis torch/_inductor/fx_passes/node_runtime_estimation.py:54:10: warning[possibly-missing-attribute] Member `distributed_c10d` may be missing on module `torch.distributed` torch/_inductor/fx_passes/node_runtime_estimation.py:55:8: warning[possibly-missing-attribute] Member `distributed_c10d` may be missing on module `torch.distributed` torch/_inductor/fx_passes/node_runtime_estimation.py:81:9: warning[possibly-missing-attribute] Member `barrier` may be missing on module `torch.distributed` -torch/_inductor/fx_passes/node_runtime_estimation.py:106:10: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` -torch/_inductor/fx_passes/node_runtime_estimation.py:159:5: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` +torch/_inductor/fx_passes/node_runtime_estimation.py:106:10: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` +torch/_inductor/fx_passes/node_runtime_estimation.py:159:5: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` torch/_inductor/fx_passes/numeric_utils.py:61:16: error[unresolved-attribute] Module `torch` has no member `allclose` torch/_inductor/fx_passes/numeric_utils.py:90:16: error[unresolved-attribute] Module `torch` has no member `allclose` -torch/_inductor/fx_passes/overlap_scheduling.py:71:12: error[unresolved-attribute] Module `torch._inductor` has no member `comm_analysis` -torch/_inductor/fx_passes/overlap_scheduling.py:83:12: error[unresolved-attribute] Module `torch.utils` has no member `flop_counter` -torch/_inductor/fx_passes/overlap_scheduling.py:100:13: error[unresolved-attribute] Module `torch._inductor` has no member `runtime` -torch/_inductor/fx_passes/overlap_scheduling.py:116:29: error[unresolved-attribute] Module `torch._inductor` has no member `fx_utils` -torch/_inductor/fx_passes/overlap_scheduling.py:139:24: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` -torch/_inductor/fx_passes/overlap_scheduling.py:172:30: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` -torch/_inductor/fx_passes/overlap_scheduling.py:173:12: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` -torch/_inductor/fx_passes/overlap_scheduling.py:376:23: error[unresolved-attribute] Module `torch._inductor` has no member `comm_analysis` -torch/_inductor/fx_passes/overlap_scheduling.py:381:27: error[unresolved-attribute] Module `torch._inductor` has no member `comm_analysis` +torch/_inductor/fx_passes/overlap_scheduling.py:71:12: warning[possibly-missing-attribute] Submodule `comm_analysis` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/overlap_scheduling.py:83:12: warning[possibly-missing-attribute] Submodule `flop_counter` may not be available as an attribute on module `torch.utils` +torch/_inductor/fx_passes/overlap_scheduling.py:100:13: warning[possibly-missing-attribute] Submodule `runtime` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/overlap_scheduling.py:116:29: warning[possibly-missing-attribute] Submodule `fx_utils` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/overlap_scheduling.py:139:24: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` +torch/_inductor/fx_passes/overlap_scheduling.py:172:30: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/overlap_scheduling.py:173:12: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/overlap_scheduling.py:376:23: warning[possibly-missing-attribute] Submodule `comm_analysis` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/overlap_scheduling.py:381:27: warning[possibly-missing-attribute] Submodule `comm_analysis` may not be available as an attribute on module `torch._inductor` torch/_inductor/fx_passes/overlap_scheduling.py:461:22: warning[possibly-missing-attribute] Member `get_world_size` may be missing on module `torch.distributed` torch/_inductor/fx_passes/overlap_scheduling.py:468:13: warning[possibly-missing-attribute] Member `all_gather_object` may be missing on module `torch.distributed` torch/_inductor/fx_passes/overlap_scheduling.py:471:42: error[unresolved-attribute] Module `torch` has no member `median` @@ -5096,27 +5464,27 @@ torch/_inductor/fx_passes/pad_mm.py:70:43: error[unresolved-attribute] Module `t torch/_inductor/fx_passes/pad_mm.py:70:66: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/fx_passes/pad_mm.py:72:19: error[unresolved-attribute] Module `torch` has no member `float32` torch/_inductor/fx_passes/pad_mm.py:72:45: error[unresolved-attribute] Module `torch` has no member `float` -torch/_inductor/fx_passes/pad_mm.py:114:9: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_inductor/fx_passes/pad_mm.py:114:9: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_inductor/fx_passes/pad_mm.py:137:12: error[unresolved-attribute] Module `torch` has no member `cat` torch/_inductor/fx_passes/pad_mm.py:217:56: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/fx_passes/pad_mm.py:225:18: error[unresolved-attribute] Module `torch` has no member `bfloat16` -torch/_inductor/fx_passes/pad_mm.py:251:24: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` -torch/_inductor/fx_passes/pad_mm.py:252:12: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` +torch/_inductor/fx_passes/pad_mm.py:251:24: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/pad_mm.py:252:12: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` torch/_inductor/fx_passes/pad_mm.py:279:40: error[unresolved-attribute] Module `torch` has no member `Size` torch/_inductor/fx_passes/pad_mm.py:279:69: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/fx_passes/pad_mm.py:284:26: error[unresolved-attribute] Module `torch` has no member `float32` -torch/_inductor/fx_passes/pad_mm.py:351:11: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_inductor/fx_passes/pad_mm.py:365:38: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_inductor/fx_passes/pad_mm.py:366:22: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_inductor/fx_passes/pad_mm.py:351:11: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/pad_mm.py:365:38: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/pad_mm.py:366:22: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_inductor/fx_passes/pad_mm.py:375:31: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/_inductor/fx_passes/pad_mm.py:377:32: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_inductor/fx_passes/pad_mm.py:377:32: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_inductor/fx_passes/pad_mm.py:381:18: error[unresolved-attribute] Module `torch` has no member `bfloat16` -torch/_inductor/fx_passes/pad_mm.py:405:13: error[unresolved-attribute] Module `torch._inductor.runtime` has no member `benchmarking` +torch/_inductor/fx_passes/pad_mm.py:405:13: warning[possibly-missing-attribute] Submodule `benchmarking` may not be available as an attribute on module `torch._inductor.runtime` torch/_inductor/fx_passes/pad_mm.py:443:17: error[unresolved-attribute] Module `torch` has no member `Size` -torch/_inductor/fx_passes/pad_mm.py:455:12: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_inductor/fx_passes/pad_mm.py:458:12: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_inductor/fx_passes/pad_mm.py:467:35: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_inductor/fx_passes/pad_mm.py:724:8: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_inductor/fx_passes/pad_mm.py:455:12: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/pad_mm.py:458:12: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/pad_mm.py:467:35: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/pad_mm.py:724:8: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_inductor/fx_passes/pad_mm.py:883:31: error[unresolved-attribute] Module `torch` has no member `empty` torch/_inductor/fx_passes/pad_mm.py:884:31: error[unresolved-attribute] Module `torch` has no member `empty` torch/_inductor/fx_passes/pad_mm.py:886:31: error[unresolved-attribute] Module `torch` has no member `empty` @@ -5124,7 +5492,7 @@ torch/_inductor/fx_passes/pad_mm.py:887:31: error[unresolved-attribute] Module ` torch/_inductor/fx_passes/pad_mm.py:889:31: error[unresolved-attribute] Module `torch` has no member `empty` torch/_inductor/fx_passes/pad_mm.py:927:13: error[invalid-argument-type] Argument to function `gen_register_replacement` is incorrect: Expected `TraceFn`, found `def joint_fwd_bwd(fn: (...) -> Any, args: Sequence[Any]) -> GraphModule` torch/_inductor/fx_passes/pad_mm.py:940:13: error[invalid-argument-type] Argument to function `gen_register_replacement` is incorrect: Expected `TraceFn`, found `def fwd_only(fn: (...) -> Any, args: Sequence[Any], *, run_functional_passes: bool = Literal[True], get_decomp_fn: ((...) -> Any) | None = None) -> GraphModule` -torch/_inductor/fx_passes/post_grad.py:96:9: error[unresolved-attribute] Module `torch.fx` has no member `passes` +torch/_inductor/fx_passes/post_grad.py:96:9: warning[possibly-missing-attribute] Submodule `passes` may not be available as an attribute on module `torch.fx` torch/_inductor/fx_passes/post_grad.py:119:8: error[unresolved-attribute] Module `torch._C` has no member `_has_mkldnn` torch/_inductor/fx_passes/post_grad.py:125:40: warning[possibly-missing-import] Member `grouped_gemm_pass` of module `torch._inductor.fx_passes.mkldnn_fusion` may be missing torch/_inductor/fx_passes/post_grad.py:398:24: error[unresolved-attribute] Module `torch` has no member `zeros` @@ -5142,7 +5510,7 @@ torch/_inductor/fx_passes/post_grad.py:708:9: error[invalid-argument-type] Argum torch/_inductor/fx_passes/post_grad.py:867:70: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/fx_passes/post_grad.py:868:16: error[unresolved-attribute] Module `torch` has no member `empty` torch/_inductor/fx_passes/post_grad.py:881:50: error[unresolved-attribute] Module `torch` has no member `int64` -torch/_inductor/fx_passes/post_grad.py:903:12: error[unresolved-attribute] Module `torch._inductor` has no member `kernel` +torch/_inductor/fx_passes/post_grad.py:903:12: warning[possibly-missing-attribute] Submodule `kernel` may not be available as an attribute on module `torch._inductor` torch/_inductor/fx_passes/post_grad.py:930:17: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/fx_passes/post_grad.py:934:15: error[unresolved-attribute] Module `torch` has no member `arange` torch/_inductor/fx_passes/post_grad.py:1049:28: error[unresolved-attribute] Module `torch` has no member `strided` @@ -5152,8 +5520,8 @@ torch/_inductor/fx_passes/post_grad.py:1677:66: error[unresolved-attribute] Modu torch/_inductor/fx_passes/post_grad.py:1782:49: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/fx_passes/post_grad.py:1812:37: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/fx_passes/post_grad.py:1839:45: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/fx_passes/post_grad.py:2001:9: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_inductor/fx_passes/post_grad.py:2002:13: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_inductor/fx_passes/post_grad.py:2001:9: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_passes/post_grad.py:2002:13: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_inductor/fx_passes/pre_grad.py:11:43: warning[possibly-missing-import] Member `detect_fake_mode` of module `torch._dynamo.utils` may be missing torch/_inductor/fx_passes/pre_grad.py:392:8: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_inductor/fx_passes/pre_grad.py:513:54: error[invalid-argument-type] Argument to function `fuse_conv_bn_eval` is incorrect: Expected `_BatchNorm`, found `Unknown | None` @@ -5297,7 +5665,7 @@ torch/_inductor/fx_passes/quantization.py:3768:27: error[unresolved-attribute] M torch/_inductor/fx_passes/quantization.py:3848:55: error[unresolved-attribute] Module `torch` has no member `contiguous_format` torch/_inductor/fx_passes/reinplace.py:722:18: error[unresolved-import] Cannot resolve imported module `triton.runtime.autotuner` torch/_inductor/fx_passes/reinplace.py:723:18: error[unresolved-import] Cannot resolve imported module `triton.runtime.jit` -torch/_inductor/fx_passes/reinplace.py:785:26: error[unresolved-attribute] Module `torch._inductor` has no member `fx_utils` +torch/_inductor/fx_passes/reinplace.py:785:26: warning[possibly-missing-attribute] Submodule `fx_utils` may not be available as an attribute on module `torch._inductor` torch/_inductor/fx_passes/replace_random.py:62:40: error[unresolved-attribute] Module `torch` has no member `empty` torch/_inductor/fx_passes/replace_random.py:63:56: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/fx_passes/replace_random.py:88:12: error[unresolved-attribute] Module `torch` has no member `empty` @@ -5507,9 +5875,11 @@ torch/_inductor/fx_passes/serialized_patterns/_sfdp_pattern_9.py:203:84: error[u torch/_inductor/fx_passes/serialized_patterns/_sfdp_pattern_9.py:218:84: error[unresolved-attribute] Module `torch` has no member `contiguous_format` torch/_inductor/fx_passes/split_cat.py:129:23: error[unresolved-attribute] Module `torch` has no member `unbind` torch/_inductor/fx_passes/split_cat.py:268:25: error[unresolved-attribute] Module `torch` has no member `unbind` +torch/_inductor/fx_passes/split_cat.py:294:8: error[unsupported-operator] Operator `<` is not supported for types `Sequence[Divergent]` and `int`, in comparing `(Any & ~None) | Sequence[Divergent] | Mapping[str, Divergent] | ... omitted 12 union elements` with `Literal[0]` torch/_inductor/fx_passes/split_cat.py:298:13: error[unresolved-attribute] Module `torch` has no member `unbind` torch/_inductor/fx_passes/split_cat.py:309:26: error[unresolved-attribute] Module `torch` has no member `cat` torch/_inductor/fx_passes/split_cat.py:309:37: error[unresolved-attribute] Module `torch` has no member `concat` +torch/_inductor/fx_passes/split_cat.py:344:8: error[unsupported-operator] Operator `<` is not supported for types `Sequence[Divergent]` and `int`, in comparing `(Any & ~None) | Sequence[Divergent] | Mapping[str, Divergent] | ... omitted 12 union elements` with `Literal[0]` torch/_inductor/fx_passes/split_cat.py:353:32: error[unresolved-attribute] Module `torch` has no member `cat` torch/_inductor/fx_passes/split_cat.py:359:13: error[unresolved-attribute] Module `torch` has no member `cat` torch/_inductor/fx_passes/split_cat.py:370:25: error[unresolved-attribute] Module `torch` has no member `stack` @@ -5569,6 +5939,7 @@ torch/_inductor/fx_passes/split_cat.py:1502:9: error[unresolved-attribute] Modul torch/_inductor/fx_passes/split_cat.py:1521:31: error[unresolved-attribute] Module `torch` has no member `cat` torch/_inductor/fx_passes/split_cat.py:1609:9: error[unresolved-attribute] Module `torch` has no member `cat` torch/_inductor/fx_passes/split_cat.py:1626:31: error[unresolved-attribute] Module `torch` has no member `cat` +torch/_inductor/fx_passes/split_cat.py:1974:8: error[unsupported-operator] Operator `<` is not supported for types `Sequence[Divergent]` and `int`, in comparing `(Any & ~None) | Sequence[Divergent] | Mapping[str, Divergent] | ... omitted 12 union elements` with `Literal[0]` torch/_inductor/fx_passes/split_cat.py:2142:16: error[unresolved-attribute] Module `torch` has no member `Size` torch/_inductor/fx_passes/split_cat.py:2154:17: error[unresolved-attribute] Module `torch` has no member `permute` torch/_inductor/fx_passes/split_cat.py:2157:50: error[unresolved-attribute] Module `torch` has no member `permute` @@ -5611,23 +5982,23 @@ torch/_inductor/fx_passes/split_cat.py:2865:25: error[unresolved-attribute] Modu torch/_inductor/fx_passes/split_cat.py:2869:67: error[unresolved-attribute] Module `torch` has no member `stack` torch/_inductor/fx_passes/split_cat.py:2876:21: error[unresolved-attribute] Module `torch` has no member `cat` torch/_inductor/fx_utils.py:125:30: error[unresolved-attribute] Module `torch` has no member `strided` -torch/_inductor/fx_utils.py:150:28: error[unresolved-attribute] Module `torch._inductor` has no member `fx_passes` -torch/_inductor/fx_utils.py:206:20: error[unresolved-attribute] Module `torch._inductor` has no member `fx_passes` +torch/_inductor/fx_utils.py:150:28: warning[possibly-missing-attribute] Submodule `fx_passes` may not be available as an attribute on module `torch._inductor` +torch/_inductor/fx_utils.py:206:20: warning[possibly-missing-attribute] Submodule `fx_passes` may not be available as an attribute on module `torch._inductor` torch/_inductor/fx_utils.py:261:12: error[unresolved-attribute] Module `torch._C` has no member `_has_storage` -torch/_inductor/fx_utils.py:325:18: error[unresolved-attribute] Module `torch.utils` has no member `flop_counter` +torch/_inductor/fx_utils.py:325:18: warning[possibly-missing-attribute] Submodule `flop_counter` may not be available as an attribute on module `torch.utils` torch/_inductor/graph.py:22:19: error[unresolved-import] Module `torch` has no member `device` torch/_inductor/graph.py:145:10: error[unresolved-import] Cannot resolve imported module `torch._inductor.fb.utils` torch/_inductor/graph.py:152:76: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/graph.py:159:16: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/graph.py:179:20: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` torch/_inductor/graph.py:279:13: error[invalid-return-type] Return type does not match returned value: expected `OpOverloadPacket[Unknown, Any] | None`, found `object` -torch/_inductor/graph.py:290:13: error[unresolved-attribute] Module `torch._higher_order_ops` has no member `triton_kernel_wrap` +torch/_inductor/graph.py:290:13: warning[possibly-missing-attribute] Submodule `triton_kernel_wrap` may not be available as an attribute on module `torch._higher_order_ops` torch/_inductor/graph.py:298:16: error[unresolved-attribute] Module `torch._C` has no member `Tag` torch/_inductor/graph.py:418:24: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` torch/_inductor/graph.py:470:39: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/graph.py:487:40: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/graph.py:592:20: error[invalid-return-type] Return type does not match returned value: expected `Sequence[Expr]`, found `list[int]` -torch/_inductor/graph.py:607:23: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/graph.py:607:23: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/graph.py:630:46: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/graph.py:637:42: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/graph.py:907:39: error[unresolved-attribute] Module `torch` has no member `device` @@ -5639,10 +6010,10 @@ torch/_inductor/graph.py:978:20: warning[possibly-missing-attribute] Attribute ` torch/_inductor/graph.py:1005:31: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/graph.py:1025:30: error[invalid-argument-type] Argument to function `register` is incorrect: Expected `Iterable[IRNode] | IRNode`, found `object` torch/_inductor/graph.py:1106:66: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/graph.py:1114:14: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_inductor/graph.py:1114:14: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_inductor/graph.py:1151:20: error[invalid-return-type] Return type does not match returned value: expected `Expr | TensorBox | None`, found `TorchBindObject` torch/_inductor/graph.py:1161:34: error[unresolved-attribute] Module `torch` has no member `Generator` -torch/_inductor/graph.py:1165:17: error[unresolved-attribute] Module `torch` has no member `_prims` +torch/_inductor/graph.py:1165:17: warning[possibly-missing-attribute] Submodule `_prims` may not be available as an attribute on module `torch` torch/_inductor/graph.py:1171:20: error[invalid-return-type] Return type does not match returned value: expected `Expr | TensorBox | None`, found `GeneratorState` torch/_inductor/graph.py:1192:71: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Sequence[Expr]`, found `Sequence[int | Expr]` torch/_inductor/graph.py:1192:78: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Sequence[Expr] | None`, found `Sequence[int | Expr]` @@ -5651,30 +6022,30 @@ torch/_inductor/graph.py:1200:78: error[invalid-argument-type] Argument to bound torch/_inductor/graph.py:1204:9: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `TensorBox | ShapeAsConstantBuffer` on object of type `dict[str, TensorBox | TorchBindObject | Expr]` torch/_inductor/graph.py:1225:16: error[invalid-return-type] Return type does not match returned value: expected `Expr | TensorBox | None`, found `TensorBox | ShapeAsConstantBuffer` torch/_inductor/graph.py:1256:31: error[unresolved-attribute] Module `torch._C` has no member `Tag` -torch/_inductor/graph.py:1261:25: error[unresolved-attribute] Module `torch._library` has no member `utils` +torch/_inductor/graph.py:1261:25: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` torch/_inductor/graph.py:1275:34: error[unresolved-attribute] Module `torch._C` has no member `Tag` -torch/_inductor/graph.py:1310:38: error[unresolved-attribute] Module `torch.fx` has no member `operator_schemas` +torch/_inductor/graph.py:1310:38: warning[possibly-missing-attribute] Submodule `operator_schemas` may not be available as an attribute on module `torch.fx` torch/_inductor/graph.py:1373:30: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` -torch/_inductor/graph.py:1460:24: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/graph.py:1460:24: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/graph.py:1471:19: error[invalid-assignment] Object of type `TensorBox | TorchBindObject | Expr` is not assignable to `IRNode` -torch/_inductor/graph.py:1475:48: error[unresolved-attribute] Module `torch._inductor` has no member `ir` -torch/_inductor/graph.py:1547:23: error[unresolved-attribute] Module `torch._higher_order_ops` has no member `triton_kernel_wrap` +torch/_inductor/graph.py:1475:48: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` +torch/_inductor/graph.py:1547:23: warning[possibly-missing-attribute] Submodule `triton_kernel_wrap` may not be available as an attribute on module `torch._higher_order_ops` torch/_inductor/graph.py:1568:25: error[unresolved-attribute] Module `torch._C` has no member `Argument` torch/_inductor/graph.py:1589:26: error[unresolved-attribute] Object of type `object` has no attribute `arguments` torch/_inductor/graph.py:1592:51: error[unresolved-attribute] Object of type `object` has no attribute `arguments` -torch/_inductor/graph.py:1625:21: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/_inductor/graph.py:1748:29: error[unresolved-attribute] Module `torch` has no member `_prims_common` +torch/_inductor/graph.py:1625:21: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/_inductor/graph.py:1748:29: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` torch/_inductor/graph.py:1763:29: error[invalid-argument-type] Argument to function `stride_ordered_for_memory_format` is incorrect: Expected `Sequence[int]`, found `Unknown | Sequence[Expr]` torch/_inductor/graph.py:1763:48: error[unresolved-attribute] Module `torch` has no member `channels_last` torch/_inductor/graph.py:1771:29: warning[possibly-missing-attribute] Attribute `data` may be missing on object of type `Unknown | IRNode` torch/_inductor/graph.py:1818:28: error[unresolved-attribute] Module `torch._C` has no member `_has_mkldnn` torch/_inductor/graph.py:1836:32: error[unresolved-attribute] Module `torch._C` has no member `has_mkl` torch/_inductor/graph.py:1856:39: error[unresolved-attribute] Object of type `IRNode` has no attribute `data` -torch/_inductor/graph.py:2129:23: error[unresolved-attribute] Module `torch._higher_order_ops` has no member `triton_kernel_wrap` +torch/_inductor/graph.py:2129:23: warning[possibly-missing-attribute] Submodule `triton_kernel_wrap` may not be available as an attribute on module `torch._higher_order_ops` torch/_inductor/graph.py:2143:66: error[unresolved-attribute] Module `torch` has no member `clone` torch/_inductor/graph.py:2203:32: error[invalid-return-type] Return type does not match returned value: expected `int | float | Tensor`, found `None` -torch/_inductor/graph.py:2215:35: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/graph.py:2286:22: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_inductor/graph.py:2215:35: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/graph.py:2286:22: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_inductor/graph.py:2500:17: warning[possibly-missing-attribute] Attribute `get_numel` may be missing on object of type `TensorBox | TorchBindObject | Expr` torch/_inductor/graph.py:2501:21: warning[possibly-missing-attribute] Attribute `get_size` may be missing on object of type `TensorBox | TorchBindObject | Expr` torch/_inductor/index_propagation.py:60:12: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -5693,6 +6064,7 @@ torch/_inductor/index_propagation.py:174:23: error[unresolved-attribute] Module torch/_inductor/index_propagation.py:179:23: error[unresolved-attribute] Module `torch` has no member `promote_types` torch/_inductor/index_propagation.py:234:57: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/index_propagation.py:336:70: error[invalid-argument-type] Argument to function `statically_known_true` is incorrect: Expected `tuple[tuple[Symbol, ValueRanges[Any]]] | None`, found `tuple[@Todo, @Todo]` +torch/_inductor/index_propagation.py:338:9: error[invalid-method-override] Invalid override of method `indirect_indexing`: Definition is incompatible with `OpsHandler.indirect_indexing` torch/_inductor/inductor_prims.py:25:29: error[unresolved-attribute] Module `torch` has no member `Tag` torch/_inductor/inductor_prims.py:59:12: error[unresolved-attribute] Module `torch` has no member `amax` torch/_inductor/inductor_prims.py:60:18: error[unresolved-attribute] Module `torch` has no member `sum` @@ -5732,8 +6104,8 @@ torch/_inductor/ir.py:406:5: error[type-assertion-failure] Type `str` is not equ torch/_inductor/ir.py:409:32: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/ir.py:429:29: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/ir.py:494:38: error[invalid-argument-type] Argument to function `significant_strides_equal` is incorrect: Expected `Sequence[int | Expr]`, found `Sequence[int | SymInt]` -torch/_inductor/ir.py:613:21: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/ir.py:623:25: error[unresolved-attribute] Module `torch._inductor` has no member `debug` +torch/_inductor/ir.py:613:21: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/ir.py:623:25: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` torch/_inductor/ir.py:658:28: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/ir.py:661:43: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/ir.py:729:38: error[unresolved-attribute] Module `torch` has no member `device` @@ -5781,7 +6153,7 @@ torch/_inductor/ir.py:1711:37: error[unresolved-attribute] Module `torch` has no torch/_inductor/ir.py:1719:24: error[unresolved-attribute] Module `torch` has no member `iinfo` torch/_inductor/ir.py:1726:24: error[unresolved-attribute] Module `torch` has no member `iinfo` torch/_inductor/ir.py:1743:37: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/_inductor/ir.py:1822:34: error[invalid-assignment] Object of type `Sequence[Symbol]` is not assignable to `Sequence[Symbol]` +torch/_inductor/ir.py:1822:34: error[invalid-assignment] Object of type `Symbol` is not assignable to `Sequence[Symbol]` torch/_inductor/ir.py:1830:47: error[invalid-argument-type] Argument to function `dtype_from_size` is incorrect: Expected `int`, found `int | Expr` torch/_inductor/ir.py:1833:36: error[invalid-argument-type] Argument to bound method `index_expr` is incorrect: Expected `Expr`, found `int | Expr` torch/_inductor/ir.py:1873:17: error[unresolved-attribute] Module `torch` has no member `device` @@ -5816,9 +6188,9 @@ torch/_inductor/ir.py:2143:16: error[unresolved-attribute] Module `torch` has no torch/_inductor/ir.py:2262:37: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/ir.py:2269:17: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/ir.py:2270:16: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/_inductor/ir.py:2326:13: error[invalid-argument-type] Argument to bound method `create` is incorrect: Expected `list[Integer]`, found `list[Unknown | int | Expr]` -torch/_inductor/ir.py:2327:13: error[invalid-argument-type] Argument to bound method `create` is incorrect: Expected `list[Integer]`, found `list[Unknown | FloorDiv]` -torch/_inductor/ir.py:2353:13: error[invalid-argument-type] Argument to bound method `create` is incorrect: Expected `list[Integer]`, found `list[Unknown | int | Expr]` +torch/_inductor/ir.py:2326:13: error[invalid-argument-type] Argument to bound method `create` is incorrect: Expected `list[Integer]`, found `list[Expr | int]` +torch/_inductor/ir.py:2327:13: error[invalid-argument-type] Argument to bound method `create` is incorrect: Expected `list[Integer]`, found `list[Integer | FloorDiv]` +torch/_inductor/ir.py:2353:13: error[invalid-argument-type] Argument to bound method `create` is incorrect: Expected `list[Integer]`, found `list[Expr | int]` torch/_inductor/ir.py:2369:19: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/ir.py:2418:16: error[invalid-return-type] Return type does not match returned value: expected `Sequence[Expr]`, found `Sequence[int | Expr]` torch/_inductor/ir.py:2433:52: error[invalid-argument-type] Argument to function `extract_free_symbols` is incorrect: Expected `Sequence[Expr]`, found `Sequence[int | Expr]` @@ -5886,6 +6258,7 @@ torch/_inductor/ir.py:3824:65: error[unresolved-attribute] Module `torch` has no torch/_inductor/ir.py:3861:53: error[invalid-argument-type] Argument to bound method `is_unbacked_symint` is incorrect: Expected `Symbol`, found `Basic` torch/_inductor/ir.py:3904:9: error[invalid-assignment] Object of type `Sequence[int]` is not assignable to attribute `stride` on type `Self@pad_strides & FlexibleLayout` torch/_inductor/ir.py:3904:41: error[invalid-argument-type] Argument to function `_pad_strides` is incorrect: Expected `Sequence[int]`, found `Sequence[Expr]` +torch/_inductor/ir.py:3941:9: error[invalid-method-override] Invalid override of method `storage_size`: Definition is incompatible with `OutputSpec.storage_size` torch/_inductor/ir.py:3960:31: error[invalid-argument-type] Argument to function `_fixed_indexer` is incorrect: Expected `Sequence[int]`, found `Sequence[Expr]` torch/_inductor/ir.py:3960:42: error[invalid-argument-type] Argument to function `_fixed_indexer` is incorrect: Expected `Sequence[int] | None`, found `Sequence[Expr]` torch/_inductor/ir.py:3997:16: error[invalid-return-type] Return type does not match returned value: expected `list[Expr]`, found `list[Unknown | None]` @@ -5919,13 +6292,17 @@ torch/_inductor/ir.py:4253:9: error[invalid-assignment] Property `group_name` de torch/_inductor/ir.py:4266:22: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/ir.py:4276:38: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/ir.py:4288:9: error[invalid-assignment] Property `target` defined in `Self@__init__` is read-only +torch/_inductor/ir.py:4300:9: error[invalid-method-override] Invalid override of method `storage_size`: Definition is incompatible with `OutputSpec.storage_size` torch/_inductor/ir.py:4358:27: error[unresolved-attribute] Object of type `object` has no attribute `layout` torch/_inductor/ir.py:4358:66: error[unresolved-attribute] Object of type `object` has no attribute `layout` torch/_inductor/ir.py:4359:9: error[unresolved-attribute] Unresolved attribute `layout` on type `object`. torch/_inductor/ir.py:4360:16: error[invalid-return-type] Return type does not match returned value: expected `IRNode`, found `object` +torch/_inductor/ir.py:4390:9: error[invalid-method-override] Invalid override of method `get_example`: Definition is incompatible with `CodegenSymbol.get_example` torch/_inductor/ir.py:4395:38: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/ir.py:4402:24: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/ir.py:4423:16: error[invalid-return-type] Return type does not match returned value: expected `int`, found `Expr` +torch/_inductor/ir.py:4444:9: error[invalid-method-override] Invalid override of method `freeze_layout_with_same_order`: Definition is incompatible with `IRNode.freeze_layout_with_same_order` +torch/_inductor/ir.py:4448:9: error[invalid-method-override] Invalid override of method `freeze_layout_with_exact_strides`: Definition is incompatible with `IRNode.freeze_layout_with_exact_strides` torch/_inductor/ir.py:4539:31: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/ir.py:4551:42: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/ir.py:4637:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Sequence[Expr]`, found `Sequence[int | Expr]` @@ -5941,9 +6318,9 @@ torch/_inductor/ir.py:4968:54: error[invalid-argument-type] Argument is incorrec torch/_inductor/ir.py:4973:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[tuple[list[Expr], list[Expr]], LoopBody | None]`, found `tuple[tuple[list[int], list[int]], LoopBody]` torch/_inductor/ir.py:5003:60: error[invalid-argument-type] Argument to function `pick_loop_order` is incorrect: Expected `Sequence[Expr]`, found `Sequence[int]` torch/_inductor/ir.py:5030:42: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/ir.py:5301:36: error[unresolved-attribute] Module `torch._inductor` has no member `select_algorithm` -torch/_inductor/ir.py:5325:21: error[unresolved-attribute] Module `torch._inductor` has no member `select_algorithm` -torch/_inductor/ir.py:5338:21: error[unresolved-attribute] Module `torch._inductor` has no member `select_algorithm` +torch/_inductor/ir.py:5301:36: warning[possibly-missing-attribute] Submodule `select_algorithm` may not be available as an attribute on module `torch._inductor` +torch/_inductor/ir.py:5325:21: warning[possibly-missing-attribute] Submodule `select_algorithm` may not be available as an attribute on module `torch._inductor` +torch/_inductor/ir.py:5338:21: warning[possibly-missing-attribute] Submodule `select_algorithm` may not be available as an attribute on module `torch._inductor` torch/_inductor/ir.py:5383:42: error[invalid-argument-type] Argument to bound method `store` is incorrect: Expected `Expr`, found `None` torch/_inductor/ir.py:5464:38: error[unresolved-attribute] Object of type `object` has no attribute `get_name` torch/_inductor/ir.py:5510:60: error[invalid-argument-type] Argument to bound method `unwrap_storage_for_input` is incorrect: Expected `IRNode`, found `object` @@ -5964,7 +6341,7 @@ torch/_inductor/ir.py:5837:28: error[unresolved-attribute] Object of type `objec torch/_inductor/ir.py:5889:40: error[unresolved-attribute] Object of type `object` has no attribute `name` torch/_inductor/ir.py:5998:31: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` torch/_inductor/ir.py:5998:72: error[unresolved-attribute] Module `torch` has no member `Generator` -torch/_inductor/ir.py:6017:32: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/ir.py:6017:32: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/ir.py:6089:35: error[unresolved-attribute] Module `torch` has no member `channels_last` torch/_inductor/ir.py:6092:35: error[unresolved-attribute] Module `torch` has no member `channels_last_3d` torch/_inductor/ir.py:6097:17: error[invalid-argument-type] Argument to bound method `freeze_layout_with_same_order` is incorrect: Expected `Sequence[int]`, found `tuple[Expr | int, ...]` @@ -5973,9 +6350,9 @@ torch/_inductor/ir.py:6139:42: error[invalid-argument-type] Argument is incorrec torch/_inductor/ir.py:6145:21: error[unresolved-attribute] Module `torch` has no member `tensor` torch/_inductor/ir.py:6233:25: error[invalid-argument-type] Argument to function `as_storage_and_layout` is incorrect: Expected `Sequence[int | Integer] | None`, found `Sequence[int | Expr] | None` torch/_inductor/ir.py:6246:56: error[invalid-argument-type] Argument to function `try_match_insignificant_strides` is incorrect: Expected `Sequence[int | SymInt]`, found `Sequence[int | Expr]` -torch/_inductor/ir.py:6320:21: error[unresolved-attribute] Module `torch._inductor` has no member `lowering` +torch/_inductor/ir.py:6320:21: warning[possibly-missing-attribute] Submodule `lowering` may not be available as an attribute on module `torch._inductor` torch/_inductor/ir.py:6332:13: error[invalid-argument-type] Argument to function `as_storage_and_layout` is incorrect: Expected `Sequence[int | Integer] | None`, found `Sequence[int | Expr] | None` -torch/_inductor/ir.py:6338:17: error[unresolved-attribute] Module `torch._inductor` has no member `lowering` +torch/_inductor/ir.py:6338:17: warning[possibly-missing-attribute] Submodule `lowering` may not be available as an attribute on module `torch._inductor` torch/_inductor/ir.py:6340:55: error[invalid-argument-type] Argument to function `try_match_insignificant_strides` is incorrect: Expected `Sequence[int | SymInt]`, found `Sequence[int | Expr]` torch/_inductor/ir.py:6381:54: error[invalid-argument-type] Argument to function `contiguous_strides` is incorrect: Expected `Sequence[int]`, found `Sequence[Expr]` torch/_inductor/ir.py:6389:50: error[invalid-argument-type] Argument to function `contiguous_strides` is incorrect: Expected `Sequence[int]`, found `Sequence[Expr]` @@ -6012,10 +6389,8 @@ torch/_inductor/ir.py:7507:50: error[unresolved-attribute] Module `torch` has no torch/_inductor/ir.py:7560:50: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/ir.py:7599:37: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/ir.py:7626:31: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/ir.py:7657:17: error[invalid-argument-type] Argument to bound method `codegen_cpp_sizevar` is incorrect: Expected `Expr`, found `Unknown | Boolean` torch/_inductor/ir.py:7660:13: error[missing-argument] No argument provided for required parameter `line` of function `writeline` torch/_inductor/ir.py:7661:17: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` -torch/_inductor/ir.py:7665:17: error[invalid-argument-type] Argument to bound method `codegen_python_sizevar` is incorrect: Expected `Expr`, found `Unknown | Boolean` torch/_inductor/ir.py:7667:13: error[missing-argument] No argument provided for required parameter `line` of function `writeline` torch/_inductor/ir.py:7667:31: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` torch/_inductor/ir.py:7668:13: error[missing-argument] No argument provided for required parameter `line` of function `writeline` @@ -6024,7 +6399,7 @@ torch/_inductor/ir.py:7671:13: error[missing-argument] No argument provided for torch/_inductor/ir.py:7671:31: error[invalid-argument-type] Argument to function `writeline` is incorrect: Expected `PythonWrapperCodegen`, found `str` torch/_inductor/ir.py:7760:48: error[unresolved-attribute] Module `torch._C` has no member `Argument` torch/_inductor/ir.py:7762:38: error[unresolved-attribute] Module `torch` has no member `ListType` -torch/_inductor/ir.py:7797:32: error[unresolved-attribute] Module `torch` has no member `_prims` +torch/_inductor/ir.py:7797:32: warning[possibly-missing-attribute] Submodule `_prims` may not be available as an attribute on module `torch` torch/_inductor/ir.py:7836:37: error[unresolved-attribute] Object of type `object` has no attribute `arguments` torch/_inductor/ir.py:7869:43: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/ir.py:7938:32: error[unresolved-attribute] Module `torch` has no member `TensorType` @@ -6084,7 +6459,7 @@ torch/_inductor/kernel/conv.py:335:12: error[unresolved-attribute] Module `torch torch/_inductor/kernel/conv.py:383:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Sequence[Expr] | None`, found `Sequence[int]` torch/_inductor/kernel/custom_op.py:70:23: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `(Unknown & ~AlwaysFalsy) | (((...) -> Any) & (() -> object) & ~AlwaysFalsy)` torch/_inductor/kernel/custom_op.py:188:27: error[unresolved-attribute] Module `torch` has no member `empty` -torch/_inductor/kernel/custom_op.py:354:16: error[unresolved-attribute] Module `torch._library` has no member `custom_ops` +torch/_inductor/kernel/custom_op.py:354:16: warning[possibly-missing-attribute] Submodule `custom_ops` may not be available as an attribute on module `torch._library` torch/_inductor/kernel/flex/common.py:56:42: error[unresolved-attribute] Module `torch` has no member `float32` torch/_inductor/kernel/flex/common.py:206:12: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/kernel/flex/common.py:207:13: error[unresolved-attribute] Module `torch` has no member `device` @@ -6101,7 +6476,7 @@ torch/_inductor/kernel/flex/flex_attention.py:164:19: error[unresolved-attribute torch/_inductor/kernel/flex/flex_attention.py:165:19: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/kernel/flex/flex_attention.py:293:15: error[unresolved-attribute] Module `torch` has no member `float32` torch/_inductor/kernel/flex/flex_attention.py:299:15: error[unresolved-attribute] Module `torch` has no member `float32` -torch/_inductor/kernel/flex/flex_attention.py:439:60: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/kernel/flex/flex_attention.py:439:60: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/kernel/flex/flex_attention.py:656:19: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/kernel/flex/flex_attention.py:657:19: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/kernel/flex/flex_attention.py:658:19: error[unresolved-attribute] Module `torch` has no member `int32` @@ -6110,7 +6485,7 @@ torch/_inductor/kernel/flex/flex_attention.py:690:19: error[unresolved-attribute torch/_inductor/kernel/flex/flex_attention.py:691:19: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/kernel/flex/flex_attention.py:692:19: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/kernel/flex/flex_attention.py:693:19: error[unresolved-attribute] Module `torch` has no member `int32` -torch/_inductor/kernel/flex/flex_attention.py:890:60: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/kernel/flex/flex_attention.py:890:60: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/kernel/flex/flex_cpu.py:97:19: error[unresolved-attribute] Module `torch` has no member `float` torch/_inductor/kernel/flex/flex_cpu.py:102:19: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/kernel/flex/flex_cpu.py:103:19: error[unresolved-attribute] Module `torch` has no member `int64` @@ -6161,7 +6536,7 @@ torch/_inductor/kernel/mm.py:1716:26: error[unresolved-attribute] Module `torch` torch/_inductor/kernel/mm.py:1781:25: error[unresolved-attribute] Module `torch` has no member `float32` torch/_inductor/kernel/mm_common.py:48:18: error[unresolved-attribute] Module `torch` has no member `float16` torch/_inductor/kernel/mm_common.py:48:33: error[unresolved-attribute] Module `torch` has no member `bfloat16` -torch/_inductor/kernel/mm_common.py:141:13: error[unresolved-attribute] Module `torch.utils` has no member `_triton` +torch/_inductor/kernel/mm_common.py:141:13: warning[possibly-missing-attribute] Submodule `_triton` may not be available as an attribute on module `torch.utils` torch/_inductor/kernel/mm_common.py:159:9: error[unresolved-attribute] Module `torch` has no member `int8` torch/_inductor/kernel/mm_common.py:160:9: error[unresolved-attribute] Module `torch` has no member `uint8` torch/_inductor/kernel/mm_common.py:161:9: error[unresolved-attribute] Module `torch` has no member `float16` @@ -6187,7 +6562,14 @@ torch/_inductor/kernel_inputs.py:275:28: error[unresolved-attribute] Module `tor torch/_inductor/lookup_table/choices.py:43:33: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/loop_body.py:284:20: error[invalid-assignment] Implicit shadowing of function `new_body` torch/_inductor/loop_body.py:287:16: error[invalid-return-type] Return type does not match returned value: expected `LoopBody`, found `def new_body(*indices: Sequence[Expr]) -> Any` +torch/_inductor/loop_body.py:644:9: error[invalid-method-override] Invalid override of method `load_seed`: Definition is incompatible with `OpsHandler.load_seed` +torch/_inductor/loop_body.py:672:9: error[invalid-method-override] Invalid override of method `index_expr`: Definition is incompatible with `OpsHandler.index_expr` +torch/_inductor/loop_body.py:679:9: error[invalid-method-override] Invalid override of method `check_bounds`: Definition is incompatible with `OpsHandler.check_bounds` torch/_inductor/loop_body.py:690:25: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/_inductor/loop_body.py:734:9: error[invalid-method-override] Invalid override of method `masked`: Definition is incompatible with `OpsHandler.masked` +torch/_inductor/loop_body.py:745:9: error[invalid-method-override] Invalid override of method `scan`: Definition is incompatible with `OpsHandler.scan` +torch/_inductor/loop_body.py:767:9: error[invalid-method-override] Invalid override of method `frexp`: Definition is incompatible with `OpsHandler.frexp` +torch/_inductor/loop_body.py:772:9: error[invalid-method-override] Invalid override of method `indirect_indexing`: Definition is incompatible with `OpsHandler.indirect_indexing` torch/_inductor/lowering.py:34:5: warning[deprecated] The function `check` is deprecated: `torch._prims_common.check` is deprecated and will be removed in the future. Please use `torch._check*` functions instead. torch/_inductor/lowering.py:185:15: error[unresolved-attribute] Module `torch._C` has no member `Tag` torch/_inductor/lowering.py:189:15: error[unresolved-attribute] Module `torch._C` has no member `Tag` @@ -6319,9 +6701,9 @@ torch/_inductor/lowering.py:2551:19: error[unresolved-attribute] Module `torch` torch/_inductor/lowering.py:2551:49: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/lowering.py:2644:19: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/lowering.py:2644:49: error[unresolved-attribute] Module `torch` has no member `int64` -torch/_inductor/lowering.py:3013:15: error[unresolved-attribute] Module `torch` has no member `_prims` -torch/_inductor/lowering.py:3014:15: error[unresolved-attribute] Module `torch` has no member `_prims` -torch/_inductor/lowering.py:3015:15: error[unresolved-attribute] Module `torch` has no member `_prims` +torch/_inductor/lowering.py:3013:15: warning[possibly-missing-attribute] Submodule `_prims` may not be available as an attribute on module `torch` +torch/_inductor/lowering.py:3014:15: warning[possibly-missing-attribute] Submodule `_prims` may not be available as an attribute on module `torch` +torch/_inductor/lowering.py:3015:15: warning[possibly-missing-attribute] Submodule `_prims` may not be available as an attribute on module `torch` torch/_inductor/lowering.py:3199:42: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/lowering.py:3200:32: error[invalid-argument-type] Argument to bound method `index_expr` is incorrect: Expected `Expr`, found `int | Unknown` torch/_inductor/lowering.py:3200:39: error[unresolved-attribute] Module `torch` has no member `int32` @@ -6387,7 +6769,7 @@ torch/_inductor/lowering.py:4708:21: error[unresolved-attribute] Module `torch` torch/_inductor/lowering.py:4709:61: error[unresolved-attribute] Module `torch` has no member `iinfo` torch/_inductor/lowering.py:4741:19: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/lowering.py:4789:42: error[unresolved-attribute] Module `torch` has no member `int8` -torch/_inductor/lowering.py:4798:9: error[unresolved-attribute] Module `torch._inductor` has no member `virtualized` +torch/_inductor/lowering.py:4798:9: warning[possibly-missing-attribute] Submodule `virtualized` may not be available as an attribute on module `torch._inductor` torch/_inductor/lowering.py:4811:71: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/lowering.py:4816:15: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/lowering.py:4986:52: error[unresolved-attribute] Module `torch` has no member `int32` @@ -6466,8 +6848,8 @@ torch/_inductor/lowering.py:6214:25: error[unresolved-attribute] Module `torch` torch/_inductor/lowering.py:6214:40: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/lowering.py:6215:25: error[unresolved-attribute] Module `torch` has no member `float` torch/_inductor/lowering.py:6291:51: error[unresolved-attribute] Module `torch` has no member `int64` -torch/_inductor/lowering.py:6526:15: error[unresolved-attribute] Module `torch._inductor` has no member `ops_handler` -torch/_inductor/lowering.py:6533:28: error[unresolved-attribute] Module `torch._inductor` has no member `virtualized` +torch/_inductor/lowering.py:6526:15: warning[possibly-missing-attribute] Submodule `ops_handler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/lowering.py:6533:28: warning[possibly-missing-attribute] Submodule `virtualized` may not be available as an attribute on module `torch._inductor` torch/_inductor/lowering.py:6599:17: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/lowering.py:6617:17: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/lowering.py:6641:17: error[unresolved-attribute] Module `torch` has no member `int64` @@ -6632,13 +7014,17 @@ torch/_inductor/ops_handler.py:281:23: error[unresolved-attribute] Module `torch torch/_inductor/ops_handler.py:296:25: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/ops_handler.py:722:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/ops_handler.py:722:30: error[unresolved-attribute] Module `torch` has no member `float32` +torch/_inductor/ops_handler.py:836:9: error[invalid-method-override] Invalid override of method `frexp`: Definition is incompatible with `OpsHandler.frexp` +torch/_inductor/ops_handler.py:848:9: error[invalid-method-override] Invalid override of method `indirect_indexing`: Definition is incompatible with `OpsHandler.indirect_indexing` +torch/_inductor/ops_handler.py:945:9: error[invalid-method-override] Invalid override of method `frexp`: Definition is incompatible with `OpsHandler.frexp` +torch/_inductor/ops_handler.py:963:9: error[invalid-method-override] Invalid override of method `indirect_indexing`: Definition is incompatible with `OpsHandler.indirect_indexing` torch/_inductor/ops_handler.py:1002:16: error[invalid-return-type] Return type does not match returned value: expected `Symbol`, found `Unknown | Expr` torch/_inductor/ops_handler.py:1017:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/ops_handler.py:1018:20: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/ops_handler.py:1107:25: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/ops_handler.py:1138:41: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/ops_handler.py:1141:43: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/_inductor/ops_handler.py:1141:59: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/ops_handler.py:1141:59: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/optimize_indexing.py:29:17: error[unresolved-attribute] Module `torch` has no member `iinfo` torch/_inductor/optimize_indexing.py:29:29: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/optimize_indexing.py:53:13: error[unresolved-attribute] Module `torch` has no member `int32` @@ -6648,19 +7034,19 @@ torch/_inductor/optimize_indexing.py:92:15: error[unresolved-attribute] Module ` torch/_inductor/optimize_indexing.py:108:33: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/output_code.py:118:16: error[invalid-return-type] Return type does not match returned value: expected `list[int]`, found `None` torch/_inductor/output_code.py:137:8: error[unresolved-attribute] Module `torch` has no member `_debug_has_internal_overlap` -torch/_inductor/output_code.py:165:19: error[unresolved-attribute] Module `torch._inductor` has no member `cudagraph_trees` +torch/_inductor/output_code.py:165:19: warning[possibly-missing-attribute] Submodule `cudagraph_trees` may not be available as an attribute on module `torch._inductor` torch/_inductor/output_code.py:421:36: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` torch/_inductor/output_code.py:561:72: error[unresolved-attribute] Module `torch` has no member `Generator` -torch/_inductor/output_code.py:604:13: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/output_code.py:605:17: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/output_code.py:609:17: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/output_code.py:611:21: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/output_code.py:614:13: error[unresolved-attribute] Module `torch._inductor` has no member `debug` -torch/_inductor/output_code.py:805:13: error[unresolved-attribute] Module `torch._inductor` has no member `cpp_builder` -torch/_inductor/output_code.py:806:16: error[unresolved-attribute] Module `torch._inductor` has no member `cpp_builder` +torch/_inductor/output_code.py:604:13: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/output_code.py:605:17: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/output_code.py:609:17: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/output_code.py:611:21: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/output_code.py:614:13: warning[possibly-missing-attribute] Submodule `debug` may not be available as an attribute on module `torch._inductor` +torch/_inductor/output_code.py:805:13: warning[possibly-missing-attribute] Submodule `cpp_builder` may not be available as an attribute on module `torch._inductor` +torch/_inductor/output_code.py:806:16: warning[possibly-missing-attribute] Submodule `cpp_builder` may not be available as an attribute on module `torch._inductor` torch/_inductor/package/package.py:127:13: error[no-matching-overload] No overload of bound method `write` matches arguments -torch/_inductor/package/package.py:129:22: error[unresolved-attribute] Module `torch._C` has no member `_aoti` -torch/_inductor/package/package.py:135:14: error[unresolved-attribute] Module `torch._C` has no member `_aoti` +torch/_inductor/package/package.py:129:22: warning[possibly-missing-attribute] Submodule `_aoti` may not be available as an attribute on module `torch._C` +torch/_inductor/package/package.py:135:14: warning[possibly-missing-attribute] Submodule `_aoti` may not be available as an attribute on module `torch._C` torch/_inductor/pattern_matcher.py:549:72: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[Unknown]`, found `(((...) -> Any) & ~(() -> object) & ~str) | (Sequence[((...) -> Any) | str] & ~(() -> object) & ~str)` torch/_inductor/pattern_matcher.py:565:26: error[unresolved-attribute] Object of type `((...) -> Any) & ~str` has no attribute `__name__` torch/_inductor/pattern_matcher.py:1032:19: error[call-non-callable] Object of type `object` is not callable @@ -6669,8 +7055,8 @@ torch/_inductor/pattern_matcher.py:1371:9: error[unresolved-attribute] Object of torch/_inductor/pattern_matcher.py:1474:21: warning[possibly-missing-attribute] Member `detect_fake_mode` may be missing on module `torch._dynamo.utils` torch/_inductor/pattern_matcher.py:1482:31: error[unresolved-attribute] Module `torch` has no member `empty_strided` torch/_inductor/pattern_matcher.py:1581:12: error[unresolved-attribute] Module `torch` has no member `is_inference_mode_enabled` -torch/_inductor/pattern_matcher.py:1658:25: error[unresolved-attribute] Module `torch._inductor` has no member `pattern_matcher` -torch/_inductor/pattern_matcher.py:1659:28: error[unresolved-attribute] Module `torch._inductor` has no member `pattern_matcher` +torch/_inductor/pattern_matcher.py:1658:25: warning[possibly-missing-attribute] Submodule `pattern_matcher` may not be available as an attribute on module `torch._inductor` +torch/_inductor/pattern_matcher.py:1659:28: warning[possibly-missing-attribute] Submodule `pattern_matcher` may not be available as an attribute on module `torch._inductor` torch/_inductor/pattern_matcher.py:1803:45: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/pattern_matcher.py:1803:59: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/pattern_matcher.py:1896:16: error[unresolved-attribute] Object of type `object` has no attribute `is_mutable` @@ -6687,7 +7073,7 @@ torch/_inductor/quantized_lowerings.py:110:65: error[unresolved-attribute] Modul torch/_inductor/quantized_lowerings.py:111:37: error[unresolved-attribute] Module `torch` has no member `uint8` torch/_inductor/quantized_lowerings.py:114:13: error[unresolved-attribute] Module `torch` has no member `tensor` torch/_inductor/quantized_lowerings.py:114:44: error[unresolved-attribute] Module `torch` has no member `int64` -torch/_inductor/quantized_lowerings.py:149:35: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/quantized_lowerings.py:149:35: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/quantized_lowerings.py:153:20: error[unresolved-attribute] Module `torch` has no member `randint` torch/_inductor/quantized_lowerings.py:153:55: error[unresolved-attribute] Module `torch` has no member `uint8` torch/_inductor/remote_cache.py:26:12: error[unresolved-import] Cannot resolve imported module `redis` @@ -6699,12 +7085,12 @@ torch/_inductor/remote_cache.py:279:16: warning[possibly-missing-attribute] Attr torch/_inductor/remote_cache.py:299:16: warning[possibly-missing-attribute] Attribute `exceptions` may be missing on object of type `Unknown | None` torch/_inductor/remote_cache.py:361:20: error[unresolved-import] Cannot resolve imported module `torch._inductor.fb.remote_cache` torch/_inductor/remote_gemm_autotune_cache.py:16:14: error[unresolved-import] Cannot resolve imported module `torch._inductor.fb.remote_gemm_autotune_cache` -torch/_inductor/runtime/autotune_cache.py:71:28: error[unresolved-attribute] Module `torch.utils` has no member `_triton` +torch/_inductor/runtime/autotune_cache.py:71:28: warning[possibly-missing-attribute] Submodule `_triton` may not be available as an attribute on module `torch.utils` torch/_inductor/runtime/autotune_cache.py:279:15: error[unresolved-attribute] Object of type `object` has no attribute `kwargs` torch/_inductor/runtime/autotune_cache.py:281:26: error[unresolved-attribute] Object of type `object` has no attribute `num_warps` torch/_inductor/runtime/autotune_cache.py:283:27: error[unresolved-attribute] Object of type `object` has no attribute `num_stages` torch/_inductor/runtime/autotune_cache.py:374:18: error[unresolved-import] Cannot resolve imported module `torch._inductor.fb.remote_cache` -torch/_inductor/runtime/autotune_cache.py:514:12: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` +torch/_inductor/runtime/autotune_cache.py:514:12: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` torch/_inductor/runtime/autotune_cache.py:528:14: error[unresolved-import] Cannot resolve imported module `torch._inductor.fb.remote_cache` torch/_inductor/runtime/autotune_cache.py:577:32: error[too-many-positional-arguments] Too many positional arguments to class `object`: expected 0, got 1 torch/_inductor/runtime/autotune_cache.py:579:9: error[unresolved-attribute] Unresolved attribute `found_by_coordesc` on type `object`. @@ -6805,20 +7191,23 @@ torch/_inductor/scheduler.py:136:35: error[invalid-argument-type] Argument to fu torch/_inductor/scheduler.py:151:20: error[invalid-return-type] Return type does not match returned value: expected `tuple[Expr, Expr]`, found `tuple[Unknown & ~None, None | Unknown]` torch/_inductor/scheduler.py:462:38: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/scheduler.py:473:18: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/scheduler.py:559:35: error[unresolved-attribute] Module `torch._inductor` has no member `ir` -torch/_inductor/scheduler.py:563:37: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/scheduler.py:559:35: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` +torch/_inductor/scheduler.py:563:37: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/scheduler.py:706:38: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/scheduler.py:754:42: error[unresolved-attribute] Module `torch._inductor` has no member `codegen` -torch/_inductor/scheduler.py:862:39: error[unresolved-attribute] Module `torch._inductor` has no member `codegen` -torch/_inductor/scheduler.py:985:16: error[unresolved-attribute] Module `torch` has no member `_prims` +torch/_inductor/scheduler.py:754:42: warning[possibly-missing-attribute] Submodule `codegen` may not be available as an attribute on module `torch._inductor` +torch/_inductor/scheduler.py:862:39: warning[possibly-missing-attribute] Submodule `codegen` may not be available as an attribute on module `torch._inductor` +torch/_inductor/scheduler.py:985:16: warning[possibly-missing-attribute] Submodule `_prims` may not be available as an attribute on module `torch` torch/_inductor/scheduler.py:1040:23: error[invalid-assignment] Object of type `TensorBox | TorchBindObject | Expr` is not assignable to `Buffer | TensorBox | TorchBindObject` -torch/_inductor/scheduler.py:1221:37: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` -torch/_inductor/scheduler.py:1222:12: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` +torch/_inductor/scheduler.py:1221:37: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` +torch/_inductor/scheduler.py:1222:12: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` torch/_inductor/scheduler.py:1399:59: error[call-non-callable] Object of type `object` is not callable torch/_inductor/scheduler.py:1989:29: error[unresolved-attribute] Module `torch` has no member `device` +torch/_inductor/scheduler.py:2001:9: error[invalid-method-override] Invalid override of method `add_fake_dep`: Definition is incompatible with `BaseSchedulerNode.add_fake_dep` +torch/_inductor/scheduler.py:2131:9: error[invalid-method-override] Invalid override of method `fuse`: Definition is incompatible with `FusedSchedulerNode.fuse` +torch/_inductor/scheduler.py:2420:9: error[invalid-method-override] Invalid override of method `add_fake_dep`: Definition is incompatible with `BaseSchedulerNode.add_fake_dep` torch/_inductor/scheduler.py:2594:29: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/scheduler.py:2615:47: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/scheduler.py:2754:12: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_inductor/scheduler.py:2754:12: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_inductor/scheduler.py:2792:42: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/scheduler.py:2796:47: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/scheduler.py:2896:24: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Self@compute_dependencies`, found `DedupList[Unknown]` @@ -6831,26 +7220,25 @@ torch/_inductor/scheduler.py:2948:13: error[invalid-argument-type] Argument to b torch/_inductor/scheduler.py:2953:69: error[invalid-type-form] Variable of type `str` is not allowed in a type expression torch/_inductor/scheduler.py:2961:21: error[invalid-assignment] Invalid subscript assignment with key of type `Basic` and value of type `None` on object of type `dict[Symbol, Unknown | None]` torch/_inductor/scheduler.py:2968:25: error[invalid-assignment] Invalid subscript assignment with key of type `Basic | Unknown` and value of type `None` on object of type `dict[Symbol, Unknown | None]` -torch/_inductor/scheduler.py:3127:16: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_inductor/scheduler.py:3127:16: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_inductor/scheduler.py:3165:42: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/scheduler.py:3439:43: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/scheduler.py:3474:33: error[unresolved-attribute] Module `torch._inductor` has no member `select_algorithm` -torch/_inductor/scheduler.py:3481:21: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/scheduler.py:3474:33: warning[possibly-missing-attribute] Submodule `select_algorithm` may not be available as an attribute on module `torch._inductor` +torch/_inductor/scheduler.py:3481:21: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/scheduler.py:3607:14: error[unresolved-import] Cannot resolve imported module `triton.compiler.errors` -torch/_inductor/scheduler.py:3667:33: error[unresolved-attribute] Module `torch._inductor` has no member `select_algorithm` +torch/_inductor/scheduler.py:3667:33: warning[possibly-missing-attribute] Submodule `select_algorithm` may not be available as an attribute on module `torch._inductor` torch/_inductor/scheduler.py:3672:29: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `tuple[Any, LambdaFuture | None, ModuleType]`, found `tuple[ChoiceCaller & Unknown, @Todo]` -torch/_inductor/scheduler.py:3722:43: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/scheduler.py:3722:43: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/scheduler.py:3745:43: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `tuple[Any, LambdaFuture | None, ModuleType]`, found `tuple[ChoiceCaller & Unknown, @Todo]` torch/_inductor/scheduler.py:4203:49: error[invalid-argument-type] Argument to bound method `statically_known_gt` is incorrect: Expected `Expr`, found `int` torch/_inductor/scheduler.py:4628:32: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/scheduler.py:5158:31: warning[possibly-missing-attribute] Attribute `data` may be missing on object of type `(TensorBox & ~TorchBindObject & ~GeneratorState) | (Expr & ~TorchBindObject & ~GeneratorState)` torch/_inductor/scheduler.py:5186:38: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/scheduler.py:5207:44: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/scheduler.py:5252:32: error[unresolved-attribute] Module `torch._inductor` has no member `ir` -torch/_inductor/scheduler.py:5272:17: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_inductor/scheduler.py:5252:32: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` +torch/_inductor/scheduler.py:5272:17: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_inductor/scheduler.py:5597:17: error[invalid-argument-type] Argument is incorrect: Expected `list[IRNode]`, found `list[IRNode | Expr | Unknown]` -torch/_inductor/scheduler.py:5812:20: error[unresolved-attribute] Module `torch._inductor` has no member `config` -torch/_inductor/scheduler.py:5852:58: error[invalid-argument-type] Argument to bound method `define_subgraph_launcher_fn` is incorrect: Expected `str`, found `Unknown | str | None` +torch/_inductor/scheduler.py:5812:20: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_inductor/scheduler.py:5901:73: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/scheduler.py:5907:54: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/scheduler.py:6210:44: error[unresolved-attribute] Module `torch` has no member `device` @@ -6861,31 +7249,31 @@ torch/_inductor/select_algorithm.py:328:19: error[unresolved-attribute] Module ` torch/_inductor/select_algorithm.py:559:44: error[call-non-callable] Object of type `WrapperHandler` is not callable torch/_inductor/select_algorithm.py:559:44: error[call-non-callable] Object of type `None` is not callable torch/_inductor/select_algorithm.py:1298:22: error[unresolved-attribute] Module `torch` has no member `float32` -torch/_inductor/select_algorithm.py:1740:17: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_inductor/select_algorithm.py:1740:17: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_inductor/select_algorithm.py:1962:26: error[invalid-assignment] Object of type `Sequence[Expr]` is not assignable to `Sequence[Symbol] | None` torch/_inductor/select_algorithm.py:1968:13: error[invalid-argument-type] Argument to bound method `generate_and_load` is incorrect: Expected `Sequence[Symbol]`, found `Sequence[Symbol] | None` torch/_inductor/select_algorithm.py:2021:32: error[unresolved-attribute] Module `torch` has no member `empty_strided` torch/_inductor/select_algorithm.py:2024:23: error[unresolved-attribute] Module `torch` has no member `uint8` torch/_inductor/select_algorithm.py:2058:17: error[invalid-argument-type] Argument to bound method `size_hints` is incorrect: Expected `Iterable[Expr | int]`, found `Sequence[Symbol] | None` -torch/_inductor/select_algorithm.py:2336:13: error[unresolved-attribute] Module `torch._C` has no member `_dynamo` -torch/_inductor/select_algorithm.py:2745:13: error[unresolved-attribute] Module `torch._inductor` has no member `autotune_process` -torch/_inductor/select_algorithm.py:2798:20: error[unresolved-attribute] Module `torch._inductor` has no member `ir` -torch/_inductor/select_algorithm.py:2799:17: error[unresolved-attribute] Module `torch._inductor` has no member `ir` -torch/_inductor/select_algorithm.py:3177:23: error[unresolved-attribute] Module `concurrent` has no member `futures` -torch/_inductor/select_algorithm.py:3178:29: error[unresolved-attribute] Module `concurrent` has no member `futures` -torch/_inductor/select_algorithm.py:3320:31: error[unresolved-attribute] Module `torch` has no member `_prims_common` +torch/_inductor/select_algorithm.py:2336:13: warning[possibly-missing-attribute] Submodule `_dynamo` may not be available as an attribute on module `torch._C` +torch/_inductor/select_algorithm.py:2745:13: warning[possibly-missing-attribute] Submodule `autotune_process` may not be available as an attribute on module `torch._inductor` +torch/_inductor/select_algorithm.py:2798:20: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` +torch/_inductor/select_algorithm.py:2799:17: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` +torch/_inductor/select_algorithm.py:3177:23: warning[possibly-missing-attribute] Submodule `futures` may not be available as an attribute on module `concurrent` +torch/_inductor/select_algorithm.py:3178:29: warning[possibly-missing-attribute] Submodule `futures` may not be available as an attribute on module `concurrent` +torch/_inductor/select_algorithm.py:3320:31: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` torch/_inductor/select_algorithm.py:3327:32: error[unresolved-attribute] Module `torch` has no member `randn` torch/_inductor/select_algorithm.py:3338:21: error[unresolved-attribute] Module `torch` has no member `as_strided` -torch/_inductor/select_algorithm.py:3345:27: error[unresolved-attribute] Module `torch` has no member `_prims_common` +torch/_inductor/select_algorithm.py:3345:27: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` torch/_inductor/select_algorithm.py:3352:28: error[unresolved-attribute] Module `torch` has no member `randn` torch/_inductor/select_algorithm.py:3362:22: error[unresolved-attribute] Module `torch` has no member `as_strided` torch/_inductor/select_algorithm.py:3451:26: error[unresolved-import] Cannot resolve imported module `triton.runtime.autotuner` -torch/_inductor/select_algorithm.py:3682:31: error[unresolved-attribute] Module `torch._inductor` has no member `select_algorithm` -torch/_inductor/select_algorithm.py:3685:35: error[unresolved-attribute] Module `torch._inductor` has no member `select_algorithm` -torch/_inductor/select_algorithm.py:3790:35: error[unresolved-attribute] Module `torch._inductor` has no member `select_algorithm` -torch/_inductor/select_algorithm.py:3794:25: error[unresolved-attribute] Module `torch._inductor` has no member `select_algorithm` +torch/_inductor/select_algorithm.py:3682:31: warning[possibly-missing-attribute] Submodule `select_algorithm` may not be available as an attribute on module `torch._inductor` +torch/_inductor/select_algorithm.py:3685:35: warning[possibly-missing-attribute] Submodule `select_algorithm` may not be available as an attribute on module `torch._inductor` +torch/_inductor/select_algorithm.py:3790:35: warning[possibly-missing-attribute] Submodule `select_algorithm` may not be available as an attribute on module `torch._inductor` +torch/_inductor/select_algorithm.py:3794:25: warning[possibly-missing-attribute] Submodule `select_algorithm` may not be available as an attribute on module `torch._inductor` torch/_inductor/select_algorithm.py:3897:17: warning[possibly-missing-attribute] Attribute `offset` may be missing on object of type `@Todo | OutputSpec` -torch/_inductor/select_algorithm.py:4000:13: error[unresolved-attribute] Module `torch._inductor` has no member `config` +torch/_inductor/select_algorithm.py:4000:13: warning[possibly-missing-attribute] Submodule `config` may not be available as an attribute on module `torch._inductor` torch/_inductor/shape_propagation.py:20:63: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/shape_propagation.py:65:30: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/shape_propagation.py:84:52: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -6907,15 +7295,16 @@ torch/_inductor/sizevars.py:596:33: error[invalid-argument-type] Argument to fun torch/_inductor/sizevars.py:613:20: error[no-matching-overload] No overload of bound method `get` matches arguments torch/_inductor/sizevars.py:933:17: error[invalid-argument-type] Argument to bound method `size_hint` is incorrect: Expected `Expr | int`, found `Basic` torch/_inductor/sizevars.py:1029:16: error[unsupported-operator] Operator `%` is unsupported between objects of type `Basic` and `Basic` -torch/_inductor/standalone_compile.py:186:18: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_inductor/standalone_compile.py:210:23: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/standalone_compile.py:211:18: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/standalone_compile.py:377:19: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/standalone_compile.py:414:15: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/standalone_compile.py:416:9: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/standalone_compile.py:419:9: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_inductor/standalone_compile.py:186:18: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_inductor/standalone_compile.py:210:23: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/standalone_compile.py:211:18: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/standalone_compile.py:377:19: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/standalone_compile.py:414:15: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/standalone_compile.py:416:9: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/standalone_compile.py:419:9: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_inductor/subgraph_lowering.py:134:12: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/subgraph_lowering.py:135:13: error[unresolved-attribute] Module `torch` has no member `device` +torch/_inductor/subgraph_lowering.py:149:9: error[invalid-method-override] Invalid override of method `placeholder`: Definition is incompatible with `OpsHandler.placeholder` torch/_inductor/template_heuristics/cutedsl.py:122:28: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Unknown | int | TensorMapUpdateMode` torch/_inductor/template_heuristics/cutedsl.py:122:28: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Unknown | int | TensorMapUpdateMode` torch/_inductor/template_heuristics/cutedsl.py:122:28: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Unknown | int | TensorMapUpdateMode` @@ -6999,6 +7388,7 @@ torch/_inductor/template_heuristics/triton.py:1648:20: error[unresolved-attribut torch/_inductor/template_heuristics/triton.py:1679:36: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/template_heuristics/triton.py:1684:22: error[unresolved-attribute] Module `torch` has no member `float16` torch/_inductor/template_heuristics/triton.py:1684:37: error[unresolved-attribute] Module `torch` has no member `bfloat16` +torch/_inductor/template_heuristics/triton.py:2160:9: error[invalid-method-override] Invalid override of method `_filter_configs`: Definition is incompatible with `BaseConfigHeuristic._filter_configs` torch/_inductor/test_operators.py:9:61: error[unresolved-attribute] Module `torch` has no member `Tag` torch/_inductor/tiling_utils.py:160:13: error[invalid-assignment] Invalid subscript assignment with key of type `Basic` and value of type `Literal[0]` on object of type `dict[Symbol, int]` torch/_inductor/tiling_utils.py:162:13: error[invalid-assignment] Invalid subscript assignment with key of type `Basic` and value of type `int` on object of type `dict[Symbol, int]` @@ -7016,13 +7406,13 @@ torch/_inductor/tiling_utils.py:206:41: error[invalid-argument-type] Argument to torch/_inductor/tiling_utils.py:211:13: error[invalid-assignment] Invalid subscript assignment with key of type `Expr` and value of type `Literal[2]` on object of type `dict[Symbol, int]` torch/_inductor/tiling_utils.py:214:35: error[invalid-argument-type] Argument to function `sympy_subs` is incorrect: Expected `dict[Expr, Any]`, found `dict[Symbol, int]` torch/_inductor/tiling_utils.py:216:9: error[invalid-assignment] Invalid subscript assignment with key of type `Expr` and value of type `Literal[0]` on object of type `dict[Symbol, int]` -torch/_inductor/tiling_utils.py:310:34: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/tiling_utils.py:327:17: error[unresolved-attribute] Module `torch._inductor` has no member `codegen` +torch/_inductor/tiling_utils.py:310:34: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/tiling_utils.py:327:17: warning[possibly-missing-attribute] Submodule `codegen` may not be available as an attribute on module `torch._inductor` torch/_inductor/tiling_utils.py:500:35: error[invalid-assignment] Object of type `tuple[Expr, ...]` is not assignable to `Expr` torch/_inductor/tiling_utils.py:501:29: error[invalid-assignment] Object of type `tuple[Expr, ...]` is not assignable to `Expr` -torch/_inductor/tiling_utils.py:518:30: error[unresolved-attribute] Module `torch._inductor` has no member `scheduler` -torch/_inductor/tiling_utils.py:551:13: error[unresolved-attribute] Module `torch._inductor` has no member `codegen` -torch/_inductor/tiling_utils.py:556:13: error[unresolved-attribute] Module `torch._inductor` has no member `codegen` +torch/_inductor/tiling_utils.py:518:30: warning[possibly-missing-attribute] Submodule `scheduler` may not be available as an attribute on module `torch._inductor` +torch/_inductor/tiling_utils.py:551:13: warning[possibly-missing-attribute] Submodule `codegen` may not be available as an attribute on module `torch._inductor` +torch/_inductor/tiling_utils.py:556:13: warning[possibly-missing-attribute] Submodule `codegen` may not be available as an attribute on module `torch._inductor` torch/_inductor/tiling_utils.py:575:47: error[invalid-argument-type] Argument to function `sympy_subs` is incorrect: Expected `dict[Expr, Any]`, found `dict[Symbol, Expr]` torch/_inductor/tiling_utils.py:578:48: error[invalid-argument-type] Argument to function `sympy_subs` is incorrect: Expected `dict[Expr, Any]`, found `dict[Symbol, Expr]` torch/_inductor/tiling_utils.py:600:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[Symbol, int]`, found `dict[Expr, Expr]` @@ -7036,6 +7426,7 @@ torch/_inductor/tiling_utils.py:767:57: error[invalid-argument-type] Argument to torch/_inductor/tiling_utils.py:775:54: error[invalid-argument-type] Argument to bound method `statically_known_lt` is incorrect: Expected `Expr`, found `Literal[8]` torch/_inductor/utils.py:115:33: warning[possibly-missing-import] Member `detect_fake_mode` of module `torch._dynamo.utils` may be missing torch/_inductor/utils.py:164:24: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `(Basic, /) -> Unknown`, found `def _is_aligned(v: Expr) -> bool` +torch/_inductor/utils.py:175:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` torch/_inductor/utils.py:177:20: error[invalid-return-type] Return type does not match returned value: expected `Expr | None`, found `int` torch/_inductor/utils.py:211:13: error[unresolved-attribute] Module `torch` has no member `empty` torch/_inductor/utils.py:211:48: error[unresolved-attribute] Module `torch` has no member `float16` @@ -7064,8 +7455,8 @@ torch/_inductor/utils.py:1146:20: error[invalid-return-type] Return type does no torch/_inductor/utils.py:1231:61: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/utils.py:1233:31: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/utils.py:1241:29: error[unresolved-attribute] Module `torch` has no member `device` -torch/_inductor/utils.py:1263:29: error[unresolved-attribute] Module `torch._inductor` has no member `runtime` -torch/_inductor/utils.py:1268:29: error[unresolved-attribute] Module `torch._inductor` has no member `runtime` +torch/_inductor/utils.py:1263:29: warning[possibly-missing-attribute] Submodule `runtime` may not be available as an attribute on module `torch._inductor` +torch/_inductor/utils.py:1268:29: warning[possibly-missing-attribute] Submodule `runtime` may not be available as an attribute on module `torch._inductor` torch/_inductor/utils.py:1390:20: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `Basic` torch/_inductor/utils.py:1390:44: error[invalid-argument-type] Argument to bound method `evaluate_expr` is incorrect: Expected `Basic`, found `SymInt | Expr` torch/_inductor/utils.py:1417:27: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -7096,7 +7487,7 @@ torch/_inductor/utils.py:1865:43: error[unresolved-attribute] Module `torch` has torch/_inductor/utils.py:1877:58: error[invalid-argument-type] Argument to bound method `statically_known_geq` is incorrect: Expected `Expr`, found `Unknown | int | Expr` torch/_inductor/utils.py:1903:21: error[unresolved-attribute] Module `torch` has no member `float8_e4m3fn` torch/_inductor/utils.py:1904:13: error[invalid-argument-type] Argument to bound method `statically_known_geq` is incorrect: Expected `Expr`, found `Unknown | int | Expr` -torch/_inductor/utils.py:1952:16: error[unresolved-attribute] Module `importlib` has no member `util` +torch/_inductor/utils.py:1952:16: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` torch/_inductor/utils.py:1996:22: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/utils.py:2036:22: error[unresolved-attribute] Module `torch` has no member `float16` torch/_inductor/utils.py:2036:37: error[unresolved-attribute] Module `torch` has no member `bfloat16` @@ -7111,7 +7502,7 @@ torch/_inductor/utils.py:2317:22: error[unresolved-attribute] Module `torch` has torch/_inductor/utils.py:2317:37: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/utils.py:2317:53: error[unresolved-attribute] Module `torch` has no member `half` torch/_inductor/utils.py:2317:65: error[unresolved-attribute] Module `torch` has no member `uint8` -torch/_inductor/utils.py:2543:12: error[unresolved-attribute] Module `unittest` has no member `mock` +torch/_inductor/utils.py:2543:12: warning[possibly-missing-attribute] Submodule `mock` may not be available as an attribute on module `unittest` torch/_inductor/utils.py:2601:24: error[unresolved-attribute] Module `torch` has no member `device` torch/_inductor/utils.py:2607:46: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/utils.py:2612:16: error[unresolved-attribute] Module `torch` has no member `int64` @@ -7132,7 +7523,7 @@ torch/_inductor/utils.py:2679:46: error[unresolved-attribute] Module `torch` has torch/_inductor/utils.py:2682:40: error[unresolved-attribute] Module `torch` has no member `float32` torch/_inductor/utils.py:2687:10: error[unresolved-import] Cannot resolve imported module `triton.testing` torch/_inductor/utils.py:2693:10: error[unresolved-import] Cannot resolve imported module `triton.runtime` -torch/_inductor/utils.py:2954:14: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_inductor/utils.py:2954:14: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_inductor/utils.py:3037:57: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/utils.py:3038:17: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/utils.py:3041:26: error[unresolved-attribute] Module `torch` has no member `int64` @@ -7141,15 +7532,15 @@ torch/_inductor/utils.py:3047:17: error[unresolved-attribute] Module `torch` has torch/_inductor/utils.py:3048:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/utils.py:3078:60: error[unresolved-attribute] Module `torch` has no member `bool` torch/_inductor/utils.py:3078:72: error[unresolved-attribute] Module `torch` has no member `int64` -torch/_inductor/utils.py:3142:23: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/utils.py:3159:10: error[unresolved-attribute] Module `unittest` has no member `mock` +torch/_inductor/utils.py:3142:23: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/utils.py:3159:10: warning[possibly-missing-attribute] Submodule `mock` may not be available as an attribute on module `unittest` torch/_inductor/utils.py:3224:13: error[unresolved-attribute] Module `torch` has no member `_foreach_copy_` torch/_inductor/utils.py:3239:14: error[unresolved-attribute] Module `torch` has no member `as_strided` torch/_inductor/utils.py:3240:12: error[unresolved-attribute] Module `torch` has no member `as_strided` torch/_inductor/utils.py:3294:15: error[unresolved-attribute] Module `torch` has no member `iinfo` torch/_inductor/utils.py:3294:27: error[unresolved-attribute] Module `torch` has no member `int32` -torch/_inductor/utils.py:3334:15: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/utils.py:3344:27: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_inductor/utils.py:3334:15: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/utils.py:3344:27: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_inductor/utils.py:3369:14: error[unresolved-import] Cannot resolve imported module `torch._inductor.fb.remote_cache` torch/_inductor/utils.py:3400:24: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_inductor/utils.py:3406:41: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -7161,8 +7552,8 @@ torch/_inductor/utils.py:3497:48: error[unresolved-attribute] Module `torch` has torch/_inductor/utils.py:3500:19: error[unresolved-attribute] Module `torch` has no member `float16` torch/_inductor/utils.py:3500:34: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/_inductor/utils.py:3504:16: error[unresolved-attribute] Module `torch` has no member `float32` -torch/_inductor/utils.py:3571:23: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_inductor/utils.py:3589:8: error[unresolved-attribute] Module `importlib` has no member `util` +torch/_inductor/utils.py:3571:23: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_inductor/utils.py:3589:8: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` torch/_inductor/utils.py:3592:12: error[unresolved-import] Cannot resolve imported module `triton.backends.compiler` torch/_inductor/utils.py:3593:12: error[unresolved-import] Cannot resolve imported module `triton.compiler.compiler` torch/_inductor/utils.py:3639:14: error[unresolved-import] Cannot resolve imported module `libfb.py.parutil` @@ -7171,21 +7562,22 @@ torch/_inductor/utils.py:3669:9: error[invalid-argument-type] Argument to bound torch/_inductor/utils.py:3670:49: error[invalid-argument-type] Argument to bound method `statically_known_geq` is incorrect: Expected `Expr`, found `int` torch/_inductor/utils.py:3671:16: error[unresolved-attribute] Module `torch` has no member `int32` torch/_inductor/utils.py:3673:16: error[unresolved-attribute] Module `torch` has no member `int64` -torch/_inductor/utils.py:4021:30: error[unresolved-attribute] Module `torch._inductor` has no member `ir` -torch/_inductor/utils.py:4022:16: error[unresolved-attribute] Module `torch._inductor` has no member `ir` -torch/_inductor/utils.py:4026:9: error[unresolved-attribute] Module `torch._inductor` has no member `ir` +torch/_inductor/utils.py:4021:30: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` +torch/_inductor/utils.py:4022:16: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` +torch/_inductor/utils.py:4026:9: warning[possibly-missing-attribute] Submodule `ir` may not be available as an attribute on module `torch._inductor` torch/_inductor/utils.py:4033:16: error[unresolved-attribute] Module `torch` has no member `empty` torch/_inductor/virtualized.py:180:20: error[unresolved-attribute] Module `torch` has no member `int64` torch/_inductor/virtualized.py:182:20: error[unresolved-attribute] Module `torch` has no member `int32` -torch/_inductor/wrapper_benchmark.py:179:17: error[unresolved-attribute] Module `torch.autograd` has no member `profiler_util` -torch/_inductor/wrapper_benchmark.py:189:13: error[unresolved-attribute] Module `torch.autograd` has no member `profiler_util` -torch/_inductor/wrapper_benchmark.py:199:13: error[unresolved-attribute] Module `torch.autograd` has no member `profiler_util` +torch/_inductor/virtualized.py:342:9: error[invalid-method-override] Invalid override of method `indirect_indexing`: Definition is incompatible with `OpsHandler.indirect_indexing` +torch/_inductor/wrapper_benchmark.py:179:17: warning[possibly-missing-attribute] Submodule `profiler_util` may not be available as an attribute on module `torch.autograd` +torch/_inductor/wrapper_benchmark.py:189:13: warning[possibly-missing-attribute] Submodule `profiler_util` may not be available as an attribute on module `torch.autograd` +torch/_inductor/wrapper_benchmark.py:199:13: warning[possibly-missing-attribute] Submodule `profiler_util` may not be available as an attribute on module `torch.autograd` torch/_jit_internal.py:47:22: error[unresolved-import] Module `torch._C` has no member `_Await` torch/_jit_internal.py:47:40: error[unresolved-import] Module `torch._C` has no member `Future` torch/_jit_internal.py:132:24: error[unresolved-attribute] Module `torch._C` has no member `ScriptFunction` torch/_jit_internal.py:1210:39: warning[possibly-missing-import] Member `RRef` of module `torch.distributed.rpc` may be missing -torch/_jit_internal.py:1239:19: error[unresolved-attribute] Module `torch._C` has no member `_jit_tree_views` -torch/_jit_internal.py:1311:24: error[unresolved-attribute] Module `torch.jit` has no member `annotations` +torch/_jit_internal.py:1239:19: warning[possibly-missing-attribute] Submodule `_jit_tree_views` may not be available as an attribute on module `torch._C` +torch/_jit_internal.py:1311:24: warning[possibly-missing-attribute] Submodule `annotations` may not be available as an attribute on module `torch.jit` torch/_jit_internal.py:1314:32: error[unresolved-attribute] Module `torch._C` has no member `TensorType` torch/_jit_internal.py:1330:13: error[unresolved-attribute] Module `torch._C` has no member `_jit_get_emit_hooks` torch/_jit_internal.py:1331:5: error[unresolved-attribute] Module `torch._C` has no member `_jit_set_emit_hooks` @@ -7193,7 +7585,6 @@ torch/_jit_internal.py:1335:9: error[unresolved-attribute] Module `torch._C` has torch/_jit_internal.py:1341:22: error[unresolved-attribute] Module `torch._C` has no member `_jit_get_emit_hooks` torch/_jit_internal.py:1342:9: error[unresolved-attribute] Module `torch._C` has no member `_jit_set_emit_hooks` torch/_jit_internal.py:1345:9: error[unresolved-attribute] Module `torch._C` has no member `_jit_set_emit_hooks` -torch/_jit_internal.py:1467:32: error[unresolved-attribute] Module `collections` has no member `abc` torch/_lazy/extract_compiled_graph.py:106:28: error[unresolved-attribute] Module `torch` has no member `device` torch/_lazy/extract_compiled_graph.py:107:20: error[unresolved-attribute] Module `torch` has no member `device` torch/_lazy/extract_compiled_graph.py:112:29: error[unresolved-attribute] Module `torch` has no member `device` @@ -7254,9 +7645,8 @@ torch/_library/custom_ops.py:847:17: error[unresolved-attribute] Module `torch._ torch/_library/custom_ops.py:847:41: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/_library/custom_ops.py:848:18: error[unresolved-attribute] Module `torch._C` has no member `_ExcludeDispatchKeyGuard` torch/_library/custom_ops.py:866:37: error[unresolved-attribute] Module `torch` has no member `float64` -torch/_library/custom_ops.py:871:28: error[unresolved-attribute] Module `collections` has no member `abc` torch/_library/custom_ops.py:937:14: error[invalid-assignment] Object of type `object` is not assignable to `CustomOpDef | OpOverload[Unknown, Any] | str` -torch/_library/effects.py:25:29: error[unresolved-attribute] Module `torch._library` has no member `utils` +torch/_library/effects.py:25:29: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` torch/_library/effects.py:51:12: error[unresolved-attribute] Module `torch._C` has no member `_get_operation_overload` torch/_library/effects.py:54:22: error[unresolved-attribute] Module `torch._C` has no member `_get_schema` torch/_library/effects.py:56:41: error[unresolved-attribute] Module `torch` has no member `ClassType` @@ -7271,11 +7661,11 @@ torch/_library/fake_class_registry.py:239:38: error[unresolved-attribute] Module torch/_library/fake_class_registry.py:326:9: error[unresolved-attribute] Module `torch._C` has no member `_get_custom_class_python_wrapper` torch/_library/fake_class_registry.py:368:14: error[unresolved-attribute] Module `torch` has no member `ScriptObject` torch/_library/fake_class_registry.py:382:43: error[unresolved-attribute] Module `torch` has no member `ScriptObject` -torch/_library/fake_class_registry.py:413:11: error[unresolved-attribute] Module `torch._library` has no member `fake_impl` -torch/_library/fake_class_registry.py:414:10: error[unresolved-attribute] Module `torch._library` has no member `fake_impl` +torch/_library/fake_class_registry.py:413:11: warning[possibly-missing-attribute] Submodule `fake_impl` may not be available as an attribute on module `torch._library` +torch/_library/fake_class_registry.py:414:10: warning[possibly-missing-attribute] Submodule `fake_impl` may not be available as an attribute on module `torch._library` torch/_library/fake_impl.py:50:16: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` torch/_library/fake_impl.py:59:16: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` -torch/_library/fake_impl.py:224:5: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` +torch/_library/fake_impl.py:224:5: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` torch/_library/fake_profile.py:27:12: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_library/fake_profile.py:28:13: error[unresolved-attribute] Module `torch` has no member `device` torch/_library/fake_profile.py:29:13: error[unresolved-attribute] Module `torch` has no member `layout` @@ -7288,11 +7678,10 @@ torch/_library/infer_schema.py:63:18: error[unresolved-attribute] Object of type torch/_library/infer_schema.py:132:37: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` torch/_library/infer_schema.py:185:50: error[unresolved-attribute] Module `torch` has no member `device` torch/_library/infer_schema.py:187:44: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/_library/infer_schema.py:222:80: error[invalid-assignment] Object of type `list[Unknown | tuple[type | _SpecialForm, str] | tuple[types.UnionType, str]]` is not assignable to `list[tuple[type | _SpecialForm | GenericAlias, str]]` -torch/_library/infer_schema.py:232:26: error[unresolved-attribute] Module `collections` has no member `abc` +torch/_library/infer_schema.py:222:80: error[invalid-assignment] Object of type `list[tuple[type | _SpecialForm | GenericAlias, str] | tuple[types.UnionType, str]]` is not assignable to `list[tuple[type | _SpecialForm | GenericAlias, str]]` torch/_library/infer_schema.py:244:46: error[invalid-argument-type] Argument to function `derived_seq_types` is incorrect: Expected `type | _SpecialForm`, found `types.UnionType` torch/_library/infer_schema.py:248:13: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[tuple[type | _SpecialForm | GenericAlias, str]]`, found `GeneratorType[tuple[types.UnionType, str], None, None]` -torch/_library/infer_schema.py:256:82: error[invalid-assignment] Object of type `list[Unknown | tuple[, str, bool, bool, bool] | tuple[, str, bool, bool, bool] | ... omitted 6 union elements]` is not assignable to `list[tuple[type | _SpecialForm, str, bool, bool, bool]]` +torch/_library/infer_schema.py:256:82: error[invalid-assignment] Object of type `list[tuple[type | _SpecialForm, str, bool, bool, bool] | tuple[types.UnionType, str, bool, bool, bool] | tuple[, str, bool, bool, bool]]` is not assignable to `list[tuple[type | _SpecialForm, str, bool, bool, bool]]` torch/_library/opaque_object.py:23:36: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` torch/_library/opaque_object.py:26:41: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` torch/_library/opaque_object.py:84:12: error[unresolved-attribute] Module `torch._C` has no member `_make_opaque_object` @@ -7306,13 +7695,13 @@ torch/_library/opaque_object.py:146:42: error[unresolved-attribute] Module `torc torch/_library/opaque_object.py:152:5: error[unresolved-attribute] Module `torch._C` has no member `_set_opaque_object_payload` torch/_library/opaque_object.py:177:5: error[unresolved-attribute] Module `torch._C` has no member `_register_opaque_type` torch/_library/opaque_object.py:187:12: error[unresolved-attribute] Module `torch._C` has no member `_is_opaque_type_registered` -torch/_library/triton.py:244:25: error[unresolved-attribute] Module `torch._subclasses` has no member `functional_tensor` +torch/_library/triton.py:244:25: warning[possibly-missing-attribute] Submodule `functional_tensor` may not be available as an attribute on module `torch._subclasses` torch/_library/triton.py:357:10: error[unresolved-import] Cannot resolve imported module `triton.runtime.autotuner` torch/_library/triton.py:358:10: error[unresolved-import] Cannot resolve imported module `triton.runtime.jit` torch/_library/utils.py:100:31: error[unresolved-attribute] Module `torch` has no member `FunctionSchema` torch/_library/utils.py:102:41: error[unresolved-attribute] Module `torch` has no member `TensorType` torch/_library/utils.py:106:41: error[unresolved-attribute] Module `torch` has no member `TensorType` -torch/_library/utils.py:109:33: error[unresolved-attribute] Module `torchgen` has no member `model` +torch/_library/utils.py:109:33: warning[possibly-missing-attribute] Submodule `model` may not be available as an attribute on module `torchgen` torch/_library/utils.py:126:27: error[unresolved-attribute] Module `torch._C` has no member `FunctionSchema` torch/_library/utils.py:141:16: error[unresolved-attribute] Module `torch._C` has no member `ListType` torch/_library/utils.py:141:28: error[unresolved-attribute] Module `torch._C` has no member `TensorType` @@ -7331,7 +7720,7 @@ torch/_library/utils.py:150:49: error[unresolved-attribute] Module `torch._C` ha torch/_library/utils.py:150:65: error[unresolved-attribute] Module `torch._C` has no member `TensorType` torch/_library/utils.py:210:13: error[unresolved-attribute] Module `torch._C` has no member `FunctionSchema` torch/_library/utils.py:211:21: error[unresolved-attribute] Module `torch._C` has no member `Argument` -torch/_library/utils.py:299:34: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_library/utils.py:299:34: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_library/utils.py:309:13: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_keys` torch/_library/utils.py:309:44: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/_library/utils.py:316:33: error[unresolved-attribute] Module `torch._C` has no member `FunctionSchema` @@ -7342,9 +7731,9 @@ torch/_library/utils.py:347:24: error[unresolved-attribute] Module `torch._C` ha torch/_library/utils.py:403:8: error[unresolved-attribute] Module `torch._C` has no member `_any_output_is_alias_to_input_or_output` torch/_library/utils.py:442:17: error[unresolved-attribute] Module `torch` has no member `equal` torch/_library/utils.py:488:8: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` -torch/_library/utils.py:492:13: error[unresolved-attribute] Module `torch._library` has no member `custom_ops` +torch/_library/utils.py:492:13: warning[possibly-missing-attribute] Submodule `custom_ops` may not be available as an attribute on module `torch._library` torch/_library/utils.py:495:12: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` -torch/_library/utils.py:499:17: error[unresolved-attribute] Module `torch._library` has no member `simple_registry` +torch/_library/utils.py:499:17: warning[possibly-missing-attribute] Submodule `simple_registry` may not be available as an attribute on module `torch._library` torch/_library/utils.py:502:12: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` torch/_library/utils.py:511:33: error[unresolved-attribute] Module `torch._C` has no member `FunctionSchema` torch/_library/utils.py:524:5: error[unresolved-attribute] Module `torch._C` has no member `Tag` @@ -7378,7 +7767,7 @@ torch/_lobpcg.py:318:25: error[unresolved-attribute] Module `torch` has no membe torch/_lobpcg.py:318:42: error[unresolved-attribute] Module `torch` has no member `complex128` torch/_lobpcg.py:320:29: error[unresolved-attribute] Module `torch` has no member `complex64` torch/_lobpcg.py:320:46: error[unresolved-attribute] Module `torch` has no member `complex128` -torch/_lobpcg.py:532:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` +torch/_lobpcg.py:532:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` torch/_lobpcg.py:610:17: error[unresolved-attribute] Module `torch` has no member `float32` torch/_lobpcg.py:610:41: error[unresolved-attribute] Module `torch` has no member `float64` torch/_lobpcg.py:656:17: error[unresolved-attribute] Module `torch` has no member `prod` @@ -9502,7 +9891,7 @@ torch/_numpy/_funcs_impl.py:328:9: error[unresolved-attribute] Module `torch` ha torch/_numpy/_funcs_impl.py:329:9: error[unresolved-attribute] Module `torch` has no member `log` torch/_numpy/_funcs_impl.py:346:12: error[unresolved-attribute] Module `torch` has no member `logspace` torch/_numpy/_funcs_impl.py:375:18: error[unresolved-attribute] Module `torch` has no member `float64` -torch/_numpy/_funcs_impl.py:375:35: error[unresolved-attribute] Object of type `DTypeLike@arange & ~None` has no attribute `is_complex` +torch/_numpy/_funcs_impl.py:375:35: warning[possibly-missing-attribute] Attribute `is_complex` may be missing on object of type `(DTypeLike@arange & ~None) | Divergent` torch/_numpy/_funcs_impl.py:381:9: error[unsupported-operator] Operator `>` is not supported for types `typing.TypeVar` and `Literal[0]`, in comparing `typing.TypeVar | (int & ~Literal[0]) | float | complex | None` with `Literal[0]` torch/_numpy/_funcs_impl.py:381:22: error[unsupported-operator] Operator `>` is not supported for types `typing.TypeVar` and `typing.TypeVar`, in comparing `typing.TypeVar | int | float | complex` with `typing.TypeVar | int | float | complex | None` torch/_numpy/_funcs_impl.py:381:40: error[unsupported-operator] Operator `<` is not supported for types `typing.TypeVar` and `Literal[0]`, in comparing `typing.TypeVar | (int & ~Literal[0]) | float | complex | None` with `Literal[0]` @@ -10079,7 +10468,7 @@ torch/_ops.py:254:8: error[unresolved-attribute] Module `torch._C` has no member torch/_ops.py:295:37: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_keyset_full` torch/_ops.py:326:20: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_ops.py:331:22: error[unresolved-attribute] Module `torch._C` has no member `_AutoDispatchBelowAutograd` -torch/_ops.py:366:21: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_ops.py:366:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_ops.py:393:24: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_keys` torch/_ops.py:440:24: error[unresolved-attribute] Module `torch._C` has no member `_disabled_torch_dispatch_impl` torch/_ops.py:486:23: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_is_dispatch_key_excluded` @@ -10106,11 +10495,11 @@ torch/_ops.py:857:51: error[unresolved-attribute] Module `torch._C` has no membe torch/_ops.py:858:16: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_any_dispatch_key` torch/_ops.py:868:41: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` torch/_ops.py:880:14: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` -torch/_ops.py:920:29: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` -torch/_ops.py:922:36: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/_ops.py:928:22: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_ops.py:920:29: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` +torch/_ops.py:922:36: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/_ops.py:928:22: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_ops.py:942:25: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_is_dispatch_key_excluded` -torch/_ops.py:957:32: error[unresolved-attribute] Module `torch._library` has no member `utils` +torch/_ops.py:957:32: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` torch/_ops.py:1030:16: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` torch/_ops.py:1031:24: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_kernel_for_dispatch_key_is_fallthrough` torch/_ops.py:1091:32: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_keyset_full` @@ -10122,8 +10511,9 @@ torch/_ops.py:1217:26: error[unresolved-attribute] Module `torch._C` has no memb torch/_ops.py:1226:22: error[unresolved-attribute] Module `torch._C` has no member `_get_schema` torch/_ops.py:1271:34: error[unresolved-attribute] Module `torch._C` has no member `_maybe_call_torch_function_for_op_packet` torch/_ops.py:1288:17: error[unresolved-attribute] Module `torch._C` has no member `_check_schema_allow_fake_script_object` +torch/_ops.py:1353:9: error[invalid-method-override] Invalid override of method `__getattr__`: Definition is incompatible with `ModuleType.__getattr__` torch/_ops.py:1391:26: error[unresolved-attribute] Module `torch._C` has no member `_jit_get_operation` -torch/_ops.py:1395:9: error[unresolved-attribute] Module `torch.jit` has no member `_builtins` +torch/_ops.py:1395:9: warning[possibly-missing-attribute] Submodule `_builtins` may not be available as an attribute on module `torch.jit` torch/_prims/__init__.py:12:22: error[unresolved-import] Module `torch._C` has no member `_get_default_device` torch/_prims/__init__.py:228:21: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_prims/__init__.py:229:28: error[unresolved-attribute] Module `torch` has no member `device` @@ -10232,7 +10622,7 @@ torch/_prims/__init__.py:1989:11: error[unresolved-attribute] Module `torch` has torch/_prims/__init__.py:1994:43: error[unresolved-attribute] Module `torch` has no member `device` torch/_prims/__init__.py:1997:37: error[unresolved-attribute] Module `torch` has no member `device` torch/_prims/__init__.py:2004:35: error[unresolved-attribute] Module `torch` has no member `device` -torch/_prims/__init__.py:2038:10: error[unresolved-attribute] Module `torch` has no member `_dispatch` +torch/_prims/__init__.py:2038:10: warning[possibly-missing-attribute] Submodule `_dispatch` may not be available as an attribute on module `torch` torch/_prims/__init__.py:2056:32: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_prims/__init__.py:2061:32: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_prims/__init__.py:2062:17: error[unresolved-attribute] Module `torch` has no member `bool` @@ -10305,10 +10695,11 @@ torch/_prims/__init__.py:2960:12: error[unresolved-attribute] Module `torch` has torch/_prims/__init__.py:2960:36: error[unresolved-attribute] Module `torch` has no member `empty_like` torch/_prims/__init__.py:2960:65: error[unresolved-attribute] Module `torch` has no member `int32` torch/_prims/__init__.py:2967:15: error[unresolved-attribute] Module `torch` has no member `frexp` -torch/_prims/context.py:38:21: error[unresolved-attribute] Module `torch._refs` has no member `fft` -torch/_prims/context.py:39:24: error[unresolved-attribute] Module `torch._refs` has no member `linalg` -torch/_prims/context.py:75:14: error[unresolved-attribute] Module `torch._refs` has no member `_conversions` -torch/_prims/context.py:77:26: error[unresolved-attribute] Module `torch._refs` has no member `_conversions` +torch/_prims/context.py:38:21: warning[possibly-missing-attribute] Submodule `fft` may not be available as an attribute on module `torch._refs` +torch/_prims/context.py:39:24: warning[possibly-missing-attribute] Submodule `linalg` may not be available as an attribute on module `torch._refs` +torch/_prims/context.py:75:14: warning[possibly-missing-attribute] Submodule `_conversions` may not be available as an attribute on module `torch._refs` +torch/_prims/context.py:77:26: warning[possibly-missing-attribute] Submodule `_conversions` may not be available as an attribute on module `torch._refs` +torch/_prims/context.py:115:9: error[invalid-method-override] Invalid override of method `__torch_function__`: Definition is incompatible with `TorchFunctionMode.__torch_function__` torch/_prims/debug_prims.py:40:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_prims/debug_prims.py:41:17: error[unresolved-attribute] Module `torch` has no member `device` torch/_prims/rng_prims.py:7:22: error[unresolved-import] Module `torch._C` has no member `DispatchKey` @@ -10498,7 +10889,7 @@ torch/_prims_common/wrappers.py:433:14: error[unresolved-attribute] Module `torc torch/_prims_common/wrappers.py:450:12: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/_prims_common/wrappers.py:486:24: error[unresolved-attribute] Module `torch` has no member `tensor` torch/_python_dispatcher.py:75:20: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_library` -torch/_refs/__init__.py:394:17: error[unresolved-attribute] Module `torch.fx.experimental` has no member `_config` +torch/_refs/__init__.py:394:17: warning[possibly-missing-attribute] Submodule `_config` may not be available as an attribute on module `torch.fx.experimental` torch/_refs/__init__.py:564:47: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__` torch/_refs/__init__.py:751:12: error[unresolved-attribute] Module `torch` has no member `zeros_like` torch/_refs/__init__.py:767:15: error[unresolved-attribute] Module `torch` has no member `mul` @@ -10644,12 +11035,6 @@ torch/_refs/__init__.py:2727:17: error[unresolved-attribute] Module `torch` has torch/_refs/__init__.py:2727:55: error[unresolved-attribute] Module `torch` has no member `full_like` torch/_refs/__init__.py:2740:28: error[unresolved-attribute] Module `torch` has no member `outer` torch/_refs/__init__.py:2742:42: error[unresolved-attribute] Module `torch` has no member `outer` -torch/_refs/__init__.py:2750:37: error[unresolved-attribute] Module `collections` has no member `abc` -torch/_refs/__init__.py:2753:36: error[unresolved-attribute] Module `collections` has no member `abc` -torch/_refs/__init__.py:2774:37: error[unresolved-attribute] Module `collections` has no member `abc` -torch/_refs/__init__.py:2777:36: error[unresolved-attribute] Module `collections` has no member `abc` -torch/_refs/__init__.py:2789:37: error[unresolved-attribute] Module `collections` has no member `abc` -torch/_refs/__init__.py:2792:36: error[unresolved-attribute] Module `collections` has no member `abc` torch/_refs/__init__.py:2825:12: error[unresolved-attribute] Module `torch` has no member `Size` torch/_refs/__init__.py:2854:21: error[unresolved-attribute] Module `torch` has no member `contiguous_format` torch/_refs/__init__.py:2981:16: error[unresolved-attribute] Module `torch` has no member `conj_physical` @@ -10659,7 +11044,7 @@ torch/_refs/__init__.py:3072:34: error[unresolved-attribute] Module `torch` has torch/_refs/__init__.py:3072:56: error[unresolved-attribute] Module `torch` has no member `contiguous_format` torch/_refs/__init__.py:3075:26: error[unresolved-attribute] Module `torch` has no member `preserve_format` torch/_refs/__init__.py:3083:12: error[unresolved-attribute] Module `torch` has no member `clone` -torch/_refs/__init__.py:3097:17: error[unresolved-attribute] Module `torch.fx.experimental` has no member `_config` +torch/_refs/__init__.py:3097:17: warning[possibly-missing-attribute] Submodule `_config` may not be available as an attribute on module `torch.fx.experimental` torch/_refs/__init__.py:3289:24: error[unresolved-attribute] Module `torch` has no member `var_mean` torch/_refs/__init__.py:3292:12: error[unresolved-attribute] Module `torch` has no member `rsqrt` torch/_refs/__init__.py:3300:13: error[unresolved-attribute] Module `torch` has no member `unsqueeze` @@ -10670,7 +11055,7 @@ torch/_refs/__init__.py:3339:27: error[unresolved-attribute] Module `torch` has torch/_refs/__init__.py:3345:29: error[unresolved-attribute] Module `torch` has no member `reshape` torch/_refs/__init__.py:3371:12: error[unresolved-attribute] Module `torch` has no member `squeeze` torch/_refs/__init__.py:3372:12: error[unresolved-attribute] Module `torch` has no member `squeeze` -torch/_refs/__init__.py:3454:2: error[unresolved-attribute] Module `torch._subclasses` has no member `fake_impls` +torch/_refs/__init__.py:3454:2: warning[possibly-missing-attribute] Submodule `fake_impls` may not be available as an attribute on module `torch._subclasses` torch/_refs/__init__.py:3503:19: error[unresolved-attribute] Module `torch` has no member `where` torch/_refs/__init__.py:3593:22: error[unresolved-attribute] Module `torch` has no member `ones` torch/_refs/__init__.py:3623:40: error[unresolved-attribute] Module `torch` has no member `view_as_real` @@ -11253,7 +11638,7 @@ torch/_subclasses/complex_tensor/_ops/common.py:185:34: error[unresolved-attribu torch/_subclasses/complex_tensor/_ops/common.py:185:50: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_subclasses/complex_tensor/_ops/common.py:237:44: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_subclasses/complex_tensor/_ops/prims.py:18:56: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/_subclasses/fake_impls.py:42:10: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` +torch/_subclasses/fake_impls.py:42:10: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` torch/_subclasses/fake_impls.py:129:19: error[unresolved-attribute] Module `torch._C` has no member `TensorType` torch/_subclasses/fake_impls.py:143:64: error[unresolved-attribute] Module `torch._C` has no member `TensorType` torch/_subclasses/fake_impls.py:156:34: error[invalid-argument-type] Argument to function `register_op_impl` is incorrect: Expected `((OpOverload[Unknown, Any], /) -> bool) | OpOverload[Unknown, Any]`, found `object` @@ -11265,11 +11650,11 @@ torch/_subclasses/fake_impls.py:239:28: error[unresolved-attribute] Module `torc torch/_subclasses/fake_impls.py:272:79: error[invalid-argument-type] Argument to function `run_fallback_kernel` is incorrect: Expected `RuntimeError`, found `None` torch/_subclasses/fake_impls.py:293:18: error[unresolved-attribute] Module `torch` has no member `Tag` torch/_subclasses/fake_impls.py:361:68: error[unresolved-attribute] Module `torch` has no member `device` -torch/_subclasses/fake_impls.py:602:9: error[unresolved-attribute] Module `torch.fx.experimental` has no member `_config` +torch/_subclasses/fake_impls.py:602:9: warning[possibly-missing-attribute] Submodule `_config` may not be available as an attribute on module `torch.fx.experimental` torch/_subclasses/fake_impls.py:616:38: error[too-many-positional-arguments] Too many positional arguments to function `infer_size`: expected 2, got 3 torch/_subclasses/fake_impls.py:619:41: error[unresolved-attribute] Module `torch` has no member `contiguous_format` torch/_subclasses/fake_impls.py:622:52: error[unresolved-attribute] Module `torch` has no member `contiguous_format` -torch/_subclasses/fake_impls.py:629:8: error[unresolved-attribute] Module `torch.fx.experimental` has no member `_config` +torch/_subclasses/fake_impls.py:629:8: warning[possibly-missing-attribute] Submodule `_config` may not be available as an attribute on module `torch.fx.experimental` torch/_subclasses/fake_impls.py:644:41: error[unresolved-attribute] Module `torch` has no member `contiguous_format` torch/_subclasses/fake_impls.py:745:68: error[unresolved-attribute] Module `torch` has no member `int64` torch/_subclasses/fake_impls.py:940:32: error[unresolved-attribute] Module `torch` has no member `Tag` @@ -11290,24 +11675,24 @@ torch/_subclasses/fake_impls.py:1413:17: error[unresolved-attribute] Module `tor torch/_subclasses/fake_impls.py:1417:35: error[unresolved-attribute] Module `torch` has no member `contiguous_format` torch/_subclasses/fake_impls.py:1426:17: error[unresolved-attribute] Module `torch` has no member `empty` torch/_subclasses/fake_impls.py:1430:35: error[unresolved-attribute] Module `torch` has no member `channels_last` -torch/_subclasses/fake_tensor.py:88:10: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` +torch/_subclasses/fake_tensor.py:88:10: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` torch/_subclasses/fake_tensor.py:162:11: error[unresolved-attribute] Module `torch._C` has no member `_unset_dispatch_mode` torch/_subclasses/fake_tensor.py:162:41: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` torch/_subclasses/fake_tensor.py:167:13: error[unresolved-attribute] Module `torch._C` has no member `_set_dispatch_mode` torch/_subclasses/fake_tensor.py:211:36: error[unresolved-attribute] Module `torch` has no member `_is_functional_tensor` torch/_subclasses/fake_tensor.py:212:25: error[unresolved-attribute] Module `torch._C` has no member `_functionalization_reapply_views_tls` -torch/_subclasses/fake_tensor.py:213:21: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_subclasses/fake_tensor.py:216:21: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_subclasses/fake_tensor.py:213:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_subclasses/fake_tensor.py:216:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_subclasses/fake_tensor.py:236:36: error[unresolved-attribute] Module `torch` has no member `_is_functional_tensor` torch/_subclasses/fake_tensor.py:237:25: error[unresolved-attribute] Module `torch._C` has no member `_functionalization_reapply_views_tls` -torch/_subclasses/fake_tensor.py:238:21: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_subclasses/fake_tensor.py:241:21: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_subclasses/fake_tensor.py:238:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_subclasses/fake_tensor.py:241:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_subclasses/fake_tensor.py:247:42: error[unresolved-attribute] Module `torch._C` has no member `_SchemaInfo` torch/_subclasses/fake_tensor.py:248:12: error[unresolved-attribute] Module `torch._C` has no member `_SchemaInfo` -torch/_subclasses/fake_tensor.py:260:22: error[unresolved-attribute] Module `torch` has no member `_decomp` +torch/_subclasses/fake_tensor.py:260:22: warning[possibly-missing-attribute] Submodule `_decomp` may not be available as an attribute on module `torch` torch/_subclasses/fake_tensor.py:277:25: error[unresolved-attribute] Module `torch` has no member `strided` torch/_subclasses/fake_tensor.py:283:16: error[unresolved-attribute] Module `torch` has no member `_is_functional_tensor` -torch/_subclasses/fake_tensor.py:370:35: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_subclasses/fake_tensor.py:370:35: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_subclasses/fake_tensor.py:395:62: error[unresolved-attribute] Module `torch` has no member `device` torch/_subclasses/fake_tensor.py:408:21: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Tensor`, found `object` torch/_subclasses/fake_tensor.py:441:17: error[unresolved-attribute] Module `torch` has no member `int64` @@ -11342,7 +11727,7 @@ torch/_subclasses/fake_tensor.py:746:66: error[unresolved-attribute] Module `tor torch/_subclasses/fake_tensor.py:768:17: error[unresolved-attribute] Module `torch._C` has no member `_get_privateuse1_backend_name` torch/_subclasses/fake_tensor.py:773:26: error[unresolved-attribute] Module `torch` has no member `device` torch/_subclasses/fake_tensor.py:777:26: error[unresolved-attribute] Module `torch` has no member `device` -torch/_subclasses/fake_tensor.py:818:17: error[unresolved-attribute] Module `torch` has no member `_export` +torch/_subclasses/fake_tensor.py:818:17: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` torch/_subclasses/fake_tensor.py:840:24: error[unresolved-attribute] Module `torch` has no member `device` torch/_subclasses/fake_tensor.py:885:31: error[unresolved-attribute] Module `torch._C` has no member `_get_dispatch_mode` torch/_subclasses/fake_tensor.py:886:13: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` @@ -11363,9 +11748,10 @@ torch/_subclasses/fake_tensor.py:1410:13: error[unresolved-attribute] Module `to torch/_subclasses/fake_tensor.py:1415:13: error[unresolved-attribute] Module `torch._C` has no member `_ensureCUDADeviceGuardSet` torch/_subclasses/fake_tensor.py:1417:32: error[unresolved-attribute] Module `torch._C` has no member `_unset_dispatch_mode` torch/_subclasses/fake_tensor.py:1425:13: error[unresolved-attribute] Module `torch._C` has no member `_set_dispatch_mode` +torch/_subclasses/fake_tensor.py:1430:9: error[invalid-method-override] Invalid override of method `__exit__`: Definition is incompatible with `TorchDispatchMode.__exit__` torch/_subclasses/fake_tensor.py:1446:17: error[unresolved-attribute] Module `torch._C` has no member `_set_dispatch_mode` torch/_subclasses/fake_tensor.py:1448:17: error[unresolved-attribute] Module `torch._C` has no member `_set_only_lift_cpu_tensors` -torch/_subclasses/fake_tensor.py:1581:22: error[unresolved-attribute] Module `torch.fx.experimental` has no member `proxy_tensor` +torch/_subclasses/fake_tensor.py:1581:22: warning[possibly-missing-attribute] Submodule `proxy_tensor` may not be available as an attribute on module `torch.fx.experimental` torch/_subclasses/fake_tensor.py:1586:13: error[unresolved-attribute] Module `torch` has no member `get_default_dtype` torch/_subclasses/fake_tensor.py:1589:13: error[unresolved-attribute] Module `torch._C` has no member `_get_default_device` torch/_subclasses/fake_tensor.py:1592:13: error[unresolved-attribute] Module `torch` has no member `is_inference_mode_enabled` @@ -11387,14 +11773,14 @@ torch/_subclasses/fake_tensor.py:2470:17: error[unresolved-attribute] Module `to torch/_subclasses/fake_tensor.py:2478:17: error[unresolved-attribute] Object of type `object` has no attribute `constant` torch/_subclasses/fake_tensor.py:2526:40: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` torch/_subclasses/fake_tensor.py:2729:21: error[call-non-callable] Object of type `object` is not callable -torch/_subclasses/fake_tensor.py:2757:27: error[unresolved-attribute] Module `torch._library` has no member `simple_registry` -torch/_subclasses/fake_tensor.py:2762:23: error[unresolved-attribute] Module `torch._library` has no member `fake_impl` -torch/_subclasses/fake_tensor.py:2763:22: error[unresolved-attribute] Module `torch._library` has no member `fake_impl` +torch/_subclasses/fake_tensor.py:2757:27: warning[possibly-missing-attribute] Submodule `simple_registry` may not be available as an attribute on module `torch._library` +torch/_subclasses/fake_tensor.py:2762:23: warning[possibly-missing-attribute] Submodule `fake_impl` may not be available as an attribute on module `torch._library` +torch/_subclasses/fake_tensor.py:2763:22: warning[possibly-missing-attribute] Submodule `fake_impl` may not be available as an attribute on module `torch._library` torch/_subclasses/fake_tensor.py:2883:46: error[unresolved-attribute] Module `torch` has no member `Tag` torch/_subclasses/fake_tensor.py:2917:17: error[unresolved-attribute] Module `torch` has no member `device` -torch/_subclasses/fake_tensor.py:2975:15: error[unresolved-attribute] Module `torch._dynamo` has no member `source` +torch/_subclasses/fake_tensor.py:2975:15: warning[possibly-missing-attribute] Submodule `source` may not be available as an attribute on module `torch._dynamo` torch/_subclasses/fake_tensor.py:3008:12: error[unresolved-attribute] Module `torch` has no member `Tag` -torch/_subclasses/fake_tensor.py:3124:18: error[unresolved-attribute] Module `torch.fx.experimental` has no member `proxy_tensor` +torch/_subclasses/fake_tensor.py:3124:18: warning[possibly-missing-attribute] Submodule `proxy_tensor` may not be available as an attribute on module `torch.fx.experimental` torch/_subclasses/fake_tensor.py:3149:8: error[unresolved-attribute] Module `torch` has no member `Tag` torch/_subclasses/fake_tensor.py:3160:23: error[unresolved-attribute] Module `torch` has no member `zeros_like` torch/_subclasses/fake_tensor.py:3160:50: error[unresolved-attribute] Object of type `T@to_real_tensor` has no attribute `fake_device` @@ -11404,7 +11790,7 @@ torch/_subclasses/fake_tensor.py:3236:20: error[unresolved-attribute] Module `to torch/_subclasses/fake_tensor.py:3253:18: error[unresolved-attribute] Module `torch._C` has no member `DisableTorchFunctionSubclass` torch/_subclasses/fake_tensor.py:3257:48: error[unresolved-attribute] Module `torch` has no member `device` torch/_subclasses/fake_tensor.py:3266:16: error[unresolved-attribute] Module `torch` has no member `device` -torch/_subclasses/fake_tensor.py:3371:9: error[unresolved-attribute] Module `torch._library` has no member `fake_impl` +torch/_subclasses/fake_tensor.py:3371:9: warning[possibly-missing-attribute] Submodule `fake_impl` may not be available as an attribute on module `torch._library` torch/_subclasses/fake_tensor.py:3397:16: error[unresolved-attribute] Module `torch` has no member `empty_strided` torch/_subclasses/fake_utils.py:28:12: error[unresolved-attribute] Module `torch._C` has no member `_has_storage` torch/_subclasses/fake_utils.py:31:9: error[unresolved-attribute] Module `torch._C` has no member `_has_storage` @@ -11412,8 +11798,8 @@ torch/_subclasses/fake_utils.py:44:16: error[unresolved-attribute] Module `torch torch/_subclasses/fake_utils.py:130:57: error[unresolved-attribute] Module `torch` has no member `strided` torch/_subclasses/fake_utils.py:157:22: error[unresolved-attribute] Module `torch` has no member `empty` torch/_subclasses/fake_utils.py:191:8: error[unresolved-attribute] Module `torch._C` has no member `_has_storage` -torch/_subclasses/fake_utils.py:197:5: error[unresolved-attribute] Module `torch` has no member `_prims` -torch/_subclasses/fake_utils.py:240:20: error[unresolved-attribute] Module `torch._subclasses` has no member `fake_impls` +torch/_subclasses/fake_utils.py:197:5: warning[possibly-missing-attribute] Submodule `_prims` may not be available as an attribute on module `torch` +torch/_subclasses/fake_utils.py:240:20: warning[possibly-missing-attribute] Submodule `fake_impls` may not be available as an attribute on module `torch._subclasses` torch/_subclasses/fake_utils.py:242:17: error[unresolved-attribute] Module `torch` has no member `Tag` torch/_subclasses/fake_utils.py:243:17: error[unresolved-attribute] Module `torch` has no member `Tag` torch/_subclasses/fake_utils.py:244:17: error[unresolved-attribute] Module `torch` has no member `Tag` @@ -11457,6 +11843,7 @@ torch/_subclasses/functional_tensor.py:340:38: error[unresolved-attribute] Modul torch/_subclasses/functional_tensor.py:342:21: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` torch/_subclasses/functional_tensor.py:344:20: error[unresolved-attribute] Module `torch._C` has no member `_get_dispatch_mode` torch/_subclasses/functional_tensor.py:345:17: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` +torch/_subclasses/functional_tensor.py:355:9: error[invalid-method-override] Invalid override of method `__exit__`: Definition is incompatible with `TorchDispatchMode.__exit__` torch/_subclasses/functional_tensor.py:429:17: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel` torch/_subclasses/functional_tensor.py:441:48: error[unresolved-attribute] Module `torch` has no member `_is_functional_tensor` torch/_subclasses/functional_tensor.py:456:19: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` @@ -11484,7 +11871,7 @@ torch/_subclasses/functional_tensor.py:584:13: error[unresolved-attribute] Modul torch/_subclasses/functional_tensor.py:586:23: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_is_dispatch_key_excluded` torch/_subclasses/functional_tensor.py:587:13: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/_subclasses/functional_tensor.py:606:13: error[unresolved-attribute] Module `torch` has no member `Tag` -torch/_subclasses/functional_tensor.py:609:18: error[unresolved-attribute] Module `torch.utils` has no member `_mode_utils` +torch/_subclasses/functional_tensor.py:609:18: warning[possibly-missing-attribute] Submodule `_mode_utils` may not be available as an attribute on module `torch.utils` torch/_subclasses/functional_tensor.py:624:32: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` torch/_subclasses/functional_tensor.py:646:28: error[unresolved-attribute] Module `torch` has no member `_is_functional_tensor` torch/_subclasses/functional_tensor.py:649:16: error[unresolved-attribute] Module `torch` has no member `_from_functional_tensor` @@ -11514,8 +11901,8 @@ torch/_subclasses/meta_utils.py:185:9: error[unresolved-attribute] Module `torch torch/_subclasses/meta_utils.py:292:25: error[unresolved-attribute] Module `torch` has no member `_is_functional_tensor` torch/_subclasses/meta_utils.py:343:21: error[unresolved-attribute] Module `torch` has no member `_from_functional_tensor` torch/_subclasses/meta_utils.py:347:33: error[unresolved-attribute] Module `torch._C` has no member `_functionalization_reapply_views_tls` -torch/_subclasses/meta_utils.py:355:33: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_subclasses/meta_utils.py:360:17: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_subclasses/meta_utils.py:355:33: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_subclasses/meta_utils.py:360:17: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_subclasses/meta_utils.py:433:45: error[unresolved-attribute] Module `torch` has no member `sparse_csr` torch/_subclasses/meta_utils.py:433:63: error[unresolved-attribute] Module `torch` has no member `sparse_bsr` torch/_subclasses/meta_utils.py:438:45: error[unresolved-attribute] Module `torch` has no member `sparse_csr` @@ -11524,7 +11911,7 @@ torch/_subclasses/meta_utils.py:443:45: error[unresolved-attribute] Module `torc torch/_subclasses/meta_utils.py:443:63: error[unresolved-attribute] Module `torch` has no member `sparse_bsc` torch/_subclasses/meta_utils.py:448:45: error[unresolved-attribute] Module `torch` has no member `sparse_csc` torch/_subclasses/meta_utils.py:448:63: error[unresolved-attribute] Module `torch` has no member `sparse_bsc` -torch/_subclasses/meta_utils.py:462:17: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/_subclasses/meta_utils.py:462:17: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/_subclasses/meta_utils.py:480:13: error[invalid-argument-type] Argument is incorrect: Expected `None`, found `None | type[Tensor]` torch/_subclasses/meta_utils.py:582:68: error[unresolved-attribute] Module `torch` has no member `device` torch/_subclasses/meta_utils.py:587:19: error[unresolved-attribute] Module `torch` has no member `device` @@ -11538,24 +11925,24 @@ torch/_subclasses/meta_utils.py:721:58: error[unresolved-attribute] Module `torc torch/_subclasses/meta_utils.py:836:25: error[unresolved-attribute] Module `torch` has no member `empty` torch/_subclasses/meta_utils.py:836:51: error[unresolved-attribute] Module `torch` has no member `uint8` torch/_subclasses/meta_utils.py:858:32: error[unresolved-attribute] Module `torch` has no member `device` -torch/_subclasses/meta_utils.py:864:17: error[unresolved-attribute] Module `torch._C` has no member `_functions` +torch/_subclasses/meta_utils.py:864:17: warning[possibly-missing-attribute] Submodule `_functions` may not be available as an attribute on module `torch._C` torch/_subclasses/meta_utils.py:902:20: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_local_exclude_set` torch/_subclasses/meta_utils.py:903:13: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` -torch/_subclasses/meta_utils.py:937:18: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_subclasses/meta_utils.py:939:17: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` -torch/_subclasses/meta_utils.py:976:24: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_subclasses/meta_utils.py:978:17: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` +torch/_subclasses/meta_utils.py:937:18: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_subclasses/meta_utils.py:939:17: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` +torch/_subclasses/meta_utils.py:976:24: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_subclasses/meta_utils.py:978:17: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` torch/_subclasses/meta_utils.py:986:20: error[unresolved-attribute] Module `torch` has no member `empty_strided` -torch/_subclasses/meta_utils.py:1000:17: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` -torch/_subclasses/meta_utils.py:1002:30: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_subclasses/meta_utils.py:1107:21: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/_subclasses/meta_utils.py:1108:33: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` -torch/_subclasses/meta_utils.py:1110:14: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` -torch/_subclasses/meta_utils.py:1119:17: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` -torch/_subclasses/meta_utils.py:1127:33: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` -torch/_subclasses/meta_utils.py:1132:26: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` -torch/_subclasses/meta_utils.py:1188:17: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` -torch/_subclasses/meta_utils.py:1273:25: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` +torch/_subclasses/meta_utils.py:1000:17: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` +torch/_subclasses/meta_utils.py:1002:30: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_subclasses/meta_utils.py:1107:21: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/_subclasses/meta_utils.py:1108:33: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` +torch/_subclasses/meta_utils.py:1110:14: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` +torch/_subclasses/meta_utils.py:1119:17: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` +torch/_subclasses/meta_utils.py:1127:33: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` +torch/_subclasses/meta_utils.py:1132:26: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` +torch/_subclasses/meta_utils.py:1188:17: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` +torch/_subclasses/meta_utils.py:1273:25: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` torch/_subclasses/meta_utils.py:1280:32: error[invalid-return-type] Return type does not match returned value: expected `Tensor`, found `None` torch/_subclasses/meta_utils.py:1343:36: error[unresolved-attribute] Module `torch` has no member `sparse_coo` torch/_subclasses/meta_utils.py:1373:37: error[unresolved-attribute] Module `torch` has no member `sparse_bsr` @@ -11564,13 +11951,13 @@ torch/_subclasses/meta_utils.py:1381:37: error[unresolved-attribute] Module `tor torch/_subclasses/meta_utils.py:1381:55: error[unresolved-attribute] Module `torch` has no member `sparse_bsr` torch/_subclasses/meta_utils.py:1435:33: error[unresolved-attribute] Module `torch` has no member `empty_strided` torch/_subclasses/meta_utils.py:1444:45: error[unresolved-attribute] Module `torch` has no member `empty_strided` -torch/_subclasses/meta_utils.py:1483:34: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_subclasses/meta_utils.py:1483:34: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_subclasses/meta_utils.py:1492:49: error[unresolved-attribute] Module `torch._C` has no member `_DisableFuncTorch` -torch/_subclasses/meta_utils.py:1499:38: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/_subclasses/meta_utils.py:1503:41: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_subclasses/meta_utils.py:1499:38: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/_subclasses/meta_utils.py:1503:41: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_subclasses/meta_utils.py:1535:41: error[unresolved-attribute] Module `torch` has no member `empty_strided` torch/_subclasses/meta_utils.py:1569:25: error[unresolved-attribute] Module `torch` has no member `_to_functional_tensor` -torch/_subclasses/meta_utils.py:1598:25: error[unresolved-attribute] Module `torch._dynamo` has no member `source` +torch/_subclasses/meta_utils.py:1598:25: warning[possibly-missing-attribute] Submodule `source` may not be available as an attribute on module `torch._dynamo` torch/_subclasses/meta_utils.py:1603:40: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_subclasses/meta_utils.py:1603:65: error[unresolved-attribute] Module `torch` has no member `dtype` torch/_subclasses/meta_utils.py:1616:35: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_is_dispatch_key_excluded` @@ -11579,15 +11966,15 @@ torch/_subclasses/meta_utils.py:1619:21: error[unresolved-attribute] Module `tor torch/_subclasses/meta_utils.py:1620:25: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/_subclasses/meta_utils.py:1626:64: error[unresolved-attribute] Module `torch` has no member `view_as_real` torch/_subclasses/meta_utils.py:1629:33: error[unresolved-attribute] Module `torch` has no member `view_as_complex` -torch/_subclasses/meta_utils.py:1687:25: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/_subclasses/meta_utils.py:1687:25: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/_subclasses/meta_utils.py:1689:25: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_set_dispatch_key_excluded` torch/_subclasses/meta_utils.py:1690:29: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/_subclasses/meta_utils.py:1720:37: error[unresolved-attribute] Module `torch` has no member `empty_strided` torch/_subclasses/meta_utils.py:1732:49: error[unresolved-attribute] Module `torch` has no member `empty_strided` torch/_subclasses/meta_utils.py:1839:17: error[unresolved-attribute] Module `torch._C` has no member `_set_conj` torch/_subclasses/meta_utils.py:1841:17: error[unresolved-attribute] Module `torch._C` has no member `_set_neg` -torch/_subclasses/meta_utils.py:1948:38: error[unresolved-attribute] Module `torch` has no member `_dispatch` -torch/_subclasses/meta_utils.py:1952:21: error[unresolved-attribute] Module `torch` has no member `_functorch` +torch/_subclasses/meta_utils.py:1948:38: warning[possibly-missing-attribute] Submodule `_dispatch` may not be available as an attribute on module `torch` +torch/_subclasses/meta_utils.py:1952:21: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` torch/_subclasses/schema_check_mode.py:19:18: error[unresolved-attribute] Module `torch._C` has no member `_SchemaArgument` torch/_subclasses/schema_check_mode.py:20:17: error[unresolved-attribute] Module `torch._C` has no member `_SchemaArgType` torch/_subclasses/schema_check_mode.py:21:14: error[unresolved-attribute] Module `torch._C` has no member `_SchemaInfo` @@ -11638,7 +12025,7 @@ torch/_tensor.py:425:13: error[unresolved-attribute] Module `torch` has no membe torch/_tensor.py:426:13: error[unresolved-attribute] Module `torch` has no member `sparse_bsc` torch/_tensor.py:428:32: error[unresolved-attribute] Module `torch` has no member `sparse_csr` torch/_tensor.py:428:50: error[unresolved-attribute] Module `torch` has no member `sparse_bsr` -torch/_tensor.py:467:34: error[unresolved-attribute] Module `torch._subclasses` has no member `functional_tensor` +torch/_tensor.py:467:34: warning[possibly-missing-attribute] Submodule `functional_tensor` may not be available as an attribute on module `torch._subclasses` torch/_tensor.py:804:14: error[unresolved-attribute] Module `torch._C` has no member `_add_docstr` torch/_tensor.py:805:9: error[unresolved-attribute] Module `torch._C` has no member `TensorBase` torch/_tensor.py:822:15: error[unresolved-attribute] Module `torch._C` has no member `_add_docstr` @@ -11689,7 +12076,7 @@ torch/_tensor_str.py:358:9: error[unresolved-attribute] Module `torch` has no me torch/_tensor_str.py:401:20: error[unresolved-attribute] Module `torch` has no member `cat` torch/_tensor_str.py:411:16: error[unresolved-attribute] Module `torch` has no member `stack` torch/_tensor_str.py:413:16: error[unresolved-attribute] Module `torch` has no member `stack` -torch/_tensor_str.py:417:8: error[unresolved-attribute] Module `torch._C` has no member `_functorch` +torch/_tensor_str.py:417:8: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` torch/_tensor_str.py:445:29: error[unresolved-attribute] Module `torch._C` has no member `_get_default_device` torch/_tensor_str.py:462:9: error[unresolved-attribute] Module `torch` has no member `cdouble` torch/_tensor_str.py:462:26: error[unresolved-attribute] Module `torch` has no member `get_default_dtype` @@ -11719,14 +12106,14 @@ torch/_tensor_str.py:614:30: error[unresolved-attribute] Module `torch` has no m torch/_tensor_str.py:628:34: error[unresolved-attribute] Module `torch` has no member `get_default_dtype` torch/_tensor_str.py:640:39: error[unresolved-attribute] Module `torch` has no member `strided` torch/_tensor_str.py:645:23: error[unresolved-attribute] Module `torch` has no member `strided` -torch/_tensor_str.py:695:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_tensor_str.py:698:8: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_tensor_str.py:703:13: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_tensor_str.py:707:8: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_tensor_str.py:708:16: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_tensor_str.py:713:8: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_tensor_str.py:715:8: error[unresolved-attribute] Module `torch._C` has no member `_functorch` -torch/_tensor_str.py:722:27: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/_tensor_str.py:695:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_tensor_str.py:698:8: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_tensor_str.py:703:13: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_tensor_str.py:707:8: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_tensor_str.py:708:16: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_tensor_str.py:713:8: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_tensor_str.py:715:8: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch._C` +torch/_tensor_str.py:722:27: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/_tensor_str.py:723:17: error[unresolved-attribute] Module `torch._C` has no member `_DisableFuncTorch` torch/_torch_docs.py:7:22: error[unresolved-import] Module `torch._C` has no member `_add_docstr` torch/_torch_docs.py:220:5: error[unresolved-attribute] Module `torch` has no member `abs` @@ -12149,7 +12536,7 @@ torch/_utils.py:78:27: error[unresolved-attribute] Module `torch` has no member torch/_utils.py:79:34: error[unresolved-attribute] Module `torch` has no member `uint8` torch/_utils.py:137:45: error[unresolved-attribute] Module `torch` has no member `device` torch/_utils.py:188:9: error[unresolved-attribute] Module `torch` has no member `empty` -torch/_utils.py:208:8: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/_utils.py:208:8: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/_utils.py:211:39: error[unresolved-attribute] Module `torch` has no member `device` torch/_utils.py:212:26: error[unresolved-attribute] Module `torch` has no member `device` torch/_utils.py:213:34: error[unresolved-attribute] Module `torch` has no member `device` @@ -12210,8 +12597,8 @@ torch/_utils.py:912:16: error[unresolved-attribute] Module `torch` has no member torch/_utils.py:973:33: error[unresolved-attribute] Module `torch._C` has no member `_unset_dispatch_mode` torch/_utils.py:974:13: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` torch/_utils.py:980:17: error[unresolved-attribute] Module `torch._C` has no member `_set_dispatch_mode` -torch/_utils.py:1063:17: error[unresolved-attribute] Module `importlib` has no member `util` -torch/_utils.py:1064:18: error[unresolved-attribute] Module `importlib` has no member `util` +torch/_utils.py:1063:17: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` +torch/_utils.py:1064:18: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` torch/_utils_internal.py:230:14: error[unresolved-import] Cannot resolve imported module `triton.testing` torch/_utils_internal.py:314:17: error[unresolved-attribute] Object of type `(...) -> _T@decorator` has no attribute `__name__` torch/_utils_internal.py:320:23: error[unresolved-attribute] Object of type `(...) -> _T@decorator` has no attribute `__name__` @@ -12257,14 +12644,14 @@ torch/accelerator/memory.py:218:12: error[unresolved-attribute] Module `torch._C torch/accelerator/memory.py:236:12: error[unresolved-attribute] Module `torch._C` has no member `_accelerator_getMemoryInfo` torch/amp/autocast_mode.py:37:12: error[unresolved-attribute] Module `torch._C` has no member `_is_autocast_available` torch/amp/autocast_mode.py:234:13: error[unresolved-attribute] Module `torch` has no member `get_autocast_dtype` -torch/amp/autocast_mode.py:236:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` +torch/amp/autocast_mode.py:236:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` torch/amp/autocast_mode.py:247:36: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/amp/autocast_mode.py:247:52: error[unresolved-attribute] Module `torch` has no member `float16` torch/amp/autocast_mode.py:249:36: error[unresolved-attribute] Module `torch._C` has no member `_get_privateuse1_backend_name` torch/amp/autocast_mode.py:268:13: error[unresolved-attribute] Module `torch` has no member `is_autocast_cache_enabled` torch/amp/autocast_mode.py:288:40: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/amp/autocast_mode.py:306:44: error[unresolved-attribute] Module `torch` has no member `bfloat16` -torch/amp/autocast_mode.py:318:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` +torch/amp/autocast_mode.py:318:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` torch/amp/autocast_mode.py:322:35: error[unresolved-attribute] Module `torch` has no member `is_autocast_cache_enabled` torch/amp/autocast_mode.py:323:21: error[unresolved-attribute] Module `torch` has no member `is_autocast_enabled` torch/amp/autocast_mode.py:324:31: error[unresolved-attribute] Module `torch` has no member `get_autocast_dtype` @@ -12272,21 +12659,19 @@ torch/amp/autocast_mode.py:325:9: error[unresolved-attribute] Module `torch` has torch/amp/autocast_mode.py:327:9: error[unresolved-attribute] Module `torch` has no member `autocast_increment_nesting` torch/amp/autocast_mode.py:328:9: error[unresolved-attribute] Module `torch` has no member `set_autocast_cache_enabled` torch/amp/autocast_mode.py:333:12: error[unresolved-attribute] Module `torch._C` has no member `_is_torch_function_mode_enabled` -torch/amp/autocast_mode.py:338:21: error[unresolved-attribute] Module `torch.fx.experimental` has no member `proxy_tensor` -torch/amp/autocast_mode.py:352:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` +torch/amp/autocast_mode.py:338:21: warning[possibly-missing-attribute] Submodule `proxy_tensor` may not be available as an attribute on module `torch.fx.experimental` +torch/amp/autocast_mode.py:352:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` torch/amp/autocast_mode.py:356:12: error[unresolved-attribute] Module `torch` has no member `autocast_decrement_nesting` torch/amp/autocast_mode.py:357:13: error[unresolved-attribute] Module `torch` has no member `clear_autocast_cache` torch/amp/autocast_mode.py:358:9: error[unresolved-attribute] Module `torch` has no member `set_autocast_enabled` torch/amp/autocast_mode.py:359:9: error[unresolved-attribute] Module `torch` has no member `set_autocast_dtype` torch/amp/autocast_mode.py:360:9: error[unresolved-attribute] Module `torch` has no member `set_autocast_cache_enabled` torch/amp/autocast_mode.py:365:12: error[unresolved-attribute] Module `torch._C` has no member `_is_torch_function_mode_enabled` -torch/amp/autocast_mode.py:370:21: error[unresolved-attribute] Module `torch.fx.experimental` has no member `proxy_tensor` -torch/amp/autocast_mode.py:379:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` +torch/amp/autocast_mode.py:370:21: warning[possibly-missing-attribute] Submodule `proxy_tensor` may not be available as an attribute on module `torch.fx.experimental` +torch/amp/autocast_mode.py:379:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` torch/amp/autocast_mode.py:389:8: error[unresolved-attribute] Module `torch._C` has no member `_is_torch_function_mode_enabled` torch/amp/autocast_mode.py:399:8: error[unresolved-attribute] Module `torch._C` has no member `_is_torch_function_mode_enabled` torch/amp/autocast_mode.py:411:37: error[unresolved-attribute] Module `torch` has no member `float64` -torch/amp/autocast_mode.py:422:28: error[unresolved-attribute] Module `collections` has no member `abc` -torch/amp/autocast_mode.py:427:28: error[unresolved-attribute] Module `collections` has no member `abc` torch/amp/autocast_mode.py:474:26: error[unresolved-attribute] Module `torch` has no member `get_autocast_dtype` torch/amp/autocast_mode.py:476:42: error[unresolved-attribute] Module `torch` has no member `is_autocast_enabled` torch/amp/autocast_mode.py:479:32: error[unresolved-attribute] Module `torch` has no member `is_autocast_enabled` @@ -12344,11 +12729,21 @@ torch/ao/nn/intrinsic/quantized/dynamic/modules/linear_relu.py:41:16: error[unre torch/ao/nn/intrinsic/quantized/dynamic/modules/linear_relu.py:41:30: error[unresolved-attribute] Module `torch` has no member `qint8` torch/ao/nn/intrinsic/quantized/dynamic/modules/linear_relu.py:46:41: error[unresolved-attribute] Module `torch` has no member `qint8` torch/ao/nn/intrinsic/quantized/dynamic/modules/linear_relu.py:51:43: error[unresolved-attribute] Module `torch` has no member `float16` +torch/ao/nn/intrinsic/quantized/modules/bn_relu.py:57:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `_BatchNorm.from_reference` +torch/ao/nn/intrinsic/quantized/modules/bn_relu.py:106:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `_BatchNorm.from_reference` +torch/ao/nn/intrinsic/quantized/modules/conv_add.py:77:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `WeightedQuantizedModule.from_reference` +torch/ao/nn/intrinsic/quantized/modules/conv_add.py:146:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `WeightedQuantizedModule.from_reference` +torch/ao/nn/intrinsic/quantized/modules/conv_relu.py:97:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `WeightedQuantizedModule.from_reference` +torch/ao/nn/intrinsic/quantized/modules/conv_relu.py:180:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `WeightedQuantizedModule.from_reference` +torch/ao/nn/intrinsic/quantized/modules/conv_relu.py:263:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `WeightedQuantizedModule.from_reference` torch/ao/nn/intrinsic/quantized/modules/linear_relu.py:36:68: error[unresolved-attribute] Module `torch` has no member `qint8` +torch/ao/nn/intrinsic/quantized/modules/linear_relu.py:52:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `Linear.from_reference` torch/ao/nn/intrinsic/quantized/modules/linear_relu.py:78:75: error[unresolved-attribute] Module `torch` has no member `qint8` torch/ao/nn/intrinsic/quantized/modules/linear_relu.py:108:25: error[unresolved-attribute] Module `torch` has no member `qint8` +torch/ao/nn/intrinsic/quantized/modules/linear_relu.py:119:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `Linear.from_reference` torch/ao/nn/intrinsic/quantized/modules/linear_relu.py:153:68: error[unresolved-attribute] Module `torch` has no member `qint8` torch/ao/nn/intrinsic/quantized/modules/linear_relu.py:174:25: error[unresolved-attribute] Module `torch` has no member `qint8` +torch/ao/nn/intrinsic/quantized/modules/linear_relu.py:183:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `Linear.from_reference` torch/ao/nn/qat/dynamic/modules/linear.py:32:29: error[unresolved-attribute] Module `torch` has no member `device` torch/ao/nn/qat/modules/conv.py:115:20: error[call-non-callable] Object of type `object` is not callable torch/ao/nn/qat/modules/embedding_ops.py:54:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool`, found `Unknown | None` @@ -12432,7 +12827,7 @@ torch/ao/nn/quantized/dynamic/modules/linear.py:48:9: error[unresolved-attribute torch/ao/nn/quantized/dynamic/modules/linear.py:52:41: error[unresolved-attribute] Module `torch` has no member `qint8` torch/ao/nn/quantized/dynamic/modules/linear.py:61:43: error[unresolved-attribute] Module `torch` has no member `float16` torch/ao/nn/quantized/dynamic/modules/linear.py:74:41: error[unresolved-attribute] Module `torch` has no member `qint8` -torch/ao/nn/quantized/dynamic/modules/linear.py:112:13: error[unresolved-attribute] Module `torch.ao.nn.qat` has no member `dynamic` +torch/ao/nn/quantized/dynamic/modules/linear.py:112:13: warning[possibly-missing-attribute] Submodule `dynamic` may not be available as an attribute on module `torch.ao.nn.qat` torch/ao/nn/quantized/dynamic/modules/linear.py:134:26: error[unresolved-attribute] Module `torch` has no member `qint8` torch/ao/nn/quantized/dynamic/modules/linear.py:134:39: error[unresolved-attribute] Module `torch` has no member `float16` torch/ao/nn/quantized/dynamic/modules/linear.py:139:21: error[unresolved-attribute] Module `torch` has no member `qint8` @@ -12562,8 +12957,15 @@ torch/ao/nn/quantized/modules/conv.py:203:9: error[unresolved-attribute] Cannot torch/ao/nn/quantized/modules/conv.py:205:9: error[unresolved-attribute] Cannot assign object of type `int` to attribute `zero_point` on type `Self@_load_from_state_dict` with custom `__setattr__` method. torch/ao/nn/quantized/modules/conv.py:250:45: error[unresolved-attribute] Module `torch` has no member `qint8` torch/ao/nn/quantized/modules/conv.py:269:49: error[unresolved-attribute] Module `torch` has no member `float` +torch/ao/nn/quantized/modules/conv.py:325:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `WeightedQuantizedModule.from_reference` +torch/ao/nn/quantized/modules/conv.py:435:9: error[invalid-method-override] Invalid override of method `set_weight_bias`: Definition is incompatible with `_ConvNd.set_weight_bias` +torch/ao/nn/quantized/modules/conv.py:567:9: error[invalid-method-override] Invalid override of method `set_weight_bias`: Definition is incompatible with `_ConvNd.set_weight_bias` +torch/ao/nn/quantized/modules/conv.py:698:9: error[invalid-method-override] Invalid override of method `set_weight_bias`: Definition is incompatible with `_ConvNd.set_weight_bias` torch/ao/nn/quantized/modules/conv.py:815:45: error[unresolved-attribute] Module `torch` has no member `qint8` torch/ao/nn/quantized/modules/conv.py:835:53: error[unresolved-attribute] Module `torch` has no member `float` +torch/ao/nn/quantized/modules/conv.py:960:9: error[invalid-method-override] Invalid override of method `set_weight_bias`: Definition is incompatible with `_ConvNd.set_weight_bias` +torch/ao/nn/quantized/modules/conv.py:1083:9: error[invalid-method-override] Invalid override of method `set_weight_bias`: Definition is incompatible with `_ConvNd.set_weight_bias` +torch/ao/nn/quantized/modules/conv.py:1208:9: error[invalid-method-override] Invalid override of method `set_weight_bias`: Definition is incompatible with `_ConvNd.set_weight_bias` torch/ao/nn/quantized/modules/embedding_ops.py:16:61: error[unresolved-attribute] Module `torch` has no member `quint8` torch/ao/nn/quantized/modules/embedding_ops.py:19:27: error[unresolved-attribute] Module `torch` has no member `quint8` torch/ao/nn/quantized/modules/embedding_ops.py:19:41: error[unresolved-attribute] Module `torch` has no member `quint4x2` @@ -12597,6 +12999,7 @@ torch/ao/nn/quantized/modules/embedding_ops.py:313:26: error[unresolved-attribut torch/ao/nn/quantized/modules/embedding_ops.py:370:40: error[unresolved-attribute] Module `torch` has no member `per_channel_affine_float_qparams` torch/ao/nn/quantized/modules/embedding_ops.py:376:25: error[unresolved-attribute] Module `torch` has no member `quint8` torch/ao/nn/quantized/modules/embedding_ops.py:376:50: error[unresolved-attribute] Module `torch` has no member `quint4x2` +torch/ao/nn/quantized/modules/embedding_ops.py:400:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `Embedding.from_reference` torch/ao/nn/quantized/modules/functional_modules.py:51:13: error[unresolved-attribute] Module `torch` has no member `add` torch/ao/nn/quantized/modules/functional_modules.py:58:13: error[unresolved-attribute] Module `torch` has no member `add` torch/ao/nn/quantized/modules/functional_modules.py:66:13: error[unresolved-attribute] Module `torch` has no member `mul` @@ -12647,6 +13050,7 @@ torch/ao/nn/quantized/modules/linear.py:224:46: error[unresolved-attribute] Modu torch/ao/nn/quantized/modules/linear.py:239:9: error[unresolved-attribute] Cannot assign object of type `float` to attribute `scale` on type `Self@_load_from_state_dict` with custom `__setattr__` method. torch/ao/nn/quantized/modules/linear.py:242:9: error[unresolved-attribute] Cannot assign object of type `int` to attribute `zero_point` on type `Self@_load_from_state_dict` with custom `__setattr__` method. torch/ao/nn/quantized/modules/linear.py:337:25: error[unresolved-attribute] Module `torch` has no member `qint8` +torch/ao/nn/quantized/modules/linear.py:346:9: error[invalid-method-override] Invalid override of method `from_reference`: Definition is incompatible with `WeightedQuantizedModule.from_reference` torch/ao/nn/quantized/modules/normalization.py:41:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool`, found `Unknown | None` torch/ao/nn/quantized/modules/normalization.py:46:39: error[unresolved-attribute] Module `torch` has no member `tensor` torch/ao/nn/quantized/modules/normalization.py:48:44: error[unresolved-attribute] Module `torch` has no member `tensor` @@ -12693,9 +13097,15 @@ torch/ao/nn/quantized/modules/utils.py:86:30: error[unresolved-attribute] Module torch/ao/nn/quantized/modules/utils.py:87:19: error[unresolved-attribute] Module `torch` has no member `quantize_per_channel` torch/ao/nn/quantized/modules/utils.py:89:25: error[unresolved-attribute] Module `torch` has no member `float` torch/ao/nn/quantized/modules/utils.py:90:22: error[unresolved-attribute] Module `torch` has no member `float` -torch/ao/nn/quantized/modules/utils.py:105:29: error[unresolved-attribute] Module `collections` has no member `abc` +torch/ao/nn/quantized/reference/modules/conv.py:86:9: error[invalid-method-override] Invalid override of method `forward`: Definition is incompatible with `torch.nn.modules.conv.Conv1d.forward` +torch/ao/nn/quantized/reference/modules/conv.py:151:9: error[invalid-method-override] Invalid override of method `forward`: Definition is incompatible with `torch.nn.modules.conv.Conv2d.forward` +torch/ao/nn/quantized/reference/modules/conv.py:216:9: error[invalid-method-override] Invalid override of method `forward`: Definition is incompatible with `torch.nn.modules.conv.Conv3d.forward` +torch/ao/nn/quantized/reference/modules/conv.py:312:9: error[invalid-method-override] Invalid override of method `forward`: Definition is incompatible with `torch.nn.modules.conv.ConvTranspose1d.forward` +torch/ao/nn/quantized/reference/modules/conv.py:393:9: error[invalid-method-override] Invalid override of method `forward`: Definition is incompatible with `torch.nn.modules.conv.ConvTranspose2d.forward` +torch/ao/nn/quantized/reference/modules/conv.py:475:9: error[invalid-method-override] Invalid override of method `forward`: Definition is incompatible with `torch.nn.modules.conv.ConvTranspose3d.forward` torch/ao/nn/quantized/reference/modules/linear.py:29:17: error[unresolved-attribute] Module `torch` has no member `device` torch/ao/nn/quantized/reference/modules/linear.py:30:16: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/ao/nn/quantized/reference/modules/linear.py:39:9: error[invalid-method-override] Invalid override of method `forward`: Definition is incompatible with `torch.nn.modules.linear.Linear.forward` torch/ao/nn/quantized/reference/modules/rnn.py:75:28: error[unresolved-attribute] Module `torch` has no member `per_tensor_affine` torch/ao/nn/quantized/reference/modules/rnn.py:76:26: error[unresolved-attribute] Module `torch` has no member `quint8` torch/ao/nn/quantized/reference/modules/rnn.py:103:17: error[unresolved-attribute] Module `torch` has no member `per_tensor_affine` @@ -12900,7 +13310,7 @@ torch/ao/ns/_numeric_suite_fx.py:203:9: error[unresolved-attribute] Cannot assig torch/ao/ns/_numeric_suite_fx.py:207:9: error[unresolved-attribute] Cannot assign object of type `Literal[True]` to attribute `enabled` on type `Self@__init__` with custom `__setattr__` method. torch/ao/ns/_numeric_suite_fx.py:209:9: error[unresolved-attribute] Cannot assign object of type `str | None` to attribute `qconfig_str` on type `Self@__init__` with custom `__setattr__` method. torch/ao/ns/_numeric_suite_fx.py:211:9: error[unresolved-attribute] Cannot assign object of type `Literal[True]` to attribute `save_activations` on type `Self@__init__` with custom `__setattr__` method. -torch/ao/ns/_numeric_suite_fx.py:254:30: error[unresolved-attribute] Module `torch.ao.ns` has no member `fx` +torch/ao/ns/_numeric_suite_fx.py:254:30: warning[possibly-missing-attribute] Submodule `fx` may not be available as an attribute on module `torch.ao.ns` torch/ao/ns/_numeric_suite_fx.py:255:9: error[unresolved-attribute] Cannot assign object of type `Literal["sqnr"]` to attribute `comparison_fn_name` on type `Self@__init__` with custom `__setattr__` method. torch/ao/ns/_numeric_suite_fx.py:257:9: error[unresolved-attribute] Cannot assign object of type `list[Unknown]` to attribute `comparisons` on type `Self@__init__` with custom `__setattr__` method. torch/ao/ns/_numeric_suite_fx.py:312:5: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` @@ -12920,11 +13330,11 @@ For migrations of users: 2. FX graph mode quantization (torch.ao.quantization.quantize_fx.prepare_fx,torch.ao.quantization.quantize_fx.convert_fx, please migrate to use torchao pt2e quantization API instead (prepare_pt2e, convert_pt2e) 3. pt2e quantization has been migrated to torchao (https://github.com/pytorch/ao/tree/main/torchao/quantization/pt2e) see https://github.com/pytorch/ao/issues/2259 for more details -torch/ao/ns/fx/graph_matcher.py:99:33: error[invalid-argument-type] Argument to bound method `add` is incorrect: Expected `Node`, found `Node | Divergent | Sequence[Divergent] | ... omitted 14 union elements` -torch/ao/ns/fx/graph_matcher.py:102:24: warning[possibly-missing-attribute] Attribute `all_input_nodes` may be missing on object of type `Node | Divergent | Sequence[Divergent] | ... omitted 14 union elements` -torch/ao/ns/fx/graph_matcher.py:110:39: error[invalid-argument-type] Argument to bound method `_is_matchable` is incorrect: Expected `Node`, found `Node | Divergent | Sequence[Divergent] | ... omitted 14 union elements` -torch/ao/ns/fx/graph_matcher.py:124:17: error[invalid-argument-type] Argument is incorrect: Expected `Node`, found `Node | Divergent | Sequence[Divergent] | ... omitted 14 union elements` -torch/ao/ns/fx/graph_matcher.py:127:17: error[invalid-argument-type] Argument is incorrect: Expected `Node`, found `Node | Divergent | Sequence[Divergent] | ... omitted 14 union elements` +torch/ao/ns/fx/graph_matcher.py:99:33: error[invalid-argument-type] Argument to bound method `add` is incorrect: Expected `Node`, found `Node | Sequence[Divergent] | Mapping[str, Divergent] | ... omitted 13 union elements` +torch/ao/ns/fx/graph_matcher.py:102:24: warning[possibly-missing-attribute] Attribute `all_input_nodes` may be missing on object of type `Node | Sequence[Divergent] | Mapping[str, Divergent] | ... omitted 13 union elements` +torch/ao/ns/fx/graph_matcher.py:110:39: error[invalid-argument-type] Argument to bound method `_is_matchable` is incorrect: Expected `Node`, found `Node | Sequence[Divergent] | Mapping[str, Divergent] | ... omitted 13 union elements` +torch/ao/ns/fx/graph_matcher.py:124:17: error[invalid-argument-type] Argument is incorrect: Expected `Node`, found `Node | Sequence[Divergent] | Mapping[str, Divergent] | ... omitted 13 union elements` +torch/ao/ns/fx/graph_matcher.py:127:17: error[invalid-argument-type] Argument is incorrect: Expected `Node`, found `Node | Sequence[Divergent] | Mapping[str, Divergent] | ... omitted 13 union elements` torch/ao/ns/fx/graph_passes.py:227:9: error[unresolved-attribute] Module `torch` has no member `quantize_per_tensor` torch/ao/ns/fx/graph_passes.py:228:52: error[unresolved-attribute] Module `torch` has no member `quint8` torch/ao/ns/fx/graph_passes.py:292:25: error[unresolved-attribute] Module `torch` has no member `dequantize` @@ -12983,8 +13393,8 @@ torch/ao/ns/fx/mappings.py:726:9: error[unresolved-attribute] Module `torch` has torch/ao/ns/fx/n_shadows_utils.py:29:5: error[unresolved-attribute] Module `torch` has no member `add` torch/ao/ns/fx/n_shadows_utils.py:32:5: error[unresolved-attribute] Module `torch` has no member `mul` torch/ao/ns/fx/n_shadows_utils.py:409:55: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/ao/ns/fx/n_shadows_utils.py:539:37: error[unresolved-attribute] Module `torch.ao.quantization` has no member `quantize_fx` -torch/ao/ns/fx/n_shadows_utils.py:1139:22: error[unresolved-attribute] Module `torch.ao.ns` has no member `fx` +torch/ao/ns/fx/n_shadows_utils.py:539:37: warning[possibly-missing-attribute] Submodule `quantize_fx` may not be available as an attribute on module `torch.ao.quantization` +torch/ao/ns/fx/n_shadows_utils.py:1139:22: warning[possibly-missing-attribute] Submodule `fx` may not be available as an attribute on module `torch.ao.ns` torch/ao/ns/fx/n_shadows_utils.py:1336:30: error[unresolved-attribute] Module `torch` has no member `stack` torch/ao/ns/fx/n_shadows_utils.py:1342:29: error[unresolved-attribute] Module `torch` has no member `mean` torch/ao/ns/fx/pattern_utils.py:115:21: error[unresolved-attribute] Module `torch` has no member `float16` @@ -13027,10 +13437,10 @@ torch/ao/pruning/_experimental/data_sparsifier/data_norm_sparsifier.py:185:25: e torch/ao/pruning/_experimental/data_sparsifier/data_norm_sparsifier.py:187:25: error[unresolved-attribute] Module `torch` has no member `zeros_like` torch/ao/pruning/_experimental/data_sparsifier/data_norm_sparsifier.py:204:21: error[unresolved-attribute] Module `torch` has no member `where` torch/ao/pruning/_experimental/data_sparsifier/lightning/tests/test_callbacks.py:127:20: error[unresolved-attribute] Module `torch` has no member `all` -torch/ao/pruning/_experimental/data_sparsifier/lightning/tests/test_callbacks.py:132:13: error[unresolved-attribute] Module `importlib` has no member `util` +torch/ao/pruning/_experimental/data_sparsifier/lightning/tests/test_callbacks.py:132:13: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` torch/ao/pruning/_experimental/data_sparsifier/lightning/tests/test_callbacks.py:222:20: error[unresolved-attribute] Module `torch` has no member `all` torch/ao/pruning/_experimental/data_sparsifier/lightning/tests/test_callbacks.py:231:20: error[unresolved-attribute] Module `torch` has no member `all` -torch/ao/pruning/_experimental/data_sparsifier/lightning/tests/test_callbacks.py:280:13: error[unresolved-attribute] Module `importlib` has no member `util` +torch/ao/pruning/_experimental/data_sparsifier/lightning/tests/test_callbacks.py:280:13: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` torch/ao/pruning/_experimental/data_sparsifier/quantization_utils.py:97:31: warning[deprecated] The function `prepare` is deprecated: torch.ao.quantization is deprecated and will be removed in 2.10. For migrations of users: 1. Eager mode quantization (torch.ao.quantization.quantize, torch.ao.quantization.quantize_dynamic), please migrate to use torchao eager mode quantize_ API instead @@ -13065,6 +13475,7 @@ torch/ao/pruning/_experimental/pruner/FPGM_pruner.py:86:25: error[unresolved-att torch/ao/pruning/_experimental/pruner/FPGM_pruner.py:95:20: error[unresolved-attribute] Module `torch` has no member `topk` torch/ao/pruning/_experimental/pruner/base_structured_sparsifier.py:188:21: error[unresolved-attribute] Module `torch` has no member `flatten` torch/ao/pruning/_experimental/pruner/base_structured_sparsifier.py:200:21: error[unresolved-attribute] Module `torch` has no member `flatten` +torch/ao/pruning/_experimental/pruner/base_structured_sparsifier.py:227:9: error[invalid-method-override] Invalid override of method `make_config_from_model`: Definition is incompatible with `BaseSparsifier.make_config_from_model` torch/ao/pruning/_experimental/pruner/base_structured_sparsifier.py:234:47: error[invalid-argument-type] Argument to bound method `make_config_from_model` is incorrect: Expected `set[type[Linear]]`, found `set[type] | Unknown` torch/ao/pruning/_experimental/pruner/base_structured_sparsifier.py:248:17: error[unresolved-attribute] Module `torch` has no member `ones` torch/ao/pruning/_experimental/pruner/base_structured_sparsifier.py:248:51: error[unresolved-attribute] Module `torch` has no member `bool` @@ -13131,6 +13542,7 @@ torch/ao/quantization/_learnable_fake_quantize.py:82:29: error[unresolved-attrib torch/ao/quantization/_learnable_fake_quantize.py:83:37: error[unresolved-attribute] Module `torch` has no member `tensor` torch/ao/quantization/_learnable_fake_quantize.py:83:51: error[unresolved-attribute] Module `torch` has no member `finfo` torch/ao/quantization/_learnable_fake_quantize.py:83:63: error[unresolved-attribute] Module `torch` has no member `float32` +torch/ao/quantization/_learnable_fake_quantize.py:157:9: error[invalid-method-override] Invalid override of method `forward`: Definition is incompatible with `FakeQuantizeBase.forward` torch/ao/quantization/_learnable_fake_quantize.py:170:17: error[unresolved-attribute] Module `torch` has no member `per_channel_symmetric` torch/ao/quantization/_learnable_fake_quantize.py:171:17: error[unresolved-attribute] Module `torch` has no member `per_tensor_symmetric` torch/ao/quantization/_learnable_fake_quantize.py:179:33: error[unresolved-attribute] Module `torch` has no member `per_channel_symmetric` @@ -13175,7 +13587,7 @@ torch/ao/quantization/backend_config/backend_config.py:230:31: error[unresolved- torch/ao/quantization/backend_config/backend_config.py:245:27: error[unresolved-attribute] Module `torch` has no member `dtype` torch/ao/quantization/backend_config/backend_config.py:252:28: error[unresolved-attribute] Module `torch` has no member `dtype` torch/ao/quantization/backend_config/backend_config.py:259:28: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/ao/quantization/backend_config/backend_config.py:382:34: error[unresolved-attribute] Module `torch.ao.quantization` has no member `backend_config` +torch/ao/quantization/backend_config/backend_config.py:382:34: warning[possibly-missing-attribute] Submodule `backend_config` may not be available as an attribute on module `torch.ao.quantization` torch/ao/quantization/backend_config/executorch.py:41:17: error[unresolved-attribute] Module `torch` has no member `quint8` torch/ao/quantization/backend_config/executorch.py:42:18: error[unresolved-attribute] Module `torch` has no member `quint8` torch/ao/quantization/backend_config/executorch.py:43:18: error[unresolved-attribute] Module `torch` has no member `qint8` @@ -13360,6 +13772,7 @@ torch/ao/quantization/experimental/adaround_fake_quantize.py:109:21: error[unres torch/ao/quantization/experimental/adaround_fake_quantize.py:111:16: error[unresolved-attribute] Module `torch` has no member `all` torch/ao/quantization/experimental/adaround_fake_quantize.py:111:26: error[unresolved-attribute] Module `torch` has no member `ge` torch/ao/quantization/experimental/adaround_fake_quantize.py:113:19: error[unresolved-attribute] Module `torch` has no member `log` +torch/ao/quantization/experimental/adaround_fake_quantize.py:116:9: error[invalid-method-override] Invalid override of method `forward`: Definition is incompatible with `FakeQuantizeBase.forward` torch/ao/quantization/experimental/adaround_fake_quantize.py:142:25: error[unresolved-attribute] Module `torch` has no member `floor` torch/ao/quantization/experimental/adaround_fake_quantize.py:146:17: error[unresolved-attribute] Module `torch` has no member `clamp` torch/ao/quantization/experimental/adaround_loss.py:26:9: error[unresolved-attribute] Cannot assign object of type `int` to attribute `max_iter` on type `Self@__init__` with custom `__setattr__` method. @@ -13446,6 +13859,7 @@ torch/ao/quantization/fake_quantize.py:207:65: error[unresolved-attribute] Modul torch/ao/quantization/fake_quantize.py:208:44: error[unresolved-attribute] Module `torch` has no member `tensor` torch/ao/quantization/fake_quantize.py:211:9: error[unresolved-attribute] Cannot assign object of type `Unknown | Literal[-1]` to attribute `ch_axis` on type `Self@__init__` with custom `__setattr__` method. torch/ao/quantization/fake_quantize.py:222:9: error[unresolved-attribute] Cannot assign object of type `bool` to attribute `is_per_channel` on type `Self@__init__` with custom `__setattr__` method. +torch/ao/quantization/fake_quantize.py:228:9: error[invalid-method-override] Invalid override of method `forward`: Definition is incompatible with `FakeQuantizeBase.forward` torch/ao/quantization/fake_quantize.py:244:21: error[unresolved-attribute] Module `torch` has no member `fake_quantize_per_channel_affine` torch/ao/quantization/fake_quantize.py:253:21: error[unresolved-attribute] Module `torch` has no member `fake_quantize_per_tensor_affine` torch/ao/quantization/fake_quantize.py:404:52: error[unresolved-attribute] Module `torch` has no member `tensor` @@ -13453,6 +13867,7 @@ torch/ao/quantization/fake_quantize.py:404:76: error[unresolved-attribute] Modul torch/ao/quantization/fake_quantize.py:405:50: error[unresolved-attribute] Module `torch` has no member `tensor` torch/ao/quantization/fake_quantize.py:405:74: error[unresolved-attribute] Module `torch` has no member `long` torch/ao/quantization/fake_quantize.py:406:9: error[unresolved-attribute] Cannot assign object of type `bool` to attribute `is_symmetric_quant` on type `Self@__init__` with custom `__setattr__` method. +torch/ao/quantization/fake_quantize.py:423:9: error[invalid-method-override] Invalid override of method `forward`: Definition is incompatible with `FakeQuantizeBase.forward` torch/ao/quantization/fake_quantize.py:424:16: error[unresolved-attribute] Module `torch` has no member `fused_moving_avg_obs_fake_quant` torch/ao/quantization/fake_quantize.py:445:11: error[unresolved-attribute] Module `torch` has no member `quint8` torch/ao/quantization/fake_quantize.py:446:13: error[unresolved-attribute] Module `torch` has no member `per_tensor_affine` @@ -13672,7 +14087,7 @@ torch/ao/quantization/fx/_equalize.py:871:43: error[unresolved-attribute] Module torch/ao/quantization/fx/_equalize.py:884:21: error[invalid-argument-type] Argument to function `scale_weight_node` is incorrect: Expected `Tensor`, found `Unknown | None` torch/ao/quantization/fx/_equalize.py:893:21: error[invalid-argument-type] Argument to function `scale_weight_functional` is incorrect: Expected `Tensor`, found `Unknown | None` torch/ao/quantization/fx/_equalize.py:960:51: error[unresolved-attribute] Module `torch` has no member `mul` -torch/ao/quantization/fx/_equalize.py:981:9: error[unresolved-attribute] Module `torch.ao.ns` has no member `fx` +torch/ao/quantization/fx/_equalize.py:981:9: warning[possibly-missing-attribute] Submodule `fx` may not be available as an attribute on module `torch.ao.ns` torch/ao/quantization/fx/_lower_to_native_backend.py:58:9: error[unresolved-attribute] Module `torch` has no member `sigmoid` torch/ao/quantization/fx/_lower_to_native_backend.py:59:9: error[unresolved-attribute] Module `torch` has no member `tanh` torch/ao/quantization/fx/_lower_to_native_backend.py:111:9: error[unresolved-attribute] Module `torch` has no member `adaptive_avg_pool1d` @@ -13727,6 +14142,8 @@ torch/ao/quantization/fx/_lower_to_native_backend.py:1156:9: error[unresolved-at torch/ao/quantization/fx/_lower_to_native_backend.py:1157:9: error[unresolved-attribute] Module `torch` has no member `matmul` torch/ao/quantization/fx/_lower_to_native_backend.py:1227:40: error[unresolved-attribute] Module `torch` has no member `quantize_per_tensor` torch/ao/quantization/fx/_lower_to_native_backend.py:1232:35: error[unresolved-attribute] Module `torch` has no member `float16` +torch/ao/quantization/fx/_model_report/detector.py:503:9: error[invalid-method-override] Invalid override of method `determine_observer_insert_points`: Definition is incompatible with `DetectorBase.determine_observer_insert_points` +torch/ao/quantization/fx/_model_report/detector.py:955:9: error[invalid-method-override] Invalid override of method `determine_observer_insert_points`: Definition is incompatible with `DetectorBase.determine_observer_insert_points` torch/ao/quantization/fx/_model_report/detector.py:1059:41: error[unresolved-attribute] Module `torch` has no member `tensor` torch/ao/quantization/fx/_model_report/detector.py:1060:41: error[unresolved-attribute] Module `torch` has no member `tensor` torch/ao/quantization/fx/_model_report/detector.py:1072:21: error[unresolved-attribute] Module `torch` has no member `flatten` @@ -13736,6 +14153,7 @@ torch/ao/quantization/fx/_model_report/detector.py:1077:31: error[unresolved-att torch/ao/quantization/fx/_model_report/detector.py:1078:31: error[unresolved-attribute] Module `torch` has no member `max` torch/ao/quantization/fx/_model_report/detector.py:1178:17: error[unresolved-attribute] Module `torch` has no member `sqrt` torch/ao/quantization/fx/_model_report/detector.py:1178:44: error[unresolved-attribute] Module `torch` has no member `sqrt` +torch/ao/quantization/fx/_model_report/detector.py:1481:9: error[invalid-method-override] Invalid override of method `determine_observer_insert_points`: Definition is incompatible with `DetectorBase.determine_observer_insert_points` torch/ao/quantization/fx/_model_report/model_report_observer.py:56:26: error[unresolved-attribute] Module `torch` has no member `qint8` torch/ao/quantization/fx/_model_report/model_report_observer.py:60:61: error[unresolved-attribute] Module `torch` has no member `tensor` torch/ao/quantization/fx/_model_report/model_report_observer.py:61:54: error[unresolved-attribute] Module `torch` has no member `tensor` @@ -13805,7 +14223,7 @@ torch/ao/quantization/fx/convert.py:482:23: error[unresolved-attribute] Module ` torch/ao/quantization/fx/convert.py:500:19: error[unresolved-attribute] Module `torch` has no member `float16` torch/ao/quantization/fx/convert.py:549:9: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `bool | (Tensor & ~AlwaysFalsy) | (Module & ~AlwaysFalsy) | @Todo` torch/ao/quantization/fx/convert.py:551:21: error[unresolved-attribute] Module `torch` has no member `float16` -torch/ao/quantization/fx/convert.py:716:22: error[unresolved-attribute] Module `torch.ao.quantization` has no member `quantize_fx` +torch/ao/quantization/fx/convert.py:716:22: warning[possibly-missing-attribute] Submodule `quantize_fx` may not be available as an attribute on module `torch.ao.quantization` torch/ao/quantization/fx/convert.py:768:19: error[unresolved-attribute] Module `torch` has no member `device` torch/ao/quantization/fx/convert.py:894:23: error[no-matching-overload] No overload of bound method `get` matches arguments torch/ao/quantization/fx/convert.py:1081:63: error[invalid-argument-type] Argument to bound method `from_dict` is incorrect: Expected `dict[str, Any]`, found `(ConvertCustomConfig & Top[dict[Unknown, Unknown]]) | dict[str, Any]` @@ -13925,9 +14343,9 @@ torch/ao/quantization/fx/utils.py:410:29: error[unresolved-attribute] Module `to torch/ao/quantization/fx/utils.py:413:29: error[unresolved-attribute] Module `torch` has no member `unsqueeze` torch/ao/quantization/fx/utils.py:417:29: error[unresolved-attribute] Module `torch` has no member `dtype` torch/ao/quantization/fx/utils.py:422:18: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/ao/quantization/fx/utils.py:512:23: error[unresolved-attribute] Module `torch.ao.quantization` has no member `fx` -torch/ao/quantization/fx/utils.py:537:23: error[unresolved-attribute] Module `torch.ao.quantization` has no member `fx` -torch/ao/quantization/fx/utils.py:732:16: error[invalid-return-type] Return type does not match returned value: expected `Node | None`, found `Node | Divergent | Divergent | ... omitted 15 union elements` +torch/ao/quantization/fx/utils.py:512:23: warning[possibly-missing-attribute] Submodule `fx` may not be available as an attribute on module `torch.ao.quantization` +torch/ao/quantization/fx/utils.py:537:23: warning[possibly-missing-attribute] Submodule `fx` may not be available as an attribute on module `torch.ao.quantization` +torch/ao/quantization/fx/utils.py:732:16: error[invalid-return-type] Return type does not match returned value: expected `Node | None`, found `Node | Divergent | Unknown | ... omitted 14 union elements` torch/ao/quantization/observer.py:150:20: warning[unsupported-base] Unsupported class base with type `ABCMeta` torch/ao/quantization/observer.py:232:15: error[unresolved-attribute] Module `torch` has no member `quint8` torch/ao/quantization/observer.py:233:17: error[unresolved-attribute] Module `torch` has no member `per_tensor_affine` @@ -14112,7 +14530,7 @@ torch/ao/quantization/pt2e/export_utils.py:143:9: error[unresolved-attribute] Mo torch/ao/quantization/pt2e/export_utils.py:144:9: error[unresolved-attribute] Module `torch` has no member `randn` torch/ao/quantization/pt2e/graph_utils.py:32:6: error[unresolved-attribute] Module `torch` has no member `add` torch/ao/quantization/pt2e/graph_utils.py:33:6: error[unresolved-attribute] Module `torch` has no member `mul` -torch/ao/quantization/pt2e/lowering.py:31:20: error[unresolved-attribute] Module `torch` has no member `_export` +torch/ao/quantization/pt2e/lowering.py:31:20: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` torch/ao/quantization/pt2e/prepare.py:326:19: error[unresolved-attribute] Module `torch` has no member `device` torch/ao/quantization/pt2e/prepare.py:423:19: error[unresolved-attribute] Module `torch` has no member `device` torch/ao/quantization/pt2e/prepare.py:476:19: error[unresolved-attribute] Module `torch` has no member `device` @@ -14382,7 +14800,7 @@ torch/ao/quantization/pt2e/representation/rewrite.py:737:53: error[unresolved-at torch/ao/quantization/pt2e/representation/rewrite.py:737:65: error[unresolved-attribute] Module `torch` has no member `float32` torch/ao/quantization/pt2e/representation/rewrite.py:741:53: error[unresolved-attribute] Module `torch` has no member `finfo` torch/ao/quantization/pt2e/representation/rewrite.py:741:65: error[unresolved-attribute] Module `torch` has no member `float32` -torch/ao/quantization/pt2e/utils.py:364:10: error[unresolved-attribute] Module `torch` has no member `_export` +torch/ao/quantization/pt2e/utils.py:364:10: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` torch/ao/quantization/pt2e/utils.py:475:46: error[unresolved-attribute] Module `torch` has no member `dtype` torch/ao/quantization/pt2e/utils.py:510:5: error[unresolved-attribute] Cannot assign object of type `TreeSpec` to attribute `_in_spec` on type `GraphModule` with custom `__setattr__` method. torch/ao/quantization/pt2e/utils.py:517:50: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -14401,14 +14819,14 @@ torch/ao/quantization/qconfig.py:517:48: error[unresolved-attribute] Module `tor torch/ao/quantization/qconfig.py:521:52: error[unresolved-attribute] Module `torch` has no member `quint8` torch/ao/quantization/qconfig_mapping.py:54:5: error[unresolved-attribute] Module `torch` has no member `sigmoid` torch/ao/quantization/qconfig_mapping.py:59:5: error[unresolved-attribute] Module `torch` has no member `tanh` -torch/ao/quantization/quantization_mappings.py:211:21: error[unresolved-attribute] Module `torch.nn` has no member `quantizable` -torch/ao/quantization/quantization_mappings.py:211:42: error[unresolved-attribute] Module `torch.nn` has no member `quantizable` -torch/ao/quantization/quantize.py:61:18: error[unresolved-attribute] Module `torch.nn` has no member `quantizable` -torch/ao/quantization/quantize.py:62:32: error[unresolved-attribute] Module `torch.nn` has no member `quantizable` -torch/ao/quantization/quantize.py:65:9: error[unresolved-attribute] Module `torch.nn` has no member `quantizable` -torch/ao/quantization/quantize.py:65:30: error[unresolved-attribute] Module `torch.nn` has no member `quantized` -torch/ao/quantization/quantize.py:66:9: error[unresolved-attribute] Module `torch.nn` has no member `quantizable` -torch/ao/quantization/quantize.py:66:44: error[unresolved-attribute] Module `torch.nn` has no member `quantized` +torch/ao/quantization/quantization_mappings.py:211:21: warning[possibly-missing-attribute] Submodule `quantizable` may not be available as an attribute on module `torch.nn` +torch/ao/quantization/quantization_mappings.py:211:42: warning[possibly-missing-attribute] Submodule `quantizable` may not be available as an attribute on module `torch.nn` +torch/ao/quantization/quantize.py:61:18: warning[possibly-missing-attribute] Submodule `quantizable` may not be available as an attribute on module `torch.nn` +torch/ao/quantization/quantize.py:62:32: warning[possibly-missing-attribute] Submodule `quantizable` may not be available as an attribute on module `torch.nn` +torch/ao/quantization/quantize.py:65:9: warning[possibly-missing-attribute] Submodule `quantizable` may not be available as an attribute on module `torch.nn` +torch/ao/quantization/quantize.py:65:30: warning[possibly-missing-attribute] Submodule `quantized` may not be available as an attribute on module `torch.nn` +torch/ao/quantization/quantize.py:66:9: warning[possibly-missing-attribute] Submodule `quantizable` may not be available as an attribute on module `torch.nn` +torch/ao/quantization/quantize.py:66:44: warning[possibly-missing-attribute] Submodule `quantized` may not be available as an attribute on module `torch.nn` torch/ao/quantization/quantize.py:377:5: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` torch/ao/quantization/quantize.py:471:5: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` torch/ao/quantization/quantize.py:477:5: warning[deprecated] The function `prepare` is deprecated: torch.ao.quantization is deprecated and will be removed in 2.10. @@ -14726,7 +15144,7 @@ torch/autograd/forward_ad.py:229:9: error[unresolved-attribute] Module `torch._C torch/autograd/function.py:297:25: error[unresolved-attribute] Module `torch._C` has no member `_FunctionBase` torch/autograd/function.py:350:5: error[unresolved-attribute] Module `torch._C` has no member `_FunctionBase` torch/autograd/function.py:580:16: error[unresolved-attribute] Module `torch._C` has no member `_are_functorch_transforms_active` -torch/autograd/function.py:582:20: error[unresolved-attribute] Module `torch._functorch` has no member `utils` +torch/autograd/function.py:582:20: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._functorch` torch/autograd/function.py:612:16: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/autograd/function.py:754:42: error[unresolved-attribute] Module `torch._C` has no member `Value` torch/autograd/functional.py:248:23: error[unresolved-attribute] Module `torch` has no member `zeros_like` @@ -14740,7 +15158,7 @@ torch/autograd/functional.py:842:21: error[unresolved-attribute] Module `torch` torch/autograd/functional.py:1083:45: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/autograd/functional.py:1193:26: error[unresolved-attribute] Module `torch` has no member `zeros_like` torch/autograd/functional.py:1198:45: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` -torch/autograd/grad_mode.py:76:16: error[unresolved-attribute] Module `torch` has no member `_jit_internal` +torch/autograd/grad_mode.py:76:16: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` torch/autograd/grad_mode.py:81:21: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/autograd/grad_mode.py:136:21: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/autograd/grad_mode.py:137:9: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` @@ -14750,7 +15168,7 @@ torch/autograd/grad_mode.py:187:9: error[unresolved-attribute] Module `torch._C` torch/autograd/grad_mode.py:190:9: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` torch/autograd/grad_mode.py:194:9: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` torch/autograd/grad_mode.py:197:9: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` -torch/autograd/grad_mode.py:280:16: error[unresolved-attribute] Module `torch` has no member `_jit_internal` +torch/autograd/grad_mode.py:280:16: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` torch/autograd/grad_mode.py:290:40: error[unresolved-attribute] Module `torch._C` has no member `_InferenceMode` torch/autograd/grad_mode.py:304:20: error[unresolved-attribute] Module `torch._C` has no member `_InferenceMode` torch/autograd/grad_mode.py:332:21: error[unresolved-attribute] Module `torch._C` has no member `_is_multithreading_enabled` @@ -14759,7 +15177,7 @@ torch/autograd/grad_mode.py:340:9: error[unresolved-attribute] Module `torch._C` torch/autograd/grad_mode.py:372:21: error[unresolved-attribute] Module `torch._C` has no member `_is_view_replay_enabled` torch/autograd/grad_mode.py:373:9: error[unresolved-attribute] Module `torch._C` has no member `_set_view_replay_enabled` torch/autograd/grad_mode.py:380:9: error[unresolved-attribute] Module `torch._C` has no member `_set_view_replay_enabled` -torch/autograd/grad_mode.py:420:9: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/autograd/grad_mode.py:420:9: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/autograd/gradcheck.py:14:42: warning[deprecated] The function `vmap` is deprecated: Please use `torch.vmap` instead of `torch._vmap_internals.vmap`. torch/autograd/gradcheck.py:38:9: error[unresolved-attribute] Module `torch` has no member `sparse_csr` torch/autograd/gradcheck.py:39:9: error[unresolved-attribute] Module `torch` has no member `sparse_csc` @@ -14768,7 +15186,6 @@ torch/autograd/gradcheck.py:41:9: error[unresolved-attribute] Module `torch` has torch/autograd/gradcheck.py:46:63: error[unresolved-attribute] Module `torch` has no member `sparse_coo` torch/autograd/gradcheck.py:62:55: error[unresolved-attribute] Module `torch` has no member `strided` torch/autograd/gradcheck.py:76:60: error[unresolved-attribute] Module `torch` has no member `strided` -torch/autograd/gradcheck.py:92:24: error[unresolved-attribute] Module `collections` has no member `abc` torch/autograd/gradcheck.py:104:22: error[unresolved-attribute] Module `torch` has no member `sparse_coo` torch/autograd/gradcheck.py:107:15: error[unresolved-attribute] Module `torch` has no member `ones` torch/autograd/gradcheck.py:107:59: error[unresolved-attribute] Module `torch` has no member `int8` @@ -14824,8 +15241,8 @@ torch/autograd/gradcheck.py:1271:52: error[unresolved-attribute] Module `torch` torch/autograd/gradcheck.py:1287:61: error[unresolved-attribute] Module `torch` has no member `zeros_like` torch/autograd/gradcheck.py:1304:28: error[unresolved-attribute] Module `torch` has no member `allclose` torch/autograd/gradcheck.py:1335:13: error[unresolved-attribute] Module `torch` has no member `zeros_like` -torch/autograd/gradcheck.py:1363:13: error[unresolved-attribute] Module `torch._C` has no member `_functions` -torch/autograd/gradcheck.py:1376:21: error[unresolved-attribute] Module `torch._C` has no member `_functions` +torch/autograd/gradcheck.py:1363:13: warning[possibly-missing-attribute] Submodule `_functions` may not be available as an attribute on module `torch._C` +torch/autograd/gradcheck.py:1376:21: warning[possibly-missing-attribute] Submodule `_functions` may not be available as an attribute on module `torch._C` torch/autograd/gradcheck.py:1442:32: error[unresolved-attribute] Module `torch` has no member `real` torch/autograd/gradcheck.py:1442:65: error[unresolved-attribute] Module `torch` has no member `imag` torch/autograd/gradcheck.py:1675:21: error[unresolved-attribute] Module `torch` has no member `promote_types` @@ -14846,33 +15263,34 @@ torch/autograd/gradcheck.py:1802:21: error[unresolved-attribute] Module `torch` torch/autograd/gradcheck.py:1826:13: error[unresolved-attribute] Module `torch` has no member `Generator` torch/autograd/gradcheck.py:1831:14: error[unresolved-attribute] Module `torch` has no member `device` torch/autograd/gradcheck.py:2248:22: error[unresolved-attribute] Module `torch` has no member `double` -torch/autograd/graph.py:175:41: error[unresolved-attribute] Module `torch._C` has no member `_functions` +torch/autograd/graph.py:175:41: warning[possibly-missing-attribute] Submodule `_functions` may not be available as an attribute on module `torch._C` torch/autograd/graph.py:228:28: error[unresolved-attribute] Module `torch._C` has no member `_FunctionBase` torch/autograd/graph.py:256:5: error[unresolved-attribute] Module `torch._C` has no member `_increment_version` -torch/autograd/graph.py:335:9: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/autograd/graph.py:340:9: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/autograd/graph.py:335:9: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/autograd/graph.py:340:9: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/autograd/graph.py:387:56: error[unresolved-attribute] Module `torch` has no member `device` torch/autograd/graph.py:390:22: error[unresolved-attribute] Module `torch` has no member `empty` torch/autograd/graph.py:399:43: error[unresolved-attribute] Module `torch` has no member `device` -torch/autograd/graph.py:430:13: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/autograd/graph.py:432:9: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/autograd/graph.py:437:13: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/autograd/graph.py:439:13: error[unresolved-attribute] Module `torch._C` has no member `_autograd` +torch/autograd/graph.py:430:13: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/autograd/graph.py:432:9: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/autograd/graph.py:437:13: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/autograd/graph.py:439:13: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` torch/autograd/graph.py:446:12: error[unresolved-attribute] Module `torch._C` has no member `_set_warn_on_accumulate_grad_stream_mismatch` torch/autograd/graph.py:539:22: error[unresolved-attribute] Module `torch._C` has no member `_current_graph_task_id` torch/autograd/graph.py:554:33: error[unresolved-attribute] Module `torch._C` has no member `_will_engine_execute_node` torch/autograd/graph.py:579:18: error[unresolved-attribute] Module `torch._C` has no member `_current_graph_task_id` -torch/autograd/graph.py:625:13: error[unresolved-attribute] Module `torch._subclasses` has no member `functional_tensor` -torch/autograd/graph.py:640:13: error[unresolved-attribute] Module `torch._subclasses` has no member `functional_tensor` +torch/autograd/graph.py:625:13: warning[possibly-missing-attribute] Submodule `functional_tensor` may not be available as an attribute on module `torch._subclasses` +torch/autograd/graph.py:640:13: warning[possibly-missing-attribute] Submodule `functional_tensor` may not be available as an attribute on module `torch._subclasses` torch/autograd/graph.py:842:16: error[unresolved-attribute] Module `torch._C` has no member `_current_autograd_node` torch/autograd/profiler.py:12:22: error[unresolved-import] Module `torch._C` has no member `_get_privateuse1_backend_name` torch/autograd/profiler.py:748:23: warning[unsupported-base] Unsupported class base with type ` | ` torch/autograd/profiler.py:818:18: error[unresolved-attribute] Module `torch._C` has no member `DisableTorchFunctionSubclass` torch/autograd/profiler.py:856:18: error[unresolved-attribute] Module `torch._C` has no member `DisableTorchFunctionSubclass` torch/autograd/profiler.py:1094:28: error[unresolved-attribute] Module `torch._C` has no member `_demangle` -torch/autograd/profiler_legacy.py:81:13: error[unresolved-attribute] Module `torch._C` has no member `_profiler` +torch/autograd/profiler_legacy.py:81:13: warning[possibly-missing-attribute] Submodule `_profiler` may not be available as an attribute on module `torch._C` torch/autograd/profiler_util.py:975:21: error[unresolved-attribute] Module `torch._C` has no member `_demangle` torch/autograd/variable.py:3:22: error[unresolved-import] Module `torch._C` has no member `_ImperativeEngine` +torch/backends/__init__.py:59:9: error[invalid-method-override] Invalid override of method `__getattr__`: Definition is incompatible with `ModuleType.__getattr__` torch/backends/__init__.py:70:13: error[unresolved-attribute] Module `torch._C` has no member `_set_fp32_precision_setter` torch/backends/__init__.py:78:20: error[unresolved-attribute] Module `torch._C` has no member `_get_fp32_precision_getter` torch/backends/__init__.py:84:19: error[unresolved-attribute] Module `torch._C` has no member `_get_fp32_precision_getter` @@ -15007,12 +15425,12 @@ torch/backends/miopen/__init__.py:14:9: error[unresolved-attribute] Module `torc torch/backends/miopen/__init__.py:44:9: error[unresolved-attribute] Module `torch._C` has no member `_get_miopen_immediate` torch/backends/miopen/__init__.py:44:41: error[unresolved-attribute] Module `torch._C` has no member `_set_miopen_immediate` torch/backends/mkl/__init__.py:7:12: error[unresolved-attribute] Module `torch._C` has no member `has_mkl` -torch/backends/mkl/__init__.py:50:14: error[unresolved-attribute] Module `torch._C` has no member `_verbose` -torch/backends/mkl/__init__.py:57:9: error[unresolved-attribute] Module `torch._C` has no member `_verbose` +torch/backends/mkl/__init__.py:50:14: warning[possibly-missing-attribute] Submodule `_verbose` may not be available as an attribute on module `torch._C` +torch/backends/mkl/__init__.py:57:9: warning[possibly-missing-attribute] Submodule `_verbose` may not be available as an attribute on module `torch._C` torch/backends/mkldnn/__init__.py:19:12: error[unresolved-attribute] Module `torch._C` has no member `_has_mkldnn` torch/backends/mkldnn/__init__.py:25:12: error[unresolved-attribute] Module `torch._C` has no member `_has_mkldnn_acl` -torch/backends/mkldnn/__init__.py:70:14: error[unresolved-attribute] Module `torch._C` has no member `_verbose` -torch/backends/mkldnn/__init__.py:77:9: error[unresolved-attribute] Module `torch._C` has no member `_verbose` +torch/backends/mkldnn/__init__.py:70:14: warning[possibly-missing-attribute] Submodule `_verbose` may not be available as an attribute on module `torch._C` +torch/backends/mkldnn/__init__.py:77:9: warning[possibly-missing-attribute] Submodule `_verbose` may not be available as an attribute on module `torch._C` torch/backends/mkldnn/__init__.py:85:9: error[unresolved-attribute] Module `torch._C` has no member `_get_mkldnn_enabled` torch/backends/mkldnn/__init__.py:86:9: error[unresolved-attribute] Module `torch._C` has no member `_get_mkldnn_deterministic` torch/backends/mkldnn/__init__.py:87:9: error[unresolved-attribute] Module `torch._C` has no member `_get_onednn_allow_tf32` @@ -15041,33 +15459,35 @@ torch/backends/opt_einsum/__init__.py:74:12: error[invalid-return-type] Return t torch/backends/quantized/__init__.py:34:33: error[unresolved-attribute] Module `torch._C` has no member `_get_qengine` torch/backends/quantized/__init__.py:37:9: error[unresolved-attribute] Module `torch._C` has no member `_set_qengine` torch/backends/quantized/__init__.py:42:20: error[unresolved-attribute] Module `torch._C` has no member `_supported_qengines` +torch/backends/quantized/__init__.py:54:9: error[invalid-method-override] Invalid override of method `__getattr__`: Definition is incompatible with `ModuleType.__getattr__` torch/backends/xeon/run_cpu.py:839:5: warning[possibly-missing-attribute] Attribute `add_argument` may be missing on object of type `Unknown | None` torch/backends/xeon/run_cpu.py:848:5: warning[possibly-missing-attribute] Attribute `add_argument` may be missing on object of type `Unknown | None` torch/backends/xeon/run_cpu.py:859:5: warning[possibly-missing-attribute] Attribute `add_argument` may be missing on object of type `Unknown | None` torch/backends/xeon/run_cpu.py:874:5: warning[possibly-missing-attribute] Attribute `add_argument` may be missing on object of type `Unknown | None` torch/backends/xeon/run_cpu.py:883:5: warning[possibly-missing-attribute] Attribute `add_argument` may be missing on object of type `Unknown | None` torch/backends/xnnpack/__init__.py:10:16: error[unresolved-attribute] Module `torch._C` has no member `_is_xnnpack_enabled` +torch/backends/xnnpack/__init__.py:21:9: error[invalid-method-override] Invalid override of method `__getattr__`: Definition is incompatible with `ModuleType.__getattr__` torch/contrib/_tensorboard_vis.py:13:10: error[unresolved-import] Cannot resolve imported module `tensorflow.core.framework` torch/contrib/_tensorboard_vis.py:14:10: error[unresolved-import] Cannot resolve imported module `tensorflow.core.util` torch/contrib/_tensorboard_vis.py:15:10: error[unresolved-import] Cannot resolve imported module `tensorflow.python.summary.writer.writer` torch/contrib/_tensorboard_vis.py:37:26: error[unresolved-attribute] Module `torch._C` has no member `GraphExecutorState` torch/cpu/__init__.py:12:16: error[unresolved-import] Module `torch` has no member `device` -torch/cpu/__init__.py:33:12: error[unresolved-attribute] Module `torch._C` has no member `_cpu` -torch/cpu/__init__.py:38:12: error[unresolved-attribute] Module `torch._C` has no member `_cpu` -torch/cpu/__init__.py:43:12: error[unresolved-attribute] Module `torch._C` has no member `_cpu` -torch/cpu/__init__.py:49:12: error[unresolved-attribute] Module `torch._C` has no member `_cpu` -torch/cpu/__init__.py:54:12: error[unresolved-attribute] Module `torch._C` has no member `_cpu` -torch/cpu/__init__.py:59:12: error[unresolved-attribute] Module `torch._C` has no member `_cpu` -torch/cpu/__init__.py:64:12: error[unresolved-attribute] Module `torch._C` has no member `_cpu` +torch/cpu/__init__.py:33:12: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` +torch/cpu/__init__.py:38:12: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` +torch/cpu/__init__.py:43:12: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` +torch/cpu/__init__.py:49:12: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` +torch/cpu/__init__.py:54:12: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` +torch/cpu/__init__.py:59:12: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` +torch/cpu/__init__.py:64:12: warning[possibly-missing-attribute] Submodule `_cpu` may not be available as an attribute on module `torch._C` torch/cpu/amp/__init__.py:2:28: warning[deprecated] The class `autocast` is deprecated: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead. torch/cpu/amp/autocast_mode.py:34:20: error[unresolved-attribute] Module `torch` has no member `dtype` torch/cpu/amp/autocast_mode.py:34:34: error[unresolved-attribute] Module `torch` has no member `bfloat16` torch/cpu/amp/autocast_mode.py:45:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/cpu/amp/autocast_mode.py:45:30: error[unresolved-attribute] Module `torch` has no member `bfloat16` -torch/cpu/amp/autocast_mode.py:48:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` -torch/cpu/amp/autocast_mode.py:58:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` -torch/cpu/amp/autocast_mode.py:64:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` -torch/cpu/amp/autocast_mode.py:69:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` +torch/cpu/amp/autocast_mode.py:48:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` +torch/cpu/amp/autocast_mode.py:58:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` +torch/cpu/amp/autocast_mode.py:64:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` +torch/cpu/amp/autocast_mode.py:69:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` torch/cuda/__init__.py:26:19: error[unresolved-import] Module `torch` has no member `device` torch/cuda/__init__.py:151:19: error[unresolved-attribute] Module `torch._C` has no member `_has_magma` torch/cuda/__init__.py:184:16: error[unresolved-attribute] Module `torch._C` has no member `_cuda_getDeviceCount` @@ -15118,7 +15538,7 @@ torch/cuda/__init__.py:1669:16: error[unresolved-attribute] Module `torch` has n torch/cuda/__init__.py:1680:16: error[unresolved-attribute] Module `torch` has no member `cdouble` torch/cuda/__init__.py:1691:16: error[unresolved-attribute] Module `torch` has no member `cfloat` torch/cuda/__init__.py:1730:16: error[call-non-callable] Object of type `None` is not callable -torch/cuda/__init__.py:1738:18: error[unresolved-attribute] Module `importlib` has no member `util` +torch/cuda/__init__.py:1738:18: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` torch/cuda/_device_limits.py:2:22: error[unresolved-import] Module `torch._C` has no member `dtype` torch/cuda/_device_limits.py:15:39: error[unresolved-attribute] Module `torch` has no member `device` torch/cuda/_device_limits.py:47:25: error[unresolved-attribute] Module `torch` has no member `float16` @@ -15129,8 +15549,8 @@ torch/cuda/_device_limits.py:87:27: error[unresolved-attribute] Module `torch` h torch/cuda/_device_limits.py:90:27: error[unresolved-attribute] Module `torch` has no member `float32` torch/cuda/_device_limits.py:92:27: error[unresolved-attribute] Module `torch` has no member `int8` torch/cuda/_device_limits.py:94:27: error[unresolved-attribute] Module `torch` has no member `float64` -torch/cuda/_gpu_trace.py:12:24: error[too-many-positional-arguments] Too many positional arguments to class `CallbackRegistry`: expected 1, got 2 -torch/cuda/_gpu_trace.py:15:22: error[too-many-positional-arguments] Too many positional arguments to class `CallbackRegistry`: expected 1, got 2 +torch/cuda/_gpu_trace.py:12:46: error[invalid-type-arguments] Too many type arguments to class `CallbackRegistry`: expected 1, got 2 +torch/cuda/_gpu_trace.py:15:44: error[invalid-type-arguments] Too many type arguments to class `CallbackRegistry`: expected 1, got 2 torch/cuda/_sanitizer.py:473:13: error[unresolved-attribute] Module `torch` has no member `FunctionSchema` torch/cuda/_sanitizer.py:474:21: error[unresolved-attribute] Module `torch` has no member `Argument` torch/cuda/_sanitizer.py:514:17: error[unresolved-attribute] Module `torch` has no member `FunctionSchema` @@ -15146,10 +15566,10 @@ torch/cuda/amp/autocast_mode.py:35:20: error[unresolved-attribute] Module `torch torch/cuda/amp/autocast_mode.py:35:34: error[unresolved-attribute] Module `torch` has no member `float16` torch/cuda/amp/autocast_mode.py:46:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/cuda/amp/autocast_mode.py:46:30: error[unresolved-attribute] Module `torch` has no member `float16` -torch/cuda/amp/autocast_mode.py:49:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` -torch/cuda/amp/autocast_mode.py:59:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` -torch/cuda/amp/autocast_mode.py:65:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` -torch/cuda/amp/autocast_mode.py:70:12: error[unresolved-attribute] Module `torch` has no member `_jit_internal` +torch/cuda/amp/autocast_mode.py:49:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` +torch/cuda/amp/autocast_mode.py:59:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` +torch/cuda/amp/autocast_mode.py:65:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` +torch/cuda/amp/autocast_mode.py:70:12: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` torch/cuda/gds.py:52:5: error[unresolved-attribute] Module `torch._C` has no member `_gds_register_buffer` torch/cuda/gds.py:69:5: error[unresolved-attribute] Module `torch._C` has no member `_gds_deregister_buffer` torch/cuda/gds.py:126:23: error[unresolved-attribute] Module `torch._C` has no member `_gds_register_handle` @@ -15164,14 +15584,14 @@ torch/cuda/graphs.py:261:13: error[invalid-argument-type] Argument to bound meth torch/cuda/graphs.py:263:13: error[parameter-already-assigned] Multiple values provided for parameter `capture_error_mode` of bound method `capture_begin` torch/cuda/graphs.py:368:8: error[unresolved-attribute] Module `torch` has no member `is_autocast_enabled` torch/cuda/graphs.py:368:40: error[unresolved-attribute] Module `torch` has no member `is_autocast_cache_enabled` -torch/cuda/graphs.py:400:23: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` -torch/cuda/graphs.py:434:27: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` +torch/cuda/graphs.py:400:23: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` +torch/cuda/graphs.py:434:27: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` torch/cuda/graphs.py:443:29: error[unresolved-attribute] Module `torch` has no member `empty_like` -torch/cuda/graphs.py:464:33: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` +torch/cuda/graphs.py:464:33: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` torch/cuda/graphs.py:479:13: error[unresolved-attribute] Module `torch` has no member `empty_like` -torch/cuda/graphs.py:520:32: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` -torch/cuda/graphs.py:563:33: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` -torch/cuda/graphs.py:565:20: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` +torch/cuda/graphs.py:520:32: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` +torch/cuda/graphs.py:563:33: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` +torch/cuda/graphs.py:565:20: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` torch/cuda/jiterator.py:88:16: error[unresolved-attribute] Module `torch._C` has no member `_cuda_jiterator_compile_and_launch_kernel` torch/cuda/memory.py:143:5: error[unresolved-import] Module `torch._C` has no member `_cuda_beginAllocateCurrentThreadToPool` torch/cuda/memory.py:144:5: error[unresolved-import] Module `torch._C` has no member `_cuda_beginAllocateToPool` @@ -15209,9 +15629,7 @@ torch/cuda/nccl.py:46:11: error[unresolved-attribute] Module `torch._C` has no m torch/cuda/nccl.py:50:14: error[unresolved-attribute] Module `torch._C` has no member `_nccl_version_suffix` torch/cuda/nccl.py:58:12: error[unresolved-attribute] Module `torch._C` has no member `_nccl_unique_id` torch/cuda/nccl.py:62:12: error[unresolved-attribute] Module `torch._C` has no member `_nccl_init_rank` -torch/cuda/nccl.py:66:31: error[unresolved-attribute] Module `collections` has no member `abc` torch/cuda/nccl.py:77:5: error[unresolved-attribute] Module `torch._C` has no member `_nccl_all_reduce` -torch/cuda/nccl.py:110:17: error[unresolved-attribute] Module `collections` has no member `abc` torch/cuda/nccl.py:122:5: error[unresolved-attribute] Module `torch._C` has no member `_nccl_reduce` torch/cuda/nccl.py:129:5: error[unresolved-attribute] Module `torch._C` has no member `_nccl_broadcast` torch/cuda/nccl.py:140:5: error[unresolved-attribute] Module `torch._C` has no member `_nccl_all_gather` @@ -15331,7 +15749,7 @@ torch/distributed/_dist2.py:130:24: error[unresolved-attribute] Module `torch` h torch/distributed/_dist2.py:151:14: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/_functional_collectives.py:10:43: warning[possibly-missing-import] Member `DeviceMesh` of module `torch.distributed.device_mesh` may be missing torch/distributed/_functional_collectives.py:94:5: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` -torch/distributed/_functional_collectives.py:96:12: error[unresolved-attribute] Module `torch.distributed` has no member `tensor` +torch/distributed/_functional_collectives.py:96:12: warning[possibly-missing-attribute] Submodule `tensor` may not be available as an attribute on module `torch.distributed` torch/distributed/_functional_collectives.py:211:15: error[unresolved-attribute] Module `torch` has no member `cat` torch/distributed/_functional_collectives.py:211:25: error[unresolved-attribute] Module `torch` has no member `chunk` torch/distributed/_functional_collectives.py:244:15: error[unresolved-attribute] Module `torch` has no member `cat` @@ -15357,9 +15775,9 @@ torch/distributed/_functional_collectives.py:845:8: error[unresolved-attribute] torch/distributed/_functional_collectives.py:845:36: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` torch/distributed/_functional_collectives.py:848:8: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_tls_is_dispatch_key_included` torch/distributed/_functional_collectives.py:849:9: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` -torch/distributed/_functional_collectives.py:890:16: error[unresolved-attribute] Module `torch._C` has no member `_distributed_c10d` -torch/distributed/_functional_collectives.py:893:9: error[unresolved-attribute] Module `torch._C` has no member `_distributed_c10d` -torch/distributed/_functional_collectives.py:896:9: error[unresolved-attribute] Module `torch._C` has no member `_distributed_c10d` +torch/distributed/_functional_collectives.py:890:16: warning[possibly-missing-attribute] Submodule `_distributed_c10d` may not be available as an attribute on module `torch._C` +torch/distributed/_functional_collectives.py:893:9: warning[possibly-missing-attribute] Submodule `_distributed_c10d` may not be available as an attribute on module `torch._C` +torch/distributed/_functional_collectives.py:896:9: warning[possibly-missing-attribute] Submodule `_distributed_c10d` may not be available as an attribute on module `torch._C` torch/distributed/_functional_collectives.py:917:12: error[unresolved-attribute] Module `torch` has no member `empty_like` torch/distributed/_functional_collectives.py:921:12: error[unresolved-attribute] Module `torch` has no member `empty_like` torch/distributed/_functional_collectives.py:925:12: error[unresolved-attribute] Module `torch` has no member `empty_like` @@ -15456,7 +15874,7 @@ torch/distributed/_shard/api.py:53:18: warning[possibly-missing-attribute] Membe torch/distributed/_shard/api.py:54:20: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/distributed/_shard/api.py:58:5: warning[possibly-missing-attribute] Member `all_gather_object` may be missing on module `torch.distributed` torch/distributed/_shard/api.py:132:34: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` -torch/distributed/_shard/checkpoint/__init__.py:19:54: error[unresolved-attribute] Module `torch.distributed` has no member `checkpoint` +torch/distributed/_shard/checkpoint/__init__.py:19:54: warning[possibly-missing-attribute] Submodule `checkpoint` may not be available as an attribute on module `torch.distributed` torch/distributed/_shard/common_op_utils.py:64:14: error[unresolved-attribute] Module `torch._C` has no member `DisableTorchFunctionSubclass` torch/distributed/_shard/sharded_tensor/__init__.py:30:12: error[unresolved-attribute] Module `torch` has no member `strided` torch/distributed/_shard/sharded_tensor/__init__.py:33:19: error[unresolved-attribute] Module `torch` has no member `contiguous_format` @@ -15692,7 +16110,7 @@ torch/distributed/_shard/sharding_spec/chunk_sharding_spec_ops/embedding_bag.py: torch/distributed/_shard/sharding_spec/chunk_sharding_spec_ops/embedding_bag.py:426:27: error[unresolved-attribute] Module `torch` has no member `cat` torch/distributed/_shard/sharding_spec/chunk_sharding_spec_ops/embedding_bag.py:435:16: error[unresolved-attribute] Module `torch` has no member `div` torch/distributed/_shard/sharding_spec/chunk_sharding_spec_ops/embedding_bag.py:467:34: error[unresolved-attribute] Module `torch` has no member `stack` -torch/distributed/_sharded_tensor/__init__.py:20:5: error[unresolved-attribute] Module `torch.distributed` has no member `_shard` +torch/distributed/_sharded_tensor/__init__.py:20:5: warning[possibly-missing-attribute] Submodule `_shard` may not be available as an attribute on module `torch.distributed` torch/distributed/_state_dict_utils.py:17:35: warning[possibly-missing-import] Member `distributed_c10d` of module `torch.distributed` may be missing torch/distributed/_state_dict_utils.py:25:18: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` torch/distributed/_state_dict_utils.py:26:22: error[unresolved-attribute] Module `torch` has no member `device` @@ -15797,12 +16215,12 @@ torch/distributed/_symmetric_memory/__init__.py:1601:13: error[unresolved-attrib torch/distributed/_symmetric_memory/__init__.py:1602:13: error[unresolved-attribute] Module `torch` has no member `float8_e5m2fnuz` torch/distributed/_symmetric_memory/__init__.py:1603:13: error[unresolved-attribute] Module `torch` has no member `float8_e4m3fnuz` torch/distributed/_symmetric_memory/__init__.py:1608:18: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/distributed/_symmetric_memory/__init__.py:1712:9: error[unresolved-attribute] Module `torch._C` has no member `_distributed_c10d` +torch/distributed/_symmetric_memory/__init__.py:1712:9: warning[possibly-missing-attribute] Submodule `_distributed_c10d` may not be available as an attribute on module `torch._C` torch/distributed/_symmetric_memory/__init__.py:1735:15: error[unresolved-attribute] Module `torch` has no member `empty_like` -torch/distributed/_symmetric_memory/__init__.py:1760:9: error[unresolved-attribute] Module `torch._C` has no member `_distributed_c10d` -torch/distributed/_symmetric_memory/__init__.py:1795:9: error[unresolved-attribute] Module `torch._C` has no member `_distributed_c10d` +torch/distributed/_symmetric_memory/__init__.py:1760:9: warning[possibly-missing-attribute] Submodule `_distributed_c10d` may not be available as an attribute on module `torch._C` +torch/distributed/_symmetric_memory/__init__.py:1795:9: warning[possibly-missing-attribute] Submodule `_distributed_c10d` may not be available as an attribute on module `torch._C` torch/distributed/_symmetric_memory/__init__.py:1921:17: error[unresolved-attribute] Module `torch` has no member `get_default_dtype` -torch/distributed/_symmetric_memory/__init__.py:1928:16: error[unresolved-attribute] Module `torch` has no member `_prims_common` +torch/distributed/_symmetric_memory/__init__.py:1928:16: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` torch/distributed/_symmetric_memory/__init__.py:1930:16: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/_symmetric_memory/__init__.py:2001:41: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/_symmetric_memory/__init__.py:2012:51: error[unresolved-attribute] Module `torch` has no member `device` @@ -15864,6 +16282,7 @@ torch/distributed/algorithms/_comm_hooks/default_hooks.py:129:5: warning[possibl torch/distributed/algorithms/_comm_hooks/default_hooks.py:136:11: error[unresolved-attribute] Module `torch` has no member `dtype` torch/distributed/algorithms/_comm_hooks/default_hooks.py:170:56: error[unresolved-attribute] Module `torch` has no member `float16` torch/distributed/algorithms/_comm_hooks/default_hooks.py:191:56: error[unresolved-attribute] Module `torch` has no member `bfloat16` +torch/distributed/algorithms/_optimizer_overlap/optimizer_overlap.py:68:9: error[invalid-method-override] Invalid override of method `register_ddp`: Definition is incompatible with `OverlappedOptimizer.register_ddp` torch/distributed/algorithms/_quantization/quantization.py:9:18: error[unresolved-attribute] Module `torch` has no member `finfo` torch/distributed/algorithms/_quantization/quantization.py:9:30: error[unresolved-attribute] Module `torch` has no member `float16` torch/distributed/algorithms/_quantization/quantization.py:10:18: error[unresolved-attribute] Module `torch` has no member `finfo` @@ -15899,7 +16318,7 @@ torch/distributed/algorithms/ddp_comm_hooks/default_hooks.py:36:47: warning[poss torch/distributed/algorithms/ddp_comm_hooks/default_hooks.py:58:12: error[unresolved-attribute] Module `torch` has no member `dtype` torch/distributed/algorithms/ddp_comm_hooks/default_hooks.py:59:20: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` torch/distributed/algorithms/ddp_comm_hooks/default_hooks.py:60:13: warning[possibly-missing-attribute] Member `GradBucket` may be missing on module `torch.distributed` -torch/distributed/algorithms/ddp_comm_hooks/default_hooks.py:82:16: error[unresolved-attribute] Module `torch.distributed` has no member `_functional_collectives` +torch/distributed/algorithms/ddp_comm_hooks/default_hooks.py:82:16: warning[possibly-missing-attribute] Submodule `_functional_collectives` may not be available as an attribute on module `torch.distributed` torch/distributed/algorithms/ddp_comm_hooks/default_hooks.py:90:15: warning[possibly-missing-attribute] Member `all_reduce` may be missing on module `torch.distributed` torch/distributed/algorithms/ddp_comm_hooks/default_hooks.py:97:20: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` torch/distributed/algorithms/ddp_comm_hooks/default_hooks.py:98:13: warning[possibly-missing-attribute] Member `GradBucket` may be missing on module `torch.distributed` @@ -16026,7 +16445,7 @@ torch/distributed/c10d_logger.py:60:30: warning[possibly-missing-attribute] Memb torch/distributed/c10d_logger.py:61:30: warning[possibly-missing-attribute] Member `get_world_size` may be missing on module `torch.distributed` torch/distributed/c10d_logger.py:62:31: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/distributed/c10d_logger.py:63:30: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` -torch/distributed/c10d_logger.py:66:28: error[unresolved-attribute] Module `torch.cuda` has no member `nccl` +torch/distributed/c10d_logger.py:66:28: warning[possibly-missing-attribute] Submodule `nccl` may not be available as an attribute on module `torch.cuda` torch/distributed/c10d_logger.py:85:38: error[unresolved-attribute] Object of type `(...) -> _T@_exception_logger` has no attribute `__name__` torch/distributed/c10d_logger.py:96:56: error[unresolved-attribute] Object of type `(...) -> _T@_time_logger` has no attribute `__name__` torch/distributed/checkpoint/__init__.py:17:38: warning[deprecated] The function `load_state_dict` is deprecated: `load_state_dict` is deprecated and will be removed in future versions. Please use `load` instead. @@ -16112,6 +16531,7 @@ torch/distributed/checkpoint/_pg_transport.py:323:49: error[unresolved-attribute torch/distributed/checkpoint/_pg_transport.py:335:20: error[unresolved-attribute] Module `torch` has no member `as_strided` torch/distributed/checkpoint/_sharded_tensor_utils.py:64:39: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/distributed/checkpoint/_sharded_tensor_utils.py:70:27: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` +torch/distributed/checkpoint/default_planner.py:359:9: error[invalid-method-override] Invalid override of method `finish_plan`: Definition is incompatible with `LoadPlanner.finish_plan` torch/distributed/checkpoint/default_planner.py:618:21: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributed/checkpoint/examples/async_checkpointing_example.py:64:40: error[invalid-argument-type] Argument to function `_patch_optimizer_state_dict` is incorrect: Expected `tuple[Optimizer, ...]`, found `Adam` torch/distributed/checkpoint/examples/async_checkpointing_example.py:70:8: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` @@ -16141,8 +16561,10 @@ torch/distributed/checkpoint/format_utils.py:108:26: error[non-subscriptable] Ca torch/distributed/checkpoint/format_utils.py:108:26: warning[possibly-missing-attribute] Attribute `to` may be missing on object of type `Any | typing.TypeVar` torch/distributed/checkpoint/format_utils.py:110:26: error[unresolved-attribute] Module `torch` has no member `empty_like` torch/distributed/checkpoint/format_utils.py:112:13: warning[possibly-missing-attribute] Member `broadcast` may be missing on module `torch.distributed` +torch/distributed/checkpoint/format_utils.py:129:9: error[invalid-method-override] Invalid override of method `set_up_storage_reader`: Definition is incompatible with `StorageReader.set_up_storage_reader` torch/distributed/checkpoint/format_utils.py:133:20: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/distributed/checkpoint/format_utils.py:136:28: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` +torch/distributed/checkpoint/format_utils.py:148:9: error[invalid-method-override] Invalid override of method `prepare_global_plan`: Definition is incompatible with `StorageReader.prepare_global_plan` torch/distributed/checkpoint/hf_storage.py:348:34: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributed/checkpoint/hf_storage.py:353:45: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributed/checkpoint/hf_storage.py:354:43: error[unresolved-attribute] Module `torch` has no member `Size` @@ -16298,7 +16720,7 @@ torch/distributed/collective_utils.py:312:5: warning[possibly-missing-attribute] torch/distributed/collective_utils.py:318:21: error[unresolved-attribute] Module `torch` has no member `hash_tensor` torch/distributed/collective_utils.py:323:16: error[unresolved-attribute] Module `torch` has no member `Generator` torch/distributed/collective_utils.py:323:40: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` -torch/distributed/collective_utils.py:340:8: error[unresolved-attribute] Module `importlib` has no member `util` +torch/distributed/collective_utils.py:340:8: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` torch/distributed/collective_utils.py:349:16: error[unresolved-attribute] Module `torch` has no member `Generator` torch/distributed/collective_utils.py:349:40: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` torch/distributed/debug/_store.py:14:26: warning[possibly-missing-attribute] Member `Store` may be missing on module `torch.distributed` @@ -16320,7 +16742,7 @@ torch/distributed/device_mesh.py:1363:59: error[unresolved-attribute] Module `to torch/distributed/distributed_c10d.py:24:22: error[unresolved-import] Module `torch._C` has no member `_DistStoreError` torch/distributed/distributed_c10d.py:379:19: error[invalid-assignment] Object of type `str` is not assignable to `Backend` torch/distributed/distributed_c10d.py:384:27: error[unresolved-attribute] Module `torch._C` has no member `_get_accelerator` -torch/distributed/distributed_c10d.py:419:35: error[invalid-assignment] Object of type `list[str]` is not assignable to `Backend` +torch/distributed/distributed_c10d.py:419:35: error[invalid-assignment] Object of type `str` is not assignable to `Backend` torch/distributed/distributed_c10d.py:539:19: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | ((...) -> Unknown)` torch/distributed/distributed_c10d.py:836:10: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/distributed_c10d.py:846:69: error[unresolved-attribute] Module `torch` has no member `device` @@ -16329,7 +16751,7 @@ torch/distributed/distributed_c10d.py:914:18: error[unresolved-attribute] Module torch/distributed/distributed_c10d.py:1203:17: error[unresolved-attribute] Module `torch` has no member `float32` torch/distributed/distributed_c10d.py:1203:50: error[unresolved-attribute] Module `torch` has no member `complex64` torch/distributed/distributed_c10d.py:1203:71: error[unresolved-attribute] Module `torch` has no member `complex128` -torch/distributed/distributed_c10d.py:1361:5: error[unresolved-attribute] Module `torch._C` has no member `_distributed_c10d` +torch/distributed/distributed_c10d.py:1361:5: warning[possibly-missing-attribute] Submodule `_distributed_c10d` may not be available as an attribute on module `torch._C` torch/distributed/distributed_c10d.py:1410:55: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/distributed_c10d.py:1421:27: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/distributed_c10d.py:1424:22: error[unresolved-attribute] Module `torch` has no member `device` @@ -16341,10 +16763,10 @@ torch/distributed/distributed_c10d.py:1558:38: error[unresolved-attribute] Modul torch/distributed/distributed_c10d.py:1561:8: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/distributed_c10d.py:1562:38: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/distributed_c10d.py:1586:31: error[unresolved-attribute] Module `torch` has no member `device` -torch/distributed/distributed_c10d.py:1696:9: error[unresolved-attribute] Module `torch._dynamo` has no member `trace_rules` +torch/distributed/distributed_c10d.py:1696:9: warning[possibly-missing-attribute] Submodule `trace_rules` may not be available as an attribute on module `torch._dynamo` torch/distributed/distributed_c10d.py:1720:21: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/distributed_c10d.py:1880:42: error[unresolved-attribute] Module `torch` has no member `device` -torch/distributed/distributed_c10d.py:2009:20: error[unresolved-attribute] Module `torch._C` has no member `_distributed_c10d` +torch/distributed/distributed_c10d.py:2009:20: warning[possibly-missing-attribute] Submodule `_distributed_c10d` may not be available as an attribute on module `torch._C` torch/distributed/distributed_c10d.py:2045:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `timedelta`, found `Unknown | None` torch/distributed/distributed_c10d.py:2069:13: error[invalid-assignment] Invalid assignment to data descriptor attribute `_timeout` on type `Options` with custom `__set__` method torch/distributed/distributed_c10d.py:2092:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `timedelta`, found `Unknown | None` @@ -16368,9 +16790,9 @@ torch/distributed/distributed_c10d.py:3067:45: error[unresolved-attribute] Modul torch/distributed/distributed_c10d.py:3070:5: error[invalid-assignment] Object of type `Unknown | RedOpType` is not assignable to attribute `reduceOp` of type `ReduceOp` torch/distributed/distributed_c10d.py:3124:5: error[invalid-assignment] Object of type `Unknown | RedOpType` is not assignable to attribute `reduceOp` of type `ReduceOp` torch/distributed/distributed_c10d.py:3145:23: error[unresolved-attribute] Module `torch` has no member `ByteTensor` -torch/distributed/distributed_c10d.py:3149:24: error[unresolved-attribute] Module `torch._C` has no member `_distributed_c10d` +torch/distributed/distributed_c10d.py:3149:24: warning[possibly-missing-attribute] Submodule `_distributed_c10d` may not be available as an attribute on module `torch._C` torch/distributed/distributed_c10d.py:3155:22: error[unresolved-attribute] Module `torch` has no member `LongTensor` -torch/distributed/distributed_c10d.py:3164:24: error[unresolved-attribute] Module `torch._C` has no member `_distributed_c10d` +torch/distributed/distributed_c10d.py:3164:24: warning[possibly-missing-attribute] Submodule `_distributed_c10d` may not be available as an attribute on module `torch._C` torch/distributed/distributed_c10d.py:3241:27: error[unresolved-attribute] Module `torch` has no member `zeros` torch/distributed/distributed_c10d.py:3242:27: error[unresolved-attribute] Module `torch` has no member `long` torch/distributed/distributed_c10d.py:3252:31: error[unresolved-attribute] Module `torch` has no member `empty` @@ -16420,7 +16842,7 @@ torch/distributed/distributed_c10d.py:4881:38: error[unresolved-attribute] Modul torch/distributed/distributed_c10d.py:4933:14: error[unresolved-attribute] Module `torch._C` has no member `_get_accelerator` torch/distributed/distributed_c10d.py:4938:23: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/distributed_c10d.py:4944:23: error[unresolved-attribute] Module `torch` has no member `device` -torch/distributed/distributed_c10d.py:5050:17: error[unresolved-attribute] Module `torch._C` has no member `_distributed_c10d` +torch/distributed/distributed_c10d.py:5050:17: warning[possibly-missing-attribute] Submodule `_distributed_c10d` may not be available as an attribute on module `torch._C` torch/distributed/distributed_c10d.py:5084:13: error[invalid-assignment] Object of type `tuple[int, ...]` is not assignable to `list[int]` torch/distributed/distributed_c10d.py:5194:45: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/distributed_c10d.py:5260:49: error[unresolved-attribute] Module `torch` has no member `device` @@ -16437,7 +16859,6 @@ torch/distributed/elastic/metrics/api.py:175:17: warning[deprecated] The functio torch/distributed/elastic/metrics/api.py:175:32: error[invalid-argument-type] Argument to function `publish_metric` is incorrect: Expected `str`, found `Unknown | None` torch/distributed/elastic/metrics/api.py:178:17: warning[deprecated] The function `publish_metric` is deprecated: Deprecated, use `put_metric(metric_group)(metric_name, metric_value)` instead torch/distributed/elastic/metrics/api.py:180:21: error[invalid-argument-type] Argument to function `publish_metric` is incorrect: Expected `str`, found `Unknown | None` -torch/distributed/elastic/multiprocessing/errors/error_handler.py:163:24: error[unresolved-attribute] Module `json` has no member `decoder` torch/distributed/elastic/rendezvous/api.py:14:31: warning[possibly-missing-import] Member `Store` of module `torch.distributed` may be missing torch/distributed/elastic/rendezvous/c10d_rendezvous_backend.py:16:31: warning[possibly-missing-import] Member `FileStore` of module `torch.distributed` may be missing torch/distributed/elastic/rendezvous/c10d_rendezvous_backend.py:16:42: warning[possibly-missing-import] Member `Store` of module `torch.distributed` may be missing @@ -16453,6 +16874,8 @@ torch/distributed/elastic/rendezvous/etcd_rendezvous_backend.py:126:16: error[in torch/distributed/elastic/rendezvous/etcd_rendezvous_backend.py:130:24: warning[possibly-missing-attribute] Attribute `value` may be missing on object of type `Unknown | EtcdResult` torch/distributed/elastic/rendezvous/etcd_rendezvous_backend.py:140:23: warning[possibly-missing-attribute] Attribute `modifiedIndex` may be missing on object of type `Unknown | EtcdResult` torch/distributed/elastic/rendezvous/etcd_store.py:15:31: warning[possibly-missing-import] Member `Store` of module `torch.distributed` may be missing +torch/distributed/elastic/rendezvous/etcd_store.py:86:9: error[invalid-method-override] Invalid override of method `add`: Definition is incompatible with `Store.add` +torch/distributed/elastic/rendezvous/etcd_store.py:124:9: error[invalid-method-override] Invalid override of method `wait`: Definition is incompatible with `Store.wait` torch/distributed/elastic/rendezvous/static_tcp_rendezvous.py:14:31: warning[possibly-missing-import] Member `PrefixStore` of module `torch.distributed` may be missing torch/distributed/elastic/rendezvous/static_tcp_rendezvous.py:14:44: warning[possibly-missing-import] Member `Store` of module `torch.distributed` may be missing torch/distributed/elastic/rendezvous/static_tcp_rendezvous.py:14:51: warning[possibly-missing-import] Member `TCPStore` of module `torch.distributed` may be missing @@ -16491,7 +16914,7 @@ torch/distributed/fsdp/_common_utils.py:503:24: error[unresolved-attribute] Modu torch/distributed/fsdp/_common_utils.py:509:59: error[unresolved-attribute] Module `torch` has no member `float32` torch/distributed/fsdp/_common_utils.py:528:62: error[unresolved-attribute] Module `torch` has no member `Stream` torch/distributed/fsdp/_common_utils.py:534:9: error[unresolved-attribute] Module `torch._C` has no member `_get_privateuse1_backend_name` -torch/distributed/fsdp/_common_utils.py:538:8: error[unresolved-attribute] Module `torch.distributed` has no member `_functional_collectives` +torch/distributed/fsdp/_common_utils.py:538:8: warning[possibly-missing-attribute] Submodule `_functional_collectives` may not be available as an attribute on module `torch.distributed` torch/distributed/fsdp/_debug_utils.py:62:12: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/distributed/fsdp/_debug_utils.py:62:37: warning[possibly-missing-attribute] Member `get_debug_level` may be missing on module `torch.distributed` torch/distributed/fsdp/_debug_utils.py:62:63: warning[possibly-missing-attribute] Member `DebugLevel` may be missing on module `torch.distributed` @@ -16503,9 +16926,9 @@ torch/distributed/fsdp/_exec_order_utils.py:200:44: error[unresolved-attribute] torch/distributed/fsdp/_exec_order_utils.py:200:57: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/fsdp/_exec_order_utils.py:201:26: error[unresolved-attribute] Module `torch` has no member `int32` torch/distributed/fsdp/_exec_order_utils.py:206:13: warning[possibly-missing-attribute] Member `all_gather_into_tensor` may be missing on module `torch.distributed` -torch/distributed/fsdp/_exec_order_utils.py:219:20: error[unresolved-attribute] Module `torch.distributed` has no member `_functional_collectives` +torch/distributed/fsdp/_exec_order_utils.py:219:20: warning[possibly-missing-attribute] Submodule `_functional_collectives` may not be available as an attribute on module `torch.distributed` torch/distributed/fsdp/_exec_order_utils.py:239:13: warning[possibly-missing-attribute] Member `all_gather_into_tensor` may be missing on module `torch.distributed` -torch/distributed/fsdp/_exec_order_utils.py:245:20: error[unresolved-attribute] Module `torch.distributed` has no member `_functional_collectives` +torch/distributed/fsdp/_exec_order_utils.py:245:20: warning[possibly-missing-attribute] Submodule `_functional_collectives` may not be available as an attribute on module `torch.distributed` torch/distributed/fsdp/_flat_param.py:185:25: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributed/fsdp/_flat_param.py:202:1: error[conflicting-metaclass] The metaclass of a derived class (`FlatParameter`) must be a subclass of the metaclasses of all its bases, but `_FlatParameterMeta` (metaclass of `FlatParameter`) and `type` (metaclass of base class `Parameter`) have no subclass relationship torch/distributed/fsdp/_flat_param.py:329:31: error[unresolved-attribute] Module `torch` has no member `Size` @@ -16526,7 +16949,7 @@ torch/distributed/fsdp/_flat_param.py:891:17: error[unresolved-attribute] Module torch/distributed/fsdp/_flat_param.py:896:16: error[unresolved-attribute] Module `torch` has no member `cat` torch/distributed/fsdp/_flat_param.py:909:34: error[unresolved-attribute] Module `torch` has no member `dtype` torch/distributed/fsdp/_flat_param.py:910:35: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/distributed/fsdp/_flat_param.py:970:20: error[unresolved-attribute] Module `torch.distributed` has no member `_functional_collectives` +torch/distributed/fsdp/_flat_param.py:970:20: warning[possibly-missing-attribute] Submodule `_functional_collectives` may not be available as an attribute on module `torch.distributed` torch/distributed/fsdp/_flat_param.py:1107:13: error[unresolved-attribute] Module `torch` has no member `flatten` torch/distributed/fsdp/_flat_param.py:1145:74: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributed/fsdp/_flat_param.py:1162:16: error[unresolved-attribute] Module `torch` has no member `Size` @@ -16546,7 +16969,7 @@ torch/distributed/fsdp/_flat_param.py:2407:25: error[unresolved-attribute] Modul torch/distributed/fsdp/_flat_param.py:2427:33: warning[possibly-missing-attribute] Member `DebugLevel` may be missing on module `torch.distributed` torch/distributed/fsdp/_flat_param.py:2428:60: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/distributed/fsdp/_flat_param.py:2642:30: error[unresolved-attribute] Module `torch` has no member `device` -torch/distributed/fsdp/_flat_param.py:2649:16: error[unresolved-attribute] Module `torch.distributed` has no member `_functional_collectives` +torch/distributed/fsdp/_flat_param.py:2649:16: warning[possibly-missing-attribute] Submodule `_functional_collectives` may not be available as an attribute on module `torch.distributed` torch/distributed/fsdp/_flat_param.py:2778:41: error[unresolved-attribute] Module `torch` has no member `dtype` torch/distributed/fsdp/_flat_param.py:2788:12: error[unresolved-attribute] Module `torch` has no member `empty` torch/distributed/fsdp/_flat_param.py:2792:32: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -16707,7 +17130,7 @@ torch/distributed/fsdp/_fully_shard/_fsdp_param_group.py:713:16: error[unresolve torch/distributed/fsdp/_fully_shard/_fsdp_param_group.py:776:44: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` torch/distributed/fsdp/_fully_shard/_fsdp_param_group.py:789:48: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` torch/distributed/fsdp/_fully_shard/_fsdp_param_group.py:797:44: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` -torch/distributed/fsdp/_fully_shard/_fsdp_param_group.py:886:13: error[unresolved-attribute] Module `torch._dynamo` has no member `comptime` +torch/distributed/fsdp/_fully_shard/_fsdp_param_group.py:886:13: warning[possibly-missing-attribute] Submodule `comptime` may not be available as an attribute on module `torch._dynamo` torch/distributed/fsdp/_fully_shard/_fsdp_state.py:18:43: warning[possibly-missing-import] Member `_get_device_handle` of module `torch.distributed.device_mesh` may be missing torch/distributed/fsdp/_fully_shard/_fsdp_state.py:55:41: error[unresolved-attribute] Module `torch` has no member `Event` torch/distributed/fsdp/_fully_shard/_fsdp_state.py:92:17: error[unresolved-attribute] Module `torch` has no member `device` @@ -16792,14 +17215,14 @@ torch/distributed/fsdp/_optim_utils.py:1925:21: warning[possibly-missing-attribu torch/distributed/fsdp/_optim_utils.py:1982:33: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/distributed/fsdp/_runtime_utils.py:151:18: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/fsdp/_runtime_utils.py:1440:12: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` -torch/distributed/fsdp/_runtime_utils.py:1446:8: error[unresolved-attribute] Module `torch.distributed` has no member `_functional_collectives` +torch/distributed/fsdp/_runtime_utils.py:1446:8: warning[possibly-missing-attribute] Submodule `_functional_collectives` may not be available as an attribute on module `torch.distributed` torch/distributed/fsdp/_runtime_utils.py:1487:12: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` -torch/distributed/fsdp/_runtime_utils.py:1496:8: error[unresolved-attribute] Module `torch.distributed` has no member `_functional_collectives` -torch/distributed/fsdp/_runtime_utils.py:1513:8: error[unresolved-attribute] Module `torch.distributed` has no member `_functional_collectives` +torch/distributed/fsdp/_runtime_utils.py:1496:8: warning[possibly-missing-attribute] Submodule `_functional_collectives` may not be available as an attribute on module `torch.distributed` +torch/distributed/fsdp/_runtime_utils.py:1513:8: warning[possibly-missing-attribute] Submodule `_functional_collectives` may not be available as an attribute on module `torch.distributed` torch/distributed/fsdp/_runtime_utils.py:1544:25: error[unresolved-attribute] Module `torch` has no member `Stream` torch/distributed/fsdp/_runtime_utils.py:1545:21: error[unresolved-attribute] Module `torch` has no member `Stream` torch/distributed/fsdp/_runtime_utils.py:1546:25: error[unresolved-attribute] Module `torch` has no member `Stream` -torch/distributed/fsdp/_runtime_utils.py:1554:8: error[unresolved-attribute] Module `torch.distributed` has no member `_functional_collectives` +torch/distributed/fsdp/_runtime_utils.py:1554:8: warning[possibly-missing-attribute] Submodule `_functional_collectives` may not be available as an attribute on module `torch.distributed` torch/distributed/fsdp/_runtime_utils.py:1636:34: error[unresolved-attribute] Module `torch` has no member `dtype` torch/distributed/fsdp/_runtime_utils.py:1637:13: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/fsdp/_runtime_utils.py:1651:16: error[unresolved-attribute] Module `torch` has no member `is_floating_point` @@ -16844,7 +17267,7 @@ change it to read from `os.environ['LOCAL_RANK']` instead. See https://pytorch.org/docs/stable/distributed.html#launch-utility for further instructions -torch/distributed/nn/__init__.py:6:4: error[unresolved-attribute] Module `torch.distributed` has no member `rpc` +torch/distributed/nn/__init__.py:6:4: warning[possibly-missing-attribute] Submodule `rpc` may not be available as an attribute on module `torch.distributed` torch/distributed/nn/api/remote_module.py:13:19: error[unresolved-import] Module `torch` has no member `device` torch/distributed/nn/api/remote_module.py:13:27: error[unresolved-import] Module `torch` has no member `dtype` torch/distributed/nn/api/remote_module.py:14:31: warning[possibly-missing-import] Member `_remote_device` of module `torch.distributed` may be missing @@ -16920,11 +17343,11 @@ torch/distributed/nn/functional.py:430:9: warning[possibly-missing-attribute] Me torch/distributed/nn/functional.py:442:18: error[unresolved-attribute] Module `torch` has no member `empty` torch/distributed/nn/functional.py:462:45: error[unresolved-attribute] Module `torch` has no member `contiguous_format` torch/distributed/nn/functional.py:463:9: warning[possibly-missing-attribute] Member `all_reduce` may be missing on module `torch.distributed` -torch/distributed/nn/jit/instantiator.py:20:22: error[unresolved-attribute] Module `torch` has no member `_jit_internal` -torch/distributed/nn/jit/instantiator.py:21:10: error[unresolved-attribute] Module `torch.jit` has no member `_state` -torch/distributed/nn/jit/instantiator.py:97:33: error[unresolved-attribute] Module `torch` has no member `_jit_internal` -torch/distributed/optim/apply_optimizer_in_backward.py:13:34: error[unresolved-attribute] Module `torch.utils` has no member `weak` -torch/distributed/optim/apply_optimizer_in_backward.py:14:25: error[unresolved-attribute] Module `torch.utils` has no member `weak` +torch/distributed/nn/jit/instantiator.py:20:22: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` +torch/distributed/nn/jit/instantiator.py:21:10: warning[possibly-missing-attribute] Submodule `_state` may not be available as an attribute on module `torch.jit` +torch/distributed/nn/jit/instantiator.py:97:33: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` +torch/distributed/optim/apply_optimizer_in_backward.py:13:34: warning[possibly-missing-attribute] Submodule `weak` may not be available as an attribute on module `torch.utils` +torch/distributed/optim/apply_optimizer_in_backward.py:14:25: warning[possibly-missing-attribute] Submodule `weak` may not be available as an attribute on module `torch.utils` torch/distributed/optim/functional_adadelta.py:77:32: error[unresolved-attribute] Module `torch` has no member `is_complex` torch/distributed/optim/functional_adadelta.py:84:37: error[unresolved-attribute] Module `torch` has no member `tensor` torch/distributed/optim/functional_adadelta.py:85:43: error[unresolved-attribute] Module `torch` has no member `zeros_like` @@ -16997,12 +17420,11 @@ torch/distributed/optim/optimizer.py:79:27: warning[possibly-missing-attribute] torch/distributed/optim/optimizer.py:88:12: warning[possibly-missing-attribute] Member `RRef` may be missing on module `torch.distributed.rpc` torch/distributed/optim/optimizer.py:102:16: warning[possibly-missing-attribute] Member `RRef` may be missing on module `torch.distributed.rpc` torch/distributed/optim/optimizer.py:189:9: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` -torch/distributed/optim/optimizer.py:194:56: error[unresolved-attribute] Module `torch.jit` has no member `_state` +torch/distributed/optim/optimizer.py:194:56: warning[possibly-missing-attribute] Submodule `_state` may not be available as an attribute on module `torch.jit` torch/distributed/optim/optimizer.py:215:37: warning[possibly-missing-attribute] Member `rpc_async` may be missing on module `torch.distributed.rpc` torch/distributed/optim/optimizer.py:239:9: warning[possibly-missing-attribute] Member `_is_valid_context` may be missing on module `torch.distributed.autograd` torch/distributed/optim/optimizer.py:248:13: warning[possibly-missing-attribute] Member `rpc_async` may be missing on module `torch.distributed.rpc` torch/distributed/optim/zero_redundancy_optimizer.py:35:13: error[unresolved-attribute] Module `torch` has no member `device` -torch/distributed/optim/zero_redundancy_optimizer.py:57:26: error[unresolved-attribute] Module `collections` has no member `abc` torch/distributed/optim/zero_redundancy_optimizer.py:76:21: warning[possibly-missing-attribute] Member `group` may be missing on module `torch.distributed` torch/distributed/optim/zero_redundancy_optimizer.py:77:13: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/optim/zero_redundancy_optimizer.py:77:28: error[unresolved-attribute] Module `torch` has no member `device` @@ -17038,6 +17460,7 @@ torch/distributed/optim/zero_redundancy_optimizer.py:793:27: warning[possibly-mi torch/distributed/optim/zero_redundancy_optimizer.py:795:17: error[invalid-argument-type] Argument to function `get_global_rank` is incorrect: Expected `ProcessGroup`, found `Unknown | ProcessGroup | None` torch/distributed/optim/zero_redundancy_optimizer.py:800:21: warning[possibly-missing-attribute] Member `broadcast` may be missing on module `torch.distributed` torch/distributed/optim/zero_redundancy_optimizer.py:828:15: error[unresolved-attribute] Module `torch` has no member `device` +torch/distributed/optim/zero_redundancy_optimizer.py:1112:9: error[invalid-method-override] Invalid override of method `step`: Definition is incompatible with `Optimizer.step` torch/distributed/optim/zero_redundancy_optimizer.py:1164:30: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/optim/zero_redundancy_optimizer.py:1350:30: error[unresolved-attribute] Module `torch` has no member `zeros` torch/distributed/optim/zero_redundancy_optimizer.py:1353:30: error[unresolved-attribute] Module `torch` has no member `empty` @@ -17149,7 +17572,7 @@ torch/distributed/rendezvous.py:16:31: warning[possibly-missing-import] Member ` torch/distributed/rendezvous.py:16:42: warning[possibly-missing-import] Member `Store` of module `torch.distributed` may be missing torch/distributed/rendezvous.py:16:49: warning[possibly-missing-import] Member `TCPStore` of module `torch.distributed` may be missing torch/distributed/rpc/__init__.py:28:27: error[unresolved-attribute] Module `torch._C` has no member `_rpc_init` -torch/distributed/rpc/__init__.py:34:9: error[unresolved-attribute] Module `torch._C` has no member `_distributed_rpc` +torch/distributed/rpc/__init__.py:34:9: warning[possibly-missing-attribute] Submodule `_distributed_rpc` may not be available as an attribute on module `torch._C` torch/distributed/rpc/__init__.py:127:9: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` torch/distributed/rpc/__init__.py:180:21: warning[possibly-missing-attribute] Member `_create_store_from_options` may be missing on module `torch.distributed` torch/distributed/rpc/__init__.py:186:35: warning[possibly-missing-attribute] Member `rendezvous` may be missing on module `torch.distributed` @@ -17167,14 +17590,14 @@ torch/distributed/rpc/_testing/faulty_agent_backend_registry.py:58:1: warning[po torch/distributed/rpc/_utils.py:41:19: warning[possibly-missing-import] Member `api` of module `torch.distributed.rpc` may be missing torch/distributed/rpc/_utils.py:41:24: warning[possibly-missing-import] Member `TensorPipeAgent` of module `torch.distributed.rpc` may be missing torch/distributed/rpc/api.py:649:5: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` -torch/distributed/rpc/api.py:650:22: error[unresolved-attribute] Module `torch.jit` has no member `_builtins` -torch/distributed/rpc/api.py:676:17: error[unresolved-attribute] Module `torch` has no member `_jit_internal` -torch/distributed/rpc/api.py:705:22: error[unresolved-attribute] Module `torch.jit` has no member `_builtins` -torch/distributed/rpc/api.py:733:17: error[unresolved-attribute] Module `torch` has no member `_jit_internal` +torch/distributed/rpc/api.py:650:22: warning[possibly-missing-attribute] Submodule `_builtins` may not be available as an attribute on module `torch.jit` +torch/distributed/rpc/api.py:676:17: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` +torch/distributed/rpc/api.py:705:22: warning[possibly-missing-attribute] Submodule `_builtins` may not be available as an attribute on module `torch.jit` +torch/distributed/rpc/api.py:733:17: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` torch/distributed/rpc/api.py:827:5: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` torch/distributed/rpc/api.py:921:5: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` -torch/distributed/rpc/api.py:931:26: error[unresolved-attribute] Module `torch._C` has no member `_profiler` -torch/distributed/rpc/api.py:948:17: error[unresolved-attribute] Module `torch` has no member `_jit_internal` +torch/distributed/rpc/api.py:931:26: warning[possibly-missing-attribute] Submodule `_profiler` may not be available as an attribute on module `torch._C` +torch/distributed/rpc/api.py:948:17: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` torch/distributed/rpc/backend_registry.py:11:15: warning[possibly-missing-import] Member `api` of module `torch.distributed.rpc` may be missing torch/distributed/rpc/backend_registry.py:123:13: warning[possibly-missing-attribute] Member `ProcessGroupGloo` may be missing on module `torch.distributed` torch/distributed/rpc/backend_registry.py:144:19: warning[possibly-missing-import] Member `TensorPipeRpcBackendOptions` of module `torch.distributed.rpc` may be missing @@ -17191,7 +17614,7 @@ torch/distributed/rpc/backend_registry.py:288:19: warning[possibly-missing-impor torch/distributed/rpc/backend_registry.py:342:19: warning[possibly-missing-import] Member `TensorPipeAgent` of module `torch.distributed.rpc` may be missing torch/distributed/rpc/backend_registry.py:342:36: warning[possibly-missing-import] Member `TensorPipeRpcBackendOptions` of module `torch.distributed.rpc` may be missing torch/distributed/rpc/backend_registry.py:344:30: warning[possibly-missing-attribute] Member `Store` may be missing on module `torch.distributed` -torch/distributed/rpc/internal.py:68:16: error[unresolved-attribute] Module `torch.distributed` has no member `rpc` +torch/distributed/rpc/internal.py:68:16: warning[possibly-missing-attribute] Submodule `rpc` may not be available as an attribute on module `torch.distributed` torch/distributed/rpc/options.py:6:15: warning[possibly-missing-import] Member `_is_tensorpipe_available` of module `torch.distributed.rpc` may be missing torch/distributed/rpc/options.py:9:30: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/rpc/options.py:14:39: error[unresolved-attribute] Module `torch` has no member `device` @@ -17213,8 +17636,8 @@ torch/distributed/rpc/server_process_global_profiler.py:9:44: warning[deprecated torch/distributed/rpc/server_process_global_profiler.py:12:5: warning[possibly-missing-import] Member `_disable_server_process_global_profiler` of module `torch.distributed.rpc` may be missing torch/distributed/rpc/server_process_global_profiler.py:13:5: warning[possibly-missing-import] Member `_enable_server_process_global_profiler` of module `torch.distributed.rpc` may be missing torch/distributed/rpc/server_process_global_profiler.py:20:38: warning[deprecated] The class `profile` is deprecated: `torch.autograd.profiler_legacy.profile` is deprecated and will be removed in a future release. Please use `torch.profiler` instead. -torch/distributed/rpc/server_process_global_profiler.py:164:17: error[unresolved-attribute] Module `torch.autograd` has no member `profiler_legacy` -torch/distributed/rpc/server_process_global_profiler.py:180:32: error[unresolved-attribute] Module `torch.autograd` has no member `profiler_util` +torch/distributed/rpc/server_process_global_profiler.py:164:17: warning[possibly-missing-attribute] Submodule `profiler_legacy` may not be available as an attribute on module `torch.autograd` +torch/distributed/rpc/server_process_global_profiler.py:180:32: warning[possibly-missing-attribute] Submodule `profiler_util` may not be available as an attribute on module `torch.autograd` torch/distributed/run.py:754:32: error[unresolved-attribute] Module `torch._C` has no member `_get_privateuse1_backend_name` torch/distributed/tensor/__init__.py:5:43: warning[possibly-missing-import] Member `DeviceMesh` of module `torch.distributed.device_mesh` may be missing torch/distributed/tensor/__init__.py:5:55: warning[possibly-missing-import] Member `init_device_mesh` of module `torch.distributed.device_mesh` may be missing @@ -17230,7 +17653,7 @@ torch/distributed/tensor/_api.py:736:5: error[unresolved-attribute] Module `torc torch/distributed/tensor/_api.py:928:5: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` torch/distributed/tensor/_api.py:1044:11: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributed/tensor/_api.py:1061:32: error[unresolved-attribute] Module `torch` has no member `strided` -torch/distributed/tensor/_api.py:1062:20: error[unresolved-attribute] Module `torch` has no member `_prims_common` +torch/distributed/tensor/_api.py:1062:20: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` torch/distributed/tensor/_api.py:1070:19: error[unresolved-attribute] Module `torch` has no member `full` torch/distributed/tensor/_api.py:1073:21: error[unresolved-attribute] Module `torch` has no member `rand` torch/distributed/tensor/_api.py:1073:46: error[unresolved-attribute] Module `torch` has no member `randn` @@ -17528,6 +17951,7 @@ torch/distributed/tensor/experimental/_context_parallel/_attention.py:977:24: er torch/distributed/tensor/experimental/_context_parallel/_attention.py:978:40: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__` torch/distributed/tensor/experimental/_context_parallel/_attention.py:1096:30: error[unresolved-attribute] Module `torch` has no member `index_select` torch/distributed/tensor/experimental/_context_parallel/_attention.py:1106:37: error[unresolved-attribute] Module `torch` has no member `index_select` +torch/distributed/tensor/experimental/_context_parallel/_attention.py:1288:9: error[invalid-method-override] Invalid override of method `_apply`: Definition is incompatible with `ParallelStyle._apply` torch/distributed/tensor/experimental/_context_parallel/_attention.py:1625:39: error[unresolved-attribute] Module `torch` has no member `index_select` torch/distributed/tensor/experimental/_context_parallel/_cp_custom_ops.py:31:13: error[unresolved-attribute] Module `torch` has no member `empty` torch/distributed/tensor/experimental/_context_parallel/_cp_custom_ops.py:32:13: error[unresolved-attribute] Module `torch` has no member `empty` @@ -17577,6 +18001,7 @@ torch/distributed/tensor/parallel/fsdp.py:52:58: error[unresolved-attribute] Mod torch/distributed/tensor/parallel/fsdp.py:78:15: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/distributed/tensor/parallel/fsdp.py:152:9: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` torch/distributed/tensor/parallel/fsdp.py:197:62: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` +torch/distributed/tensor/parallel/fsdp.py:342:9: error[invalid-method-override] Invalid override of method `post_unflatten_transform`: Definition is incompatible with `FSDPExtensions.post_unflatten_transform` torch/distributed/tensor/parallel/fsdp.py:367:13: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` torch/distributed/tensor/parallel/fsdp.py:368:26: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/tensor/parallel/loss.py:11:43: warning[possibly-missing-import] Member `DeviceMesh` of module `torch.distributed.device_mesh` may be missing @@ -17608,28 +18033,28 @@ torch/distributed/tensor/parallel/loss.py:454:5: error[invalid-assignment] Canno torch/distributed/tensor/parallel/loss.py:454:14: error[invalid-assignment] Cannot assign to a subscript on an object of type `tuple[object, ...]` torch/distributed/tensor/parallel/loss.py:456:5: error[invalid-assignment] Cannot assign to a subscript on an object of type `tuple[object, ...]` torch/distributed/tensor/placement_types.py:12:43: warning[possibly-missing-import] Member `DeviceMesh` of module `torch.distributed.device_mesh` may be missing -torch/distributed/tensor/placement_types.py:31:13: error[unresolved-attribute] Module `torch._C` has no member `_distributed` +torch/distributed/tensor/placement_types.py:31:13: warning[possibly-missing-attribute] Submodule `_distributed` may not be available as an attribute on module `torch._C` torch/distributed/tensor/placement_types.py:71:28: error[unresolved-attribute] Module `torch` has no member `chunk` torch/distributed/tensor/placement_types.py:188:18: error[unresolved-attribute] Module `torch` has no member `empty_like` torch/distributed/tensor/placement_types.py:235:22: error[unresolved-attribute] Module `torch` has no member `cat` torch/distributed/tensor/placement_types.py:491:1: error[inconsistent-mro] Cannot create a consistent method resolution order (MRO) for class `_StridedShard` with bases list `[Unknown, ]` -torch/distributed/tensor/placement_types.py:491:21: error[unresolved-attribute] Module `torch._C` has no member `_distributed` +torch/distributed/tensor/placement_types.py:491:21: warning[possibly-missing-attribute] Submodule `_distributed` may not be available as an attribute on module `torch._C` torch/distributed/tensor/placement_types.py:605:21: error[unresolved-attribute] Module `torch` has no member `cat` torch/distributed/tensor/placement_types.py:637:26: error[unresolved-attribute] Module `torch` has no member `arange` torch/distributed/tensor/placement_types.py:674:23: error[unresolved-attribute] Module `torch` has no member `cat` torch/distributed/tensor/placement_types.py:675:27: error[unresolved-attribute] Module `torch` has no member `argsort` torch/distributed/tensor/placement_types.py:676:28: error[unresolved-attribute] Module `torch` has no member `index_select` torch/distributed/tensor/placement_types.py:696:26: error[unresolved-attribute] Module `torch` has no member `arange` -torch/distributed/tensor/placement_types.py:715:17: error[unresolved-attribute] Module `torch._C` has no member `_distributed` -torch/distributed/tensor/placement_types.py:773:15: error[unresolved-attribute] Module `torch._C` has no member `_distributed` +torch/distributed/tensor/placement_types.py:715:17: warning[possibly-missing-attribute] Submodule `_distributed` may not be available as an attribute on module `torch._C` +torch/distributed/tensor/placement_types.py:773:15: warning[possibly-missing-attribute] Submodule `_distributed` may not be available as an attribute on module `torch._C` torch/distributed/tensor/placement_types.py:862:28: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributed/utils.py:47:21: error[unresolved-attribute] Module `torch` has no member `dtype` torch/distributed/utils.py:60:16: error[unresolved-attribute] Module `torch` has no member `is_floating_point` torch/distributed/utils.py:87:31: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/utils.py:93:31: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/utils.py:167:48: error[unresolved-attribute] Module `torch` has no member `Size` -torch/distributed/utils.py:176:16: error[unresolved-attribute] Module `torch.distributed` has no member `_functional_collectives` -torch/distributed/utils.py:196:16: error[unresolved-attribute] Module `torch.distributed` has no member `_functional_collectives` +torch/distributed/utils.py:176:16: warning[possibly-missing-attribute] Submodule `_functional_collectives` may not be available as an attribute on module `torch.distributed` +torch/distributed/utils.py:196:16: warning[possibly-missing-attribute] Submodule `_functional_collectives` may not be available as an attribute on module `torch.distributed` torch/distributed/utils.py:261:20: error[unresolved-attribute] Module `torch` has no member `device` torch/distributed/utils.py:282:20: warning[possibly-missing-attribute] Member `ProcessGroup` may be missing on module `torch.distributed` torch/distributed/utils.py:284:23: warning[possibly-missing-attribute] Member `Logger` may be missing on module `torch.distributed` @@ -17660,6 +18085,7 @@ torch/distributions/bernoulli.py:133:18: error[unresolved-attribute] Module `tor torch/distributions/bernoulli.py:133:40: warning[possibly-missing-attribute] Attribute `dtype` may be missing on object of type `Unknown | lazy_property[Unknown, Unknown] | Tensor` torch/distributions/bernoulli.py:133:66: warning[possibly-missing-attribute] Attribute `device` may be missing on object of type `Unknown | lazy_property[Unknown, Unknown] | Tensor` torch/distributions/bernoulli.py:141:17: error[unresolved-attribute] Module `torch` has no member `logit` +torch/distributions/bernoulli.py:144:9: error[invalid-method-override] Invalid override of method `_log_normalizer`: Definition is incompatible with `ExponentialFamily._log_normalizer` torch/distributions/bernoulli.py:145:16: error[unresolved-attribute] Module `torch` has no member `log1p` torch/distributions/bernoulli.py:145:28: error[unresolved-attribute] Module `torch` has no member `exp` torch/distributions/beta.py:49:45: error[unresolved-attribute] Module `torch` has no member `tensor` @@ -17668,6 +18094,7 @@ torch/distributions/beta.py:66:23: error[unresolved-attribute] Module `torch` ha torch/distributions/beta.py:91:23: error[unresolved-attribute] Module `torch` has no member `stack` torch/distributions/beta.py:101:20: error[unresolved-attribute] Module `torch` has no member `tensor` torch/distributions/beta.py:109:20: error[unresolved-attribute] Module `torch` has no member `tensor` +torch/distributions/beta.py:118:9: error[invalid-method-override] Invalid override of method `_log_normalizer`: Definition is incompatible with `ExponentialFamily._log_normalizer` torch/distributions/beta.py:119:16: error[unresolved-attribute] Module `torch` has no member `lgamma` torch/distributions/beta.py:119:34: error[unresolved-attribute] Module `torch` has no member `lgamma` torch/distributions/beta.py:119:52: error[unresolved-attribute] Module `torch` has no member `lgamma` @@ -17732,11 +18159,13 @@ torch/distributions/cauchy.py:73:16: error[unresolved-attribute] Module `torch` torch/distributions/cauchy.py:77:45: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributions/cauchy.py:94:16: error[unresolved-attribute] Module `torch` has no member `atan` torch/distributions/cauchy.py:97:16: error[unresolved-attribute] Module `torch` has no member `tan` +torch/distributions/constraints.py:152:9: error[invalid-method-override] Invalid override of method `check`: Definition is incompatible with `Constraint.check` torch/distributions/constraints.py:212:9: error[invalid-parameter-default] Default value of type `NotImplementedType` is not assignable to annotated parameter type `bool | None` torch/distributions/constraints.py:213:9: error[invalid-parameter-default] Default value of type `NotImplementedType` is not assignable to annotated parameter type `int | None` torch/distributions/constraints.py:227:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool | None`, found `Unknown | bool | None | NotImplementedType` torch/distributions/constraints.py:227:48: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `int | None`, found `Unknown | int | None | NotImplementedType` torch/distributions/constraints.py:521:16: error[unresolved-attribute] Module `torch` has no member `all` +torch/distributions/constraints.py:539:9: error[invalid-method-override] Invalid override of method `check`: Definition is incompatible with `Constraint.check` torch/distributions/constraints.py:582:13: error[unresolved-attribute] Module `torch` has no member `finfo` torch/distributions/constraints.py:597:16: error[unresolved-attribute] Module `torch` has no member `full` torch/distributions/constraints.py:600:19: error[unresolved-attribute] Module `torch` has no member `bool` @@ -17815,6 +18244,7 @@ torch/distributions/continuous_bernoulli.py:225:22: error[unresolved-attribute] torch/distributions/continuous_bernoulli.py:225:34: error[unsupported-operator] Unary operator `-` is unsupported for type `Unknown | lazy_property[Unknown, Unknown]` torch/distributions/continuous_bernoulli.py:226:22: error[unresolved-attribute] Module `torch` has no member `log` torch/distributions/continuous_bernoulli.py:235:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[Tensor]`, found `tuple[Unknown | lazy_property[Unknown, Unknown]]` +torch/distributions/continuous_bernoulli.py:238:9: error[invalid-method-override] Invalid override of method `_log_normalizer`: Definition is incompatible with `ExponentialFamily._log_normalizer` torch/distributions/continuous_bernoulli.py:240:24: error[unresolved-attribute] Module `torch` has no member `max` torch/distributions/continuous_bernoulli.py:241:13: error[unresolved-attribute] Module `torch` has no member `le` torch/distributions/continuous_bernoulli.py:241:47: error[unresolved-attribute] Module `torch` has no member `gt` @@ -17837,6 +18267,7 @@ torch/distributions/dirichlet.py:126:13: error[unresolved-attribute] Module `tor torch/distributions/dirichlet.py:127:15: error[unresolved-attribute] Module `torch` has no member `lgamma` torch/distributions/dirichlet.py:128:26: error[unresolved-attribute] Module `torch` has no member `digamma` torch/distributions/dirichlet.py:129:45: error[unresolved-attribute] Module `torch` has no member `digamma` +torch/distributions/dirichlet.py:137:9: error[invalid-method-override] Invalid override of method `_log_normalizer`: Definition is incompatible with `ExponentialFamily._log_normalizer` torch/distributions/dirichlet.py:138:37: error[unresolved-attribute] Module `torch` has no member `lgamma` torch/distributions/distribution.py:49:22: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributions/distribution.py:49:35: error[unresolved-attribute] Module `torch` has no member `Size` @@ -17862,6 +18293,7 @@ torch/distributions/exponential.py:69:45: error[unresolved-attribute] Module `to torch/distributions/exponential.py:81:20: error[unresolved-attribute] Module `torch` has no member `exp` torch/distributions/exponential.py:84:17: error[unresolved-attribute] Module `torch` has no member `log1p` torch/distributions/exponential.py:87:22: error[unresolved-attribute] Module `torch` has no member `log` +torch/distributions/exponential.py:94:9: error[invalid-method-override] Invalid override of method `_log_normalizer`: Definition is incompatible with `ExponentialFamily._log_normalizer` torch/distributions/exponential.py:95:17: error[unresolved-attribute] Module `torch` has no member `log` torch/distributions/fishersnedecor.py:48:27: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributions/fishersnedecor.py:55:23: error[unresolved-attribute] Module `torch` has no member `Size` @@ -17883,6 +18315,7 @@ torch/distributions/gamma.py:98:15: error[unresolved-attribute] Module `torch` h torch/distributions/gamma.py:104:15: error[unresolved-attribute] Module `torch` has no member `log` torch/distributions/gamma.py:105:15: error[unresolved-attribute] Module `torch` has no member `lgamma` torch/distributions/gamma.py:106:44: error[unresolved-attribute] Module `torch` has no member `digamma` +torch/distributions/gamma.py:114:9: error[invalid-method-override] Invalid override of method `_log_normalizer`: Definition is incompatible with `ExponentialFamily._log_normalizer` torch/distributions/gamma.py:115:16: error[unresolved-attribute] Module `torch` has no member `lgamma` torch/distributions/gamma.py:115:48: error[unresolved-attribute] Module `torch` has no member `log` torch/distributions/generalized_pareto.py:55:27: error[unresolved-attribute] Module `torch` has no member `Size` @@ -17955,8 +18388,10 @@ torch/distributions/half_cauchy.py:59:16: error[unresolved-attribute] Module `to torch/distributions/half_cauchy.py:68:16: error[unresolved-attribute] Module `torch` has no member `zeros_like` torch/distributions/half_cauchy.py:77:17: error[unresolved-attribute] Module `torch` has no member `as_tensor` torch/distributions/half_cauchy.py:81:20: error[unresolved-attribute] Module `torch` has no member `where` +torch/distributions/half_cauchy.py:89:9: error[invalid-method-override] Invalid override of method `icdf`: Definition is incompatible with `TransformedDistribution.icdf` torch/distributions/half_normal.py:63:16: error[unresolved-attribute] Module `torch` has no member `zeros_like` torch/distributions/half_normal.py:73:20: error[unresolved-attribute] Module `torch` has no member `where` +torch/distributions/half_normal.py:81:9: error[invalid-method-override] Invalid override of method `icdf`: Definition is incompatible with `TransformedDistribution.icdf` torch/distributions/independent.py:5:19: error[unresolved-import] Module `torch` has no member `Size` torch/distributions/independent.py:72:23: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributions/independent.py:113:35: error[unresolved-attribute] Module `torch` has no member `Size` @@ -18059,7 +18494,9 @@ torch/distributions/mixture_same_family.py:110:23: error[unresolved-attribute] M torch/distributions/mixture_same_family.py:142:16: error[unresolved-attribute] Module `torch` has no member `sum` torch/distributions/mixture_same_family.py:150:25: error[unresolved-attribute] Module `torch` has no member `sum` torch/distributions/mixture_same_family.py:153:25: error[unresolved-attribute] Module `torch` has no member `sum` +torch/distributions/mixture_same_family.py:159:9: error[invalid-method-override] Invalid override of method `cdf`: Definition is incompatible with `Distribution.cdf` torch/distributions/mixture_same_family.py:164:16: error[unresolved-attribute] Module `torch` has no member `sum` +torch/distributions/mixture_same_family.py:166:9: error[invalid-method-override] Invalid override of method `log_prob`: Definition is incompatible with `Distribution.log_prob` torch/distributions/mixture_same_family.py:171:24: error[unresolved-attribute] Module `torch` has no member `log_softmax` torch/distributions/mixture_same_family.py:174:16: error[unresolved-attribute] Module `torch` has no member `logsumexp` torch/distributions/mixture_same_family.py:176:35: error[unresolved-attribute] Module `torch` has no member `Size` @@ -18126,6 +18563,7 @@ torch/distributions/normal.py:83:45: error[unresolved-attribute] Module `torch` torch/distributions/normal.py:109:17: error[unresolved-attribute] Module `torch` has no member `erf` torch/distributions/normal.py:113:40: error[unresolved-attribute] Module `torch` has no member `erfinv` torch/distributions/normal.py:116:52: error[unresolved-attribute] Module `torch` has no member `log` +torch/distributions/normal.py:123:9: error[invalid-method-override] Invalid override of method `_log_normalizer`: Definition is incompatible with `ExponentialFamily._log_normalizer` torch/distributions/normal.py:124:45: error[unresolved-attribute] Module `torch` has no member `log` torch/distributions/one_hot_categorical.py:63:23: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributions/one_hot_categorical.py:76:16: error[invalid-return-type] Return type does not match returned value: expected `Tensor`, found `Unknown | lazy_property[Unknown, Unknown]` @@ -18146,6 +18584,7 @@ torch/distributions/poisson.py:65:23: error[unresolved-attribute] Module `torch` torch/distributions/poisson.py:71:35: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributions/poisson.py:74:20: error[unresolved-attribute] Module `torch` has no member `poisson` torch/distributions/poisson.py:84:17: error[unresolved-attribute] Module `torch` has no member `log` +torch/distributions/poisson.py:87:9: error[invalid-method-override] Invalid override of method `_log_normalizer`: Definition is incompatible with `ExponentialFamily._log_normalizer` torch/distributions/poisson.py:88:16: error[unresolved-attribute] Module `torch` has no member `exp` torch/distributions/relaxed_bernoulli.py:70:27: error[unresolved-attribute] Module `torch` has no member `Size` torch/distributions/relaxed_bernoulli.py:72:27: warning[possibly-missing-attribute] Attribute `size` may be missing on object of type `Unknown | lazy_property[Unknown, Unknown] | Tensor` @@ -18296,26 +18735,27 @@ torch/distributions/wishart.py:312:15: error[unresolved-attribute] Module `torch torch/distributions/wishart.py:314:15: error[unresolved-attribute] Module `torch` has no member `cholesky_solve` torch/distributions/wishart.py:331:15: error[unresolved-attribute] Module `torch` has no member `mvlgamma` torch/distributions/wishart.py:340:16: error[unsupported-operator] Unary operator `-` is unsupported for type `Unknown | lazy_property[Unknown, Unknown]` +torch/distributions/wishart.py:343:9: error[invalid-method-override] Invalid override of method `_log_normalizer`: Definition is incompatible with `ExponentialFamily._log_normalizer` torch/distributions/wishart.py:347:13: error[unresolved-attribute] Module `torch` has no member `mvlgamma` -torch/export/__init__.py:300:17: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` -torch/export/__init__.py:302:17: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` -torch/export/__init__.py:303:17: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` +torch/export/__init__.py:300:17: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` +torch/export/__init__.py:302:17: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` +torch/export/__init__.py:303:17: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` torch/export/_draft_export.py:299:9: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `GET_DTRACE_STRUCTURED` of type `Literal[False]` -torch/export/_draft_export.py:386:9: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/export/_leakage_detection_utils.py:41:28: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` +torch/export/_draft_export.py:386:9: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/export/_leakage_detection_utils.py:41:28: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` torch/export/_safeguard.py:21:13: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` torch/export/_safeguard.py:25:25: error[unresolved-attribute] Module `torch._C` has no member `is_grad_enabled` torch/export/_safeguard.py:28:29: error[index-out-of-bounds] Index 0 is out of bounds for tuple `tuple[()]` with length 0 torch/export/_safeguard.py:29:20: error[unresolved-attribute] Module `torch._C` has no member `_get_dispatch_mode` torch/export/_safeguard.py:29:48: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` -torch/export/_trace.py:190:11: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/export/_trace.py:193:9: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/export/_trace.py:194:15: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/export/_trace.py:196:9: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/export/_trace.py:200:16: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/export/_trace.py:828:16: error[unresolved-attribute] Module `torch` has no member `_functorch` -torch/export/_trace.py:829:16: error[unresolved-attribute] Module `torch` has no member `_export` -torch/export/_trace.py:843:20: error[unresolved-attribute] Module `torch` has no member `_export` +torch/export/_trace.py:190:11: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/export/_trace.py:193:9: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/export/_trace.py:194:15: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/export/_trace.py:196:9: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/export/_trace.py:200:16: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/export/_trace.py:828:16: warning[possibly-missing-attribute] Submodule `_functorch` may not be available as an attribute on module `torch` +torch/export/_trace.py:829:16: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` +torch/export/_trace.py:843:20: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` torch/export/_trace.py:1497:9: error[unresolved-attribute] Cannot assign object of type `(...) -> Any` to attribute `forward` on type `Module` with custom `__setattr__` method. torch/export/_trace.py:1502:22: error[unresolved-attribute] Module `torch._C` has no member `_jit_texpr_fuser_enabled` torch/export/_trace.py:1503:5: error[unresolved-attribute] Module `torch._C` has no member `_jit_set_texpr_fuser_enabled` @@ -18324,19 +18764,19 @@ torch/export/_trace.py:1604:5: error[unresolved-attribute] Cannot assign object torch/export/_trace.py:1728:24: error[unresolved-attribute] Module `torch._C` has no member `_is_torch_function_mode_enabled` torch/export/_trace.py:1806:29: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` torch/export/_trace.py:1810:21: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` -torch/export/_trace.py:2015:30: error[unresolved-attribute] Module `torch.fx` has no member `traceback` -torch/export/_trace.py:2176:28: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/export/_trace.py:2181:23: error[unresolved-attribute] Module `torch` has no member `_export` -torch/export/_trace.py:2211:20: error[unresolved-attribute] Module `torch` has no member `_export` -torch/export/_trace.py:2261:23: error[unresolved-attribute] Module `torch` has no member `_export` -torch/export/_trace.py:2443:5: error[unresolved-attribute] Module `torch` has no member `_export` +torch/export/_trace.py:2015:30: warning[possibly-missing-attribute] Submodule `traceback` may not be available as an attribute on module `torch.fx` +torch/export/_trace.py:2176:28: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/export/_trace.py:2181:23: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` +torch/export/_trace.py:2211:20: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` +torch/export/_trace.py:2261:23: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` +torch/export/_trace.py:2443:5: warning[possibly-missing-attribute] Submodule `_export` may not be available as an attribute on module `torch` torch/export/_unlift.py:477:9: error[unresolved-attribute] Cannot assign object of type `(Unknown & ~AlwaysFalsy) | list[Unknown]` to attribute `range_constraints` on type `Self@__init__` with custom `__setattr__` method. torch/export/_unlift.py:478:9: error[unresolved-attribute] Cannot assign object of type `Literal[True]` to attribute `validate_inputs` on type `Self@__init__` with custom `__setattr__` method. -torch/export/_unlift.py:694:18: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/export/_unlift.py:860:32: error[unresolved-attribute] Module `torch.fx` has no member `_utils` -torch/export/dynamic_shapes.py:572:28: error[unresolved-attribute] Module `torch._dynamo` has no member `source` -torch/export/dynamic_shapes.py:573:33: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` -torch/export/dynamic_shapes.py:912:13: error[unresolved-attribute] Module `torch.export` has no member `_unlift` +torch/export/_unlift.py:694:18: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/export/_unlift.py:860:32: warning[possibly-missing-attribute] Submodule `_utils` may not be available as an attribute on module `torch.fx` +torch/export/dynamic_shapes.py:572:28: warning[possibly-missing-attribute] Submodule `source` may not be available as an attribute on module `torch._dynamo` +torch/export/dynamic_shapes.py:573:33: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` +torch/export/dynamic_shapes.py:912:13: warning[possibly-missing-attribute] Submodule `_unlift` may not be available as an attribute on module `torch.export` torch/export/exported_program.py:158:5: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/export/exported_program.py:159:5: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/export/exported_program.py:160:5: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` @@ -18361,8 +18801,8 @@ torch/export/exported_program.py:187:5: error[unresolved-attribute] Module `torc torch/export/exported_program.py:214:12: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/export/exported_program.py:215:40: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/export/exported_program.py:217:29: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` -torch/export/exported_program.py:1705:36: error[unresolved-attribute] Module `torch._dynamo` has no member `source` -torch/export/exported_program.py:1709:18: error[unresolved-attribute] Module `torch.fx.experimental` has no member `symbolic_shapes` +torch/export/exported_program.py:1705:36: warning[possibly-missing-attribute] Submodule `source` may not be available as an attribute on module `torch._dynamo` +torch/export/exported_program.py:1709:18: warning[possibly-missing-attribute] Submodule `symbolic_shapes` may not be available as an attribute on module `torch.fx.experimental` torch/export/graph_signature.py:564:23: error[unresolved-import] Module `torch` has no member `ScriptObject` torch/export/passes/__init__.py:12:42: error[unresolved-attribute] Module `torch` has no member `device` torch/export/passes/__init__.py:29:22: error[unresolved-attribute] Module `torch` has no member `device` @@ -18370,14 +18810,14 @@ torch/export/passes/__init__.py:30:25: error[unresolved-attribute] Module `torch torch/export/pt2_archive/_package.py:494:37: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` torch/export/pt2_archive/_package.py:504:35: error[unresolved-attribute] Module `torch._C` has no member `ScriptObject` torch/export/pt2_archive/_package.py:543:28: error[unresolved-attribute] Module `torch._C` has no member `_pickle_save` -torch/export/pt2_archive/_package.py:723:32: error[unresolved-attribute] Module `torch._C` has no member `_aoti` +torch/export/pt2_archive/_package.py:723:32: warning[possibly-missing-attribute] Submodule `_aoti` may not be available as an attribute on module `torch._C` torch/export/pt2_archive/_package.py:789:18: error[unresolved-attribute] Module `torch` has no member `frombuffer` torch/export/pt2_archive/_package.py:798:18: error[unresolved-attribute] Module `torch` has no member `zeros` torch/export/pt2_archive/_package.py:879:33: error[unresolved-attribute] Module `torch` has no member `as_strided` torch/export/pt2_archive/_package.py:935:39: error[unresolved-attribute] Module `torch` has no member `as_strided` torch/export/pt2_archive/_package.py:949:43: error[unresolved-attribute] Module `torch._C` has no member `_pickle_load_obj` -torch/export/pt2_archive/_package.py:1023:27: error[unresolved-attribute] Module `torch._inductor` has no member `codecache` -torch/export/pt2_archive/_package.py:1037:9: error[unresolved-attribute] Module `torch._C` has no member `_aoti` +torch/export/pt2_archive/_package.py:1023:27: warning[possibly-missing-attribute] Submodule `codecache` may not be available as an attribute on module `torch._inductor` +torch/export/pt2_archive/_package.py:1037:9: warning[possibly-missing-attribute] Submodule `_aoti` may not be available as an attribute on module `torch._C` torch/export/pt2_archive/_package.py:1147:17: error[no-matching-overload] No overload of bound method `write` matches arguments torch/export/pt2_archive/_package_weights.py:125:35: error[unresolved-attribute] Module `torch` has no member `dtype` torch/export/unflatten.py:84:35: error[unresolved-attribute] Module `torch` has no member `ScriptObject` @@ -18402,7 +18842,7 @@ torch/export/unflatten.py:549:9: error[unresolved-attribute] Cannot assign objec torch/export/unflatten.py:617:13: error[unresolved-attribute] Cannot assign object of type `Literal[True]` to attribute `adapted` on type `Self@process_forward_inputs` with custom `__setattr__` method. torch/export/unflatten.py:1771:58: error[unresolved-attribute] Module `torch` has no member `ScriptObject` torch/functional.py:10:22: error[unresolved-import] Module `torch._C` has no member `_add_docstr` -torch/functional.py:108:18: error[unresolved-attribute] Module `torch` has no member `_refs` +torch/functional.py:108:18: warning[possibly-missing-attribute] Submodule `_refs` may not be available as an attribute on module `torch` torch/functional.py:110:20: error[unresolved-attribute] Module `torch` has no member `Size` torch/functional.py:111:16: error[unresolved-attribute] Module `torch` has no member `Size` torch/functional.py:115:22: error[unresolved-attribute] Module `torch` has no member `zeros` @@ -18427,16 +18867,16 @@ torch/futures/__init__.py:313:9: error[unresolved-attribute] Module `torch._C` h torch/futures/__init__.py:313:41: error[unresolved-attribute] Module `torch._C` has no member `Future` torch/futures/__init__.py:334:20: error[unresolved-attribute] Module `torch._C` has no member `_collect_all` torch/futures/__init__.py:334:52: error[unresolved-attribute] Module `torch._C` has no member `Future` -torch/fx/_graph_pickler.py:101:30: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/fx/_graph_pickler.py:101:30: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/fx/_graph_pickler.py:208:20: error[invalid-return-type] Return type does not match returned value: expected `tuple[(Self@reduce_helper, _UnpickleState, /) -> _SymNodeT@reduce_helper, tuple[Self@reduce_helper, _UnpickleStateToken]]`, found `tuple[def unpickle_sym_int(self, unpickle_state: _UnpickleState) -> SymInt, tuple[Unknown, Unknown | _UnpickleStateToken]]` -torch/fx/_graph_pickler.py:250:33: error[unresolved-attribute] Module `torch._subclasses` has no member `meta_utils` +torch/fx/_graph_pickler.py:250:33: warning[possibly-missing-attribute] Submodule `meta_utils` may not be available as an attribute on module `torch._subclasses` torch/fx/_graph_pickler.py:278:68: error[unresolved-attribute] Module `torch` has no member `device` -torch/fx/_graph_pickler.py:317:16: error[unresolved-attribute] Module `torch._dynamo` has no member `variables` -torch/fx/_graph_pickler.py:324:21: error[unresolved-attribute] Module `torch._dynamo` has no member `variables` -torch/fx/_graph_pickler.py:358:27: error[unresolved-attribute] Module `torch.fx` has no member `_lazy_graph_module` +torch/fx/_graph_pickler.py:317:16: warning[possibly-missing-attribute] Submodule `variables` may not be available as an attribute on module `torch._dynamo` +torch/fx/_graph_pickler.py:324:21: warning[possibly-missing-attribute] Submodule `variables` may not be available as an attribute on module `torch._dynamo` +torch/fx/_graph_pickler.py:358:27: warning[possibly-missing-attribute] Submodule `_lazy_graph_module` may not be available as an attribute on module `torch.fx` torch/fx/_graph_pickler.py:557:20: error[unresolved-import] Cannot resolve imported module `einops` -torch/fx/_graph_pickler.py:599:42: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/fx/_graph_pickler.py:601:42: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/fx/_graph_pickler.py:599:42: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/fx/_graph_pickler.py:601:42: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/fx/_symbolic_trace.py:44:19: error[unresolved-attribute] Module `torch` has no member `ScriptObject` torch/fx/_symbolic_trace.py:800:32: error[unresolved-attribute] Object of type `object` has no attribute `co_name` torch/fx/_symbolic_trace.py:801:36: error[unresolved-attribute] Object of type `object` has no attribute `co_filename` @@ -18532,35 +18972,36 @@ torch/fx/experimental/proxy_tensor.py:952:18: error[unresolved-attribute] Module torch/fx/experimental/proxy_tensor.py:952:34: error[unresolved-attribute] Module `torch` has no member `float16` torch/fx/experimental/proxy_tensor.py:1073:8: error[unresolved-attribute] Module `torch` has no member `Tag` torch/fx/experimental/proxy_tensor.py:1190:9: error[unresolved-attribute] Module `torch` has no member `Tag` -torch/fx/experimental/proxy_tensor.py:1382:13: error[unresolved-attribute] Module `torch._higher_order_ops` has no member `triton_kernel_wrap` -torch/fx/experimental/proxy_tensor.py:1383:13: error[unresolved-attribute] Module `torch._higher_order_ops` has no member `triton_kernel_wrap` +torch/fx/experimental/proxy_tensor.py:1382:13: warning[possibly-missing-attribute] Submodule `triton_kernel_wrap` may not be available as an attribute on module `torch._higher_order_ops` +torch/fx/experimental/proxy_tensor.py:1383:13: warning[possibly-missing-attribute] Submodule `triton_kernel_wrap` may not be available as an attribute on module `torch._higher_order_ops` torch/fx/experimental/proxy_tensor.py:1411:53: error[unresolved-attribute] Module `torch._C` has no member `Tag` torch/fx/experimental/proxy_tensor.py:1495:69: error[unresolved-attribute] Object of type `((...) -> Unknown) & ~Module` has no attribute `__name__` -torch/fx/experimental/proxy_tensor.py:1496:12: error[unresolved-attribute] Module `torch.fx` has no member `_lazy_graph_module` +torch/fx/experimental/proxy_tensor.py:1496:12: warning[possibly-missing-attribute] Submodule `_lazy_graph_module` may not be available as an attribute on module `torch.fx` torch/fx/experimental/proxy_tensor.py:1569:22: error[unresolved-attribute] Module `torch._C` has no member `_TensorMeta` torch/fx/experimental/proxy_tensor.py:1599:22: error[unresolved-attribute] Module `torch._C` has no member `_TensorMeta` torch/fx/experimental/proxy_tensor.py:1616:17: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` torch/fx/experimental/proxy_tensor.py:1623:24: error[unresolved-attribute] Module `torch._C` has no member `_set_grad_enabled` -torch/fx/experimental/proxy_tensor.py:1632:13: error[unresolved-attribute] Module `torch._functorch` has no member `predispatch` -torch/fx/experimental/proxy_tensor.py:1633:13: error[unresolved-attribute] Module `torch._functorch` has no member `predispatch` -torch/fx/experimental/proxy_tensor.py:1634:13: error[unresolved-attribute] Module `torch._functorch` has no member `predispatch` -torch/fx/experimental/proxy_tensor.py:1635:13: error[unresolved-attribute] Module `torch._functorch` has no member `predispatch` -torch/fx/experimental/proxy_tensor.py:1636:13: error[unresolved-attribute] Module `torch._functorch` has no member `vmap` +torch/fx/experimental/proxy_tensor.py:1632:13: warning[possibly-missing-attribute] Submodule `predispatch` may not be available as an attribute on module `torch._functorch` +torch/fx/experimental/proxy_tensor.py:1633:13: warning[possibly-missing-attribute] Submodule `predispatch` may not be available as an attribute on module `torch._functorch` +torch/fx/experimental/proxy_tensor.py:1634:13: warning[possibly-missing-attribute] Submodule `predispatch` may not be available as an attribute on module `torch._functorch` +torch/fx/experimental/proxy_tensor.py:1635:13: warning[possibly-missing-attribute] Submodule `predispatch` may not be available as an attribute on module `torch._functorch` +torch/fx/experimental/proxy_tensor.py:1636:13: warning[possibly-missing-attribute] Submodule `vmap` may not be available as an attribute on module `torch._functorch` torch/fx/experimental/proxy_tensor.py:1670:14: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/fx/experimental/proxy_tensor.py:1679:26: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` torch/fx/experimental/proxy_tensor.py:1693:22: error[unresolved-attribute] Module `torch._C` has no member `_TensorMeta` torch/fx/experimental/proxy_tensor.py:1707:51: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` +torch/fx/experimental/proxy_tensor.py:1711:9: error[invalid-method-override] Invalid override of method `__exit__`: Definition is incompatible with `TorchDispatchMode.__exit__` torch/fx/experimental/proxy_tensor.py:1733:22: error[unresolved-attribute] Module `torch._C` has no member `_TensorMeta` torch/fx/experimental/proxy_tensor.py:1998:17: error[unresolved-attribute] Module `torch` has no member `is_autocast_cache_enabled` torch/fx/experimental/proxy_tensor.py:1999:5: error[unresolved-attribute] Module `torch` has no member `set_autocast_cache_enabled` torch/fx/experimental/proxy_tensor.py:2003:9: error[unresolved-attribute] Module `torch` has no member `set_autocast_cache_enabled` -torch/fx/experimental/proxy_tensor.py:2334:47: error[unresolved-attribute] Module `torch` has no member `_decomp` +torch/fx/experimental/proxy_tensor.py:2334:47: warning[possibly-missing-attribute] Submodule `_decomp` may not be available as an attribute on module `torch` torch/fx/experimental/proxy_tensor.py:2400:53: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphModule`, found `object` torch/fx/experimental/proxy_tensor.py:2410:36: warning[possibly-missing-attribute] Member `detect_fake_mode` may be missing on module `torch._dynamo.utils` torch/fx/experimental/proxy_tensor.py:2425:36: warning[possibly-missing-attribute] Member `detect_fake_mode` may be missing on module `torch._dynamo.utils` torch/fx/experimental/proxy_tensor.py:2537:36: error[unresolved-attribute] Module `torch` has no member `ScriptObject` -torch/fx/experimental/proxy_tensor.py:2611:31: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/fx/experimental/proxy_tensor.py:2707:12: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` +torch/fx/experimental/proxy_tensor.py:2611:31: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/fx/experimental/proxy_tensor.py:2707:12: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` torch/fx/experimental/proxy_tensor.py:2723:9: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` torch/fx/experimental/proxy_tensor.py:2725:12: error[unresolved-attribute] Module `torch._C` has no member `_get_dispatch_mode` torch/fx/experimental/proxy_tensor.py:2725:40: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` @@ -18573,9 +19014,9 @@ torch/fx/experimental/schema_type_annotation.py:110:38: error[unresolved-attribu torch/fx/experimental/shape_inference/infer_shape.py:53:30: error[unresolved-attribute] Module `torch` has no member `randn` torch/fx/experimental/symbolic_shapes.py:253:9: error[invalid-return-type] Return type does not match returned value: expected `tuple[int, int | SymInt, int]`, found `tuple[Literal[1], Unknown, int] | tuple[Literal[0], @Todo]` torch/fx/experimental/symbolic_shapes.py:253:13: warning[possibly-missing-attribute] Attribute `node` may be missing on object of type `int | SymInt` -torch/fx/experimental/symbolic_shapes.py:326:9: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/fx/experimental/symbolic_shapes.py:327:9: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/fx/experimental/symbolic_shapes.py:339:9: error[unresolved-attribute] Module `torch._logging` has no member `structured` +torch/fx/experimental/symbolic_shapes.py:326:9: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/fx/experimental/symbolic_shapes.py:327:9: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/fx/experimental/symbolic_shapes.py:339:9: warning[possibly-missing-attribute] Submodule `structured` may not be available as an attribute on module `torch._logging` torch/fx/experimental/symbolic_shapes.py:810:16: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `(Unknown & ~AlwaysTruthy) | bool | None` torch/fx/experimental/symbolic_shapes.py:932:35: warning[possibly-missing-attribute] Attribute `size` may be missing on object of type `(Tensor & ~SymInt & ~SymFloat & ~SymBool & ~SymNode & ~Basic & ~int & ~float & ~tuple[object, ...] & ~Top[list[Unknown]]) | (Sequence[SymInt | SymFloat | SymBool | ... omitted 4 union elements] & ~SymInt & ~SymFloat & ~SymBool & ~SymNode & ~Basic & ~int & ~float & ~tuple[object, ...] & ~Top[list[Unknown]])` torch/fx/experimental/symbolic_shapes.py:940:26: error[unresolved-attribute] Module `torch` has no member `Generator` @@ -18586,18 +19027,19 @@ torch/fx/experimental/symbolic_shapes.py:1229:13: error[unresolved-attribute] Mo torch/fx/experimental/symbolic_shapes.py:1230:13: error[unresolved-attribute] Module `torch` has no member `sparse_bsc` torch/fx/experimental/symbolic_shapes.py:1295:31: error[invalid-argument-type] Argument to function `_symint_wrap` is incorrect: Expected `Symbol`, found `Integer | Symbol` torch/fx/experimental/symbolic_shapes.py:1309:24: error[invalid-argument-type] Argument to bound method `remove` is incorrect: Expected `Symbol`, found `Integer | Symbol` -torch/fx/experimental/symbolic_shapes.py:1452:8: error[unresolved-attribute] Module `torch.fx` has no member `experimental` -torch/fx/experimental/symbolic_shapes.py:2091:9: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/fx/experimental/symbolic_shapes.py:2092:9: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/fx/experimental/symbolic_shapes.py:2093:9: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` +torch/fx/experimental/symbolic_shapes.py:1452:8: warning[possibly-missing-attribute] Submodule `experimental` may not be available as an attribute on module `torch.fx` +torch/fx/experimental/symbolic_shapes.py:2091:9: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/fx/experimental/symbolic_shapes.py:2092:9: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/fx/experimental/symbolic_shapes.py:2093:9: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` torch/fx/experimental/symbolic_shapes.py:2331:16: error[invalid-return-type] Return type does not match returned value: expected `_SympyT@_fast_expand`, found `Expr` -torch/fx/experimental/symbolic_shapes.py:2354:28: error[invalid-assignment] Object of type `tuple[Expr, bool]` is not assignable to `list[Expr]` -torch/fx/experimental/symbolic_shapes.py:2355:28: error[invalid-assignment] Object of type `tuple[Expr, bool]` is not assignable to `list[Expr]` +torch/fx/experimental/symbolic_shapes.py:2354:28: error[invalid-assignment] Object of type `Expr` is not assignable to `list[Expr]` +torch/fx/experimental/symbolic_shapes.py:2355:28: error[invalid-assignment] Object of type `Expr` is not assignable to `list[Expr]` torch/fx/experimental/symbolic_shapes.py:2357:20: error[unsupported-operator] Operator `/` is unsupported between objects of type `list[Expr]` and `list[Expr]` torch/fx/experimental/symbolic_shapes.py:2375:33: error[invalid-argument-type] Argument to function `_fast_expand` is incorrect: Argument type `` does not satisfy constraints (`Expr`, `Boolean`, `Basic`) of type variable `_SympyT` torch/fx/experimental/symbolic_shapes.py:2378:20: error[invalid-return-type] Return type does not match returned value: expected `_SympyT@safe_expand`, found `` -torch/fx/experimental/symbolic_shapes.py:3032:18: error[unresolved-attribute] Module `torch.utils` has no member `_sympy` -torch/fx/experimental/symbolic_shapes.py:3134:38: error[unresolved-attribute] Module `sympy.ntheory` has no member `modular` +torch/fx/experimental/symbolic_shapes.py:2652:9: error[invalid-method-override] Invalid override of method `_print_Float`: Definition is incompatible with `ExprPrinter._print_Float` +torch/fx/experimental/symbolic_shapes.py:3032:18: warning[possibly-missing-attribute] Submodule `_sympy` may not be available as an attribute on module `torch.utils` +torch/fx/experimental/symbolic_shapes.py:3134:38: warning[possibly-missing-attribute] Submodule `modular` may not be available as an attribute on module `sympy.ntheory` torch/fx/experimental/symbolic_shapes.py:3452:33: error[invalid-argument-type] Argument to function `_check_same_range` is incorrect: Expected `Mapping[str, int]`, found `dict[Unknown | str, Unknown | Expr]` torch/fx/experimental/symbolic_shapes.py:3955:57: warning[possibly-missing-import] Member `TranslationValidator` of module `torch.fx.experimental.validator` may be missing torch/fx/experimental/symbolic_shapes.py:4016:16: error[unresolved-attribute] Object of type `Expr` has no attribute `node` @@ -18620,6 +19062,7 @@ torch/fx/experimental/symbolic_shapes.py:7717:21: error[invalid-argument-type] M torch/fx/experimental/symbolic_shapes.py:7722:29: error[invalid-argument-type] Method `__getitem__` of type `bound method Counter[Symbol].__getitem__(key: Symbol, /) -> int` cannot be called with key of type `Basic` on object of type `Counter[Symbol]` torch/fx/experimental/symbolic_shapes.py:7783:20: error[invalid-return-type] Return type does not match returned value: expected `bool`, found `Basic` torch/fx/experimental/symbolic_shapes.py:7855:56: error[unresolved-attribute] Object of type `Expr` has no attribute `is_integer` +torch/fx/experimental/symbolic_shapes.py:7976:9: error[invalid-method-override] Invalid override of method `_print_Symbol`: Definition is incompatible with `StrPrinter._print_Symbol` torch/fx/experimental/symbolic_shapes.py:7999:22: error[unresolved-attribute] Object of type `Basic` has no attribute `name` torch/fx/experimental/symbolic_shapes.py:7999:59: error[unresolved-attribute] Object of type `Basic` has no attribute `name` torch/fx/experimental/symbolic_shapes.py:8020:25: error[unresolved-attribute] Object of type `Basic` has no attribute `name` @@ -18643,8 +19086,10 @@ torch/fx/graph.py:757:25: error[unresolved-attribute] Object of type `(((...) -> torch/fx/graph.py:762:42: error[unresolved-attribute] Object of type `(((...) -> Any) & (() -> object)) | (str & (() -> object))` has no attribute `__name__` torch/fx/graph.py:770:25: error[unresolved-attribute] Object of type `(((...) -> Any) & (() -> object)) | (str & (() -> object))` has no attribute `__name__` torch/fx/graph.py:773:44: error[unresolved-attribute] Object of type `(((...) -> Any) & (() -> object)) | (str & (() -> object))` has no attribute `__name__` +torch/fx/graph.py:964:9: error[invalid-method-override] Invalid override of method `process_outputs`: Definition is incompatible with `CodeGen.process_outputs` +torch/fx/graph.py:1097:9: error[invalid-method-override] Invalid override of method `process_outputs`: Definition is incompatible with `CodeGen.process_outputs` torch/fx/graph.py:1786:18: error[unresolved-attribute] Object of type `(((...) -> Any) & (() -> object)) | (str & (() -> object))` has no attribute `__name__` -torch/fx/graph.py:2072:12: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/fx/graph.py:2072:12: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/fx/graph_module.py:195:23: warning[unsupported-base] Unsupported class base with type `(Any & ~None) | ` torch/fx/graph_module.py:484:23: error[invalid-assignment] Object of type `type` is not assignable to `type[GraphModule]` torch/fx/graph_module.py:523:17: error[unresolved-attribute] Cannot assign object of type `bool` to attribute `training` on type `Self@__init__` with custom `__setattr__` method. @@ -18699,18 +19144,18 @@ torch/fx/operator_schemas.py:82:10: error[invalid-legacy-type-variable] A `TypeV torch/fx/operator_schemas.py:89:48: error[unresolved-attribute] Module `torch._C` has no member `JitType` torch/fx/operator_schemas.py:99:16: error[unresolved-attribute] Module `torch._C` has no member `FunctionSchema` torch/fx/operator_schemas.py:155:16: error[unresolved-attribute] Module `torch._C` has no member `FunctionSchema` -torch/fx/operator_schemas.py:233:19: error[unresolved-attribute] Module `torch.jit` has no member `_builtins` +torch/fx/operator_schemas.py:233:19: warning[possibly-missing-attribute] Submodule `_builtins` may not be available as an attribute on module `torch.jit` torch/fx/operator_schemas.py:237:19: error[unresolved-attribute] Module `torch._C` has no member `_jit_get_schemas_for_operator` torch/fx/operator_schemas.py:328:51: error[unresolved-attribute] Module `torch` has no member `dtype` torch/fx/operator_schemas.py:382:18: error[invalid-assignment] Object of type `object` is not assignable to `(...) -> Unknown` -torch/fx/passes/_tensorify_python_scalars.py:94:2: error[unresolved-attribute] Module `torch.fx` has no member `_compatibility` +torch/fx/passes/_tensorify_python_scalars.py:94:2: warning[possibly-missing-attribute] Submodule `_compatibility` may not be available as an attribute on module `torch.fx` torch/fx/passes/_tensorify_python_scalars.py:157:25: error[unresolved-attribute] Module `torch` has no member `bool` torch/fx/passes/_tensorify_python_scalars.py:160:25: error[unresolved-attribute] Module `torch` has no member `int64` torch/fx/passes/_tensorify_python_scalars.py:163:25: error[unresolved-attribute] Module `torch` has no member `float64` torch/fx/passes/_tensorify_python_scalars.py:228:46: error[unresolved-attribute] Module `torch` has no member `float64` torch/fx/passes/_tensorify_python_scalars.py:296:46: error[unresolved-attribute] Module `torch` has no member `bool` -torch/fx/passes/dialect/common/cse_pass.py:45:2: error[unresolved-attribute] Module `torch.fx` has no member `_compatibility` -torch/fx/passes/dialect/common/cse_pass.py:50:2: error[unresolved-attribute] Module `torch.fx` has no member `_compatibility` +torch/fx/passes/dialect/common/cse_pass.py:45:2: warning[possibly-missing-attribute] Submodule `_compatibility` may not be available as an attribute on module `torch.fx` +torch/fx/passes/dialect/common/cse_pass.py:50:2: warning[possibly-missing-attribute] Submodule `_compatibility` may not be available as an attribute on module `torch.fx` torch/fx/passes/graph_drawer.py:18:12: error[unresolved-import] Cannot resolve imported module `pydot` torch/fx/passes/graph_drawer.py:349:21: error[unresolved-attribute] Module `torch` has no member `per_tensor_affine` torch/fx/passes/graph_drawer.py:350:21: error[unresolved-attribute] Module `torch` has no member `per_tensor_symmetric` @@ -18729,10 +19174,10 @@ torch/fx/passes/operator_support.py:29:30: error[unresolved-attribute] Module `t torch/fx/passes/operator_support.py:191:44: error[unresolved-attribute] Module `torch` has no member `dtype` torch/fx/passes/pass_manager.py:224:52: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__` torch/fx/passes/pass_manager.py:231:16: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__` -torch/fx/passes/regional_inductor.py:178:10: error[unresolved-attribute] Module `torch.fx` has no member `traceback` +torch/fx/passes/regional_inductor.py:178:10: warning[possibly-missing-attribute] Submodule `traceback` may not be available as an attribute on module `torch.fx` torch/fx/passes/reinplace.py:546:67: error[unresolved-attribute] Module `torch` has no member `TensorType` torch/fx/passes/reinplace.py:567:24: error[unresolved-attribute] Module `torch` has no member `_debug_has_internal_overlap` -torch/fx/passes/reinplace.py:732:64: warning[possibly-missing-attribute] Attribute `meta` may be missing on object of type `Unknown | Divergent | Sequence[Divergent] | ... omitted 14 union elements` +torch/fx/passes/reinplace.py:732:64: warning[possibly-missing-attribute] Attribute `meta` may be missing on object of type `Unknown | Sequence[Divergent] | Mapping[str, Divergent] | ... omitted 13 union elements` torch/fx/passes/runtime_assert.py:149:72: error[unresolved-attribute] Module `torch` has no member `Size` torch/fx/passes/shape_prop.py:25:12: error[unresolved-attribute] Module `torch` has no member `Size` torch/fx/passes/shape_prop.py:26:12: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -18765,7 +19210,7 @@ torch/hub.py:64:10: error[unresolved-import] Cannot resolve imported module `tqd torch/hub.py:885:16: warning[deprecated] The function `_legacy_zip_load` is deprecated: Falling back to the old format < 1.6. This support will be deprecated in favor of default zipfile format introduced in 1.6. Please redo torch.save() to save it in the new zipfile format. torch/jit/__init__.py:117:12: error[unresolved-attribute] Module `torch._C` has no member `_export_opnames` torch/jit/__init__.py:121:9: error[unresolved-attribute] Module `torch._C` has no member `JITException` -torch/jit/__init__.py:259:16: error[unresolved-attribute] Module `torch` has no member `_jit_internal` +torch/jit/__init__.py:259:16: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` torch/jit/__init__.py:284:5: error[unresolved-attribute] Module `torch._C` has no member `_jit_set_llga_enabled` torch/jit/__init__.py:289:12: error[unresolved-attribute] Module `torch._C` has no member `_jit_llga_enabled` torch/jit/__init__.py:294:8: error[unresolved-attribute] Module `torch._C` has no member `_jit_init` @@ -18855,17 +19300,17 @@ torch/jit/_monkeytype_config.py:155:20: error[invalid-return-type] Return type d torch/jit/_passes/_property_propagation.py:11:19: error[unresolved-import] Module `torch` has no member `TensorType` torch/jit/_passes/_property_propagation.py:12:22: error[unresolved-import] Module `torch._C` has no member `Graph` torch/jit/_passes/_property_propagation.py:26:32: error[unresolved-attribute] Module `torch._C` has no member `ClassType` -torch/jit/_recursive.py:58:20: error[unresolved-attribute] Module `torch.jit` has no member `frontend` +torch/jit/_recursive.py:58:20: warning[possibly-missing-attribute] Submodule `frontend` may not be available as an attribute on module `torch.jit` torch/jit/_recursive.py:59:24: error[unresolved-attribute] Module `torch._C` has no member `_jit_script_class_compile` torch/jit/_recursive.py:128:5: error[unresolved-attribute] Module `torch` has no member `device` torch/jit/_recursive.py:129:5: error[unresolved-attribute] Module `torch` has no member `layout` torch/jit/_recursive.py:130:5: error[unresolved-attribute] Module `torch` has no member `dtype` torch/jit/_recursive.py:131:5: error[unresolved-attribute] Module `torch` has no member `qscheme` -torch/jit/_recursive.py:154:21: error[unresolved-attribute] Module `torch._C` has no member `_jit_tree_views` +torch/jit/_recursive.py:154:21: warning[possibly-missing-attribute] Submodule `_jit_tree_views` may not be available as an attribute on module `torch._C` torch/jit/_recursive.py:189:29: error[unresolved-attribute] Module `torch._C` has no member `ConcreteModuleTypeBuilder` -torch/jit/_recursive.py:224:31: error[unresolved-attribute] Module `torch.jit` has no member `annotations` +torch/jit/_recursive.py:224:31: warning[possibly-missing-attribute] Submodule `annotations` may not be available as an attribute on module `torch.jit` torch/jit/_recursive.py:227:29: error[unresolved-attribute] Module `torch._C` has no member `InferredType` -torch/jit/_recursive.py:229:31: error[unresolved-attribute] Module `torch.jit` has no member `annotations` +torch/jit/_recursive.py:229:31: warning[possibly-missing-attribute] Submodule `annotations` may not be available as an attribute on module `torch.jit` torch/jit/_recursive.py:230:29: error[unresolved-attribute] Module `torch._C` has no member `InferredType` torch/jit/_recursive.py:232:29: error[unresolved-attribute] Module `torch._C` has no member `_jit_try_infer_type` torch/jit/_recursive.py:277:33: error[unresolved-attribute] Module `torch._C` has no member `ConcreteModuleType` @@ -18877,17 +19322,19 @@ torch/jit/_recursive.py:526:18: error[unresolved-attribute] Module `torch._C` ha torch/jit/_recursive.py:568:18: error[unresolved-attribute] Module `torch._C` has no member `_create_module_with_type` torch/jit/_recursive.py:594:40: error[unresolved-attribute] Module `torch._C` has no member `InterfaceType` torch/jit/_recursive.py:635:9: error[unresolved-attribute] Module `torch._C` has no member `_run_emit_module_hook` -torch/jit/_recursive.py:781:17: error[unresolved-attribute] Module `torch.jit` has no member `annotations` +torch/jit/_recursive.py:781:17: warning[possibly-missing-attribute] Submodule `annotations` may not be available as an attribute on module `torch.jit` torch/jit/_recursive.py:802:23: error[unresolved-attribute] Module `torch._C` has no member `_replace_overloaded_method_decl` torch/jit/_recursive.py:1006:33: error[unresolved-attribute] Module `torch._C` has no member `ModuleDict` torch/jit/_recursive.py:1008:40: error[unresolved-attribute] Module `torch._C` has no member `ConcreteModuleType` torch/jit/_script.py:32:5: warning[possibly-missing-import] Member `monkeytype_trace` of module `torch.jit._monkeytype_config` may be missing torch/jit/_script.py:64:18: error[unresolved-attribute] Module `torch._C` has no member `ScriptFunction` torch/jit/_script.py:236:26: error[unresolved-attribute] Module `torch._C` has no member `ModuleDict` -torch/jit/_script.py:325:21: error[unresolved-attribute] Module `torch.jit` has no member `_recursive` +torch/jit/_script.py:325:21: warning[possibly-missing-attribute] Submodule `_recursive` may not be available as an attribute on module `torch.jit` torch/jit/_script.py:401:44: error[unresolved-attribute] Module `torch._C` has no member `PyTorchFileReader` torch/jit/_script.py:406:10: error[unresolved-attribute] Module `torch._C` has no member `CompilationUnit` torch/jit/_script.py:407:18: error[unresolved-attribute] Module `torch._C` has no member `_import_ir_module_from_package` +torch/jit/_script.py:548:13: error[invalid-method-override] Invalid override of method `__getattr__`: Definition is incompatible with `Module.__getattr__` +torch/jit/_script.py:553:13: error[invalid-method-override] Invalid override of method `__setattr__`: Definition is incompatible with `Module.__setattr__` torch/jit/_script.py:561:38: error[invalid-argument-type] Argument to function `isinstance` is incorrect: Expected `type | UnionType | tuple[Divergent, ...]`, found `@Todo | (def Attribute(value, type) -> Unknown)` torch/jit/_script.py:593:19: error[unresolved-attribute] Module `torch._C` has no member `_parse_source_def` torch/jit/_script.py:673:13: warning[possibly-missing-attribute] Attribute `_finalize_scriptmodule` may be missing on object of type ` | ` @@ -18896,23 +19343,29 @@ torch/jit/_script.py:682:17: error[unresolved-attribute] Module `torch._C` has n torch/jit/_script.py:699:35: error[unresolved-attribute] Module `torch._C` has no member `ConcreteModuleType` torch/jit/_script.py:705:37: error[unresolved-attribute] Module `torch._C` has no member `ModuleDict` torch/jit/_script.py:717:38: error[unresolved-attribute] Module `torch._C` has no member `ScriptMethod` -torch/jit/_script.py:889:20: error[unresolved-attribute] Module `torch.jit` has no member `_recursive` -torch/jit/_script.py:892:20: error[unresolved-attribute] Module `torch.jit` has no member `_recursive` +torch/jit/_script.py:837:13: error[invalid-method-override] Invalid override of method `__getattr__`: Definition is incompatible with `Module.__getattr__` +torch/jit/_script.py:861:13: error[invalid-method-override] Invalid override of method `__setattr__`: Definition is incompatible with `Module.__setattr__` +torch/jit/_script.py:889:20: warning[possibly-missing-attribute] Submodule `_recursive` may not be available as an attribute on module `torch.jit` +torch/jit/_script.py:892:20: warning[possibly-missing-attribute] Submodule `_recursive` may not be available as an attribute on module `torch.jit` torch/jit/_script.py:949:20: warning[possibly-missing-attribute] Attribute `_construct` may be missing on object of type ` | ` -torch/jit/_script.py:1188:16: error[unresolved-attribute] Module `torch.jit` has no member `_recursive` -torch/jit/_script.py:1189:18: error[unresolved-attribute] Module `torch.jit` has no member `_recursive` +torch/jit/_script.py:1188:16: warning[possibly-missing-attribute] Submodule `_recursive` may not be available as an attribute on module `torch.jit` +torch/jit/_script.py:1189:18: warning[possibly-missing-attribute] Submodule `_recursive` may not be available as an attribute on module `torch.jit` torch/jit/_script.py:1250:14: error[unresolved-attribute] Module `torch._C` has no member `_jit_script_compile` -torch/jit/_script.py:1262:16: error[unresolved-attribute] Module `torch.jit` has no member `_recursive` -torch/jit/_script.py:1513:19: error[unresolved-attribute] Module `torch.jit` has no member `frontend` -torch/jit/_script.py:1523:26: error[unresolved-attribute] Module `torch.jit` has no member `annotations` +torch/jit/_script.py:1262:16: warning[possibly-missing-attribute] Submodule `_recursive` may not be available as an attribute on module `torch.jit` +torch/jit/_script.py:1513:19: warning[possibly-missing-attribute] Submodule `frontend` may not be available as an attribute on module `torch.jit` +torch/jit/_script.py:1523:26: warning[possibly-missing-attribute] Submodule `annotations` may not be available as an attribute on module `torch.jit` torch/jit/_script.py:1533:10: error[unresolved-attribute] Module `torch._C` has no member `_jit_script_compile_overload` torch/jit/_script.py:1652:25: error[unresolved-attribute] Module `torch._C` has no member `_jit_script_interface_compile` torch/jit/_script.py:1663:19: error[unresolved-attribute] Module `torch._C` has no member `CallStack` torch/jit/_script.py:1668:19: error[unresolved-attribute] Module `torch._C` has no member `CompilationUnit` torch/jit/_script.pyi:20:5: warning[possibly-missing-import] Member `monkeytype_trace` of module `torch.jit._monkeytype_config` may be missing torch/jit/_script.pyi:53:18: error[unresolved-attribute] Module `torch._C` has no member `ScriptFunction` +torch/jit/_script.pyi:129:9: error[invalid-method-override] Invalid override of method `__getattr__`: Definition is incompatible with `Module.__getattr__` +torch/jit/_script.pyi:130:9: error[invalid-method-override] Invalid override of method `__setattr__`: Definition is incompatible with `Module.__setattr__` torch/jit/_script.pyi:140:24: error[unresolved-attribute] Module `torch` has no member `Graph` torch/jit/_script.pyi:142:32: error[unresolved-attribute] Module `torch` has no member `Graph` +torch/jit/_script.pyi:168:9: error[invalid-method-override] Invalid override of method `__getattr__`: Definition is incompatible with `Module.__getattr__` +torch/jit/_script.pyi:169:9: error[invalid-method-override] Invalid override of method `__setattr__`: Definition is incompatible with `Module.__setattr__` torch/jit/_script.pyi:205:6: error[unresolved-attribute] Module `torch` has no member `ScriptDict` torch/jit/_script.pyi:213:6: error[unresolved-attribute] Module `torch` has no member `ScriptList` torch/jit/_serialization.py:190:10: error[unresolved-attribute] Module `torch._C` has no member `CompilationUnit` @@ -18955,16 +19408,18 @@ torch/jit/_trace.py:393:13: error[unresolved-attribute] Module `torch._C` has no torch/jit/_trace.py:530:37: error[unresolved-attribute] Module `torch` has no member `cdouble` torch/jit/_trace.py:531:36: error[unresolved-attribute] Module `torch` has no member `cdouble` torch/jit/_trace.py:610:1: error[unresolved-attribute] Module `torch._C` has no member `_tracer_warn_use_python` -torch/jit/_trace.py:625:10: error[unresolved-attribute] Module `torch` has no member `_jit_internal` -torch/jit/_trace.py:626:34: error[unresolved-attribute] Module `torch.jit` has no member `_recursive` -torch/jit/_trace.py:627:16: error[unresolved-attribute] Module `torch.jit` has no member `_recursive` +torch/jit/_trace.py:625:10: warning[possibly-missing-attribute] Submodule `_jit_internal` may not be available as an attribute on module `torch` +torch/jit/_trace.py:626:34: warning[possibly-missing-attribute] Submodule `_recursive` may not be available as an attribute on module `torch.jit` +torch/jit/_trace.py:627:16: warning[possibly-missing-attribute] Submodule `_recursive` may not be available as an attribute on module `torch.jit` torch/jit/_trace.py:664:20: error[unresolved-attribute] Module `torch` has no member `allclose` torch/jit/_trace.py:747:32: error[invalid-argument-type] Argument to class `tuple` is incorrect: Expected `Iterable[object]`, found `(Unknown & ~tuple[object, ...]) | None` torch/jit/_trace.py:760:18: error[unresolved-attribute] Module `torch._C` has no member `_create_function_from_trace_with_dict` torch/jit/_trace.py:770:18: error[unresolved-attribute] Module `torch._C` has no member `_create_function_from_trace` torch/jit/_trace.py:1263:12: error[unresolved-attribute] Module `torch._C` has no member `_is_tracing` torch/jit/_trace.py:1310:17: error[unresolved-attribute] Module `torch._C` has no member `_jit_is_script_object` -torch/jit/_trace.py:1329:25: error[unresolved-attribute] Module `torch.jit` has no member `_recursive` +torch/jit/_trace.py:1329:25: warning[possibly-missing-attribute] Submodule `_recursive` may not be available as an attribute on module `torch.jit` +torch/jit/_trace.py:1341:9: error[invalid-method-override] Invalid override of method `__getattr__`: Definition is incompatible with `Module.__getattr__` +torch/jit/_trace.py:1346:9: error[invalid-method-override] Invalid override of method `__setattr__`: Definition is incompatible with `Module.__setattr__` torch/jit/frontend.py:73:62: warning[possibly-missing-import] Member `monkeytype_trace` of module `torch.jit._monkeytype_config` may be missing torch/jit/frontend.py:156:29: error[unresolved-attribute] Module `torch._C` has no member `ErrorReport` torch/jit/frontend.py:272:14: error[unresolved-attribute] Module `torch._C` has no member `ErrorReport` @@ -18993,33 +19448,33 @@ torch/jit/quantized.py:89:43: error[unresolved-attribute] Module `torch` has no torch/jit/quantized.py:96:40: error[unresolved-attribute] Module `torch` has no member `int8` torch/jit/supported_ops.py:66:38: error[unresolved-attribute] Module `torch._C` has no member `TensorType` torch/jit/supported_ops.py:74:23: error[unresolved-attribute] Module `torch._C` has no member `_jit_get_schemas_for_operator` -torch/jit/supported_ops.py:112:16: error[unresolved-attribute] Module `torch.jit` has no member `_builtins` +torch/jit/supported_ops.py:112:16: warning[possibly-missing-attribute] Submodule `_builtins` may not be available as an attribute on module `torch.jit` torch/jit/supported_ops.py:117:27: error[unresolved-attribute] Module `torch._C` has no member `_jit_get_schemas_for_operator` -torch/jit/supported_ops.py:127:30: error[unresolved-attribute] Module `torch.jit` has no member `_builtins` +torch/jit/supported_ops.py:127:30: warning[possibly-missing-attribute] Submodule `_builtins` may not be available as an attribute on module `torch.jit` torch/jit/supported_ops.py:166:23: error[unresolved-attribute] Module `torch._C` has no member `_jit_get_schemas_for_operator` torch/jit/supported_ops.py:184:23: error[unresolved-attribute] Module `torch._C` has no member `_jit_get_schemas_for_operator` torch/jit/supported_ops.py:274:19: error[unresolved-attribute] Module `torch._C` has no member `_jit_get_schemas_for_operator` torch/jit/unsupported_tensor_ops.py:14:14: error[unresolved-attribute] Module `torch` has no member `tensor` torch/library.py:101:33: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_library` -torch/library.py:107:42: error[unresolved-attribute] Module `torch._library` has no member `utils` +torch/library.py:107:42: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` torch/library.py:155:29: error[unresolved-attribute] Module `torch` has no member `Tag` -torch/library.py:182:18: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:197:17: error[unresolved-attribute] Module `torch._library` has no member `simple_registry` -torch/library.py:226:17: error[unresolved-attribute] Module `torch._library` has no member `simple_registry` +torch/library.py:182:18: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:197:17: warning[possibly-missing-attribute] Submodule `simple_registry` may not be available as an attribute on module `torch._library` +torch/library.py:226:17: warning[possibly-missing-attribute] Submodule `simple_registry` may not be available as an attribute on module `torch._library` torch/library.py:247:16: error[unresolved-attribute] Module `torch` has no member `DispatchKeySet` torch/library.py:247:55: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/library.py:346:16: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` -torch/library.py:543:23: error[unresolved-attribute] Module `torch._library` has no member `utils` +torch/library.py:543:23: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` torch/library.py:718:27: error[unresolved-attribute] Module `torch._C` has no member `_parse_dispatch_key` -torch/library.py:731:24: error[unresolved-attribute] Module `torch._library` has no member `utils` +torch/library.py:731:24: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` torch/library.py:764:12: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_key_for_device` -torch/library.py:782:36: error[unresolved-attribute] Module `torch._library` has no member `custom_ops` -torch/library.py:837:42: error[unresolved-attribute] Module `torch._library` has no member `custom_ops` +torch/library.py:782:36: warning[possibly-missing-attribute] Submodule `custom_ops` may not be available as an attribute on module `torch._library` +torch/library.py:837:42: warning[possibly-missing-attribute] Submodule `custom_ops` may not be available as an attribute on module `torch._library` torch/library.py:844:30: error[invalid-argument-type] Argument to function `_maybe_get_opdef` is incorrect: Expected `CustomOpDef | OpOverload[Unknown, Any] | str`, found `object` -torch/library.py:897:42: error[unresolved-attribute] Module `torch._library` has no member `custom_ops` +torch/library.py:897:42: warning[possibly-missing-attribute] Submodule `custom_ops` may not be available as an attribute on module `torch._library` torch/library.py:907:30: error[invalid-argument-type] Argument to function `_maybe_get_opdef` is incorrect: Expected `CustomOpDef | OpOverload[Unknown, Any] | str`, found `object` -torch/library.py:913:11: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:915:25: error[unresolved-attribute] Module `torch._library` has no member `utils` +torch/library.py:913:11: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:915:25: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` torch/library.py:928:35: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/library.py:929:35: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/library.py:932:27: error[unresolved-attribute] Module `torch._C` has no member `DispatchKeySet` @@ -19027,33 +19482,33 @@ torch/library.py:933:13: error[unresolved-attribute] Module `torch._C` has no me torch/library.py:934:13: error[unresolved-attribute] Module `torch._C` has no member `DispatchKeySet` torch/library.py:934:37: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` torch/library.py:935:14: error[unresolved-attribute] Module `torch._C` has no member `_ExcludeDispatchKeyGuard` -torch/library.py:1051:42: error[unresolved-attribute] Module `torch._library` has no member `custom_ops` +torch/library.py:1051:42: warning[possibly-missing-attribute] Submodule `custom_ops` may not be available as an attribute on module `torch._library` torch/library.py:1056:30: error[invalid-argument-type] Argument to function `_maybe_get_opdef` is incorrect: Expected `CustomOpDef | OpOverload[Unknown, Any] | str`, found `object` -torch/library.py:1067:30: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:1101:42: error[unresolved-attribute] Module `torch._library` has no member `custom_ops` +torch/library.py:1067:30: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:1101:42: warning[possibly-missing-attribute] Submodule `custom_ops` may not be available as an attribute on module `torch._library` torch/library.py:1109:30: error[invalid-argument-type] Argument to function `_maybe_get_opdef` is incorrect: Expected `CustomOpDef | OpOverload[Unknown, Any] | str`, found `object` -torch/library.py:1114:20: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:1215:42: error[unresolved-attribute] Module `torch._library` has no member `custom_ops` +torch/library.py:1114:20: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:1215:42: warning[possibly-missing-attribute] Submodule `custom_ops` may not be available as an attribute on module `torch._library` torch/library.py:1222:30: error[invalid-argument-type] Argument to function `_maybe_get_opdef` is incorrect: Expected `CustomOpDef | OpOverload[Unknown, Any] | str`, found `object` -torch/library.py:1229:10: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:1231:12: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:1237:8: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:1244:12: error[unresolved-attribute] Module `torch._library` has no member `autograd` -torch/library.py:1245:23: error[unresolved-attribute] Module `torch._library` has no member `autograd` -torch/library.py:1246:25: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:1306:42: error[unresolved-attribute] Module `torch._library` has no member `custom_ops` +torch/library.py:1229:10: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:1231:12: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:1237:8: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:1244:12: warning[possibly-missing-attribute] Submodule `autograd` may not be available as an attribute on module `torch._library` +torch/library.py:1245:23: warning[possibly-missing-attribute] Submodule `autograd` may not be available as an attribute on module `torch._library` +torch/library.py:1246:25: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:1306:42: warning[possibly-missing-attribute] Submodule `custom_ops` may not be available as an attribute on module `torch._library` torch/library.py:1313:30: error[invalid-argument-type] Argument to function `_maybe_get_opdef` is incorrect: Expected `CustomOpDef | OpOverload[Unknown, Any] | str`, found `object` -torch/library.py:1319:30: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:1420:42: error[unresolved-attribute] Module `torch._library` has no member `custom_ops` +torch/library.py:1319:30: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:1420:42: warning[possibly-missing-attribute] Submodule `custom_ops` may not be available as an attribute on module `torch._library` torch/library.py:1425:30: error[invalid-argument-type] Argument to function `_maybe_get_opdef` is incorrect: Expected `CustomOpDef | OpOverload[Unknown, Any] | str`, found `object` -torch/library.py:1430:10: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:1432:8: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:1442:29: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:1475:14: error[unresolved-attribute] Module `torch._library` has no member `utils` +torch/library.py:1430:10: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:1432:8: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:1442:29: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:1475:14: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` torch/library.py:1480:24: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_pystub` -torch/library.py:1484:16: error[unresolved-attribute] Module `torch._library` has no member `utils` -torch/library.py:1518:19: error[unresolved-attribute] Module `torch._library` has no member `fake_impl` -torch/library.py:1524:12: error[unresolved-attribute] Module `torch._library` has no member `fake_impl` +torch/library.py:1484:16: warning[possibly-missing-attribute] Submodule `utils` may not be available as an attribute on module `torch._library` +torch/library.py:1518:19: warning[possibly-missing-attribute] Submodule `fake_impl` may not be available as an attribute on module `torch._library` +torch/library.py:1524:12: warning[possibly-missing-attribute] Submodule `fake_impl` may not be available as an attribute on module `torch._library` torch/library.py:1528:50: error[unresolved-attribute] Module `torch` has no member `DispatchKey` torch/library.py:1529:6: error[unresolved-attribute] Module `torch._C` has no member `_SafeKernelFunction` torch/library.py:1594:28: error[unresolved-attribute] Module `torch._C` has no member `DispatchKey` @@ -19367,7 +19822,7 @@ torch/multiprocessing/reductions.py:494:30: error[unresolved-attribute] Module ` torch/multiprocessing/reductions.py:494:48: error[unresolved-attribute] Module `torch` has no member `sparse_bsr` torch/multiprocessing/reductions.py:497:32: error[unresolved-attribute] Module `torch` has no member `sparse_csc` torch/multiprocessing/reductions.py:497:50: error[unresolved-attribute] Module `torch` has no member `sparse_bsc` -torch/multiprocessing/reductions.py:619:14: error[unresolved-attribute] Module `multiprocessing` has no member `reduction` +torch/multiprocessing/reductions.py:619:14: warning[possibly-missing-attribute] Submodule `reduction` may not be available as an attribute on module `multiprocessing` torch/nativert/backends/_lower_utils.py:22:13: error[unresolved-attribute] Cannot assign object of type `TreeSpec` to attribute `in_spec` on type `Self@__init__` with custom `__setattr__` method. torch/nativert/backends/_lower_utils.py:23:13: error[unresolved-attribute] Cannot assign object of type `TreeSpec` to attribute `out_spec` on type `Self@__init__` with custom `__setattr__` method. torch/nativert/backends/_lower_utils.py:79:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[ExportedProgram, list[str | Weights] | dict[str, list[str | Weights]]]`, found `tuple[ExportedProgram, list[str | Weights] | (GraphModule & Top[list[Unknown]])]` @@ -19475,8 +19930,8 @@ torch/nested/_internal/ops.py:2728:21: error[unresolved-attribute] Module `torch torch/nested/_internal/ops.py:2732:22: error[unresolved-attribute] Module `torch` has no member `matmul` torch/nested/_internal/sdpa.py:352:52: error[unresolved-attribute] Module `torch` has no member `int32` torch/nested/_internal/sdpa.py:358:46: error[unresolved-attribute] Module `torch` has no member `int32` -torch/nested/_internal/sdpa.py:657:13: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` -torch/nested/_internal/sdpa.py:660:24: error[unresolved-attribute] Module `torch.utils` has no member `flop_counter` +torch/nested/_internal/sdpa.py:657:13: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` +torch/nested/_internal/sdpa.py:660:24: warning[possibly-missing-attribute] Submodule `flop_counter` may not be available as an attribute on module `torch.utils` torch/nested/_internal/sdpa.py:694:47: error[unresolved-attribute] Module `torch` has no member `is_autocast_enabled` torch/nested/_internal/sdpa.py:700:24: error[unresolved-attribute] Module `torch` has no member `get_autocast_dtype` torch/nested/_internal/sdpa.py:704:27: error[unresolved-attribute] Module `torch` has no member `float64` @@ -19662,8 +20117,8 @@ torch/nn/modules/activation.py:916:9: error[unresolved-attribute] Cannot assign torch/nn/modules/activation.py:993:9: error[unresolved-attribute] Cannot assign object of type `int | float` to attribute `beta` on type `Self@__init__` with custom `__setattr__` method. torch/nn/modules/activation.py:994:9: error[unresolved-attribute] Cannot assign object of type `int | float` to attribute `threshold` on type `Self@__init__` with custom `__setattr__` method. torch/nn/modules/activation.py:1041:9: error[unresolved-attribute] Cannot assign object of type `int | float` to attribute `lambd` on type `Self@__init__` with custom `__setattr__` method. -torch/nn/modules/activation.py:1075:13: error[unresolved-attribute] Module `torch.utils` has no member `_python_dispatch` -torch/nn/modules/activation.py:1080:28: error[unresolved-attribute] Module `torch.fx.experimental` has no member `proxy_tensor` +torch/nn/modules/activation.py:1075:13: warning[possibly-missing-attribute] Submodule `_python_dispatch` may not be available as an attribute on module `torch.utils` +torch/nn/modules/activation.py:1080:28: warning[possibly-missing-attribute] Submodule `proxy_tensor` may not be available as an attribute on module `torch.fx.experimental` torch/nn/modules/activation.py:1189:9: error[unresolved-attribute] Cannot assign object of type `Unknown | float` to attribute `dropout` on type `Self@__init__` with custom `__setattr__` method. torch/nn/modules/activation.py:1190:9: error[unresolved-attribute] Cannot assign object of type `Unknown | Literal[False]` to attribute `batch_first` on type `Self@__init__` with custom `__setattr__` method. torch/nn/modules/activation.py:1198:17: error[unresolved-attribute] Module `torch` has no member `empty` @@ -19968,7 +20423,6 @@ torch/nn/modules/upsampling.py:166:13: error[unresolved-attribute] Cannot assign torch/nn/modules/upsampling.py:167:9: error[unresolved-attribute] Cannot assign object of type `str` to attribute `mode` on type `Self@__init__` with custom `__setattr__` method. torch/nn/modules/upsampling.py:168:9: error[unresolved-attribute] Cannot assign object of type `bool | None` to attribute `align_corners` on type `Self@__init__` with custom `__setattr__` method. torch/nn/modules/upsampling.py:169:9: error[unresolved-attribute] Cannot assign object of type `bool | None` to attribute `recompute_scale_factor` on type `Self@__init__` with custom `__setattr__` method. -torch/nn/modules/utils.py:12:26: error[unresolved-attribute] Module `collections` has no member `abc` torch/nn/modules/utils.py:72:21: error[unresolved-attribute] Object of type `object` has no attribute `keys` torch/nn/modules/utils.py:83:17: error[invalid-assignment] Cannot assign to a subscript on an object of type `object` torch/nn/modules/utils.py:83:48: error[unresolved-attribute] Object of type `object` has no attribute `pop` @@ -19998,7 +20452,7 @@ torch/nn/parallel/data_parallel.py:218:57: error[unresolved-attribute] Module `t torch/nn/parallel/data_parallel.py:225:32: error[unresolved-attribute] Module `torch` has no member `device` torch/nn/parallel/data_parallel.py:226:26: error[unresolved-attribute] Module `torch` has no member `device` torch/nn/parallel/data_parallel.py:264:22: error[unresolved-attribute] Module `torch` has no member `device` -torch/nn/parallel/distributed.py:43:4: error[unresolved-attribute] Module `torch.distributed` has no member `rpc` +torch/nn/parallel/distributed.py:43:4: warning[possibly-missing-attribute] Submodule `rpc` may not be available as an attribute on module `torch.distributed` torch/nn/parallel/distributed.py:45:39: warning[possibly-missing-import] Member `RRef` of module `torch.distributed.rpc` may be missing torch/nn/parallel/distributed.py:90:18: error[unresolved-attribute] Module `torch` has no member `dtype` torch/nn/parallel/distributed.py:91:19: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -20039,8 +20493,8 @@ torch/nn/parallel/distributed.py:915:31: error[unresolved-attribute] Module `tor torch/nn/parallel/distributed.py:927:9: error[unresolved-attribute] Cannot assign object of type `Literal[False]` to attribute `_has_rebuilt_buckets` on type `Self@__init__` with custom `__setattr__` method. torch/nn/parallel/distributed.py:932:9: error[unresolved-attribute] Cannot assign object of type `Literal[False]` to attribute `_lazy_init_ran` on type `Self@__init__` with custom `__setattr__` method. torch/nn/parallel/distributed.py:940:13: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `_fuse_ddp_communication` of type `Literal[False]` -torch/nn/parallel/distributed.py:944:13: error[unresolved-attribute] Module `torch._dynamo` has no member `trace_rules` -torch/nn/parallel/distributed.py:947:13: error[unresolved-attribute] Module `torch._dynamo` has no member `trace_rules` +torch/nn/parallel/distributed.py:944:13: warning[possibly-missing-attribute] Submodule `trace_rules` may not be available as an attribute on module `torch._dynamo` +torch/nn/parallel/distributed.py:947:13: warning[possibly-missing-attribute] Submodule `trace_rules` may not be available as an attribute on module `torch._dynamo` torch/nn/parallel/distributed.py:952:9: error[unresolved-attribute] Cannot assign object of type `Literal[True]` to attribute `_ddp_sink_clone` on type `Self@__init__` with custom `__setattr__` method. torch/nn/parallel/distributed.py:972:41: warning[possibly-missing-attribute] Attribute `size` may be missing on object of type `Unknown | ProcessGroup | None` torch/nn/parallel/distributed.py:973:61: error[invalid-argument-type] Argument to function `all_reduce` is incorrect: Expected `list[int] | list[list[int]] | ProcessGroup | ... omitted 3 union elements`, found `Unknown | ProcessGroup | None` @@ -20052,7 +20506,7 @@ torch/nn/parallel/distributed.py:1012:9: warning[possibly-missing-attribute] Mem torch/nn/parallel/distributed.py:1012:35: error[invalid-argument-type] Argument to function `_broadcast_coalesced` is incorrect: Expected `ProcessGroup`, found `Unknown | ProcessGroup | None` torch/nn/parallel/distributed.py:1036:9: error[unresolved-attribute] Cannot assign object of type `Literal[True]` to attribute `_delay_all_reduce_all_params` on type `Self@_register_delay_all_reduce_hook` with custom `__setattr__` method. torch/nn/parallel/distributed.py:1050:13: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` -torch/nn/parallel/distributed.py:1055:17: error[unresolved-attribute] Module `torch.distributed` has no member `optim` +torch/nn/parallel/distributed.py:1055:17: warning[possibly-missing-attribute] Submodule `optim` may not be available as an attribute on module `torch.distributed` torch/nn/parallel/distributed.py:1125:30: error[unresolved-attribute] Module `torch` has no member `Event` torch/nn/parallel/distributed.py:1204:21: warning[possibly-missing-attribute] Member `_DEFAULT_FIRST_BUCKET_BYTES` may be missing on module `torch.distributed` torch/nn/parallel/distributed.py:1212:13: warning[possibly-missing-attribute] Member `_compute_bucket_assignment_by_size` may be missing on module `torch.distributed` @@ -20091,7 +20545,7 @@ torch/nn/parallel/distributed.py:2165:23: error[unresolved-attribute] Module `to torch/nn/parallel/distributed.py:2169:9: warning[possibly-missing-attribute] Member `all_reduce` may be missing on module `torch.distributed` torch/nn/parallel/distributed.py:2239:56: warning[possibly-missing-attribute] Member `GradBucket` may be missing on module `torch.distributed` torch/nn/parallel/distributed.py:2261:21: warning[possibly-missing-attribute] Member `is_nccl_available` may be missing on module `torch.distributed` -torch/nn/parallel/distributed.py:2262:21: error[unresolved-attribute] Module `torch.cuda` has no member `nccl` +torch/nn/parallel/distributed.py:2262:21: warning[possibly-missing-attribute] Submodule `nccl` may not be available as an attribute on module `torch.cuda` torch/nn/parallel/distributed.py:2266:21: warning[possibly-missing-attribute] Member `is_xccl_available` may be missing on module `torch.distributed` torch/nn/parallel/distributed.py:2278:16: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/nn/parallel/distributed.py:2372:9: error[unresolved-attribute] Cannot assign object of type `Literal[True]` to attribute `static_graph` on type `Self@_set_static_graph` with custom `__setattr__` method. @@ -20193,7 +20647,6 @@ torch/nn/utils/parametrizations.py:520:35: error[unresolved-attribute] Module `t torch/nn/utils/parametrize.py:133:9: error[unresolved-attribute] Cannot assign object of type `bool` to attribute `unsafe` on type `Self@__init__` with custom `__setattr__` method. torch/nn/utils/parametrize.py:176:9: error[unresolved-attribute] Cannot assign object of type `bool` to attribute `is_tensor` on type `Self@__init__` with custom `__setattr__` method. torch/nn/utils/parametrize.py:177:9: error[unresolved-attribute] Cannot assign object of type `int` to attribute `ntensors` on type `Self@__init__` with custom `__setattr__` method. -torch/nn/utils/parametrize.py:283:42: error[unresolved-attribute] Module `collections` has no member `abc` torch/nn/utils/parametrize.py:371:5: error[unresolved-attribute] Cannot assign object of type `type` to attribute `__class__` on type `Module` with custom `__setattr__` method. torch/nn/utils/parametrize.py:759:9: error[unresolved-attribute] Cannot assign object of type `type` to attribute `__class__` on type `Module` with custom `__setattr__` method. torch/nn/utils/prune.py:171:28: error[unresolved-attribute] Module `torch` has no member `ones_like` @@ -20211,11 +20664,9 @@ torch/nn/utils/prune.py:631:20: error[unresolved-attribute] Module `torch` has n torch/nn/utils/prune.py:735:16: error[unresolved-attribute] Module `torch` has no member `topk` torch/nn/utils/prune.py:743:20: error[unresolved-attribute] Module `torch` has no member `zeros_like` torch/nn/utils/prune.py:1115:45: error[unresolved-attribute] Module `torch` has no member `ones_like` -torch/nn/utils/rnn.py:95:16: error[invalid-return-type] Return type does not match returned value: expected `Self@pin_memory`, found `PackedSequence` torch/nn/utils/rnn.py:105:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/nn/utils/rnn.py:113:23: error[unresolved-attribute] Module `torch` has no member `device` torch/nn/utils/rnn.py:114:16: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/nn/utils/rnn.py:156:20: error[invalid-return-type] Return type does not match returned value: expected `Self@to`, found `PackedSequence` torch/nn/utils/rnn.py:160:14: error[unresolved-attribute] Module `torch` has no member `tensor` torch/nn/utils/rnn.py:169:14: error[unresolved-attribute] Module `torch` has no member `tensor` torch/nn/utils/rnn.py:178:30: error[unresolved-attribute] Module `torch` has no member `double` @@ -20263,8 +20714,8 @@ torch/onnx/_internal/exporter/_building.py:20:6: error[unresolved-import] Cannot torch/onnx/_internal/exporter/_building.py:21:6: error[unresolved-import] Cannot resolve imported module `onnxscript.ir` torch/onnx/_internal/exporter/_building.py:28:12: error[unresolved-import] Cannot resolve imported module `onnx` torch/onnx/_internal/exporter/_capture_strategies.py:52:5: error[invalid-assignment] Implicit shadowing of function `isinstance` -torch/onnx/_internal/exporter/_capture_strategies.py:172:20: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` -torch/onnx/_internal/exporter/_capture_strategies.py:227:20: error[unresolved-attribute] Module `torch._dynamo` has no member `exc` +torch/onnx/_internal/exporter/_capture_strategies.py:172:20: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` +torch/onnx/_internal/exporter/_capture_strategies.py:227:20: warning[possibly-missing-attribute] Submodule `exc` may not be available as an attribute on module `torch._dynamo` torch/onnx/_internal/exporter/_core.py:18:8: error[unresolved-import] Cannot resolve imported module `onnxscript` torch/onnx/_internal/exporter/_core.py:19:8: error[unresolved-import] Cannot resolve imported module `onnxscript.evaluator` torch/onnx/_internal/exporter/_core.py:20:6: error[unresolved-import] Cannot resolve imported module `onnxscript` @@ -20406,9 +20857,11 @@ torch/onnx/_internal/fx/_pass.py:211:20: warning[possibly-missing-attribute] Mem torch/onnx/_internal/fx/passes/type_promotion.py:53:31: error[unresolved-attribute] Module `torch` has no member `dtype` torch/onnx/_internal/fx/passes/type_promotion.py:56:33: error[unresolved-attribute] Module `torch` has no member `dtype` torch/onnx/_internal/fx/passes/type_promotion.py:59:16: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/onnx/_internal/fx/passes/type_promotion.py:153:9: error[invalid-method-override] Invalid override of method `__eq__`: Definition is incompatible with `TypePromotionRule.__eq__` torch/onnx/_internal/fx/passes/type_promotion.py:168:31: error[unresolved-attribute] Module `torch` has no member `dtype` torch/onnx/_internal/fx/passes/type_promotion.py:168:58: error[unresolved-attribute] Module `torch` has no member `dtype` torch/onnx/_internal/fx/passes/type_promotion.py:169:10: error[unresolved-attribute] Module `torch` has no member `dtype` +torch/onnx/_internal/fx/passes/type_promotion.py:270:9: error[invalid-method-override] Invalid override of method `__eq__`: Definition is incompatible with `TypePromotionRule.__eq__` torch/onnx/_internal/fx/passes/type_promotion.py:290:16: error[unresolved-attribute] Module `torch` has no member `dtype` torch/onnx/_internal/fx/passes/type_promotion.py:329:29: error[unresolved-attribute] Module `torch` has no member `bool` torch/onnx/_internal/fx/passes/type_promotion.py:331:24: error[unresolved-attribute] Module `torch` has no member `uint8` @@ -22004,17 +22457,17 @@ torch/optim/swa_utils.py:333:33: error[unresolved-attribute] Module `torch` has torch/package/package_exporter.py:219:9: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` torch/package/package_exporter.py:227:25: error[unresolved-attribute] Module `torch._C` has no member `PyTorchFileWriter` torch/package/package_exporter.py:239:41: error[unresolved-attribute] Module `torch._C` has no member `ScriptModuleSerializer` -torch/package/package_exporter.py:252:41: error[unresolved-attribute] Module `collections` has no member `abc` torch/package/package_importer.py:88:41: error[unresolved-attribute] Module `torch._C` has no member `PyTorchFileReader` torch/package/package_importer.py:104:9: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` torch/package/package_importer.py:107:39: error[unresolved-attribute] Module `torch._C` has no member `PyTorchFileReader` torch/package/package_importer.py:113:35: error[unresolved-attribute] Module `torch._C` has no member `PyTorchFileReader` torch/package/package_importer.py:118:31: error[unresolved-attribute] Module `torch._C` has no member `PyTorchFileReader` torch/package/package_importer.py:120:9: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_metadata` +torch/package/package_importer.py:157:9: error[invalid-method-override] Invalid override of method `import_module`: Definition is incompatible with `Importer.import_module` torch/package/package_importer.py:231:27: error[unresolved-attribute] Module `torch._C` has no member `DeserializationStorageContext` torch/package/package_importer.py:242:48: error[unresolved-attribute] Module `torch._C` has no member `PyTorchFileReader` torch/package/package_importer.py:255:29: error[unresolved-attribute] Module `torch` has no member `uint8` -torch/package/package_importer.py:374:18: error[unresolved-attribute] Module `importlib` has no member `util` +torch/package/package_importer.py:374:18: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` torch/package/package_importer.py:733:1: error[invalid-assignment] Implicit shadowing of function `getfile` torch/profiler/_memory_profiler.py:11:22: error[unresolved-import] Module `torch._C` has no member `FunctionSchema` torch/profiler/_memory_profiler.py:67:13: error[unresolved-attribute] Module `torch` has no member `device` @@ -22093,13 +22546,14 @@ torch/profiler/_utils.py:331:69: error[unresolved-attribute] Module `torch` has torch/profiler/_utils.py:332:44: error[unresolved-attribute] Module `torch` has no member `mean` torch/profiler/_utils.py:332:69: error[unresolved-attribute] Module `torch` has no member `std` torch/profiler/profiler.py:17:22: error[unresolved-import] Module `torch._C` has no member `_get_privateuse1_backend_name` +torch/profiler/profiler.py:48:9: error[invalid-method-override] Invalid override of method `default`: Definition is incompatible with `JSONEncoder.default` torch/profiler/profiler.py:382:43: warning[possibly-missing-attribute] Member `is_initialized` may be missing on module `torch.distributed` torch/profiler/profiler.py:385:19: warning[possibly-missing-attribute] Member `get_backend` may be missing on module `torch.distributed` torch/profiler/profiler.py:388:21: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/profiler/profiler.py:389:27: warning[possibly-missing-attribute] Member `get_world_size` may be missing on module `torch.distributed` torch/profiler/profiler.py:390:25: warning[possibly-missing-attribute] Member `get_pg_count` may be missing on module `torch.distributed` torch/profiler/profiler.py:391:26: warning[possibly-missing-attribute] Member `distributed_c10d` may be missing on module `torch.distributed` -torch/profiler/profiler.py:394:28: error[unresolved-attribute] Module `torch.cuda` has no member `nccl` +torch/profiler/profiler.py:394:28: warning[possibly-missing-attribute] Submodule `nccl` may not be available as an attribute on module `torch.cuda` torch/profiler/profiler.py:1157:17: warning[possibly-missing-attribute] Member `is_initialized` may be missing on module `torch.distributed` torch/profiler/profiler.py:1159:30: warning[possibly-missing-attribute] Member `distributed_c10d` may be missing on module `torch.distributed` torch/profiler/python_tracer.py:14:28: error[no-matching-overload] No overload of function `dirname` matches arguments @@ -22242,11 +22696,11 @@ torch/serialization.py:1528:44: error[invalid-argument-type] Argument to functio torch/serialization.py:1585:30: error[unresolved-attribute] Module `torch` has no member `layout` torch/serialization.py:1592:16: error[unresolved-attribute] Module `torch` has no member `layout` torch/serialization.py:1728:30: error[unresolved-attribute] Module `torch` has no member `empty` -torch/serialization.py:1759:20: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/serialization.py:1836:8: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/serialization.py:1759:20: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/serialization.py:1836:8: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/serialization.py:1881:35: error[unresolved-attribute] Module `torch` has no member `device` -torch/serialization.py:2025:12: error[unresolved-attribute] Module `torch` has no member `_guards` -torch/serialization.py:2072:12: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/serialization.py:2025:12: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` +torch/serialization.py:2072:12: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/serialization.py:2099:21: error[unresolved-attribute] Module `torch` has no member `uint8` torch/serialization.py:2147:5: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_metadata` torch/signal/windows/windows.py:64:40: error[unresolved-attribute] Module `torch` has no member `dtype` @@ -22629,7 +23083,6 @@ torch/storage.py:614:22: error[unresolved-attribute] Module `torch` has no membe torch/storage.py:665:30: error[unresolved-attribute] Module `torch._C` has no member `_get_privateuse1_backend_name` torch/storage.py:674:29: error[unresolved-attribute] Module `torch` has no member `device` torch/storage.py:676:12: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/storage.py:741:49: error[unresolved-attribute] Module `collections` has no member `abc` torch/storage.py:817:38: error[unresolved-attribute] Module `torch` has no member `dtype` torch/storage.py:840:26: error[unresolved-attribute] Module `torch` has no member `get_default_dtype` torch/storage.py:841:22: error[unresolved-attribute] Module `torch` has no member `device` @@ -22638,8 +23091,6 @@ torch/storage.py:845:17: error[unresolved-attribute] Module `torch` has no membe torch/storage.py:846:17: error[unresolved-attribute] Module `torch` has no member `quint2x4` torch/storage.py:847:17: error[unresolved-attribute] Module `torch` has no member `qint32` torch/storage.py:848:17: error[unresolved-attribute] Module `torch` has no member `qint8` -torch/storage.py:863:42: error[unresolved-attribute] Module `collections` has no member `abc` -torch/storage.py:902:20: error[invalid-return-type] Return type does not match returned value: expected `Self@_new_wrapped_storage`, found `TypedStorage` torch/storage.py:944:13: error[unresolved-attribute] Module `torch` has no member `quint8` torch/storage.py:945:13: error[unresolved-attribute] Module `torch` has no member `quint4x2` torch/storage.py:946:13: error[unresolved-attribute] Module `torch` has no member `quint2x4` @@ -22781,7 +23232,7 @@ torch/testing/_comparison.py:1037:25: error[unresolved-attribute] Module `torch` torch/testing/_comparison.py:1084:19: error[unresolved-attribute] Module `torch` has no member `isclose` torch/testing/_comparison.py:1087:12: error[unresolved-attribute] Module `torch` has no member `all` torch/testing/_comparison.py:1090:28: error[unresolved-attribute] Module `torch` has no member `Size` -torch/testing/_comparison.py:1323:19: error[invalid-assignment] Object of type `list[Unknown | list[ErrorMeta]]` is not assignable to `list[ErrorMeta]` +torch/testing/_comparison.py:1323:19: error[invalid-assignment] Object of type `list[ErrorMeta | list[ErrorMeta]]` is not assignable to `list[ErrorMeta]` torch/testing/_comparison.py:1325:12: error[invalid-return-type] Return type does not match returned value: expected `list[ErrorMeta]`, found `ErrorMeta` torch/testing/_comparison.py:1625:18: error[unresolved-attribute] Module `torch` has no member `tensor` torch/testing/_comparison.py:1627:20: error[unresolved-attribute] Module `torch` has no member `tensor` @@ -22828,9 +23279,9 @@ torch/testing/_creation.py:249:31: error[unresolved-attribute] Module `torch` ha torch/testing/_creation.py:253:18: error[unresolved-attribute] Module `torch` has no member `empty` torch/testing/_creation.py:253:58: error[unresolved-attribute] Module `torch` has no member `float32` torch/testing/_creation.py:270:59: error[unresolved-attribute] Module `torch` has no member `finfo` -torch/testing/_utils.py:34:10: error[unresolved-attribute] Module `torch.utils` has no member `_mode_utils` +torch/testing/_utils.py:34:10: warning[possibly-missing-attribute] Submodule `_mode_utils` may not be available as an attribute on module `torch.utils` torch/testing/_utils.py:34:49: error[unresolved-attribute] Module `torch._C` has no member `_DisableFuncTorch` -torch/testing/_utils.py:49:14: error[unresolved-attribute] Module `torch.utils` has no member `_mode_utils` +torch/testing/_utils.py:49:14: warning[possibly-missing-attribute] Submodule `_mode_utils` may not be available as an attribute on module `torch.utils` torch/testing/_utils.py:49:53: error[unresolved-attribute] Module `torch._C` has no member `_DisableFuncTorch` torch/torch_version.py:5:6: error[unresolved-import] Cannot resolve imported module `torch.version` torch/types.py:20:5: error[unresolved-import] Module `torch` has no member `device` @@ -22938,6 +23389,9 @@ torch/utils/_foreach_utils.py:57:57: error[unresolved-attribute] Module `torch` torch/utils/_functools.py:30:37: error[unresolved-attribute] Object of type `(...) -> _T@cache_method` has no attribute `__name__` torch/utils/_import_utils.py:30:12: error[unresolved-import] Cannot resolve imported module `dill` torch/utils/_mode_utils.py:15:15: error[unresolved-attribute] Module `torch._C` has no member `_DisableTorchDispatch` +torch/utils/_ordered_set.py:39:9: error[invalid-method-override] Invalid override of method `__contains__`: Definition is incompatible with `AbstractSet.__contains__` +torch/utils/_ordered_set.py:51:9: error[invalid-method-override] Invalid override of method `add`: Definition is incompatible with `MutableSet.add` +torch/utils/_ordered_set.py:54:9: error[invalid-method-override] Invalid override of method `discard`: Definition is incompatible with `MutableSet.discard` torch/utils/_ordered_set.py:142:13: error[no-matching-overload] No overload of bound method `update` matches arguments torch/utils/_ordered_set.py:142:13: error[no-matching-overload] No overload of bound method `update` matches arguments torch/utils/_ordered_set.py:142:13: error[no-matching-overload] No overload of bound method `update` matches arguments @@ -22963,7 +23417,7 @@ torch/utils/_python_dispatch.py:318:32: error[unresolved-attribute] Module `torc torch/utils/_python_dispatch.py:324:35: error[unresolved-attribute] Module `torch._C` has no member `_TorchDispatchModeKey` torch/utils/_python_dispatch.py:414:12: error[unresolved-attribute] Module `torch._C` has no member `Size` torch/utils/_python_dispatch.py:439:24: error[unresolved-attribute] Module `torch` has no member `memory_format` -torch/utils/_python_dispatch.py:445:17: error[unresolved-attribute] Module `torch` has no member `_prims_common` +torch/utils/_python_dispatch.py:445:17: warning[possibly-missing-attribute] Submodule `_prims_common` may not be available as an attribute on module `torch` torch/utils/_python_dispatch.py:450:24: error[unresolved-attribute] Module `torch` has no member `memory_format` torch/utils/_python_dispatch.py:460:24: error[unresolved-attribute] Module `torch` has no member `memory_format` torch/utils/_python_dispatch.py:610:17: error[unresolved-attribute] Module `torch` has no member `_functionalize_unsafe_set` @@ -22972,10 +23426,11 @@ torch/utils/_python_dispatch.py:753:28: error[unresolved-attribute] Module `torc torch/utils/_python_dispatch.py:797:27: error[unresolved-attribute] Module `torch._C` has no member `_parse_dispatch_key` torch/utils/_python_dispatch.py:798:17: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_key_for_device` torch/utils/_python_dispatch.py:804:40: error[unresolved-attribute] Module `torch._C` has no member `_dispatch_has_kernel_for_dispatch_key` -torch/utils/_python_dispatch.py:882:18: error[unresolved-attribute] Module `torch.utils` has no member `_mode_utils` +torch/utils/_python_dispatch.py:882:18: warning[possibly-missing-attribute] Submodule `_mode_utils` may not be available as an attribute on module `torch.utils` torch/utils/_python_dispatch.py:885:31: error[unresolved-attribute] Module `torch._C` has no member `_meta_in_tls_dispatch_include` torch/utils/_python_dispatch.py:886:17: error[unresolved-attribute] Module `torch._C` has no member `_set_meta_in_tls_dispatch_include` torch/utils/_python_dispatch.py:890:21: error[unresolved-attribute] Module `torch._C` has no member `_set_meta_in_tls_dispatch_include` +torch/utils/_pytree.py:111:9: error[invalid-method-override] Invalid override of method `default`: Definition is incompatible with `JSONEncoder.default` torch/utils/_pytree.py:357:21: error[not-iterable] Object of type `list[str] | None` may not be iterable torch/utils/_pytree.py:719:9: error[invalid-parameter-default] Default value of type `EllipsisType` is not assignable to annotated parameter type `dict[str, Any]` torch/utils/_pytree.py:766:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[list[tuple[KeyEntry, T@_tuple_flatten_with_keys]], Any]`, found `tuple[list[tuple[SequenceKey[Unknown], T@_tuple_flatten_with_keys] | Unknown], Any]` @@ -22985,7 +23440,7 @@ torch/utils/_pytree.py:812:12: error[invalid-return-type] Return type does not m torch/utils/_pytree.py:865:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[list[tuple[KeyEntry, T@_ordereddict_flatten_with_keys]], Any]`, found `tuple[list[tuple[MappingKey[Unknown, Unknown], Unknown] | Unknown], Any]` torch/utils/_pytree.py:890:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[list[tuple[KeyEntry, T@_defaultdict_flatten_with_keys]], Any]`, found `tuple[list[tuple[MappingKey[Unknown, Unknown], Unknown] | Unknown], Any]` torch/utils/_pytree.py:949:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[list[tuple[KeyEntry, T@_deque_flatten_with_keys]], Any]`, found `tuple[list[tuple[SequenceKey[Unknown], T@_deque_flatten_with_keys] | Unknown], Any]` -torch/utils/_pytree.py:1012:34: error[invalid-assignment] Object of type `frozenset[Unknown | | | ... omitted 5 union elements]` is not assignable to `frozenset[type]` +torch/utils/_pytree.py:1012:34: error[invalid-assignment] Object of type `frozenset[type | Unknown | ((typename: str, field_names: Iterable[str], *, rename: bool = Literal[False], module: str | None = None, defaults: Iterable[Any] | None = None) -> type[tuple[Unknown, ...]])]` is not assignable to `frozenset[type]` torch/utils/_pytree.py:1119:30: error[unresolved-attribute] Object of type `typing.Self` has no attribute `num_nodes` torch/utils/_pytree.py:1120:31: error[unresolved-attribute] Object of type `typing.Self` has no attribute `num_leaves` torch/utils/_pytree.py:1131:62: error[too-many-positional-arguments] Too many positional arguments to bound method `__repr__`: expected 1, got 2 @@ -23005,13 +23460,34 @@ torch/utils/_stats.py:28:68: error[unresolved-attribute] Object of type `(...) - torch/utils/_strobelight/examples/cli_function_profiler_example.py:22:20: error[unresolved-attribute] Module `torch` has no member `rand` torch/utils/_strobelight/examples/cli_function_profiler_example.py:22:38: error[unresolved-attribute] Module `torch` has no member `rand` torch/utils/_strobelight/examples/cli_function_profiler_example.py:22:56: error[unresolved-attribute] Module `torch` has no member `rand` +torch/utils/_sympy/functions.py:219:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:323:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:402:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:418:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` torch/utils/_sympy/functions.py:440:16: error[unresolved-attribute] Object of type `Expr` has no attribute `is_even` torch/utils/_sympy/functions.py:442:16: error[unresolved-attribute] Object of type `Expr` has no attribute `is_odd` torch/utils/_sympy/functions.py:476:27: error[unresolved-attribute] Object of type `Basic` has no attribute `is_positive` +torch/utils/_sympy/functions.py:489:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:548:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` torch/utils/_sympy/functions.py:559:53: error[unresolved-attribute] Object of type `Basic` has no attribute `precedence` +torch/utils/_sympy/functions.py:567:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:598:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:608:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:873:9: error[invalid-method-override] Invalid override of method `_new_args_filter`: Definition is incompatible with `LatticeOp._new_args_filter` +torch/utils/_sympy/functions.py:1071:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:1098:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:1120:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:1145:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:1242:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:1255:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:1270:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:1300:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:1311:9: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` torch/utils/_sympy/functions.py:1353:20: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `Basic` torch/utils/_sympy/functions.py:1357:22: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | Buffer | SupportsFloat | SupportsIndex`, found `Basic` -torch/utils/_sympy/interp.py:103:9: error[unresolved-attribute] Module `sympy.functions.elementary` has no member `piecewise` +torch/utils/_sympy/functions.py:1376:13: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/functions.py:1441:13: error[invalid-method-override] Invalid override of method `eval`: Definition is incompatible with `Application.eval` +torch/utils/_sympy/interp.py:103:9: warning[possibly-missing-attribute] Submodule `piecewise` may not be available as an attribute on module `sympy.functions.elementary` torch/utils/_sympy/interp.py:125:58: error[unresolved-attribute] Module `torch` has no member `int64` torch/utils/_sympy/interp.py:132:43: error[unresolved-attribute] Module `torch` has no member `float64` torch/utils/_sympy/interp.py:191:17: error[unresolved-attribute] Module `torch` has no member `int64` @@ -23019,9 +23495,12 @@ torch/utils/_sympy/interp.py:197:17: error[unresolved-attribute] Module `torch` torch/utils/_sympy/interp.py:199:17: error[unresolved-attribute] Module `torch` has no member `int64` torch/utils/_sympy/interp.py:201:17: error[unresolved-attribute] Module `torch` has no member `double` torch/utils/_sympy/interp.py:220:17: error[invalid-argument-type] Argument to function `sympy_interp` is incorrect: Expected `Expr | Boolean`, found `Basic` +torch/utils/_sympy/numbers.py:123:9: error[invalid-method-override] Invalid override of method `_eval_power`: Definition is incompatible with `Expr._eval_power` torch/utils/_sympy/numbers.py:136:16: error[unresolved-attribute] Object of type `re` has no attribute `is_positive` +torch/utils/_sympy/numbers.py:311:9: error[invalid-method-override] Invalid override of method `_eval_power`: Definition is incompatible with `Expr._eval_power` torch/utils/_sympy/printers.py:29:46: error[unresolved-attribute] Object of type `Expr` has no attribute `rel_op` torch/utils/_sympy/printers.py:56:12: error[unresolved-attribute] Object of type `Expr` has no attribute `_prec` +torch/utils/_sympy/printers.py:72:9: error[invalid-method-override] Invalid override of method `_print_Pow`: Definition is incompatible with `StrPrinter._print_Pow` torch/utils/_sympy/printers.py:74:23: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `Basic` torch/utils/_sympy/printers.py:76:19: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `Basic` torch/utils/_sympy/printers.py:195:34: error[invalid-argument-type] Argument to bound method `_helper_sqrt` is incorrect: Expected `Expr`, found `Basic` @@ -23031,6 +23510,7 @@ torch/utils/_sympy/printers.py:373:16: error[unresolved-attribute] Object of typ torch/utils/_sympy/printers.py:384:12: error[unresolved-attribute] Object of type `Expr` has no attribute `is_integer` torch/utils/_sympy/printers.py:392:53: error[unresolved-attribute] Object of type `Expr` has no attribute `is_integer` torch/utils/_sympy/printers.py:398:53: error[unresolved-attribute] Object of type `Expr` has no attribute `is_integer` +torch/utils/_sympy/printers.py:442:9: error[invalid-method-override] Invalid override of method `_print_Pow`: Definition is incompatible with `StrPrinter._print_Pow` torch/utils/_sympy/printers.py:449:12: error[unresolved-attribute] Object of type `Basic` has no attribute `is_integer` torch/utils/_sympy/printers.py:450:23: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `Basic` torch/utils/_sympy/printers.py:464:57: error[unresolved-attribute] Object of type `Expr` has no attribute `is_integer` @@ -23067,13 +23547,13 @@ torch/utils/_sympy/value_ranges.py:493:23: error[unresolved-attribute] Module `t torch/utils/_sympy/value_ranges.py:502:46: error[invalid-argument-type] Argument to function `increasing_map` is incorrect: Expected `(Expr, /) -> Expr`, found `` torch/utils/_sympy/value_ranges.py:510:16: error[no-matching-overload] No overload of function `decreasing_map` matches arguments torch/utils/_sympy/value_ranges.py:794:20: error[no-matching-overload] No overload of function `coordinatewise_increasing_map` matches arguments -torch/utils/_sympy/value_ranges.py:908:46: error[unresolved-attribute] Module `sympy.functions.elementary` has no member `integers` -torch/utils/_sympy/value_ranges.py:913:16: error[unresolved-attribute] Module `sympy.functions.elementary` has no member `integers` -torch/utils/_sympy/value_ranges.py:937:28: error[unresolved-attribute] Module `sympy.functions.elementary` has no member `integers` -torch/utils/_sympy/value_ranges.py:943:28: error[unresolved-attribute] Module `sympy.functions.elementary` has no member `integers` +torch/utils/_sympy/value_ranges.py:908:46: warning[possibly-missing-attribute] Submodule `integers` may not be available as an attribute on module `sympy.functions.elementary` +torch/utils/_sympy/value_ranges.py:913:16: warning[possibly-missing-attribute] Submodule `integers` may not be available as an attribute on module `sympy.functions.elementary` +torch/utils/_sympy/value_ranges.py:937:28: warning[possibly-missing-attribute] Submodule `integers` may not be available as an attribute on module `sympy.functions.elementary` +torch/utils/_sympy/value_ranges.py:943:28: warning[possibly-missing-attribute] Submodule `integers` may not be available as an attribute on module `sympy.functions.elementary` torch/utils/_sympy/value_ranges.py:961:51: error[invalid-argument-type] Argument to function `increasing_map` is incorrect: Expected `(Expr, /) -> Expr`, found `` torch/utils/_sympy/value_ranges.py:1078:46: error[invalid-argument-type] Argument to function `increasing_map` is incorrect: Expected `(Expr, /) -> Expr`, found `` -torch/utils/_sympy/value_ranges.py:1104:15: error[unresolved-attribute] Module `torch` has no member `_guards` +torch/utils/_sympy/value_ranges.py:1104:15: warning[possibly-missing-attribute] Submodule `_guards` may not be available as an attribute on module `torch` torch/utils/_triton.py:9:16: error[unresolved-import] Cannot resolve imported module `triton` torch/utils/_triton.py:19:16: error[unresolved-import] Cannot resolve imported module `triton` torch/utils/_triton.py:43:22: error[unresolved-import] Cannot resolve imported module `triton.tools.experimental_descriptor` @@ -23100,11 +23580,11 @@ torch/utils/backend_registration.py:253:14: error[unresolved-attribute] Module ` torch/utils/backend_registration.py:270:55: error[unresolved-attribute] Module `torch` has no member `dtype` torch/utils/backend_registration.py:311:33: error[unresolved-attribute] Module `torch` has no member `device` torch/utils/backend_registration.py:357:29: error[unresolved-attribute] Module `torch` has no member `dtype` -torch/utils/backend_registration.py:469:29: error[unresolved-attribute] Module `torch._C` has no member `_acc` -torch/utils/backend_registration.py:480:25: error[unresolved-attribute] Module `torch._C` has no member `_acc` -torch/utils/backend_registration.py:482:16: error[unresolved-attribute] Module `torch._C` has no member `_autograd` -torch/utils/backend_registration.py:520:5: error[unresolved-attribute] Module `torch._C` has no member `_acc` -torch/utils/backend_registration.py:521:5: error[unresolved-attribute] Module `torch._C` has no member `_acc` +torch/utils/backend_registration.py:469:29: warning[possibly-missing-attribute] Submodule `_acc` may not be available as an attribute on module `torch._C` +torch/utils/backend_registration.py:480:25: warning[possibly-missing-attribute] Submodule `_acc` may not be available as an attribute on module `torch._C` +torch/utils/backend_registration.py:482:16: warning[possibly-missing-attribute] Submodule `_autograd` may not be available as an attribute on module `torch._C` +torch/utils/backend_registration.py:520:5: warning[possibly-missing-attribute] Submodule `_acc` may not be available as an attribute on module `torch._C` +torch/utils/backend_registration.py:521:5: warning[possibly-missing-attribute] Submodule `_acc` may not be available as an attribute on module `torch._C` torch/utils/benchmark/examples/compare.py:61:22: error[unresolved-attribute] Module `torch` has no member `ones` torch/utils/benchmark/examples/compare.py:62:22: error[unresolved-attribute] Module `torch` has no member `ones` torch/utils/benchmark/examples/compare.py:63:25: error[unresolved-attribute] Module `torch` has no member `zeros` @@ -23199,8 +23679,8 @@ torch/utils/checkpoint.py:1646:9: error[unresolved-attribute] Module `torch._C` torch/utils/checkpoint.py:1651:16: error[unresolved-attribute] Module `torch._C` has no member `_get_graph_exec_group` torch/utils/collect_env.py:725:19: error[unresolved-attribute] Module `torch._C` has no member `_show_config` torch/utils/cpp_backtrace.py:2:22: error[unresolved-import] Module `torch._C` has no member `_get_cpp_backtrace` -torch/utils/cpp_extension.py:156:21: error[unresolved-attribute] Module `importlib` has no member `metadata` -torch/utils/cpp_extension.py:161:16: error[unresolved-attribute] Module `importlib` has no member `metadata` +torch/utils/cpp_extension.py:156:21: warning[possibly-missing-attribute] Submodule `metadata` may not be available as an attribute on module `importlib` +torch/utils/cpp_extension.py:161:16: warning[possibly-missing-attribute] Submodule `metadata` may not be available as an attribute on module `importlib` torch/utils/cpp_extension.py:797:26: error[no-matching-overload] No overload of function `abspath` matches arguments torch/utils/cpp_extension.py:910:13: error[unresolved-attribute] Unresolved attribute `cflags` on type `Self@build_extensions`. torch/utils/cpp_extension.py:941:39: error[unresolved-attribute] Object of type `Self@build_extensions` has no attribute `cflags` @@ -23212,20 +23692,13 @@ torch/utils/cpp_extension.py:958:54: error[unresolved-attribute] Object of type torch/utils/cpp_extension.py:961:37: error[unresolved-attribute] Object of type `Self@build_extensions` has no attribute `cflags` torch/utils/cpp_extension.py:962:54: error[unresolved-attribute] Object of type `Self@build_extensions` has no attribute `cflags` torch/utils/cpp_extension.py:988:26: error[no-matching-overload] No overload of function `abspath` matches arguments +torch/utils/cpp_extension.py:1094:9: error[invalid-method-override] Invalid override of method `get_ext_filename`: Definition is incompatible with `build_ext.get_ext_filename` torch/utils/cpp_extension.py:2466:60: warning[possibly-missing-attribute] Member `is_initialized` may be missing on module `torch.distributed` torch/utils/cpp_extension.py:2466:98: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/utils/cpp_extension.py:2515:21: error[unresolved-attribute] Module `torch._C` has no member `_cuda_getArchFlags` -torch/utils/cpp_extension.py:2657:16: error[unresolved-attribute] Module `importlib` has no member `util` -torch/utils/cpp_extension.py:2660:18: error[unresolved-attribute] Module `importlib` has no member `util` +torch/utils/cpp_extension.py:2657:16: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` +torch/utils/cpp_extension.py:2660:18: warning[possibly-missing-attribute] Submodule `util` may not be available as an attribute on module `importlib` torch/utils/data/_utils/collate.py:70:16: error[unresolved-attribute] Module `torch` has no member `as_tensor` -torch/utils/data/_utils/collate.py:71:27: error[unresolved-attribute] Module `collections` has no member `abc` -torch/utils/data/_utils/collate.py:73:33: error[unresolved-attribute] Module `collections` has no member `abc` -torch/utils/data/_utils/collate.py:90:27: error[unresolved-attribute] Module `collections` has no member `abc` -torch/utils/data/_utils/collate.py:94:33: error[unresolved-attribute] Module `collections` has no member `abc` -torch/utils/data/_utils/collate.py:163:25: error[unresolved-attribute] Module `collections` has no member `abc` -torch/utils/data/_utils/collate.py:165:33: error[unresolved-attribute] Module `collections` has no member `abc` -torch/utils/data/_utils/collate.py:202:27: error[unresolved-attribute] Module `collections` has no member `abc` -torch/utils/data/_utils/collate.py:220:37: error[unresolved-attribute] Module `collections` has no member `abc` torch/utils/data/_utils/collate.py:259:9: error[unresolved-attribute] Module `torch` has no member `sparse_coo` torch/utils/data/_utils/collate.py:260:9: error[unresolved-attribute] Module `torch` has no member `sparse_csr` torch/utils/data/_utils/collate.py:261:9: error[unresolved-attribute] Module `torch` has no member `sparse_bsr` @@ -23238,10 +23711,6 @@ torch/utils/data/_utils/collate.py:304:12: error[unresolved-attribute] Module `t torch/utils/data/_utils/collate.py:304:38: error[unresolved-attribute] Module `torch` has no member `float64` torch/utils/data/_utils/collate.py:312:12: error[unresolved-attribute] Module `torch` has no member `tensor` torch/utils/data/_utils/pin_memory.py:21:5: error[unresolved-attribute] Module `torch` has no member `set_num_threads` -torch/utils/data/_utils/pin_memory.py:60:27: error[unresolved-attribute] Module `collections` has no member `abc` -torch/utils/data/_utils/pin_memory.py:62:33: error[unresolved-attribute] Module `collections` has no member `abc` -torch/utils/data/_utils/pin_memory.py:86:27: error[unresolved-attribute] Module `collections` has no member `abc` -torch/utils/data/_utils/pin_memory.py:88:33: error[unresolved-attribute] Module `collections` has no member `abc` torch/utils/data/_utils/signal_handling.py:40:5: error[unresolved-import] Module `torch._C` has no member `_error_if_any_worker_fails` torch/utils/data/_utils/signal_handling.py:41:5: error[unresolved-import] Module `torch._C` has no member `_remove_worker_pids` torch/utils/data/_utils/signal_handling.py:42:5: error[unresolved-import] Module `torch._C` has no member `_set_worker_pids` @@ -23276,10 +23745,11 @@ torch/utils/data/datapipes/dataframe/dataframes.py:155:19: error[not-iterable] O torch/utils/data/datapipes/dataframe/dataframes.py:188:9: warning[possibly-missing-attribute] Attribute `append` may be missing on object of type `Unknown | list[Unknown] | None` torch/utils/data/datapipes/dataframe/dataframes.py:287:9: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method torch/utils/data/datapipes/dataframe/dataframes.py:289:19: error[not-iterable] Object of type `Unknown | list[Unknown] | None` may not be iterable -torch/utils/data/datapipes/dataframe/dataframes.py:389:41: error[invalid-assignment] Object of type `dict[Unknown | str, Unknown | list[Unknown] | None]` is not assignable to `dict[str, list[Any]]` +torch/utils/data/datapipes/dataframe/dataframes.py:389:41: error[invalid-assignment] Object of type `dict[str, list[Any] | Unknown | None]` is not assignable to `dict[str, list[Any]]` torch/utils/data/datapipes/dataframe/dataframes.py:405:35: error[non-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method torch/utils/data/datapipes/dataframe/dataframes.py:470:30: error[no-matching-overload] No overload of function `iter` matches arguments torch/utils/data/datapipes/datapipe.py:139:16: error[invalid-return-type] Return type does not match returned value: expected `Iterator[_T_co@IterDataPipe]`, found `Self@__iter__` +torch/utils/data/datapipes/datapipe.py:426:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `Dataset.__getitem__` torch/utils/data/datapipes/gen_pyi.py:64:30: warning[deprecated] The function `materialize_lines` is deprecated: `torch.utils.data.datapipes.gen_pyi.materialize_lines` is deprecated and will be removed in the future. torch/utils/data/datapipes/iter/callable.py:79:9: error[unresolved-attribute] Module `torch._C` has no member `_log_api_usage_once` torch/utils/data/datapipes/iter/callable.py:122:17: error[invalid-assignment] Invalid subscript assignment with key of type `(Unknown & ~Top[list[Unknown]] & ~tuple[object, ...]) | None` and value of type `Unknown` on object of type `list[Unknown]` @@ -23306,6 +23776,8 @@ torch/utils/data/datapipes/utils/decoder.py:297:20: error[unresolved-import] Can torch/utils/data/dataset.py:17:19: error[unresolved-import] Module `torch` has no member `default_generator` torch/utils/data/dataset.py:17:38: error[unresolved-import] Module `torch` has no member `Generator` torch/utils/data/dataset.py:17:49: error[unresolved-import] Module `torch` has no member `randperm` +torch/utils/data/dataset.py:333:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `Dataset.__getitem__` +torch/utils/data/dataset.py:402:9: error[invalid-method-override] Invalid override of method `__getitem__`: Definition is incompatible with `Dataset.__getitem__` torch/utils/data/distributed.py:78:28: warning[possibly-missing-attribute] Member `get_world_size` may be missing on module `torch.distributed` torch/utils/data/distributed.py:82:20: warning[possibly-missing-attribute] Member `get_rank` may be missing on module `torch.distributed` torch/utils/data/distributed.py:110:17: error[unresolved-attribute] Module `torch` has no member `Generator` @@ -23330,7 +23802,9 @@ torch/utils/data/sampler.py:264:57: error[unresolved-attribute] Module `torch` h torch/utils/data/sampler.py:277:23: error[unresolved-attribute] Module `torch` has no member `multinomial` torch/utils/data/standard_pipes.ipynb:cell 3:6:20: error[not-iterable] Object of type `Unknown | Literal[20]` may not be iterable torch/utils/data/typing.ipynb:cell 3:3:11: error[unresolved-reference] Name `get_ipython` used when not defined +torch/utils/data/typing.ipynb:cell 5:2:9: error[invalid-method-override] Invalid override of method `__iter__`: Definition is incompatible with `IterDataPipe.__iter__` torch/utils/data/typing.ipynb:cell 5:2:27: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `str` +torch/utils/data/typing.ipynb:cell 7:2:9: error[invalid-method-override] Invalid override of method `__iter__`: Definition is incompatible with `IterDataPipe.__iter__` torch/utils/data/typing.ipynb:cell 7:2:27: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `Iterator[str]` torch/utils/data/typing.ipynb:cell 9:2:27: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `Iterator[tuple[int, str]]` torch/utils/data/typing.ipynb:cell 10:2:27: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `Iterator[int]` @@ -23349,10 +23823,10 @@ torch/utils/dlpack.py:135:26: error[unresolved-attribute] Module `torch` has no torch/utils/dlpack.py:136:39: error[unresolved-attribute] Module `torch` has no member `device` torch/utils/dlpack.py:138:35: error[unresolved-attribute] Module `torch._C` has no member `_torchDeviceToDLDevice` torch/utils/dlpack.py:171:12: error[unresolved-attribute] Module `torch._C` has no member `_from_dlpack` -torch/utils/flop_counter.py:52:9: error[unresolved-attribute] Module `torch.utils` has no member `_pytree` +torch/utils/flop_counter.py:52:9: warning[possibly-missing-attribute] Submodule `_pytree` may not be available as an attribute on module `torch.utils` torch/utils/flop_counter.py:160:46: error[invalid-argument-type] Argument to function `conv_flop_count` is incorrect: Expected `list[int]`, found `Unknown | None` torch/utils/hooks.py:168:35: error[unresolved-attribute] Module `torch` has no member `is_grad_enabled` -torch/utils/hooks.py:171:23: error[unresolved-attribute] Module `torch.nn.modules` has no member `_functions` +torch/utils/hooks.py:171:23: warning[possibly-missing-attribute] Submodule `_functions` may not be available as an attribute on module `torch.nn.modules` torch/utils/jit/log_extract.py:30:37: error[unresolved-attribute] Module `torch._C` has no member `TensorType` torch/utils/jit/log_extract.py:43:12: error[unresolved-attribute] Module `torch` has no member `empty_strided` torch/utils/jit/log_extract.py:46:13: error[unresolved-attribute] Module `torch._C` has no member `parse_ir` @@ -23385,7 +23859,7 @@ torch/utils/mobile_optimizer.py:6:22: error[unresolved-import] Module `torch._C` torch/utils/mobile_optimizer.py:59:32: error[unresolved-attribute] Module `torch._C` has no member `_jit_pass_optimize_for_mobile` torch/utils/mobile_optimizer.py:64:32: error[unresolved-attribute] Module `torch._C` has no member `_jit_pass_vulkan_optimize_for_mobile` torch/utils/mobile_optimizer.py:69:32: error[unresolved-attribute] Module `torch._C` has no member `_jit_pass_metal_optimize_for_mobile` -torch/utils/mobile_optimizer.py:73:12: error[unresolved-attribute] Module `torch.jit` has no member `_recursive` +torch/utils/mobile_optimizer.py:73:12: warning[possibly-missing-attribute] Submodule `_recursive` may not be available as an attribute on module `torch.jit` torch/utils/model_dump/__init__.py:396:46: error[invalid-argument-type] Argument to function `read_text` is incorrect: Expected `str | ModuleType`, found `str | None` torch/utils/model_dump/__init__.py:398:45: error[invalid-argument-type] Argument to function `read_text` is incorrect: Expected `str | ModuleType`, found `str | None` torch/utils/model_dump/__init__.py:401:50: error[invalid-argument-type] Argument to function `read_binary` is incorrect: Expected `str | ModuleType`, found `str | None` @@ -23475,8 +23949,8 @@ torch/xpu/__init__.py:474:28: error[unresolved-attribute] Module `torch` has no torch/xpu/__init__.py:474:45: error[unresolved-attribute] Module `torch._C` has no member `Generator` torch/xpu/__init__.py:487:42: error[unresolved-attribute] Module `torch` has no member `device` torch/xpu/__init__.py:505:51: error[unresolved-attribute] Module `torch` has no member `device` -torch/xpu/_gpu_trace.py:8:24: error[too-many-positional-arguments] Too many positional arguments to class `CallbackRegistry`: expected 1, got 2 -torch/xpu/_gpu_trace.py:11:22: error[too-many-positional-arguments] Too many positional arguments to class `CallbackRegistry`: expected 1, got 2 +torch/xpu/_gpu_trace.py:8:46: error[invalid-type-arguments] Too many type arguments to class `CallbackRegistry`: expected 1, got 2 +torch/xpu/_gpu_trace.py:11:44: error[invalid-type-arguments] Too many type arguments to class `CallbackRegistry`: expected 1, got 2 torch/xpu/_utils.py:29:18: error[unresolved-attribute] Module `torch` has no member `device` torch/xpu/_utils.py:30:27: error[unresolved-attribute] Module `torch` has no member `device` torch/xpu/memory.py:23:9: error[unresolved-attribute] Module `torch._C` has no member `_xpu_emptyCache` @@ -23496,4 +23970,4 @@ torch/xpu/random.py:52:18: error[unresolved-attribute] Module `torch` has no mem torch/xpu/random.py:54:18: error[unresolved-attribute] Module `torch` has no member `device` torch/xpu/streams.py:14:14: error[unresolved-attribute] Module `torch._C` has no member `_XpuStreamBase` torch/xpu/streams.py:103:13: error[unresolved-attribute] Module `torch._C` has no member `_XpuEventBase` -Found 23326 diagnostics +Found 23800 diagnostics diff --git a/scripts/ty_benchmark/src/benchmark/lsp_client.py b/scripts/ty_benchmark/src/benchmark/lsp_client.py new file mode 100644 index 0000000000..bd932e667d --- /dev/null +++ b/scripts/ty_benchmark/src/benchmark/lsp_client.py @@ -0,0 +1,173 @@ +"""Simple LSP client for benchmarking diagnostic response times.""" + +import asyncio +import logging +from asyncio import Future +from pathlib import Path +from typing import Any, NamedTuple, cast, override + +from lsprotocol import types as lsp +from pygls.lsp.client import LanguageClient + + +def _register_notebook_structure_hooks(converter): + """Register structure hooks for notebook document types to work around cattrs deserialization issues.""" + + # Define a union type that cattrs struggles with. + notebook_filter_union = ( + str + | lsp.NotebookDocumentFilterNotebookType + | lsp.NotebookDocumentFilterScheme + | lsp.NotebookDocumentFilterPattern + | None + ) + + def structure_notebook_filter(obj: Any, _type): + """Structure a notebook filter field from various possible types.""" + if obj is None: + return None + if isinstance(obj, str): + return obj + if isinstance(obj, dict): + # Try to structure it as one of the known types. + if "notebookType" in obj: + return converter.structure(obj, lsp.NotebookDocumentFilterNotebookType) + elif "scheme" in obj: + return converter.structure(obj, lsp.NotebookDocumentFilterScheme) + elif "pattern" in obj: + return converter.structure(obj, lsp.NotebookDocumentFilterPattern) + return obj + + converter.register_structure_hook(notebook_filter_union, structure_notebook_filter) + + +class LSPClient(LanguageClient): + """A minimal LSP client for benchmarking purposes.""" + + server_capabilities: lsp.ServerCapabilities + diagnostics: dict[str, Future[lsp.PublishDiagnosticsParams]] + + def __init__( + self, + ): + super().__init__( + "ty_benchmark", + "v1", + ) + + # Register custom structure hooks to work around lsprotocol/cattrs issues. + _register_notebook_structure_hooks(self.protocol._converter) + + self.diagnostics = {} + + @self.feature(lsp.TEXT_DOCUMENT_PUBLISH_DIAGNOSTICS) + def publish_diagnostics( + client: LSPClient, params: lsp.PublishDiagnosticsParams + ): + logging.info( + f"Received publish_diagnostics for {params.uri} with version={params.version}, diagnostics count={len(params.diagnostics)}" + ) + future = self.diagnostics.get(params.uri, None) + + if future is None or future.done(): + future = asyncio.Future() + self.diagnostics[params.uri] = future + + future.set_result(params) + + @self.feature(lsp.WINDOW_LOG_MESSAGE) + def log_message(client: LSPClient, params: lsp.LogMessageParams): + if params.type == lsp.MessageType.Error: + logging.error(f"server error: {params.message}") + elif params.type == lsp.MessageType.Warning: + logging.warning(f"server warning: {params.message}") + else: + logging.info(f"server info: {params.message}") + + @override + async def initialize_async( + self, params: lsp.InitializeParams + ) -> lsp.InitializeResult: + result = await super().initialize_async(params) + + self.server_capabilities = result.capabilities + + logging.info( + f"Pull diagnostic support: {self.server_supports_pull_diagnostics}" + ) + + return result + + def clear_pending_publish_diagnostics(self): + self.diagnostics.clear() + + @property + def server_supports_pull_diagnostics(self) -> bool: + diagnostic_provider = self.server_capabilities.diagnostic_provider + + return diagnostic_provider is not None + + async def text_document_diagnostics_async(self, path: Path) -> list[lsp.Diagnostic]: + """ + Returns the diagnostics for `path` + + Uses pull diagnostics if the server supports it or waits for a publish diagnostics + notification if not. + """ + if self.server_supports_pull_diagnostics: + pull_diagnostics = await self.text_document_diagnostic_async( + lsp.DocumentDiagnosticParams( + text_document=lsp.TextDocumentIdentifier(uri=path.as_uri()) + ) + ) + + assert isinstance( + pull_diagnostics, lsp.RelatedFullDocumentDiagnosticReport + ), "Expected a full diagnostic report" + + return list(pull_diagnostics.items) + + # Use publish diagnostics otherwise. + # Pyrefly doesn't support pull diagnostics as of today (27th of November 2025) + publish_diagnostics = await self.wait_for_push_diagnostics_async(path) + return list(publish_diagnostics.diagnostics) + + async def text_documents_diagnostics_async( + self, files: list[Path] + ) -> list[FileDiagnostics]: + responses = await asyncio.gather( + *[self.text_document_diagnostics_async(f) for f in files] + ) + + responses = cast( + list[lsp.Diagnostic], + responses, + ) + + return [ + FileDiagnostics(file, diagnostics=list(response)) + for file, response in zip(files, responses) + ] + + async def wait_for_push_diagnostics_async( + self, path: Path, timeout: float = 60 + ) -> lsp.PublishDiagnosticsParams: + future = self.diagnostics.get(path.as_uri(), None) + + if future is None: + future = asyncio.Future() + self.diagnostics[path.as_uri()] = future + + try: + logging.info(f"Waiting for push diagnostics for {path}") + result = await asyncio.wait_for(future, timeout) + logging.info(f"Awaited push diagnostics for {path}") + finally: + self.diagnostics.pop(path.as_uri()) + + return result + + +class FileDiagnostics(NamedTuple): + file: Path + diagnostics: list[lsp.Diagnostic] diff --git a/scripts/ty_benchmark/src/benchmark/projects.py b/scripts/ty_benchmark/src/benchmark/projects.py index 51c7a99fe5..8675b69cd4 100644 --- a/scripts/ty_benchmark/src/benchmark/projects.py +++ b/scripts/ty_benchmark/src/benchmark/projects.py @@ -32,6 +32,8 @@ class Project(NamedTuple): exclude: list[str] = [] """The directories and files to exclude from checks.""" + edit: IncrementalEdit | None = None + def clone(self, checkout_dir: Path) -> None: # Skip cloning if the project has already been cloned (the script doesn't yet support updating) if (checkout_dir / ".git").exists(): @@ -95,6 +97,33 @@ class Project(NamedTuple): logging.info(f"Cloned {self.name} to {checkout_dir}.") +class IncrementalEdit(NamedTuple): + """Description of an edit to measure incremental performance""" + + edited_file: str + """The file to which to apply the edit.""" + + affected_files: list[str] + """Files other than the main file that's affected by the edit.""" + + replace_text: str + """The original code snippet to find and replace in the main file.""" + + replacement: str + """The new code snippet to insert in place of `replace_text`""" + + def apply_to(self, text: str) -> str | None: + """Applies the edit to the given text. + + Returns: + The modified text or None if the edit couldn't be applied""" + + if self.replace_text not in text: + return None + + return text.replace(self.replace_text, self.replacement, 1) + + # Selection of projects taken from # [mypy-primer](https://github.com/hauntsaninja/mypy_primer/blob/0ea6cc614b3e91084059b9a3acc58f94c066a211/mypy_primer/projects.py#L71). # May require frequent updating, especially the dependencies list @@ -116,6 +145,12 @@ ALL: Final = [ "--extra", "d", ], + edit=IncrementalEdit( + edited_file="src/black/nodes.py", + replace_text="LN = Union[Leaf, Node]", + replacement="LN = Union[Leaf, Node, int]", + affected_files=["src/black/linegen.py"], + ), ), Project( name="discord.py", @@ -128,6 +163,12 @@ ALL: Final = [ "pyproject.toml", "typing_extensions>=4.3,<5", ], + edit=IncrementalEdit( + edited_file="discord/abc.py", + replace_text="id: int", + replacement="id: str", + affected_files=["discord/channel.py"], + ), ), # Fairly chunky project, requires the pydantic mypy plugin. # @@ -146,6 +187,12 @@ ALL: Final = [ "-r", "requirements.txt", ], + edit=IncrementalEdit( + edited_file="homeassistant/core.py", + affected_files=["homeassistant/helpers/event.py"], + replace_text="type CALLBACK_TYPE = Callable[[], None]", + replacement="type CALLBACK_TYPE = Callable[[str], None]", + ), ), Project( name="isort", @@ -154,6 +201,12 @@ ALL: Final = [ python_version="3.11", include=["isort"], install_arguments=["types-colorama", "colorama"], + edit=IncrementalEdit( + edited_file="isort/settings.py", + replace_text="def is_skipped(self, file_path: Path) -> bool:", + replacement="def is_skipped(self, file_path: str) -> bool:", + affected_files=["isort/files.py"], + ), ), Project( name="jinja", @@ -162,6 +215,24 @@ ALL: Final = [ python_version="3.10", include=["src"], install_arguments=["-r", "pyproject.toml"], + edit=IncrementalEdit( + edited_file="src/jinja2/nodes.py", + replace_text="""def iter_child_nodes( + self, + exclude: t.Container[str] | None = None, + only: t.Container[str] | None = None, + ) -> t.Iterator["Node"]""", + replacement="""def iter_child_nodes( + self, + exclude: t.Container[str] | None = None, + only: t.Container[str] | None = None, + ) -> t.Iterator[str]""", + affected_files=[ + "src/jinja2/compiler.py", + "src/jinja2/idtracking.py", + "src/jinja2/visitor.py", + ], + ), ), Project( name="pandas", @@ -174,6 +245,12 @@ ALL: Final = [ "-r", "requirements-dev.txt", ], + edit=IncrementalEdit( + edited_file="pandas/_typing.py", + replace_text='Axis: TypeAlias = AxisInt | Literal["index", "columns", "rows"]', + replacement='Axis: TypeAlias = Literal["index", "columns", "rows"]', + affected_files=["pandas/core/frame.py"], + ), ), Project( name="pandas-stubs", @@ -196,6 +273,7 @@ ALL: Final = [ "scipy >=1.9.1", "scipy-stubs >=1.15.3.0", ], + edit=None, # Tricky in a stubs only project as there are no actual method calls. ), Project( name="prefect", @@ -215,6 +293,22 @@ ALL: Final = [ "--group", "dev", ], + edit=IncrementalEdit( + edited_file="src/prefect/server/models/events.py", + replace_text="""async def deployment_status_event( + session: AsyncSession, + deployment_id: UUID, + status: DeploymentStatus, + occurred: DateTime, +) -> Event:""", + replacement="""async def deployment_status_event( + session: AsyncSession, + deployment_id: UUID, + status: DeploymentStatus, + occurred: DateTime, +) -> int:""", + affected_files=["src/prefect/server/models/deployments.py"], + ), ), Project( name="pytorch", @@ -283,5 +377,22 @@ ALL: Final = [ "mypy==1.16.0", # pytorch pins mypy, ], python_version="3.11", + edit=IncrementalEdit( + edited_file="torch/nn/__init__.py", + replace_text="""from torch.nn.parameter import ( # usort: skip + Buffer as Buffer, + Parameter as Parameter, + UninitializedBuffer as UninitializedBuffer, + UninitializedParameter as UninitializedParameter, +)""", + replacement="""from torch.nn.parameter import ( # usort: skip + Buffer as Buffer, + UninitializedBuffer as UninitializedBuffer, + UninitializedParameter as UninitializedParameter, +)""", + affected_files=[ + "torch/distributed/pipelining/_backward.py", + ], + ), ), ] diff --git a/scripts/ty_benchmark/src/benchmark/test_lsp_diagnostics.py b/scripts/ty_benchmark/src/benchmark/test_lsp_diagnostics.py new file mode 100644 index 0000000000..fde0c433c4 --- /dev/null +++ b/scripts/ty_benchmark/src/benchmark/test_lsp_diagnostics.py @@ -0,0 +1,486 @@ +""" +Benchmarks for LSP servers + +When debugging test failures, run pytest with `-s -v --log-cli-level=DEBUG` +""" + +import asyncio +import tempfile +from abc import ABC, abstractmethod +from collections import Counter +from collections.abc import Callable, Generator +from pathlib import Path +from typing import Any, Final, override + +import pytest +from lsprotocol import types as lsp + +from benchmark.lsp_client import FileDiagnostics, LSPClient +from benchmark.projects import ALL as ALL_PROJECTS +from benchmark.projects import IncrementalEdit, Project +from benchmark.tool import Pyrefly, Pyright, Tool, Ty +from benchmark.venv import Venv + +# Tools to benchmark (only those with LSP support). +TOOLS_TO_BENCHMARK: Final = [ + Ty(), + Pyright(), + Pyrefly(), +] + +SEVERITY_LABELS: Final = {1: "Error", 2: "Warning", 3: "Info", 4: "Hint"} + + +@pytest.fixture(scope="module", params=ALL_PROJECTS, ids=lambda p: p.name) +def project_setup( + request, +) -> Generator[tuple[Project, Venv], None, None]: + """Set up a project and its venv once per module (shared across all tests for this project).""" + project: Project = request.param + + with tempfile.TemporaryDirectory() as tempdir: + cwd = Path(tempdir) + project.clone(cwd) + + venv = Venv.create(cwd, project.python_version) + venv.install(project.install_arguments) + + yield project, venv + + +@pytest.fixture( + scope="function", + params=TOOLS_TO_BENCHMARK, + ids=lambda t: t.name(), +) +def tool(request) -> Tool: + """Provide each tool to test.""" + return request.param + + +def test_fetch_diagnostics( + request, benchmark, project_setup: tuple[Project, Venv], tool: Tool +): + """Benchmark the time to receive initial diagnostics after starting the server.""" + + project, venv = project_setup + + run_benchmark( + request, + benchmark, + project, + tool, + venv, + FetchDiagnostics, + ) + + +def test_incremental_edit( + request, benchmark, project_setup: tuple[Project, Venv], tool: Tool +): + """Benchmark the time to receive diagnostics after making an edit to a file.""" + + project, venv = project_setup + + run_benchmark(request, benchmark, project, tool, venv, IncrementalEditTest) + + +def run_benchmark( + request: Any, + benchmark: Any, + project: Project, + tool: Tool, + venv: Venv, + init_test: Callable[[Project, Tool, Venv], LspTest], +): + # Set benchmark group to project name for better readability. + benchmark.group = project.name + verbose = request.config.getoption("verbose") > 0 + + edited_file_backup: Path | None = None + + # some make changes to the main file. Create a backup and restore it before each test + # and once the entire suite is done. + if project.edit: + edited_file_path = venv.project_path / project.edit.edited_file + edited_file_backup = edited_file_path.with_name(edited_file_path.name + ".bak") + edited_file_path.copy(edited_file_backup) + + try: + tool.write_config(project, venv) + + # Use asyncio.Runner to keep the same event loop alive across setup and measure. + with asyncio.Runner() as runner: + + def setup(): + if edited_file_backup: + edited_file_backup.copy(edited_file_backup.with_suffix("")) + + test = init_test(project, tool, venv) + + runner.run(test.setup()) + return (test,), {} + + def run(test: LspTest) -> None: + runner.run(test.run()) + + def teardown(test: LspTest) -> None: + nonlocal verbose + + test.assert_output(verbose=verbose) + runner.run(test.teardown()) + + # Only do verbose output on the first (warm-up) run to avoid + # that the printing changes the benchmark result. + verbose = False + + # Run the benchmark using pedantic mode. + benchmark.pedantic( + run, + setup=setup, + teardown=teardown, + # total executions = rounds * iterations + warmup_rounds=2, + rounds=10, + iterations=1, + ) + finally: + if edited_file_backup: + edited_file_backup.copy(edited_file_backup.with_suffix("")) + + +class LspTest(ABC): + client: LSPClient + venv: Venv + project: Project + tool: Tool + edit: IncrementalEdit + + def __init__(self, project: Project, tool: Tool, venv: Venv): + edit = project.edit + if not edit: + pytest.skip(f"{project.name} does not have an incremental edit") + return + + self.project = project + self.venv = venv + self.tool = tool + self.client = LSPClient() + self.edit = edit + + @property + def cwd(self) -> Path: + return self.venv.project_path + + @property + def edited_file_path(self) -> Path: + return self.absolute_file_path(self.edit.edited_file) + + def absolute_file_path(self, file_path: str) -> Path: + return self.cwd / file_path + + def files_to_check(self) -> Generator[Path, None, None]: + yield self.edited_file_path + + for file in self.edit.affected_files: + yield self.absolute_file_path(file) + + def open_all_files(self): + for file_path in self.files_to_check(): + self.open_file(file_path) + + def open_file(self, path: Path): + self.client.text_document_did_open( + lsp.DidOpenTextDocumentParams( + text_document=lsp.TextDocumentItem( + uri=path.as_uri(), + language_id="python", + version=1, + text=path.read_text(), + ) + ) + ) + + async def initialize(self): + lsp_cmd = self.tool.lsp_command(self.project, self.venv) + if lsp_cmd is None: + pytest.skip(f"{self.tool.name()} doesn't support LSP") + return + + await self.client.start_io(*lsp_cmd, cwd=self.cwd) + + await self.client.initialize_async( + lsp.InitializeParams( + root_uri=self.cwd.as_uri(), + workspace_folders=[ + lsp.WorkspaceFolder(uri=self.cwd.as_uri(), name=self.cwd.name) + ], + capabilities=lsp.ClientCapabilities( + text_document=lsp.TextDocumentClientCapabilities( + diagnostic=lsp.DiagnosticClientCapabilities( + data_support=True, dynamic_registration=False + ), + synchronization=lsp.TextDocumentSyncClientCapabilities( + did_save=True, + ), + ), + ), + ), + ) + + self.client.initialized(lsp.InitializedParams()) + + @abstractmethod + async def setup(self): ... + + @abstractmethod + async def run(self): ... + + @abstractmethod + def assert_output(self, verbose=False): ... + + async def teardown(self): + await self.client.shutdown_async(None) + self.client.exit(None) + await self.client.stop() + + +class FetchDiagnostics(LspTest): + diagnostics: list[FileDiagnostics] | None = None + + @override + async def setup(self): + await self.initialize() + self.open_all_files() + + @override + async def run(self): + self.diagnostics = await self.client.text_documents_diagnostics_async( + list(self.files_to_check()) + ) + + @override + def assert_output(self, verbose=False): + if self.diagnostics is None: + pytest.fail("No diagnostics were fetched") + return + + if verbose: + for file, diagnostics in self.diagnostics: + if diagnostics: + print_diagnostics(file, diagnostics, self.venv.project_path) + + +class IncrementalEditTest(LspTest): + before_edit_diagnostics: list[FileDiagnostics] | None = None + after_edit_diagnostics: list[FileDiagnostics] | None = None + new_content: str + + def __init__(self, project: Project, tool: Tool, venv: Venv): + super().__init__(project, tool, venv) + new_content = self.edit.apply_to(self.edited_file_path.read_text()) + + if new_content is None: + pytest.fail( + f"Could not find expected text in {self.edited_file_path}:\n" + f"Expected to find: {self.edit.replace_text}\n" + f"This may indicate the project has been updated or the configuration is incorrect." + ) + return + + self.new_content = new_content + + @override + async def setup(self): + await self.initialize() + + self.open_all_files() + + self.before_edit_diagnostics = ( + await self.client.text_documents_diagnostics_async( + list(self.files_to_check()) + ) + ) + + if not self.client.server_supports_pull_diagnostics: + # Pyrefly sometimes sends more than one publish diagnostic per file, + # and it doesn't support versioned publish diagnostics, making it impossible + # for the client to tell if we already received the newest publish diagnostic + # notification or not. Because of that, sleep, clear all publish diagnostic + # notifications before sending the change notification. + await asyncio.sleep(1) + self.client.clear_pending_publish_diagnostics() + + @override + async def run(self): + self.client.text_document_did_change( + lsp.DidChangeTextDocumentParams( + text_document=lsp.VersionedTextDocumentIdentifier( + uri=self.edited_file_path.as_uri(), + version=2, + ), + content_changes=[ + lsp.TextDocumentContentChangeWholeDocument(text=self.new_content) + ], + ), + ) + + all_files = list(self.files_to_check()) + + # wait for the didChange publish notifications or pull the new diagnostics + self.after_edit_diagnostics = ( + await self.client.text_documents_diagnostics_async(all_files) + ) + + after_did_change_sum = sum( + len(diagnostics) for f, diagnostics in self.after_edit_diagnostics + ) + + # IMPORTANT: Write the file back to disk! + # Pyrefly, as of Nov 27, requires that the content on disk + # is updated to show cross-file diagnostics. + self.edited_file_path.write_text(self.new_content) + + self.client.text_document_did_save( + lsp.DidSaveTextDocumentParams( + text_document=lsp.TextDocumentIdentifier( + uri=self.edited_file_path.as_uri(), + ), + ) + ) + + # Pyrefly only publishes cross-file diagnostics after did_save. + if isinstance(self.tool, Pyrefly): + after_did_save_sum = after_did_change_sum + + # Pyrefly sometimes publishes multiple publish diagnostics after a `didSave`. + # Especially if checking takes long, as it, e.g., is the case for homeassistant. + # We need to wait until pyrefly sends us the cross-file diagnostics. + # For now, we use a very simple heuristics where we simply check if the diagnostic + # count between the `didChange` (not cross-file) and `didSave` (cross-file) is different. + while after_did_save_sum == after_did_change_sum: + self.after_edit_diagnostics = ( + await self.client.text_documents_diagnostics_async(all_files) + ) + + after_did_save_sum = sum( + len(diagnostics) for f, diagnostics in self.after_edit_diagnostics + ) + + @override + def assert_output(self, verbose=False): + assert self.before_edit_diagnostics is not None, ( + "The before edit diagnostics should be initialized. Did you forget to call `setup`?" + ) + assert self.after_edit_diagnostics is not None, ( + "The after edit diagnostics should be initialized if the test ran at least once. Did you forget to call `run`?" + ) + + before_edit_count = sum( + len(diagnostics) for _, diagnostics in self.before_edit_diagnostics + ) + + after_edit_count = sum( + len(diagnostics) for _, diagnostics in self.after_edit_diagnostics + ) + + assert after_edit_count > before_edit_count, ( + f"Expected more diagnostics after the change. " + f"Initial: {before_edit_count}, After change: {after_edit_count}" + ) + + if verbose: + print_diagnostic_diff( + self.before_edit_diagnostics, + self.after_edit_diagnostics, + self.project.name, + self.tool.name(), + self.venv.project_path, + ) + + +def print_diagnostics( + file: Path, diagnostics: list[lsp.Diagnostic], cwd: Path, label: str | None = None +): + file = file.relative_to(cwd) + + if label: + print(f"\n{file}: {len(diagnostics)} {label}") + else: + print(f"\n{file}: {len(diagnostics)} diagnostics") + + for diag in diagnostics: + severity = SEVERITY_LABELS.get(diag.severity, f"Unknown({diag.severity})") + print( + f"{file}:{diag.range.start.line + 1}:{diag.range.start.character + 1} [{severity}] {diag.message}" + ) + + +type DiagnosticSignature = tuple[Path, str | int | None, str] + + +def diagnostic_signature(file: Path, diagnostic: lsp.Diagnostic) -> DiagnosticSignature: + """Create a signature for a diagnostic based on file, code, and message (ignoring position).""" + return (file, diagnostic.code, diagnostic.message) + + +def count_diagnostic_signatures( + diagnostics_list: list[FileDiagnostics], +) -> Counter[DiagnosticSignature]: + """Count occurrences of each diagnostic signature.""" + return Counter( + diagnostic_signature(file, diagnostic) + for file, diagnostics in diagnostics_list + for diagnostic in diagnostics + ) + + +def diff_diagnostics( + old: list[FileDiagnostics], + new: list[FileDiagnostics], +) -> list[FileDiagnostics]: + """Return diagnostics in `new` that aren't in `old`.""" + diff_counts = count_diagnostic_signatures(new) - count_diagnostic_signatures(old) + + result: list[FileDiagnostics] = [] + for file, diagnostics in new: + new_for_file = [] + for d in diagnostics: + sig = diagnostic_signature(file, d) + if diff_counts[sig] > 0: + diff_counts[sig] -= 1 + new_for_file.append(d) + if new_for_file: + result.append(FileDiagnostics(file, new_for_file)) + + return result + + +def print_diagnostic_diff( + before_diagnostics: list[FileDiagnostics], + after_diagnostics: list[FileDiagnostics], + project_name: str, + tool_name: str, + cwd: Path, +) -> None: + """Print the difference in diagnostics before and after a change.""" + + added = diff_diagnostics(before_diagnostics, after_diagnostics) + removed = diff_diagnostics(after_diagnostics, before_diagnostics) + + total_added = sum(len(diagnostics) for _, diagnostics in added) + total_removed = sum(len(diagnostics) for _, diagnostics in removed) + + print(f"\n{'=' * 80}") + print(f"Diagnostic Diff: {project_name} - {tool_name}") + print(f"{'=' * 80}") + print(f"Added: {total_added} diagnostic(s)") + print(f"Removed: {total_removed} diagnostic(s)") + + for file, diagnostics in added: + print_diagnostics(file, diagnostics, cwd, "added") + + for file, diagnostics in removed: + print_diagnostics(file, diagnostics, cwd, "removed") + + print(f"{'=' * 80}") diff --git a/scripts/ty_benchmark/src/benchmark/tool.py b/scripts/ty_benchmark/src/benchmark/tool.py index 9feabfda70..4798dd3fdb 100644 --- a/scripts/ty_benchmark/src/benchmark/tool.py +++ b/scripts/ty_benchmark/src/benchmark/tool.py @@ -27,6 +27,9 @@ def which_tool(name: str, path: Path | None = None) -> Path: class Tool(abc.ABC): + @abc.abstractmethod + def name(self) -> str: ... + def write_config(self, project: Project, venv: Venv) -> None: """Write the tool's configuration file.""" @@ -48,13 +51,17 @@ class Tool(abc.ABC): def command(self, project: Project, venv: Venv, single_threaded: bool) -> Command: """Generate a command to benchmark a given tool.""" + @abc.abstractmethod + def lsp_command(self, project: Project, venv: Venv) -> list[str] | None: + """Generate command to start LSP server, or None if not supported.""" + class Ty(Tool): path: Path - name: str + _name: str def __init__(self, *, path: Path | None = None): - self.name = str(path) if path else "ty" + self._name = str(path) if path else "ty" executable = "ty.exe" if sys.platform == "win32" else "ty" self.path = ( path or (Path(__file__) / "../../../../../target/release" / executable) @@ -64,6 +71,10 @@ class Ty(Tool): f"ty not found at '{self.path}'. Run `cargo build --release --bin ty`." ) + @override + def name(self) -> str: + return self._name + @override def config(self, project: Project, venv: Venv): return ( @@ -91,7 +102,11 @@ class Ty(Tool): for exclude in project.exclude: command.extend(["--exclude", exclude]) - return Command(name=self.name, command=command) + return Command(name=self._name, command=command) + + @override + def lsp_command(self, project: Project, venv: Venv) -> list[str] | None: + return [str(self.path), "server"] class Mypy(Tool): @@ -102,6 +117,10 @@ class Mypy(Tool): self.path = path self.warm = warm + @override + def name(self) -> str: + return "mypy" + @override def command(self, project: Project, venv: Venv, single_threaded: bool) -> Command: path = self.path or which_tool("mypy", venv.bin) @@ -142,24 +161,37 @@ class Mypy(Tool): command=command, ) + @override + def lsp_command(self, project: Project, venv: Venv) -> list[str] | None: + # Mypy doesn't have official LSP support. + return None + class Pyright(Tool): path: Path + lsp_path: Path def __init__(self, *, path: Path | None = None): if path: self.path = path - else: + # Assume langserver is in the same directory. if sys.platform == "win32": - self.path = Path("./node_modules/.bin/pyright.cmd").resolve() + self.lsp_path = path.with_name("pyright-langserver.cmd") else: - self.path = Path("./node_modules/.bin/pyright").resolve() + self.lsp_path = path.with_name("pyright-langserver") + else: + self.path = npm_bin_path("pyright") + self.lsp_path = npm_bin_path("pyright-langserver") if not self.path.exists(): print( "Pyright executable not found. Did you ran `npm install` in the `ty_benchmark` directory?" ) + @override + def name(self) -> str: + return "pyright" + @override def config(self, project: Project, venv: Venv): return ( @@ -197,6 +229,11 @@ class Pyright(Tool): command=command, ) + @override + def lsp_command(self, project: Project, venv: Venv) -> list[str] | None: + # Pyright LSP server is a separate executable. + return [str(self.lsp_path), "--stdio"] + class Pyrefly(Tool): path: Path @@ -204,6 +241,10 @@ class Pyrefly(Tool): def __init__(self, *, path: Path | None = None): self.path = path or which_tool("pyrefly") + @override + def name(self) -> str: + return "pyrefly" + @override def config(self, project: Project, venv: Venv): return ( @@ -234,3 +275,18 @@ class Pyrefly(Tool): name="Pyrefly", command=command, ) + + @override + def lsp_command(self, project: Project, venv: Venv) -> list[str] | None: + # Pyrefly LSP server. + # Turn-off pyrefly's indexing mode as it results in significant load after opening the first file, + # skewing benchmark results and we don't use any of the features that require indexing. + return [str(self.path), "lsp", "--indexing-mode", "none"] + + +def npm_bin_path(name: str) -> Path: + if sys.platform == "win32": + return Path(f"./node_modules/.bin/{name}.cmd").resolve() + + else: + return (Path("./node_modules/.bin") / name).resolve() diff --git a/scripts/ty_benchmark/uv.lock b/scripts/ty_benchmark/uv.lock index c6846b0e74..b6e4f9c209 100644 --- a/scripts/ty_benchmark/uv.lock +++ b/scripts/ty_benchmark/uv.lock @@ -1,6 +1,59 @@ version = 1 revision = 3 -requires-python = ">=3.12" +requires-python = ">=3.14" + +[[package]] +name = "attrs" +version = "25.4.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6b/5c/685e6633917e101e5dcb62b9dd76946cbb57c26e133bae9e0cd36033c0a9/attrs-25.4.0.tar.gz", hash = "sha256:16d5969b87f0859ef33a48b35d55ac1be6e42ae49d5e853b597db70c35c57e11", size = 934251, upload-time = "2025-10-06T13:54:44.725Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3a/2a/7cc015f5b9f5db42b7d48157e23356022889fc354a2813c15934b7cb5c0e/attrs-25.4.0-py3-none-any.whl", hash = "sha256:adcf7e2a1fb3b36ac48d97835bb6d8ade15b8dcce26aba8bf1d14847b57a3373", size = 67615, upload-time = "2025-10-06T13:54:43.17Z" }, +] + +[[package]] +name = "cattrs" +version = "25.3.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "attrs" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/6e/00/2432bb2d445b39b5407f0a90e01b9a271475eea7caf913d7a86bcb956385/cattrs-25.3.0.tar.gz", hash = "sha256:1ac88d9e5eda10436c4517e390a4142d88638fe682c436c93db7ce4a277b884a", size = 509321, upload-time = "2025-10-07T12:26:08.737Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d8/2b/a40e1488fdfa02d3f9a653a61a5935ea08b3c2225ee818db6a76c7ba9695/cattrs-25.3.0-py3-none-any.whl", hash = "sha256:9896e84e0a5bf723bc7b4b68f4481785367ce07a8a02e7e9ee6eb2819bc306ff", size = 70738, upload-time = "2025-10-07T12:26:06.603Z" }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, +] + +[[package]] +name = "iniconfig" +version = "2.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730", size = 20503, upload-time = "2025-10-18T21:55:43.219Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12", size = 7484, upload-time = "2025-10-18T21:55:41.639Z" }, +] + +[[package]] +name = "lsprotocol" +version = "2025.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "attrs" }, + { name = "cattrs" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e9/26/67b84e6ec1402f0e6764ef3d2a0aaf9a79522cc1d37738f4e5bb0b21521a/lsprotocol-2025.0.0.tar.gz", hash = "sha256:e879da2b9301e82cfc3e60d805630487ac2f7ab17492f4f5ba5aaba94fe56c29", size = 74896, upload-time = "2025-06-17T21:30:18.156Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7b/f0/92f2d609d6642b5f30cb50a885d2bf1483301c69d5786286500d15651ef2/lsprotocol-2025.0.0-py3-none-any.whl", hash = "sha256:f9d78f25221f2a60eaa4a96d3b4ffae011b107537facee61d3da3313880995c7", size = 76250, upload-time = "2025-06-17T21:30:19.455Z" }, +] [[package]] name = "mslex" @@ -12,19 +65,98 @@ wheels = [ ] [[package]] -name = "pyrefly" -version = "0.42.1" +name = "packaging" +version = "25.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/cb/a4/6faf9e361689cbdd4752a0561efb9191f176c5af4ae808ec97beef9aaa50/pyrefly-0.42.1.tar.gz", hash = "sha256:18f569fee2f48ea75f35a7b0d6232c2f409ecdc7343cee786e3f7d80028fc113", size = 3851967, upload-time = "2025-11-18T06:03:56.314Z" } +sdist = { url = "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", size = 165727, upload-time = "2025-04-19T11:48:59.673Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/fa/ac/c0ac659456187f948209ff2195d754bb7922b4332c3801e66e38897968f2/pyrefly-0.42.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:cfdd79dfa4836a2947c0ddc75f26fc7c0a681ae92d03fb72830767808f404a62", size = 9509024, upload-time = "2025-11-18T06:03:39.109Z" }, - { url = "https://files.pythonhosted.org/packages/62/56/344139a1733628804d82bc328b4ee69b6175e9d0ce7d829ba5ef2fe8403e/pyrefly-0.42.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:747521ed8a99d814a9754b3f98066c8b03e9edadb51b7184b86bc4614e4b50a1", size = 9024185, upload-time = "2025-11-18T06:03:41.353Z" }, - { url = "https://files.pythonhosted.org/packages/de/cd/f320908a150487472957f3a0c4d977483024cc2aff5ddd62d0c4ec4dfa2f/pyrefly-0.42.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2084f0fe4cb0a9df3ac1aba6550ddbd980a2b166604ed70d8d34cf1a048067ad", size = 9258639, upload-time = "2025-11-18T06:03:43.411Z" }, - { url = "https://files.pythonhosted.org/packages/3b/62/128ea27ac7ad19b837b34811bcfd9b65806daf152c64f904e3c76ceb2cec/pyrefly-0.42.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:30194ef7428b4060be2fb5fa0a41227b8d4db73bf009aa97ffc930ced3bb234f", size = 10174041, upload-time = "2025-11-18T06:03:45.739Z" }, - { url = "https://files.pythonhosted.org/packages/2b/89/6dabc2a96a97e2d7533517033aab2d0ba98bdaac59c35d7fe22d85f8c78b/pyrefly-0.42.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bf4a4472a42c7f9eaada8a16d61983114299847d35dece68de698dbb90770710", size = 9797317, upload-time = "2025-11-18T06:03:47.863Z" }, - { url = "https://files.pythonhosted.org/packages/ca/a6/071e08ab9b287b3d41fdc7f564ce63bb2eab9a415746d0a48b2794b20871/pyrefly-0.42.1-py3-none-win32.whl", hash = "sha256:84bb9a8ea5b79da065c855673d98fe28b45ebe4b1ed933f1e7da0ba335a40c86", size = 9325929, upload-time = "2025-11-18T06:03:49.925Z" }, - { url = "https://files.pythonhosted.org/packages/5d/69/1b8a133006eb83a75891865a706e981040318b0d7198e14838040b46cd04/pyrefly-0.42.1-py3-none-win_amd64.whl", hash = "sha256:825f5240d1b20490ac87bb880211b30fa532f634bd65c76e5bab656ad47eb80b", size = 9793448, upload-time = "2025-11-18T06:03:52.372Z" }, - { url = "https://files.pythonhosted.org/packages/85/a1/e9c7fe11ebea2b18bcbcb26c4be8c87d25ddc1e3ff1cf942aabce1e0f637/pyrefly-0.42.1-py3-none-win_arm64.whl", hash = "sha256:b0ff3be4beaab9131b6f08b1156fc62d37e977802b5c6c626ad1a1141c2b2e65", size = 9345936, upload-time = "2025-11-18T06:03:54.233Z" }, + { url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469, upload-time = "2025-04-19T11:48:57.875Z" }, +] + +[[package]] +name = "pluggy" +version = "1.6.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" }, +] + +[[package]] +name = "py-cpuinfo" +version = "9.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/37/a8/d832f7293ebb21690860d2e01d8115e5ff6f2ae8bbdc953f0eb0fa4bd2c7/py-cpuinfo-9.0.0.tar.gz", hash = "sha256:3cdbbf3fac90dc6f118bfd64384f309edeadd902d7c8fb17f02ffa1fc3f49690", size = 104716, upload-time = "2022-10-25T20:38:06.303Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e0/a9/023730ba63db1e494a271cb018dcd361bd2c917ba7004c3e49d5daf795a2/py_cpuinfo-9.0.0-py3-none-any.whl", hash = "sha256:859625bc251f64e21f077d099d4162689c762b5d6a4c3c97553d56241c9674d5", size = 22335, upload-time = "2022-10-25T20:38:27.636Z" }, +] + +[[package]] +name = "pygls" +version = "2.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "attrs" }, + { name = "cattrs" }, + { name = "lsprotocol" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/87/50/2bfc32f3acbc8941042919b59c9f592291127b55d7331b72e67ce7b62f08/pygls-2.0.0.tar.gz", hash = "sha256:99accd03de1ca76fe1e7e317f0968ebccf7b9955afed6e2e3e188606a20b4f07", size = 55796, upload-time = "2025-10-17T19:22:47.925Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cc/09/14feafc13bebb9c85b29b374889c1549d3700cb572f2d43a1bb940d70315/pygls-2.0.0-py3-none-any.whl", hash = "sha256:b4e54bba806f76781017ded8fd07463b98670f959042c44170cd362088b200cc", size = 69533, upload-time = "2025-10-17T19:22:46.63Z" }, +] + +[[package]] +name = "pygments" +version = "2.19.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" }, +] + +[[package]] +name = "pyrefly" +version = "0.43.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/58/2c/f318536b85546b9aadb8e3e264e05401000a70fa88957c2bd0e6034b63ac/pyrefly-0.43.1.tar.gz", hash = "sha256:f97b09a45cbff445025f2581bd7bc20ff904baef19b97d134262e11f88fb154e", size = 3884459, upload-time = "2025-11-24T18:51:50.302Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cc/93/1d075912889258410e58fe774e22d2661acba8920e223466c333c7aad889/pyrefly-0.43.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e60ada6bd3eb203e72457f3613d35e9997db1b378298c851301cfe84b58c3be9", size = 9790079, upload-time = "2025-11-24T18:51:32.751Z" }, + { url = "https://files.pythonhosted.org/packages/fc/c2/c235e5d24f3a12ece2102c7cfc68fce1ad8c89cedc23bfb1eb60421e0e31/pyrefly-0.43.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:488b5b77ab8c0998fe9fa48a0ac8c443b13a57a40ba2d998bf29296b5c674cab", size = 9396136, upload-time = "2025-11-24T18:51:35.152Z" }, + { url = "https://files.pythonhosted.org/packages/13/ef/658c8dfd1b2f32637a05bc99bfec32e130bcd948b72e9643661217615d16/pyrefly-0.43.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9e2af14499acce4382aec72d36fcf2807bf667f839bc528bacac83b75106643f", size = 9633606, upload-time = "2025-11-24T18:51:37.353Z" }, + { url = "https://files.pythonhosted.org/packages/d9/bc/3ad135f312106787d1c6951f93bac45cc9afeb6709458a90254794050a4b/pyrefly-0.43.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5cad0ffbed68e99cd072a8bbe1faa30a4a26efa485775e2a9d0e5426a84ef19f", size = 10483447, upload-time = "2025-11-24T18:51:39.441Z" }, + { url = "https://files.pythonhosted.org/packages/45/5c/6c2e6585f27eb57157141e2dd70087b7c9bc60ec3309ad1127d2f5ff1806/pyrefly-0.43.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dc79bdb599b377178457950c5cc4a61dfb82d8ab388758d1958accddfcef7f6b", size = 10087696, upload-time = "2025-11-24T18:51:41.763Z" }, + { url = "https://files.pythonhosted.org/packages/b7/d6/a0c4c33b238e52bce0f10d795dfb03e42498d67a68787baa4e8a394283c6/pyrefly-0.43.1-py3-none-win32.whl", hash = "sha256:e7253b185bb5e5149fb0698f909ccfe7f95d128fbc52fadada0ed539991bcc60", size = 9572615, upload-time = "2025-11-24T18:51:43.929Z" }, + { url = "https://files.pythonhosted.org/packages/a4/e2/fb48a560f15acc597e680f95744e988211f662ff68455f92b0e19fb8b23b/pyrefly-0.43.1-py3-none-win_amd64.whl", hash = "sha256:8befa8a7d529db11ed075e1cfec3e30607dffea4a6e4c7622cce50fcec2467cf", size = 10195087, upload-time = "2025-11-24T18:51:45.953Z" }, + { url = "https://files.pythonhosted.org/packages/e5/e7/18815ed07edbabc104d28e0fd3fae542c83e90ace322b85ef2f8e5a79feb/pyrefly-0.43.1-py3-none-win_arm64.whl", hash = "sha256:8359bb854f5a238c364346836291947ef084516329a50bb400fddf0dd8a9b461", size = 9799746, upload-time = "2025-11-24T18:51:47.958Z" }, +] + +[[package]] +name = "pytest" +version = "9.0.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "iniconfig" }, + { name = "packaging" }, + { name = "pluggy" }, + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/07/56/f013048ac4bc4c1d9be45afd4ab209ea62822fb1598f40687e6bf45dcea4/pytest-9.0.1.tar.gz", hash = "sha256:3e9c069ea73583e255c3b21cf46b8d3c56f6e3a1a8f6da94ccb0fcf57b9d73c8", size = 1564125, upload-time = "2025-11-12T13:05:09.333Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0b/8b/6300fb80f858cda1c51ffa17075df5d846757081d11ab4aa35cef9e6258b/pytest-9.0.1-py3-none-any.whl", hash = "sha256:67be0030d194df2dfa7b556f2e56fb3c3315bd5c8822c6951162b92b32ce7dad", size = 373668, upload-time = "2025-11-12T13:05:07.379Z" }, +] + +[[package]] +name = "pytest-benchmark" +version = "5.2.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "py-cpuinfo" }, + { name = "pytest" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/24/34/9f732b76456d64faffbef6232f1f9dbec7a7c4999ff46282fa418bd1af66/pytest_benchmark-5.2.3.tar.gz", hash = "sha256:deb7317998a23c650fd4ff76e1230066a76cb45dcece0aca5607143c619e7779", size = 341340, upload-time = "2025-11-09T18:48:43.215Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/33/29/e756e715a48959f1c0045342088d7ca9762a2f509b945f362a316e9412b7/pytest_benchmark-5.2.3-py3-none-any.whl", hash = "sha256:bc839726ad20e99aaa0d11a127445457b4219bdb9e80a1afc4b51da7f96b0803", size = 45255, upload-time = "2025-11-09T18:48:39.765Z" }, ] [[package]] @@ -32,12 +164,29 @@ name = "ty-benchmark" version = "0.0.1" source = { editable = "." } dependencies = [ + { name = "lsprotocol" }, { name = "mslex" }, + { name = "pygls" }, { name = "pyrefly" }, + { name = "pytest" }, + { name = "pytest-benchmark" }, ] [package.metadata] requires-dist = [ + { name = "lsprotocol", specifier = ">=2025.0.0" }, { name = "mslex", specifier = ">=1.3.0" }, - { name = "pyrefly", specifier = ">=0.41.3" }, + { name = "pygls", specifier = ">=2.0.0" }, + { name = "pyrefly", specifier = ">=0.43.1" }, + { name = "pytest", specifier = ">=8.0.0" }, + { name = "pytest-benchmark", specifier = ">=4.0.0" }, +] + +[[package]] +name = "typing-extensions" +version = "4.15.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" }, ] From a2096ee2cb846d885c1e6e6f6abe36be1f2b6983 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 1 Dec 2025 11:36:02 +0000 Subject: [PATCH 44/67] [ty] Emit `invalid-named-tuple` on namedtuple classes that have field names starting with underscores (#21697) --- .../resources/mdtest/named_tuple.md | 18 ++++++++ ...edTuples_cannot_h…_(e2ed186fe2b2fc35).snap | 43 +++++++++++++++++++ .../src/types/diagnostic.rs | 40 +++++++++++++++-- .../src/types/infer/builder.rs | 13 +++++- 4 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 crates/ty_python_semantic/resources/mdtest/snapshots/named_tuple.md_-_`NamedTuple`_-_NamedTuples_cannot_h…_(e2ed186fe2b2fc35).snap diff --git a/crates/ty_python_semantic/resources/mdtest/named_tuple.md b/crates/ty_python_semantic/resources/mdtest/named_tuple.md index 439cfff06b..a34e115117 100644 --- a/crates/ty_python_semantic/resources/mdtest/named_tuple.md +++ b/crates/ty_python_semantic/resources/mdtest/named_tuple.md @@ -482,3 +482,21 @@ class F(NamedTuple): super(F, F(42)) # fine ``` + +## NamedTuples cannot have field names starting with underscores + + + +```py +from typing import NamedTuple + +class Foo(NamedTuple): + # error: [invalid-named-tuple] "NamedTuple field `_bar` cannot start with an underscore" + _bar: int + +class Bar(NamedTuple): + x: int + +class Baz(Bar): + _whatever: str # `Baz` is not a NamedTuple class, so this is fine +``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/named_tuple.md_-_`NamedTuple`_-_NamedTuples_cannot_h…_(e2ed186fe2b2fc35).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/named_tuple.md_-_`NamedTuple`_-_NamedTuples_cannot_h…_(e2ed186fe2b2fc35).snap new file mode 100644 index 0000000000..9ef81c9f38 --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/named_tuple.md_-_`NamedTuple`_-_NamedTuples_cannot_h…_(e2ed186fe2b2fc35).snap @@ -0,0 +1,43 @@ +--- +source: crates/ty_test/src/lib.rs +expression: snapshot +--- +--- +mdtest name: named_tuple.md - `NamedTuple` - NamedTuples cannot have field names starting with underscores +mdtest path: crates/ty_python_semantic/resources/mdtest/named_tuple.md +--- + +# Python source files + +## mdtest_snippet.py + +``` + 1 | from typing import NamedTuple + 2 | + 3 | class Foo(NamedTuple): + 4 | # error: [invalid-named-tuple] "NamedTuple field `_bar` cannot start with an underscore" + 5 | _bar: int + 6 | + 7 | class Bar(NamedTuple): + 8 | x: int + 9 | +10 | class Baz(Bar): +11 | _whatever: str # `Baz` is not a NamedTuple class, so this is fine +``` + +# Diagnostics + +``` +error[invalid-named-tuple]: NamedTuple field name cannot start with an underscore + --> src/mdtest_snippet.py:5:5 + | +3 | class Foo(NamedTuple): +4 | # error: [invalid-named-tuple] "NamedTuple field `_bar` cannot start with an underscore" +5 | _bar: int + | ^^^^^^^^^ Class definition will raise `TypeError` at runtime due to this field +6 | +7 | class Bar(NamedTuple): + | +info: rule `invalid-named-tuple` is enabled by default + +``` diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index 8e92c495cf..f4f62a0f0b 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -3529,7 +3529,7 @@ pub(crate) fn report_invalid_key_on_typed_dict<'db>( pub(super) fn report_namedtuple_field_without_default_after_field_with_default<'db>( context: &InferContext<'db, '_>, class: ClassLiteral<'db>, - (field, field_def): &(Name, Option>), + (field, field_def): (&str, Option>), (field_with_default, field_with_default_def): &(Name, Option>), ) { let db = context.db(); @@ -3542,9 +3542,9 @@ pub(super) fn report_namedtuple_field_without_default_after_field_with_default<' let Some(builder) = context.report_lint(&INVALID_NAMED_TUPLE, diagnostic_range) else { return; }; - let mut diagnostic = builder.into_diagnostic(format_args!( + let mut diagnostic = builder.into_diagnostic( "NamedTuple field without default value cannot follow field(s) with default value(s)", - )); + ); diagnostic.set_primary_message(format_args!( "Field `{field}` defined here without a default value", @@ -3575,6 +3575,40 @@ pub(super) fn report_namedtuple_field_without_default_after_field_with_default<' } } +pub(super) fn report_named_tuple_field_with_leading_underscore<'db>( + context: &InferContext<'db, '_>, + class: ClassLiteral<'db>, + field_name: &str, + field_definition: Option>, +) { + let db = context.db(); + let module = context.module(); + + let diagnostic_range = field_definition + .map(|definition| definition.kind(db).full_range(module)) + .unwrap_or_else(|| class.header_range(db)); + + let Some(builder) = context.report_lint(&INVALID_NAMED_TUPLE, diagnostic_range) else { + return; + }; + let mut diagnostic = + builder.into_diagnostic("NamedTuple field name cannot start with an underscore"); + + if field_definition.is_some() { + diagnostic.set_primary_message( + "Class definition will raise `TypeError` at runtime due to this field", + ); + } else { + diagnostic.set_primary_message(format_args!( + "Class definition will raise `TypeError` at runtime due to field `{field_name}`", + )); + } + + diagnostic.set_concise_message(format_args!( + "NamedTuple field `{field_name}` cannot start with an underscore" + )); +} + pub(crate) fn report_missing_typed_dict_key<'db>( context: &InferContext<'db, '_>, constructor_node: AnyNodeRef, diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index 4c97ad8c60..1359f5c97a 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -76,7 +76,7 @@ use crate::types::diagnostic::{ report_invalid_exception_raised, report_invalid_exception_tuple_caught, report_invalid_generator_function_return_type, report_invalid_key_on_typed_dict, report_invalid_or_unsupported_base, report_invalid_return_type, - report_invalid_type_checking_constant, + report_invalid_type_checking_constant, report_named_tuple_field_with_leading_underscore, report_namedtuple_field_without_default_after_field_with_default, report_non_subscriptable, report_possibly_missing_attribute, report_possibly_unresolved_reference, report_rebound_typevar, report_slice_step_size_zero, @@ -628,6 +628,15 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { for (field_name, field) in class.own_fields(self.db(), None, CodeGeneratorKind::NamedTuple) { + if field_name.starts_with('_') { + report_named_tuple_field_with_leading_underscore( + &self.context, + class, + &field_name, + field.single_declaration, + ); + } + if matches!( field.kind, FieldKind::NamedTuple { @@ -641,7 +650,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { report_namedtuple_field_without_default_after_field_with_default( &self.context, class, - &(field_name, field.single_declaration), + (&field_name, field.single_declaration), field_with_default, ); } From 3a11e714c6258f063ba7d93352d975b3a913bc42 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 1 Dec 2025 12:25:49 +0000 Subject: [PATCH 45/67] [ty] Show the user where the type variable was defined in `invalid-type-arguments` diagnostics (#21727) --- .../mdtest/generics/legacy/classes.md | 31 ++++++++ .../mdtest/generics/pep695/classes.md | 26 +++++++ ...iagnostics_for_bad_…_(2ceba7b720e21b8b).snap | 78 +++++++++++++++++++ ...iagnostics_for_bad_…_(cf706b07cf0ec31f).snap | 71 +++++++++++++++++ .../src/types/infer/builder.rs | 44 ++++++++--- 5 files changed, 238 insertions(+), 12 deletions(-) create mode 100644 crates/ty_python_semantic/resources/mdtest/snapshots/classes.md_-_Generic_classes___Leg…_-_Diagnostics_for_bad_…_(2ceba7b720e21b8b).snap create mode 100644 crates/ty_python_semantic/resources/mdtest/snapshots/classes.md_-_Generic_classes___PEP…_-_Diagnostics_for_bad_…_(cf706b07cf0ec31f).snap diff --git a/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md b/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md index 755fa3237c..a655e397a6 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md @@ -210,6 +210,37 @@ reveal_type(WithDefault[str, str]()) # revealed: WithDefault[str, str] reveal_type(WithDefault[str]()) # revealed: WithDefault[str, int] ``` +## Diagnostics for bad specializations + +We show the user where the type variable was defined if a specialization is given that doesn't +satisfy the type variable's upper bound or constraints: + + + +`library.py`: + +```py +from typing import TypeVar, Generic + +T = TypeVar("T", bound=str) +U = TypeVar("U", int, bytes) + +class Bounded(Generic[T]): + x: T + +class Constrained(Generic[U]): + x: U +``` + +`main.py`: + +```py +from library import Bounded, Constrained + +x: Bounded[int] # error: [invalid-type-arguments] +y: Constrained[str] # error: [invalid-type-arguments] +``` + ## Inferring generic class parameters We can infer the type parameter from a type context: diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md index 7a997dd3e4..a110783ed2 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md @@ -191,6 +191,32 @@ reveal_type(WithDefault[str, str]()) # revealed: WithDefault[str, str] reveal_type(WithDefault[str]()) # revealed: WithDefault[str, int] ``` +## Diagnostics for bad specializations + +We show the user where the type variable was defined if a specialization is given that doesn't +satisfy the type variable's upper bound or constraints: + + + +`library.py`: + +```py +class Bounded[T: str]: + x: T + +class Constrained[U: (int, bytes)]: + x: U +``` + +`main.py`: + +```py +from library import Bounded, Constrained + +x: Bounded[int] # error: [invalid-type-arguments] +y: Constrained[str] # error: [invalid-type-arguments] +``` + ## Inferring generic class parameters We can infer the type parameter from a type context: diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/classes.md_-_Generic_classes___Leg…_-_Diagnostics_for_bad_…_(2ceba7b720e21b8b).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/classes.md_-_Generic_classes___Leg…_-_Diagnostics_for_bad_…_(2ceba7b720e21b8b).snap new file mode 100644 index 0000000000..59aaa2d5dd --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/classes.md_-_Generic_classes___Leg…_-_Diagnostics_for_bad_…_(2ceba7b720e21b8b).snap @@ -0,0 +1,78 @@ +--- +source: crates/ty_test/src/lib.rs +expression: snapshot +--- +--- +mdtest name: classes.md - Generic classes: Legacy syntax - Diagnostics for bad specializations +mdtest path: crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md +--- + +# Python source files + +## library.py + +``` + 1 | from typing import TypeVar, Generic + 2 | + 3 | T = TypeVar("T", bound=str) + 4 | U = TypeVar("U", int, bytes) + 5 | + 6 | class Bounded(Generic[T]): + 7 | x: T + 8 | + 9 | class Constrained(Generic[U]): +10 | x: U +``` + +## main.py + +``` +1 | from library import Bounded, Constrained +2 | +3 | x: Bounded[int] # error: [invalid-type-arguments] +4 | y: Constrained[str] # error: [invalid-type-arguments] +``` + +# Diagnostics + +``` +error[invalid-type-arguments]: Type `int` is not assignable to upper bound `str` of type variable `T@Bounded` + --> src/main.py:3:12 + | +1 | from library import Bounded, Constrained +2 | +3 | x: Bounded[int] # error: [invalid-type-arguments] + | ^^^ +4 | y: Constrained[str] # error: [invalid-type-arguments] + | + ::: src/library.py:3:1 + | +1 | from typing import TypeVar, Generic +2 | +3 | T = TypeVar("T", bound=str) + | - Type variable defined here +4 | U = TypeVar("U", int, bytes) + | +info: rule `invalid-type-arguments` is enabled by default + +``` + +``` +error[invalid-type-arguments]: Type `str` does not satisfy constraints `int`, `bytes` of type variable `U@Constrained` + --> src/main.py:4:16 + | +3 | x: Bounded[int] # error: [invalid-type-arguments] +4 | y: Constrained[str] # error: [invalid-type-arguments] + | ^^^ + | + ::: src/library.py:4:1 + | +3 | T = TypeVar("T", bound=str) +4 | U = TypeVar("U", int, bytes) + | - Type variable defined here +5 | +6 | class Bounded(Generic[T]): + | +info: rule `invalid-type-arguments` is enabled by default + +``` diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/classes.md_-_Generic_classes___PEP…_-_Diagnostics_for_bad_…_(cf706b07cf0ec31f).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/classes.md_-_Generic_classes___PEP…_-_Diagnostics_for_bad_…_(cf706b07cf0ec31f).snap new file mode 100644 index 0000000000..56692b997e --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/classes.md_-_Generic_classes___PEP…_-_Diagnostics_for_bad_…_(cf706b07cf0ec31f).snap @@ -0,0 +1,71 @@ +--- +source: crates/ty_test/src/lib.rs +expression: snapshot +--- +--- +mdtest name: classes.md - Generic classes: PEP 695 syntax - Diagnostics for bad specializations +mdtest path: crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md +--- + +# Python source files + +## library.py + +``` +1 | class Bounded[T: str]: +2 | x: T +3 | +4 | class Constrained[U: (int, bytes)]: +5 | x: U +``` + +## main.py + +``` +1 | from library import Bounded, Constrained +2 | +3 | x: Bounded[int] # error: [invalid-type-arguments] +4 | y: Constrained[str] # error: [invalid-type-arguments] +``` + +# Diagnostics + +``` +error[invalid-type-arguments]: Type `int` is not assignable to upper bound `str` of type variable `T@Bounded` + --> src/main.py:3:12 + | +1 | from library import Bounded, Constrained +2 | +3 | x: Bounded[int] # error: [invalid-type-arguments] + | ^^^ +4 | y: Constrained[str] # error: [invalid-type-arguments] + | + ::: src/library.py:1:15 + | +1 | class Bounded[T: str]: + | - Type variable defined here +2 | x: T + | +info: rule `invalid-type-arguments` is enabled by default + +``` + +``` +error[invalid-type-arguments]: Type `str` does not satisfy constraints `int`, `bytes` of type variable `U@Constrained` + --> src/main.py:4:16 + | +3 | x: Bounded[int] # error: [invalid-type-arguments] +4 | y: Constrained[str] # error: [invalid-type-arguments] + | ^^^ + | + ::: src/library.py:4:19 + | +2 | x: T +3 | +4 | class Constrained[U: (int, bytes)]: + | - Type variable defined here +5 | x: U + | +info: rule `invalid-type-arguments` is enabled by default + +``` diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index 1359f5c97a..61ac9059ae 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -1,9 +1,9 @@ use std::iter; use itertools::{Either, EitherOrBoth, Itertools}; -use ruff_db::diagnostic::{Annotation, DiagnosticId, Severity}; +use ruff_db::diagnostic::{Annotation, Diagnostic, DiagnosticId, Severity, Span}; use ruff_db::files::File; -use ruff_db::parsed::ParsedModuleRef; +use ruff_db::parsed::{ParsedModuleRef, parsed_module}; use ruff_python_ast::visitor::{Visitor, walk_expr}; use ruff_python_ast::{ self as ast, AnyNodeRef, ExprContext, HasNodeIndex, NodeIndex, PythonVersion, @@ -102,14 +102,15 @@ use crate::types::typed_dict::{ }; use crate::types::visitor::any_over_type; use crate::types::{ - CallDunderError, CallableBinding, CallableType, CallableTypes, ClassLiteral, ClassType, - DataclassParams, DynamicType, InternedType, IntersectionBuilder, IntersectionType, KnownClass, - KnownInstanceType, LintDiagnosticGuard, MemberLookupPolicy, MetaclassCandidate, - PEP695TypeAliasType, ParameterForm, SpecialFormType, SubclassOfType, TrackedConstraintSet, - Truthiness, Type, TypeAliasType, TypeAndQualifiers, TypeContext, TypeQualifiers, - TypeVarBoundOrConstraints, TypeVarBoundOrConstraintsEvaluation, TypeVarDefaultEvaluation, - TypeVarIdentity, TypeVarInstance, TypeVarKind, TypeVarVariance, TypedDictType, UnionBuilder, - UnionType, UnionTypeInstance, binding_type, infer_scope_types, overrides, todo_type, + BoundTypeVarInstance, CallDunderError, CallableBinding, CallableType, CallableTypes, + ClassLiteral, ClassType, DataclassParams, DynamicType, InternedType, IntersectionBuilder, + IntersectionType, KnownClass, KnownInstanceType, LintDiagnosticGuard, MemberLookupPolicy, + MetaclassCandidate, PEP695TypeAliasType, ParameterForm, SpecialFormType, SubclassOfType, + TrackedConstraintSet, Truthiness, Type, TypeAliasType, TypeAndQualifiers, TypeContext, + TypeQualifiers, TypeVarBoundOrConstraints, TypeVarBoundOrConstraintsEvaluation, + TypeVarDefaultEvaluation, TypeVarIdentity, TypeVarInstance, TypeVarKind, TypeVarVariance, + TypedDictType, UnionBuilder, UnionType, UnionTypeInstance, binding_type, infer_scope_types, + overrides, todo_type, }; use crate::types::{ClassBase, add_inferred_python_version_hint_to_diagnostic}; use crate::unpack::{EvaluationMode, UnpackPosition}; @@ -11292,6 +11293,23 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { generic_context: GenericContext<'db>, specialize: impl FnOnce(&[Option>]) -> Type<'db>, ) -> Type<'db> { + fn add_typevar_definition<'db>( + db: &'db dyn Db, + diagnostic: &mut Diagnostic, + typevar: BoundTypeVarInstance<'db>, + ) { + let Some(definition) = typevar.typevar(db).definition(db) else { + return; + }; + let file = definition.file(db); + let module = parsed_module(db, file).load(db); + let range = definition.focus_range(db, &module).range(); + diagnostic.annotate( + Annotation::secondary(Span::from(file).with_range(range)) + .message("Type variable defined here"), + ); + } + let db = self.db(); let slice_node = subscript.slice.as_ref(); @@ -11349,13 +11367,14 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { if let Some(builder) = self.context.report_lint(&INVALID_TYPE_ARGUMENTS, node) { - builder.into_diagnostic(format_args!( + let mut diagnostic = builder.into_diagnostic(format_args!( "Type `{}` is not assignable to upper bound `{}` \ of type variable `{}`", provided_type.display(db), bound.display(db), typevar.identity(db).display(db), )); + add_typevar_definition(db, &mut diagnostic, typevar); } has_error = true; continue; @@ -11374,7 +11393,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { if let Some(builder) = self.context.report_lint(&INVALID_TYPE_ARGUMENTS, node) { - builder.into_diagnostic(format_args!( + let mut diagnostic = builder.into_diagnostic(format_args!( "Type `{}` does not satisfy constraints `{}` \ of type variable `{}`", provided_type.display(db), @@ -11385,6 +11404,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { .format("`, `"), typevar.identity(db).display(db), )); + add_typevar_definition(db, &mut diagnostic, typevar); } has_error = true; continue; From 5358ddae8857a0450f2a083ecdb7b9d2c0af9981 Mon Sep 17 00:00:00 2001 From: David Peter Date: Mon, 1 Dec 2025 13:52:36 +0100 Subject: [PATCH 46/67] [ty] Exhaustiveness checking for generic classes (#21726) ## Summary We had tests for this already, but they used generic classes that were bivariant in their type parameter, and so this case wasn't captured. closes https://github.com/astral-sh/ty/issues/1702 ## Test Plan Updated Markdown tests --- .../resources/mdtest/exhaustiveness_checking.md | 13 ++++++++++--- .../src/semantic_index/reachability_constraints.rs | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/ty_python_semantic/resources/mdtest/exhaustiveness_checking.md b/crates/ty_python_semantic/resources/mdtest/exhaustiveness_checking.md index 4379498f2d..1d7cbfd401 100644 --- a/crates/ty_python_semantic/resources/mdtest/exhaustiveness_checking.md +++ b/crates/ty_python_semantic/resources/mdtest/exhaustiveness_checking.md @@ -284,10 +284,17 @@ python-version = "3.12" ```py from typing import assert_never -class A[T]: ... +class A[T]: + value: T + class ASub[T](A[T]): ... -class B[T]: ... -class C[T]: ... + +class B[T]: + value: T + +class C[T]: + value: T + class D: ... class E: ... class F: ... diff --git a/crates/ty_python_semantic/src/semantic_index/reachability_constraints.rs b/crates/ty_python_semantic/src/semantic_index/reachability_constraints.rs index d7ab0f621c..76ec1a70f0 100644 --- a/crates/ty_python_semantic/src/semantic_index/reachability_constraints.rs +++ b/crates/ty_python_semantic/src/semantic_index/reachability_constraints.rs @@ -336,6 +336,7 @@ fn pattern_kind_to_type<'db>(db: &'db dyn Db, kind: &PatternPredicateKind<'db>) infer_expression_type(db, *class_expr, TypeContext::default()) .to_instance(db) .unwrap_or(Type::Never) + .top_materialization(db) } else { Type::Never } From 116fd7c7afdbb0c63595025cf930afeb5351672b Mon Sep 17 00:00:00 2001 From: David Peter Date: Mon, 1 Dec 2025 14:02:38 +0100 Subject: [PATCH 47/67] [ty] Remove `GenericAlias`-related todo type (#21728) ## Summary If you manage to create an `typing.GenericAlias` instance without us knowing how that was created, then we don't know what to do with this in a type annotation. So it's better to be explicit and show an error instead of failing silently with a `@Todo` type. ## Test Plan * New Markdown tests * Zero ecosystem impact --- .../mdtest/annotations/generic_alias.md | 34 +++++++++++++++++++ .../resources/mdtest/annotations/new_types.md | 20 ++++------- crates/ty_python_semantic/src/types.rs | 3 -- 3 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 crates/ty_python_semantic/resources/mdtest/annotations/generic_alias.md diff --git a/crates/ty_python_semantic/resources/mdtest/annotations/generic_alias.md b/crates/ty_python_semantic/resources/mdtest/annotations/generic_alias.md new file mode 100644 index 0000000000..86a115d90e --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/annotations/generic_alias.md @@ -0,0 +1,34 @@ +# GenericAlias in type expressions + +We recognize if a `types.GenericAlias` instance is created by specializing a generic class. We don't +explicitly mention it in our type display, but `list[int]` in the example below is a `GenericAlias` +instance at runtime: + +```py +Numbers = list[int] + +# At runtime, `Numbers` is an instance of `types.GenericAlias`. Showing +# this as `list[int]` is more helpful, though: +reveal_type(Numbers) # revealed: + +def _(numbers: Numbers) -> None: + reveal_type(numbers) # revealed: list[int] +``` + +It is also valid to create `GenericAlias` instances manually: + +```py +from types import GenericAlias + +Strings = GenericAlias(list, (str,)) + +reveal_type(Strings) # revealed: GenericAlias +``` + +However, using such a `GenericAlias` instance in a type expression is currently not supported: + +```py +# error: [invalid-type-form] "Variable of type `GenericAlias` is not allowed in a type expression" +def _(strings: Strings) -> None: + reveal_type(strings) # revealed: Unknown +``` diff --git a/crates/ty_python_semantic/resources/mdtest/annotations/new_types.md b/crates/ty_python_semantic/resources/mdtest/annotations/new_types.md index a41b6ad870..39a88cff49 100644 --- a/crates/ty_python_semantic/resources/mdtest/annotations/new_types.md +++ b/crates/ty_python_semantic/resources/mdtest/annotations/new_types.md @@ -1,24 +1,16 @@ # NewType -## Valid forms +## Basic usage + +`NewType` can be used to create distinct types that are based on existing types: ```py from typing_extensions import NewType -from types import GenericAlias -X = GenericAlias(type, ()) -A = NewType("A", int) -# TODO: typeshed for `typing.GenericAlias` uses `type` for the first argument. `NewType` should be special-cased -# to be compatible with `type` -# error: [invalid-argument-type] "Argument to function `__new__` is incorrect: Expected `type`, found ``" -B = GenericAlias(A, ()) +UserId = NewType("UserId", int) -def _( - a: A, - b: B, -): - reveal_type(a) # revealed: A - reveal_type(b) # revealed: @Todo(Support for `typing.GenericAlias` instances in type expressions) +def _(user_id: UserId): + reveal_type(user_id) # revealed: UserId ``` ## Subtyping diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index ff41b2d06d..a81e09edc8 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -7372,9 +7372,6 @@ impl<'db> Type<'db> { Some(KnownClass::TypeVarTuple) => Ok(todo_type!( "Support for `typing.TypeVarTuple` instances in type expressions" )), - Some(KnownClass::GenericAlias) => Ok(todo_type!( - "Support for `typing.GenericAlias` instances in type expressions" - )), _ => Err(InvalidTypeExpressionError { invalid_expressions: smallvec::smallvec_inline![ InvalidTypeExpression::InvalidType(*self, scope_id) From 0e651b50b7d0c2614c5958e78525213e759e5b41 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 1 Dec 2025 13:24:07 +0000 Subject: [PATCH 48/67] [ty] Fix false positives for `class F(Generic[*Ts]): ...` (#21723) --- .../mdtest/generics/legacy/classes.md | 9 ++++++ crates/ty_python_semantic/src/types.rs | 22 ++++++++------- .../src/types/class_base.rs | 4 ++- .../src/types/infer/builder.rs | 28 +++++++++++++++---- .../types/infer/builder/type_expression.rs | 2 +- .../src/types/type_ordering.rs | 3 ++ 6 files changed, 50 insertions(+), 18 deletions(-) diff --git a/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md b/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md index a655e397a6..9e0696a5c2 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md @@ -5,6 +5,11 @@ At its simplest, to define a generic class using the legacy syntax, you inherit from the `typing.Generic` special form, which is "specialized" with the generic class's type variables. +```toml +[environment] +python-version = "3.11" +``` + ```py from ty_extensions import generic_context from typing_extensions import Generic, TypeVar, TypeVarTuple, ParamSpec, Unpack @@ -19,7 +24,9 @@ class MultipleTypevars(Generic[T, S]): ... class SingleParamSpec(Generic[P]): ... class TypeVarAndParamSpec(Generic[P, T]): ... class SingleTypeVarTuple(Generic[Unpack[Ts]]): ... +class StarredSingleTypeVarTuple(Generic[*Ts]): ... class TypeVarAndTypeVarTuple(Generic[T, Unpack[Ts]]): ... +class StarredTypeVarAndTypeVarTuple(Generic[T, *Ts]): ... # revealed: ty_extensions.GenericContext[T@SingleTypevar] reveal_type(generic_context(SingleTypevar)) @@ -34,6 +41,8 @@ reveal_type(generic_context(TypeVarAndParamSpec)) # TODO: support `TypeVarTuple` properly (these should not reveal `None`) reveal_type(generic_context(SingleTypeVarTuple)) # revealed: None reveal_type(generic_context(TypeVarAndTypeVarTuple)) # revealed: None +reveal_type(generic_context(StarredSingleTypeVarTuple)) # revealed: None +reveal_type(generic_context(StarredTypeVarAndTypeVarTuple)) # revealed: None ``` Inheriting from `Generic` multiple times yields a `duplicate-base` diagnostic, just like any other diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index a81e09edc8..92aa8ae4e8 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -956,8 +956,13 @@ impl<'db> Type<'db> { self.is_instance_of(db, KnownClass::NotImplementedType) } - pub(crate) const fn is_todo(&self) -> bool { - matches!(self, Type::Dynamic(DynamicType::Todo(_))) + pub(crate) fn is_todo(&self) -> bool { + self.as_dynamic().is_some_and(|dynamic| match dynamic { + DynamicType::Any | DynamicType::Unknown | DynamicType::Divergent(_) => false, + DynamicType::Todo(_) | DynamicType::TodoStarredExpression | DynamicType::TodoUnpack => { + true + } + }) } pub const fn is_generic_alias(&self) -> bool { @@ -8133,7 +8138,7 @@ impl<'db> Type<'db> { Self::AlwaysFalsy => Type::SpecialForm(SpecialFormType::AlwaysFalsy).definition(db), // These types have no definition - Self::Dynamic(DynamicType::Divergent(_) | DynamicType::Todo(_) | DynamicType::TodoUnpack) + Self::Dynamic(DynamicType::Divergent(_) | DynamicType::Todo(_) | DynamicType::TodoUnpack | DynamicType::TodoStarredExpression) | Self::Callable(_) | Self::TypeIs(_) => None, } @@ -8794,6 +8799,8 @@ pub enum DynamicType { Todo(TodoType), /// A special Todo-variant for `Unpack[Ts]`, so that we can treat it specially in `Generic[Unpack[Ts]]` TodoUnpack, + /// A special Todo-variant for `*Ts`, so that we can treat it specially in `Generic[Unpack[Ts]]` + TodoStarredExpression, /// A type that is determined to be divergent during recursive type inference. Divergent(DivergentType), } @@ -8824,13 +8831,8 @@ impl std::fmt::Display for DynamicType { // `DynamicType::Todo`'s display should be explicit that is not a valid display of // any other type DynamicType::Todo(todo) => write!(f, "@Todo{todo}"), - DynamicType::TodoUnpack => { - if cfg!(debug_assertions) { - f.write_str("@Todo(typing.Unpack)") - } else { - f.write_str("@Todo") - } - } + DynamicType::TodoUnpack => f.write_str("@Todo(typing.Unpack)"), + DynamicType::TodoStarredExpression => f.write_str("@Todo(StarredExpression)"), DynamicType::Divergent(_) => f.write_str("Divergent"), } } diff --git a/crates/ty_python_semantic/src/types/class_base.rs b/crates/ty_python_semantic/src/types/class_base.rs index 4d85a1cc75..c29f72d4f9 100644 --- a/crates/ty_python_semantic/src/types/class_base.rs +++ b/crates/ty_python_semantic/src/types/class_base.rs @@ -63,7 +63,9 @@ impl<'db> ClassBase<'db> { ClassBase::Class(class) => class.name(db), ClassBase::Dynamic(DynamicType::Any) => "Any", ClassBase::Dynamic(DynamicType::Unknown) => "Unknown", - ClassBase::Dynamic(DynamicType::Todo(_) | DynamicType::TodoUnpack) => "@Todo", + ClassBase::Dynamic( + DynamicType::Todo(_) | DynamicType::TodoUnpack | DynamicType::TodoStarredExpression, + ) => "@Todo", ClassBase::Dynamic(DynamicType::Divergent(_)) => "Divergent", ClassBase::Protocol => "Protocol", ClassBase::Generic => "Generic", diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index 61ac9059ae..77f587e2fc 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -8407,7 +8407,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { }); // TODO - todo_type!("starred expression") + Type::Dynamic(DynamicType::TodoStarredExpression) } fn infer_yield_expression(&mut self, yield_expression: &ast::ExprYield) -> Type<'db> { @@ -9571,10 +9571,24 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { (unknown @ Type::Dynamic(DynamicType::Unknown), _, _) | (_, unknown @ Type::Dynamic(DynamicType::Unknown), _) => Some(unknown), - (todo @ Type::Dynamic(DynamicType::Todo(_) | DynamicType::TodoUnpack), _, _) - | (_, todo @ Type::Dynamic(DynamicType::Todo(_) | DynamicType::TodoUnpack), _) => { - Some(todo) - } + ( + todo @ Type::Dynamic( + DynamicType::Todo(_) + | DynamicType::TodoUnpack + | DynamicType::TodoStarredExpression, + ), + _, + _, + ) + | ( + _, + todo @ Type::Dynamic( + DynamicType::Todo(_) + | DynamicType::TodoUnpack + | DynamicType::TodoStarredExpression, + ), + _, + ) => Some(todo), (Type::Never, _, _) | (_, Type::Never, _) => Some(Type::Never), @@ -11898,7 +11912,9 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { self.db(), *typevar, &|ty| match ty { - Type::Dynamic(DynamicType::TodoUnpack) => true, + Type::Dynamic( + DynamicType::TodoUnpack | DynamicType::TodoStarredExpression, + ) => true, Type::NominalInstance(nominal) => matches!( nominal.known_class(self.db()), Some(KnownClass::TypeVarTuple | KnownClass::ParamSpec) diff --git a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs index 153f46dda3..0e3a326139 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs @@ -499,7 +499,7 @@ impl<'db> TypeInferenceBuilder<'db, '_> { if starred_type.exact_tuple_instance_spec(self.db()).is_some() { starred_type } else { - todo_type!("PEP 646") + Type::Dynamic(DynamicType::TodoStarredExpression) } } diff --git a/crates/ty_python_semantic/src/types/type_ordering.rs b/crates/ty_python_semantic/src/types/type_ordering.rs index d2c9a71208..f57855fcb4 100644 --- a/crates/ty_python_semantic/src/types/type_ordering.rs +++ b/crates/ty_python_semantic/src/types/type_ordering.rs @@ -274,6 +274,9 @@ fn dynamic_elements_ordering(left: DynamicType, right: DynamicType) -> Ordering (DynamicType::TodoUnpack, _) => Ordering::Less, (_, DynamicType::TodoUnpack) => Ordering::Greater, + (DynamicType::TodoStarredExpression, _) => Ordering::Less, + (_, DynamicType::TodoStarredExpression) => Ordering::Greater, + (DynamicType::Divergent(left), DynamicType::Divergent(right)) => left.cmp(&right), (DynamicType::Divergent(_), _) => Ordering::Less, (_, DynamicType::Divergent(_)) => Ordering::Greater, From a561e6659d52f3a56566f1b71b613dbd5a871809 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Mon, 1 Dec 2025 09:44:31 -0500 Subject: [PATCH 49/67] [ty] Exclude `typing_extensions` from completions unless it's really available This works by adding a third module resolution mode that lets the caller opt into _some_ shadowing of modules that is otherwise not allowed (for `typing` and `typing_extensions`). Fixes astral-sh/ty#1658 --- .../completion-evaluation-tasks.csv | 2 +- crates/ty_ide/src/all_symbols.rs | 19 +++- crates/ty_ide/src/completion.rs | 87 ++++++++++++++++-- crates/ty_python_semantic/src/lib.rs | 3 +- .../src/module_resolver/list.rs | 7 +- .../src/module_resolver/mod.rs | 2 +- .../src/module_resolver/resolver.rs | 89 +++++++++++++++---- .../ty_python_semantic/src/semantic_model.rs | 8 +- ...ions__code_action_undefined_decorator.snap | 46 ---------- ...code_action_undefined_reference_multi.snap | 46 ---------- .../snapshots/e2e__notebook__auto_import.snap | 44 +-------- .../e2e__notebook__auto_import_docstring.snap | 44 +-------- ...2e__notebook__auto_import_from_future.snap | 44 +-------- .../e2e__notebook__auto_import_same_cell.snap | 44 +-------- 14 files changed, 188 insertions(+), 297 deletions(-) diff --git a/crates/ty_completion_eval/completion-evaluation-tasks.csv b/crates/ty_completion_eval/completion-evaluation-tasks.csv index 8e62771cd9..f8347cb8e5 100644 --- a/crates/ty_completion_eval/completion-evaluation-tasks.csv +++ b/crates/ty_completion_eval/completion-evaluation-tasks.csv @@ -25,4 +25,4 @@ scope-simple-long-identifier,main.py,0,1 tstring-completions,main.py,0,1 ty-extensions-lower-stdlib,main.py,0,8 type-var-typing-over-ast,main.py,0,3 -type-var-typing-over-ast,main.py,1,278 +type-var-typing-over-ast,main.py,1,275 diff --git a/crates/ty_ide/src/all_symbols.rs b/crates/ty_ide/src/all_symbols.rs index 46fff1593b..5f5774cd69 100644 --- a/crates/ty_ide/src/all_symbols.rs +++ b/crates/ty_ide/src/all_symbols.rs @@ -1,6 +1,6 @@ use ruff_db::files::File; use ty_project::Db; -use ty_python_semantic::{Module, all_modules}; +use ty_python_semantic::{Module, ModuleName, all_modules, resolve_real_shadowable_module}; use crate::symbols::{QueryPattern, SymbolInfo, symbols_for_file_global_only}; @@ -8,12 +8,20 @@ use crate::symbols::{QueryPattern, SymbolInfo, symbols_for_file_global_only}; /// /// Returns symbols from all files in the workspace and dependencies, filtered /// by the query. -pub fn all_symbols<'db>(db: &'db dyn Db, query: &QueryPattern) -> Vec> { +pub fn all_symbols<'db>( + db: &'db dyn Db, + importing_from: File, + query: &QueryPattern, +) -> Vec> { // If the query is empty, return immediately to avoid expensive file scanning if query.will_match_everything() { return Vec::new(); } + let typing_extensions = ModuleName::new("typing_extensions").unwrap(); + let is_typing_extensions_available = importing_from.is_stub(db) + || resolve_real_shadowable_module(db, &typing_extensions).is_some(); + let results = std::sync::Mutex::new(Vec::new()); { let modules = all_modules(db); @@ -28,6 +36,11 @@ pub fn all_symbols<'db>(db: &'db dyn Db, query: &QueryPattern) -> Vec String { - let symbols = all_symbols(&self.db, &QueryPattern::fuzzy(query)); + let symbols = all_symbols(&self.db, self.cursor.file, &QueryPattern::fuzzy(query)); if symbols.is_empty() { return "No symbols found".to_string(); diff --git a/crates/ty_ide/src/completion.rs b/crates/ty_ide/src/completion.rs index 8b4c38beb4..45576ae531 100644 --- a/crates/ty_ide/src/completion.rs +++ b/crates/ty_ide/src/completion.rs @@ -517,7 +517,7 @@ fn add_unimported_completions<'db>( let importer = Importer::new(db, &stylist, file, source.as_str(), parsed); let members = importer.members_in_scope_at(scoped.node, scoped.node.start()); - for symbol in all_symbols(db, &completions.query) { + for symbol in all_symbols(db, file, &completions.query) { if symbol.module.file(db) == Some(file) || symbol.module.is_known(db, KnownModule::Builtins) { continue; @@ -5566,10 +5566,7 @@ def foo(param: s) #[test] fn from_import_no_space_not_suggests_import() { let builder = completion_test_builder("from typing"); - assert_snapshot!(builder.build().snapshot(), @r" - typing - typing_extensions - "); + assert_snapshot!(builder.build().snapshot(), @"typing"); } #[test] @@ -5785,6 +5782,86 @@ from .imp "); } + #[test] + fn typing_extensions_excluded_from_import() { + let builder = completion_test_builder("from typing").module_names(); + assert_snapshot!(builder.build().snapshot(), @"typing :: Current module"); + } + + #[test] + fn typing_extensions_excluded_from_auto_import() { + let builder = completion_test_builder("deprecated") + .auto_import() + .module_names(); + assert_snapshot!(builder.build().snapshot(), @r" + Deprecated :: importlib.metadata + DeprecatedList :: importlib.metadata + DeprecatedNonAbstract :: importlib.metadata + DeprecatedTuple :: importlib.metadata + deprecated :: warnings + "); + } + + #[test] + fn typing_extensions_included_from_import() { + let builder = CursorTest::builder() + .source("typing_extensions.py", "deprecated = 1") + .source("foo.py", "from typing") + .completion_test_builder() + .module_names(); + assert_snapshot!(builder.build().snapshot(), @r" + typing :: Current module + typing_extensions :: Current module + "); + } + + #[test] + fn typing_extensions_included_from_auto_import() { + let builder = CursorTest::builder() + .source("typing_extensions.py", "deprecated = 1") + .source("foo.py", "deprecated") + .completion_test_builder() + .auto_import() + .module_names(); + assert_snapshot!(builder.build().snapshot(), @r" + Deprecated :: importlib.metadata + DeprecatedList :: importlib.metadata + DeprecatedNonAbstract :: importlib.metadata + DeprecatedTuple :: importlib.metadata + deprecated :: typing_extensions + deprecated :: warnings + "); + } + + #[test] + fn typing_extensions_included_from_import_in_stub() { + let builder = CursorTest::builder() + .source("foo.pyi", "from typing") + .completion_test_builder() + .module_names(); + assert_snapshot!(builder.build().snapshot(), @r" + typing :: Current module + typing_extensions :: Current module + "); + } + + #[test] + fn typing_extensions_included_from_auto_import_in_stub() { + let builder = CursorTest::builder() + .source("foo.pyi", "deprecated") + .completion_test_builder() + .auto_import() + .module_names(); + assert_snapshot!(builder.build().snapshot(), @r" + Deprecated :: importlib.metadata + DeprecatedList :: importlib.metadata + DeprecatedNonAbstract :: importlib.metadata + DeprecatedTuple :: importlib.metadata + deprecated :: typing_extensions + deprecated :: warnings + "); + } + /// A way to create a simple single-file (named `main.py`) completion test /// builder. /// diff --git a/crates/ty_python_semantic/src/lib.rs b/crates/ty_python_semantic/src/lib.rs index be50dc9b52..8c1776e154 100644 --- a/crates/ty_python_semantic/src/lib.rs +++ b/crates/ty_python_semantic/src/lib.rs @@ -13,7 +13,8 @@ pub use diagnostic::add_inferred_python_version_hint_to_diagnostic; pub use module_name::{ModuleName, ModuleNameResolutionError}; pub use module_resolver::{ KnownModule, Module, SearchPath, SearchPathValidationError, SearchPaths, all_modules, - list_modules, resolve_module, resolve_real_module, system_module_search_paths, + list_modules, resolve_module, resolve_real_module, resolve_real_shadowable_module, + system_module_search_paths, }; pub use program::{ Program, ProgramSettings, PythonVersionFileSource, PythonVersionSource, diff --git a/crates/ty_python_semantic/src/module_resolver/list.rs b/crates/ty_python_semantic/src/module_resolver/list.rs index a7957e3c98..1f87ae5a34 100644 --- a/crates/ty_python_semantic/src/module_resolver/list.rs +++ b/crates/ty_python_semantic/src/module_resolver/list.rs @@ -8,9 +8,7 @@ use crate::program::Program; use super::module::{Module, ModuleKind}; use super::path::{ModulePath, SearchPath, SystemOrVendoredPathRef}; -use super::resolver::{ - ModuleResolveMode, ResolverContext, is_non_shadowable, resolve_file_module, search_paths, -}; +use super::resolver::{ModuleResolveMode, ResolverContext, resolve_file_module, search_paths}; /// List all available modules, including all sub-modules, sorted in lexicographic order. pub fn all_modules(db: &dyn Db) -> Vec> { @@ -309,7 +307,8 @@ impl<'db> Lister<'db> { /// Returns true if the given module name cannot be shadowable. fn is_non_shadowable(&self, name: &ModuleName) -> bool { - is_non_shadowable(self.python_version().minor, name.as_str()) + ModuleResolveMode::StubsAllowed + .is_non_shadowable(self.python_version().minor, name.as_str()) } /// Returns the Python version we want to perform module resolution diff --git a/crates/ty_python_semantic/src/module_resolver/mod.rs b/crates/ty_python_semantic/src/module_resolver/mod.rs index 11d03cf7b5..cc541d9b31 100644 --- a/crates/ty_python_semantic/src/module_resolver/mod.rs +++ b/crates/ty_python_semantic/src/module_resolver/mod.rs @@ -6,7 +6,7 @@ pub use module::Module; pub use path::{SearchPath, SearchPathValidationError}; pub use resolver::SearchPaths; pub(crate) use resolver::file_to_module; -pub use resolver::{resolve_module, resolve_real_module}; +pub use resolver::{resolve_module, resolve_real_module, resolve_real_shadowable_module}; use ruff_db::system::SystemPath; use crate::Db; diff --git a/crates/ty_python_semantic/src/module_resolver/resolver.rs b/crates/ty_python_semantic/src/module_resolver/resolver.rs index 349d685862..ecf92d2d83 100644 --- a/crates/ty_python_semantic/src/module_resolver/resolver.rs +++ b/crates/ty_python_semantic/src/module_resolver/resolver.rs @@ -47,8 +47,33 @@ pub fn resolve_real_module<'db>(db: &'db dyn Db, module_name: &ModuleName) -> Op resolve_module_query(db, interned_name) } +/// Resolves a module name to a module (stubs not allowed, some shadowing is +/// allowed). +/// +/// In particular, this allows `typing_extensions` to be shadowed by a +/// non-standard library module. This is useful in the context of the LSP +/// where we don't want to pretend as if these modules are always available at +/// runtime. +/// +/// This should generally only be used within the context of the LSP. Using it +/// within ty proper risks being unable to resolve builtin modules since they +/// are involved in an import cycle with `builtins`. +pub fn resolve_real_shadowable_module<'db>( + db: &'db dyn Db, + module_name: &ModuleName, +) -> Option> { + let interned_name = ModuleNameIngredient::new( + db, + module_name, + ModuleResolveMode::StubsNotAllowedSomeShadowingAllowed, + ); + + resolve_module_query(db, interned_name) +} + /// Which files should be visible when doing a module query #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, get_size2::GetSize)] +#[allow(clippy::enum_variant_names)] pub(crate) enum ModuleResolveMode { /// Stubs are allowed to appear. /// @@ -61,6 +86,13 @@ pub(crate) enum ModuleResolveMode { /// implementations. When querying searchpaths this also notably replaces typeshed with /// the "real" stdlib. StubsNotAllowed, + /// Like `StubsNotAllowed`, but permits some modules to be shadowed. + /// + /// In particular, this allows `typing_extensions` to be shadowed by a + /// non-standard library module. This is useful in the context of the LSP + /// where we don't want to pretend as if these modules are always available + /// at runtime. + StubsNotAllowedSomeShadowingAllowed, } #[salsa::interned(heap_size=ruff_memory_usage::heap_size)] @@ -73,6 +105,39 @@ impl ModuleResolveMode { fn stubs_allowed(self) -> bool { matches!(self, Self::StubsAllowed) } + + /// Returns `true` if the module name refers to a standard library module + /// which can't be shadowed by a first-party module. + /// + /// This includes "builtin" modules, which can never be shadowed at runtime + /// either. Additionally, certain other modules that are involved in an + /// import cycle with `builtins` (`types`, `typing_extensions`, etc.) are + /// also considered non-shadowable, unless the module resolution mode + /// specifically opts into allowing some of them to be shadowed. This + /// latter set of modules cannot be allowed to be shadowed by first-party + /// or "extra-path" modules in ty proper, or we risk panics in unexpected + /// places due to being unable to resolve builtin symbols. This is similar + /// behaviour to other type checkers such as mypy: + /// + pub(super) fn is_non_shadowable(self, minor_version: u8, module_name: &str) -> bool { + // Builtin modules are never shadowable, no matter what. + if ruff_python_stdlib::sys::is_builtin_module(minor_version, module_name) { + return true; + } + // Similarly for `types`, which is always available at runtime. + if module_name == "types" { + return true; + } + + // Otherwise, some modules should only be conditionally allowed + // to be shadowed, depending on the module resolution mode. + match self { + ModuleResolveMode::StubsAllowed | ModuleResolveMode::StubsNotAllowed => { + module_name == "typing_extensions" + } + ModuleResolveMode::StubsNotAllowedSomeShadowingAllowed => false, + } + } } /// Salsa query that resolves an interned [`ModuleNameIngredient`] to a module. @@ -386,7 +451,10 @@ impl SearchPaths { pub(crate) fn stdlib(&self, mode: ModuleResolveMode) -> Option<&SearchPath> { match mode { ModuleResolveMode::StubsAllowed => self.stdlib_path.as_ref(), - ModuleResolveMode::StubsNotAllowed => self.real_stdlib_path.as_ref(), + ModuleResolveMode::StubsNotAllowed + | ModuleResolveMode::StubsNotAllowedSomeShadowingAllowed => { + self.real_stdlib_path.as_ref() + } } } @@ -439,7 +507,8 @@ pub(crate) fn dynamic_resolution_paths<'db>( // Use the `ModuleResolveMode` to determine which stdlib (if any) to mark as existing let stdlib = match mode.mode(db) { ModuleResolveMode::StubsAllowed => stdlib_path, - ModuleResolveMode::StubsNotAllowed => real_stdlib_path, + ModuleResolveMode::StubsNotAllowed + | ModuleResolveMode::StubsNotAllowedSomeShadowingAllowed => real_stdlib_path, }; if let Some(path) = stdlib.as_ref().and_then(SearchPath::as_system_path) { existing_paths.insert(Cow::Borrowed(path)); @@ -684,27 +753,13 @@ struct ModuleNameIngredient<'db> { pub(super) mode: ModuleResolveMode, } -/// Returns `true` if the module name refers to a standard library module which can't be shadowed -/// by a first-party module. -/// -/// This includes "builtin" modules, which can never be shadowed at runtime either, as well as -/// certain other modules that are involved in an import cycle with `builtins` (`types`, -/// `typing_extensions`, etc.). This latter set of modules cannot be allowed to be shadowed by -/// first-party or "extra-path" modules, or we risk panics in unexpected places due to being -/// unable to resolve builtin symbols. This is similar behaviour to other type checkers such -/// as mypy: -pub(super) fn is_non_shadowable(minor_version: u8, module_name: &str) -> bool { - matches!(module_name, "types" | "typing_extensions") - || ruff_python_stdlib::sys::is_builtin_module(minor_version, module_name) -} - /// Given a module name and a list of search paths in which to lookup modules, /// attempt to resolve the module name fn resolve_name(db: &dyn Db, name: &ModuleName, mode: ModuleResolveMode) -> Option { let program = Program::get(db); let python_version = program.python_version(db); let resolver_state = ResolverContext::new(db, python_version, mode); - let is_non_shadowable = is_non_shadowable(python_version.minor, name.as_str()); + let is_non_shadowable = mode.is_non_shadowable(python_version.minor, name.as_str()); let name = RelaxedModuleName::new(name); let stub_name = name.to_stub_package(); diff --git a/crates/ty_python_semantic/src/semantic_model.rs b/crates/ty_python_semantic/src/semantic_model.rs index e2c550b0b3..236305cb73 100644 --- a/crates/ty_python_semantic/src/semantic_model.rs +++ b/crates/ty_python_semantic/src/semantic_model.rs @@ -6,7 +6,6 @@ use ruff_python_parser::Parsed; use ruff_source_file::LineIndex; use rustc_hash::FxHashMap; -use crate::Db; use crate::module_name::ModuleName; use crate::module_resolver::{KnownModule, Module, list_modules, resolve_module}; use crate::semantic_index::definition::Definition; @@ -14,6 +13,7 @@ use crate::semantic_index::scope::FileScopeId; use crate::semantic_index::semantic_index; use crate::types::ide_support::{Member, all_declarations_and_bindings, all_members}; use crate::types::{Type, binding_type, infer_scope_types}; +use crate::{Db, resolve_real_shadowable_module}; /// The primary interface the LSP should use for querying semantic information about a [`File`]. /// @@ -105,8 +105,14 @@ impl<'db> SemanticModel<'db> { /// Returns completions for symbols available in a `import ` context. pub fn import_completions(&self) -> Vec> { + let typing_extensions = ModuleName::new("typing_extensions").unwrap(); + let is_typing_extensions_available = self.file.is_stub(self.db) + || resolve_real_shadowable_module(self.db, &typing_extensions).is_some(); list_modules(self.db) .into_iter() + .filter(|module| { + is_typing_extensions_available || module.name(self.db) != &typing_extensions + }) .map(|module| { let builtin = module.is_known(self.db, KnownModule::Builtins); let ty = Type::module_literal(self.db, self.file, module); diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_decorator.snap b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_decorator.snap index 576c493622..44c5c5cd22 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_decorator.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_decorator.snap @@ -3,52 +3,6 @@ source: crates/ty_server/tests/e2e/code_actions.rs expression: code_actions --- [ - { - "title": "import typing_extensions.deprecated", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { - "line": 1, - "character": 1 - }, - "end": { - "line": 1, - "character": 11 - } - }, - "severity": 1, - "code": "unresolved-reference", - "codeDescription": { - "href": "https://ty.dev/rules#unresolved-reference" - }, - "source": "ty", - "message": "Name `deprecated` used when not defined", - "relatedInformation": [] - } - ], - "edit": { - "changes": { - "file:///src/foo.py": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "from typing_extensions import deprecated\n" - } - ] - } - }, - "isPreferred": true - }, { "title": "import warnings.deprecated", "kind": "quickfix", diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_reference_multi.snap b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_reference_multi.snap index d081e783de..a57ac11745 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_reference_multi.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_undefined_reference_multi.snap @@ -49,52 +49,6 @@ expression: code_actions }, "isPreferred": true }, - { - "title": "import typing_extensions.Literal", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 3 - }, - "end": { - "line": 0, - "character": 10 - } - }, - "severity": 1, - "code": "unresolved-reference", - "codeDescription": { - "href": "https://ty.dev/rules#unresolved-reference" - }, - "source": "ty", - "message": "Name `Literal` used when not defined", - "relatedInformation": [] - } - ], - "edit": { - "changes": { - "file:///src/foo.py": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "from typing_extensions import Literal\n" - } - ] - } - }, - "isPreferred": true - }, { "title": "Ignore 'unresolved-reference' for this line", "kind": "quickfix", diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import.snap b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import.snap index 0b1f8ad282..cb2f8c55e3 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import.snap @@ -24,31 +24,10 @@ expression: completions } ] }, - { - "label": "Literal (import typing_extensions)", - "kind": 6, - "sortText": " 51", - "insertText": "Literal", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 1, - "character": 0 - }, - "end": { - "line": 1, - "character": 0 - } - }, - "newText": "from typing_extensions import Literal\n" - } - ] - }, { "label": "LiteralString (import typing)", "kind": 6, - "sortText": " 52", + "sortText": " 51", "insertText": "LiteralString", "additionalTextEdits": [ { @@ -65,26 +44,5 @@ expression: completions "newText": "from typing import LiteralString\n" } ] - }, - { - "label": "LiteralString (import typing_extensions)", - "kind": 6, - "sortText": " 53", - "insertText": "LiteralString", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 1, - "character": 0 - }, - "end": { - "line": 1, - "character": 0 - } - }, - "newText": "from typing_extensions import LiteralString\n" - } - ] } ] diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_docstring.snap b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_docstring.snap index 0b1f8ad282..cb2f8c55e3 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_docstring.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_docstring.snap @@ -24,31 +24,10 @@ expression: completions } ] }, - { - "label": "Literal (import typing_extensions)", - "kind": 6, - "sortText": " 51", - "insertText": "Literal", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 1, - "character": 0 - }, - "end": { - "line": 1, - "character": 0 - } - }, - "newText": "from typing_extensions import Literal\n" - } - ] - }, { "label": "LiteralString (import typing)", "kind": 6, - "sortText": " 52", + "sortText": " 51", "insertText": "LiteralString", "additionalTextEdits": [ { @@ -65,26 +44,5 @@ expression: completions "newText": "from typing import LiteralString\n" } ] - }, - { - "label": "LiteralString (import typing_extensions)", - "kind": 6, - "sortText": " 53", - "insertText": "LiteralString", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 1, - "character": 0 - }, - "end": { - "line": 1, - "character": 0 - } - }, - "newText": "from typing_extensions import LiteralString\n" - } - ] } ] diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_from_future.snap b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_from_future.snap index 0b1f8ad282..cb2f8c55e3 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_from_future.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_from_future.snap @@ -24,31 +24,10 @@ expression: completions } ] }, - { - "label": "Literal (import typing_extensions)", - "kind": 6, - "sortText": " 51", - "insertText": "Literal", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 1, - "character": 0 - }, - "end": { - "line": 1, - "character": 0 - } - }, - "newText": "from typing_extensions import Literal\n" - } - ] - }, { "label": "LiteralString (import typing)", "kind": 6, - "sortText": " 52", + "sortText": " 51", "insertText": "LiteralString", "additionalTextEdits": [ { @@ -65,26 +44,5 @@ expression: completions "newText": "from typing import LiteralString\n" } ] - }, - { - "label": "LiteralString (import typing_extensions)", - "kind": 6, - "sortText": " 53", - "insertText": "LiteralString", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 1, - "character": 0 - }, - "end": { - "line": 1, - "character": 0 - } - }, - "newText": "from typing_extensions import LiteralString\n" - } - ] } ] diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_same_cell.snap b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_same_cell.snap index ac3881368b..b7d8c9907a 100644 --- a/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_same_cell.snap +++ b/crates/ty_server/tests/e2e/snapshots/e2e__notebook__auto_import_same_cell.snap @@ -24,31 +24,10 @@ expression: completions } ] }, - { - "label": "Literal (import typing_extensions)", - "kind": 6, - "sortText": " 51", - "insertText": "Literal", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "from typing_extensions import Literal\n" - } - ] - }, { "label": "LiteralString (import typing)", "kind": 6, - "sortText": " 52", + "sortText": " 51", "insertText": "LiteralString", "additionalTextEdits": [ { @@ -65,26 +44,5 @@ expression: completions "newText": ", LiteralString" } ] - }, - { - "label": "LiteralString (import typing_extensions)", - "kind": 6, - "sortText": " 53", - "insertText": "LiteralString", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "from typing_extensions import LiteralString\n" - } - ] } ] From b4f618e180df3a203c76c7e723f6c66c20889977 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Mon, 1 Dec 2025 17:51:34 +0100 Subject: [PATCH 50/67] Use OIDC instead of codspeed token (#21719) --- .github/workflows/ci.yaml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2685f96f94..d77ef83e43 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -942,6 +942,9 @@ jobs: needs.determine_changes.outputs.linter == 'true' ) timeout-minutes: 20 + permissions: + contents: read # required for actions/checkout + id-token: write # required for OIDC authentication with CodSpeed steps: - name: "Checkout Branch" uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 @@ -967,9 +970,8 @@ jobs: - name: "Run benchmarks" uses: CodSpeedHQ/action@346a2d8a8d9d38909abd0bc3d23f773110f076ad # v4.4.1 with: - mode: instrumentation + mode: simulation run: cargo codspeed run - token: ${{ secrets.CODSPEED_TOKEN }} benchmarks-instrumented-ty: name: "benchmarks instrumented (ty)" @@ -982,6 +984,9 @@ jobs: needs.determine_changes.outputs.ty == 'true' ) timeout-minutes: 20 + permissions: + contents: read # required for actions/checkout + id-token: write # required for OIDC authentication with CodSpeed steps: - name: "Checkout Branch" uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 @@ -1007,9 +1012,8 @@ jobs: - name: "Run benchmarks" uses: CodSpeedHQ/action@346a2d8a8d9d38909abd0bc3d23f773110f076ad # v4.4.1 with: - mode: instrumentation + mode: simulation run: cargo codspeed run - token: ${{ secrets.CODSPEED_TOKEN }} benchmarks-walltime: name: "benchmarks walltime (${{ matrix.benchmarks }})" @@ -1017,6 +1021,9 @@ jobs: needs: determine_changes if: ${{ github.repository == 'astral-sh/ruff' && !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.ty == 'true' || github.ref == 'refs/heads/main') }} timeout-minutes: 20 + permissions: + contents: read # required for actions/checkout + id-token: write # required for OIDC authentication with CodSpeed strategy: matrix: benchmarks: @@ -1054,4 +1061,3 @@ jobs: with: mode: walltime run: cargo codspeed run --bench ty_walltime "${{ matrix.benchmarks }}" - token: ${{ secrets.CODSPEED_TOKEN }} From 3738ab1c46197650bdfda349db5e546f634361d9 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Mon, 1 Dec 2025 17:53:45 +0100 Subject: [PATCH 51/67] [ty] Fix find references for type defined in stub (#21732) --- crates/ty_ide/src/find_references.rs | 66 ++++++++++++++++++++++++++++ crates/ty_ide/src/references.rs | 17 +++---- 2 files changed, 73 insertions(+), 10 deletions(-) diff --git a/crates/ty_ide/src/find_references.rs b/crates/ty_ide/src/find_references.rs index 856e1b8b2c..a6b60bc6c2 100644 --- a/crates/ty_ide/src/find_references.rs +++ b/crates/ty_ide/src/find_references.rs @@ -1656,4 +1656,70 @@ func_alias() | "); } + + #[test] + fn stub_target() { + let test = CursorTest::builder() + .source( + "path.pyi", + r#" + class Path: + def __init__(self, path: str): ... + "#, + ) + .source( + "path.py", + r#" + class Path: + def __init__(self, path: str): + self.path = path + "#, + ) + .source( + "importer.py", + r#" + from path import Path + + a: Path = Path("test") + "#, + ) + .build(); + + assert_snapshot!(test.references(), @r###" + info[references]: Reference 1 + --> path.pyi:2:7 + | + 2 | class Path: + | ^^^^ + 3 | def __init__(self, path: str): ... + | + + info[references]: Reference 2 + --> importer.py:2:18 + | + 2 | from path import Path + | ^^^^ + 3 | + 4 | a: Path = Path("test") + | + + info[references]: Reference 3 + --> importer.py:4:4 + | + 2 | from path import Path + 3 | + 4 | a: Path = Path("test") + | ^^^^ + | + + info[references]: Reference 4 + --> importer.py:4:11 + | + 2 | from path import Path + 3 | + 4 | a: Path = Path("test") + | ^^^^ + | + "###); + } } diff --git a/crates/ty_ide/src/references.rs b/crates/ty_ide/src/references.rs index 79d111155a..27f1a3f2cb 100644 --- a/crates/ty_ide/src/references.rs +++ b/crates/ty_ide/src/references.rs @@ -12,7 +12,7 @@ use crate::find_node::CoveringNode; use crate::goto::GotoTarget; -use crate::{Db, NavigationTarget, ReferenceKind, ReferenceTarget}; +use crate::{Db, NavigationTargets, ReferenceKind, ReferenceTarget}; use ruff_db::files::File; use ruff_python_ast::{ self as ast, AnyNodeRef, @@ -49,10 +49,9 @@ pub(crate) fn references( // When finding references, do not resolve any local aliases. let model = SemanticModel::new(db, file); - let target_definitions_nav = goto_target + let target_definitions = goto_target .get_definition_targets(&model, ImportAliasResolution::PreserveAliases)? - .definition_targets(db)?; - let target_definitions: Vec = target_definitions_nav.into_iter().collect(); + .declaration_targets(db)?; // Extract the target text from the goto target for fast comparison let target_text = goto_target.to_string()?; @@ -115,7 +114,7 @@ pub(crate) fn references( fn references_for_file( db: &dyn Db, file: File, - target_definitions: &[NavigationTarget], + target_definitions: &NavigationTargets, target_text: &str, mode: ReferencesMode, references: &mut Vec, @@ -159,7 +158,7 @@ fn is_symbol_externally_visible(goto_target: &GotoTarget<'_>) -> bool { struct LocalReferencesFinder<'a> { model: &'a SemanticModel<'a>, tokens: &'a Tokens, - target_definitions: &'a [NavigationTarget], + target_definitions: &'a NavigationTargets, references: &'a mut Vec, mode: ReferencesMode, target_text: &'a str, @@ -318,12 +317,10 @@ impl LocalReferencesFinder<'_> { GotoTarget::from_covering_node(self.model, covering_node, offset, self.tokens) { // Get the definitions for this goto target - if let Some(current_definitions_nav) = goto_target + if let Some(current_definitions) = goto_target .get_definition_targets(self.model, ImportAliasResolution::PreserveAliases) .and_then(|definitions| definitions.declaration_targets(self.model.db())) { - let current_definitions: Vec = - current_definitions_nav.into_iter().collect(); // Check if any of the current definitions match our target definitions if self.navigation_targets_match(¤t_definitions) { // Determine if this is a read or write reference @@ -337,7 +334,7 @@ impl LocalReferencesFinder<'_> { } /// Check if `Vec` match our target definitions - fn navigation_targets_match(&self, current_targets: &[NavigationTarget]) -> bool { + fn navigation_targets_match(&self, current_targets: &NavigationTargets) -> bool { // Since we're comparing the same symbol, all definitions should be equivalent // We only need to check against the first target definition if let Some(first_target) = self.target_definitions.iter().next() { From 53299cbff46451425806187129b86bb0f8b4af35 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Mon, 1 Dec 2025 13:15:20 -0500 Subject: [PATCH 52/67] Enable PEP 740 attestations when publishing to PyPI (#21735) --- .github/workflows/publish-pypi.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index a66345429a..e2d1fe3587 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -18,8 +18,7 @@ jobs: environment: name: release permissions: - # For PyPI's trusted publishing. - id-token: write + id-token: write # For PyPI's trusted publishing + PEP 740 attestations steps: - name: "Install uv" uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 @@ -28,5 +27,8 @@ jobs: pattern: wheels-* path: wheels merge-multiple: true + - uses: astral-sh/attest-action@2c727738cea36d6c97dd85eb133ea0e0e8fe754b # v0.0.4 + with: + paths: wheels/* - name: Publish to PyPi run: uv publish -v wheels/* From 52f59c5c39057caa13be5a65cb51093528031bf0 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Mon, 1 Dec 2025 11:04:20 -0500 Subject: [PATCH 53/67] [ty] Fix auto-import code action to handle pre-existing import Previously, the code action to do auto-import on a pre-existing symbol assumed that the auto-importer would always generate an import statement. But sometimes an import statement already exists. A good example of this is the following snippet: ``` import warnings @deprecated def myfunc(): pass ``` Specifically, `deprecated` exists in `warnings` but isn't currently imported. A code action to fix this could feasibly do two transformations here. One is: ``` import warnings @warnings.deprecated def myfunc(): pass ``` Another is: ``` from warnings import deprecated import warnings @deprecated def myfunc(): pass ``` The existing auto-import infrastructure chooses the former, since it reuses a pre-existing import statement. But this PR chooses the latter for the case of a code action. I'm not 100% sure this is the correct choice, but it seems to defer more strongly to what the user has typed. That is, that they want to use it unqualified because it's what has been typed. So we should add the necessary import statement to make that work. Fixes astral-sh/ty#1668 --- crates/ty_ide/src/completion.rs | 26 ++++- crates/ty_ide/src/importer.rs | 10 ++ crates/ty_server/tests/e2e/code_actions.rs | 39 ++++++++ ...n_existing_import_undefined_decorator.snap | 98 +++++++++++++++++++ 4 files changed, 169 insertions(+), 4 deletions(-) create mode 100644 crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_existing_import_undefined_decorator.snap diff --git a/crates/ty_ide/src/completion.rs b/crates/ty_ide/src/completion.rs index 45576ae531..811c2f6aef 100644 --- a/crates/ty_ide/src/completion.rs +++ b/crates/ty_ide/src/completion.rs @@ -417,7 +417,16 @@ pub fn completion<'db>( } if settings.auto_import { if let Some(scoped) = scoped { - add_unimported_completions(db, file, &parsed, scoped, &mut completions); + add_unimported_completions( + db, + file, + &parsed, + scoped, + |module_name: &ModuleName, symbol: &str| { + ImportRequest::import_from(module_name.as_str(), symbol) + }, + &mut completions, + ); } } } @@ -453,7 +462,16 @@ pub(crate) fn missing_imports( ) -> Vec { let mut completions = Completions::exactly(db, symbol); let scoped = ScopedTarget { node }; - add_unimported_completions(db, file, parsed, scoped, &mut completions); + add_unimported_completions( + db, + file, + parsed, + scoped, + |module_name: &ModuleName, symbol: &str| { + ImportRequest::import_from(module_name.as_str(), symbol).force() + }, + &mut completions, + ); completions.into_imports() } @@ -502,6 +520,7 @@ fn add_unimported_completions<'db>( file: File, parsed: &ParsedModuleRef, scoped: ScopedTarget<'_>, + create_import_request: impl for<'a> Fn(&'a ModuleName, &'a str) -> ImportRequest<'a>, completions: &mut Completions<'db>, ) { // This is redundant since `all_symbols` will also bail @@ -523,8 +542,7 @@ fn add_unimported_completions<'db>( continue; } - let request = - ImportRequest::import_from(symbol.module.name(db).as_str(), &symbol.symbol.name); + let request = create_import_request(symbol.module.name(db), &symbol.symbol.name); // FIXME: `all_symbols` doesn't account for wildcard imports. // Since we're looking at every module, this is probably // "fine," but it might mean that we import a symbol from the diff --git a/crates/ty_ide/src/importer.rs b/crates/ty_ide/src/importer.rs index 680fb1d8cd..94b2457e74 100644 --- a/crates/ty_ide/src/importer.rs +++ b/crates/ty_ide/src/importer.rs @@ -553,6 +553,16 @@ impl<'a> ImportRequest<'a> { } } + /// Causes this request to become a command. This will force the + /// requested import style, even if another style would be more + /// appropriate generally. + pub(crate) fn force(mut self) -> Self { + Self { + force_style: true, + ..self + } + } + /// Attempts to change the import request style so that the chances /// of an import conflict are minimized (although not always reduced /// to zero). diff --git a/crates/ty_server/tests/e2e/code_actions.rs b/crates/ty_server/tests/e2e/code_actions.rs index baee6c0b42..77f4d42fcb 100644 --- a/crates/ty_server/tests/e2e/code_actions.rs +++ b/crates/ty_server/tests/e2e/code_actions.rs @@ -198,6 +198,45 @@ def my_func(): ... Ok(()) } +// Using an unimported decorator `@deprecated` +#[test] +fn code_action_existing_import_undefined_decorator() -> Result<()> { + let workspace_root = SystemPath::new("src"); + let foo = SystemPath::new("src/foo.py"); + let foo_content = r#"\ +import warnings + +@deprecated("do not use!!!") +def my_func(): ... +"#; + + let ty_toml = SystemPath::new("ty.toml"); + let ty_toml_content = ""; + + let mut server = TestServerBuilder::new()? + .with_workspace(workspace_root, None)? + .with_file(ty_toml, ty_toml_content)? + .with_file(foo, foo_content)? + .enable_pull_diagnostics(true) + .build() + .wait_until_workspaces_are_initialized(); + + server.open_text_document(foo, &foo_content, 1); + + // Wait for diagnostics to be computed. + let diagnostics = server.document_diagnostic_request(foo, None); + let range = full_range(foo_content); + let code_action_params = code_actions_at(&server, diagnostics, foo, range); + + // Get code actions + let code_action_id = server.send_request::(code_action_params); + let code_actions = server.await_response::(&code_action_id); + + insta::assert_json_snapshot!(code_actions); + + Ok(()) +} + // Accessing `typing.Literal` without `typing` imported (ideally we suggest importing `typing`) #[test] fn code_action_attribute_access_on_unimported() -> Result<()> { diff --git a/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_existing_import_undefined_decorator.snap b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_existing_import_undefined_decorator.snap new file mode 100644 index 0000000000..fd022ed8b2 --- /dev/null +++ b/crates/ty_server/tests/e2e/snapshots/e2e__code_actions__code_action_existing_import_undefined_decorator.snap @@ -0,0 +1,98 @@ +--- +source: crates/ty_server/tests/e2e/code_actions.rs +expression: code_actions +--- +[ + { + "title": "import warnings.deprecated", + "kind": "quickfix", + "diagnostics": [ + { + "range": { + "start": { + "line": 3, + "character": 1 + }, + "end": { + "line": 3, + "character": 11 + } + }, + "severity": 1, + "code": "unresolved-reference", + "codeDescription": { + "href": "https://ty.dev/rules#unresolved-reference" + }, + "source": "ty", + "message": "Name `deprecated` used when not defined", + "relatedInformation": [] + } + ], + "edit": { + "changes": { + "file:///src/foo.py": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "from warnings import deprecated\n" + } + ] + } + }, + "isPreferred": true + }, + { + "title": "Ignore 'unresolved-reference' for this line", + "kind": "quickfix", + "diagnostics": [ + { + "range": { + "start": { + "line": 3, + "character": 1 + }, + "end": { + "line": 3, + "character": 11 + } + }, + "severity": 1, + "code": "unresolved-reference", + "codeDescription": { + "href": "https://ty.dev/rules#unresolved-reference" + }, + "source": "ty", + "message": "Name `deprecated` used when not defined", + "relatedInformation": [] + } + ], + "edit": { + "changes": { + "file:///src/foo.py": [ + { + "range": { + "start": { + "line": 3, + "character": 28 + }, + "end": { + "line": 3, + "character": 28 + } + }, + "newText": " # ty:ignore[unresolved-reference]" + } + ] + } + }, + "isPreferred": false + } +] From bc44dc2afb52b8e2da527e07c6d499173ec4f210 Mon Sep 17 00:00:00 2001 From: Dan Parizher <105245560+danparizher@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:26:55 -0500 Subject: [PATCH 54/67] [`flake8-use-pathlib`] Mark fixes unsafe for return type changes (`PTH104`, `PTH105`, `PTH109`, `PTH115`) (#21440) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Marks fixes as unsafe when they change return types (`None` → `Path`, `str`/`bytes` → `Path`, `str` → `Path`), except when the call is a top-level expression. Fixes #21431. ## Problem Fixes for `os.rename`, `os.replace`, `os.getcwd`/`os.getcwdb`, and `os.readlink` were marked safe despite changing return types, which can break code that uses the return value. ## Approach Added `is_top_level_expression_call` helper to detect when a call is a top-level expression (return value unused). Updated `check_os_pathlib_two_arg_calls` and `check_os_pathlib_single_arg_calls` to mark fixes as unsafe unless the call is a top-level expression. Updated PTH109 to use the helper for applicability determination. ## Test Plan Updated snapshots for `preview_full_name.py`, `preview_import_as.py`, `preview_import_from.py`, and `preview_import_from_as.py` to reflect unsafe markers. --------- Co-authored-by: Brent Westbrook --- .../src/rules/flake8_use_pathlib/helpers.rs | 34 +++++++++++-------- .../flake8_use_pathlib/rules/os_getcwd.rs | 17 +++++++--- .../rules/os_path_abspath.rs | 6 +++- .../rules/os_path_basename.rs | 2 +- .../rules/os_path_dirname.rs | 6 +++- .../rules/os_path_exists.rs | 3 +- .../rules/os_path_expanduser.rs | 6 +++- .../rules/os_path_getatime.rs | 3 +- .../rules/os_path_getctime.rs | 3 +- .../rules/os_path_getmtime.rs | 3 +- .../rules/os_path_getsize.rs | 3 +- .../flake8_use_pathlib/rules/os_path_isabs.rs | 3 +- .../flake8_use_pathlib/rules/os_path_isdir.rs | 3 +- .../rules/os_path_isfile.rs | 3 +- .../rules/os_path_islink.rs | 3 +- .../rules/os_path_samefile.rs | 7 ++-- .../flake8_use_pathlib/rules/os_readlink.rs | 13 ++++++- .../flake8_use_pathlib/rules/os_remove.rs | 3 +- .../flake8_use_pathlib/rules/os_rename.rs | 29 +++++++++++++--- .../flake8_use_pathlib/rules/os_replace.rs | 19 +++++++++-- .../flake8_use_pathlib/rules/os_rmdir.rs | 3 +- .../flake8_use_pathlib/rules/os_unlink.rs | 3 +- 22 files changed, 129 insertions(+), 46 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/helpers.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/helpers.rs index 3ba017ecb7..24d9daee25 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/helpers.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/helpers.rs @@ -57,7 +57,7 @@ pub(crate) fn check_os_pathlib_single_arg_calls( fn_argument: &str, fix_enabled: bool, violation: impl Violation, - applicability: Option, + applicability: Applicability, ) { if call.arguments.len() != 1 { return; @@ -91,18 +91,14 @@ pub(crate) fn check_os_pathlib_single_arg_calls( let edit = Edit::range_replacement(replacement, range); - let fix = match applicability { - Some(Applicability::Unsafe) => Fix::unsafe_edits(edit, [import_edit]), - _ => { - let applicability = if checker.comment_ranges().intersects(range) { - Applicability::Unsafe - } else { - Applicability::Safe - }; - Fix::applicable_edits(edit, [import_edit], applicability) - } + let applicability = match applicability { + Applicability::DisplayOnly => Applicability::DisplayOnly, + _ if checker.comment_ranges().intersects(range) => Applicability::Unsafe, + _ => applicability, }; + let fix = Fix::applicable_edits(edit, [import_edit], applicability); + Ok(fix) }); } @@ -138,6 +134,7 @@ pub(crate) fn is_file_descriptor(expr: &Expr, semantic: &SemanticModel) -> bool typing::is_int(binding, semantic) } +#[expect(clippy::too_many_arguments)] pub(crate) fn check_os_pathlib_two_arg_calls( checker: &Checker, call: &ExprCall, @@ -146,6 +143,7 @@ pub(crate) fn check_os_pathlib_two_arg_calls( second_arg: &str, fix_enabled: bool, violation: impl Violation, + applicability: Applicability, ) { let range = call.range(); let mut diagnostic = checker.report_diagnostic(violation, call.func.range()); @@ -174,10 +172,10 @@ pub(crate) fn check_os_pathlib_two_arg_calls( format!("{binding}({path_code}).{attr}({second_code})") }; - let applicability = if checker.comment_ranges().intersects(range) { - Applicability::Unsafe - } else { - Applicability::Safe + let applicability = match applicability { + Applicability::DisplayOnly => Applicability::DisplayOnly, + _ if checker.comment_ranges().intersects(range) => Applicability::Unsafe, + _ => applicability, }; Ok(Fix::applicable_edits( @@ -209,3 +207,9 @@ pub(crate) fn is_argument_non_default(arguments: &Arguments, name: &str, positio .find_argument_value(name, position) .is_some_and(|expr| !expr.is_none_literal_expr()) } + +/// Returns `true` if the given call is a top-level expression in its statement. +/// This means the call's return value is not used, so return type changes don't matter. +pub(crate) fn is_top_level_expression_call(checker: &Checker) -> bool { + checker.semantic().current_expression_parent().is_none() +} diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_getcwd.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_getcwd.rs index 7bb533246d..4174b5825a 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_getcwd.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_getcwd.rs @@ -1,12 +1,14 @@ -use crate::checkers::ast::Checker; -use crate::importer::ImportRequest; -use crate::preview::is_fix_os_getcwd_enabled; -use crate::{FixAvailability, Violation}; use ruff_diagnostics::{Applicability, Edit, Fix}; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; use ruff_text_size::Ranged; +use crate::checkers::ast::Checker; +use crate::importer::ImportRequest; +use crate::preview::is_fix_os_getcwd_enabled; +use crate::rules::flake8_use_pathlib::helpers::is_top_level_expression_call; +use crate::{FixAvailability, Violation}; + /// ## What it does /// Checks for uses of `os.getcwd` and `os.getcwdb`. /// @@ -37,6 +39,8 @@ use ruff_text_size::Ranged; /// /// ## Fix Safety /// This rule's fix is marked as unsafe if the replacement would remove comments attached to the original expression. +/// Additionally, the fix is marked as unsafe when the return value is used because the type changes +/// from `str` or `bytes` to a `Path` object. /// /// ## References /// - [Python documentation: `Path.cwd`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.cwd) @@ -83,7 +87,10 @@ pub(crate) fn os_getcwd(checker: &Checker, call: &ExprCall, segments: &[&str]) { checker.semantic(), )?; - let applicability = if checker.comment_ranges().intersects(range) { + // Unsafe when the fix would delete comments or change a used return value + let applicability = if checker.comment_ranges().intersects(range) + || !is_top_level_expression_call(checker) + { Applicability::Unsafe } else { Applicability::Safe diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_abspath.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_abspath.rs index 9b58561e88..b51ce5cc6d 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_abspath.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_abspath.rs @@ -45,6 +45,10 @@ use crate::{FixAvailability, Violation}; /// behaviors is required, there's no existing `pathlib` alternative. See CPython issue /// [#69200](https://github.com/python/cpython/issues/69200). /// +/// Additionally, the fix is marked as unsafe because `os.path.abspath()` returns `str` or `bytes` (`AnyStr`), +/// while `Path.resolve()` returns a `Path` object. This change in return type can break code that uses +/// the return value. +/// /// ## References /// - [Python documentation: `Path.resolve`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.resolve) /// - [Python documentation: `os.path.abspath`](https://docs.python.org/3/library/os.path.html#os.path.abspath) @@ -85,6 +89,6 @@ pub(crate) fn os_path_abspath(checker: &Checker, call: &ExprCall, segments: &[&s "path", is_fix_os_path_abspath_enabled(checker.settings()), OsPathAbspath, - Some(Applicability::Unsafe), + Applicability::Unsafe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_basename.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_basename.rs index ca69d07ce3..c11c0ac114 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_basename.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_basename.rs @@ -82,6 +82,6 @@ pub(crate) fn os_path_basename(checker: &Checker, call: &ExprCall, segments: &[& "p", is_fix_os_path_basename_enabled(checker.settings()), OsPathBasename, - Some(Applicability::Unsafe), + Applicability::Unsafe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_dirname.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_dirname.rs index d3175c2035..69b44738f4 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_dirname.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_dirname.rs @@ -42,6 +42,10 @@ use crate::{FixAvailability, Violation}; /// As a result, code relying on the exact string returned by `os.path.dirname` /// may behave differently after the fix. /// +/// Additionally, the fix is marked as unsafe because `os.path.dirname()` returns `str` or `bytes` (`AnyStr`), +/// while `Path.parent` returns a `Path` object. This change in return type can break code that uses +/// the return value. +/// /// ## Known issues /// While using `pathlib` can improve the readability and type safety of your code, /// it can be less performant than the lower-level alternatives that work directly with strings, @@ -82,6 +86,6 @@ pub(crate) fn os_path_dirname(checker: &Checker, call: &ExprCall, segments: &[&s "p", is_fix_os_path_dirname_enabled(checker.settings()), OsPathDirname, - Some(Applicability::Unsafe), + Applicability::Unsafe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_exists.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_exists.rs index f3fe32a641..2b130c72d0 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_exists.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_exists.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; @@ -72,6 +73,6 @@ pub(crate) fn os_path_exists(checker: &Checker, call: &ExprCall, segments: &[&st "path", is_fix_os_path_exists_enabled(checker.settings()), OsPathExists, - None, + Applicability::Safe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_expanduser.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_expanduser.rs index d544acde39..2b1fdb8980 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_expanduser.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_expanduser.rs @@ -41,6 +41,10 @@ use crate::{FixAvailability, Violation}; /// directory can't be resolved: `os.path.expanduser` returns the /// input unchanged, while `Path.expanduser` raises `RuntimeError`. /// +/// Additionally, the fix is marked as unsafe because `os.path.expanduser()` returns `str` or `bytes` (`AnyStr`), +/// while `Path.expanduser()` returns a `Path` object. This change in return type can break code that uses +/// the return value. +/// /// ## References /// - [Python documentation: `Path.expanduser`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.expanduser) /// - [Python documentation: `os.path.expanduser`](https://docs.python.org/3/library/os.path.html#os.path.expanduser) @@ -76,6 +80,6 @@ pub(crate) fn os_path_expanduser(checker: &Checker, call: &ExprCall, segments: & "path", is_fix_os_path_expanduser_enabled(checker.settings()), OsPathExpanduser, - Some(Applicability::Unsafe), + Applicability::Unsafe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getatime.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getatime.rs index 0f148f4033..eb8fd1f989 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getatime.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getatime.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; @@ -75,6 +76,6 @@ pub(crate) fn os_path_getatime(checker: &Checker, call: &ExprCall, segments: &[& "filename", is_fix_os_path_getatime_enabled(checker.settings()), OsPathGetatime, - None, + Applicability::Safe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getctime.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getctime.rs index 86bce28aed..3739391711 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getctime.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getctime.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; @@ -76,6 +77,6 @@ pub(crate) fn os_path_getctime(checker: &Checker, call: &ExprCall, segments: &[& "filename", is_fix_os_path_getctime_enabled(checker.settings()), OsPathGetctime, - None, + Applicability::Safe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getmtime.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getmtime.rs index 42e77e3fe9..2853a83986 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getmtime.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getmtime.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; @@ -76,6 +77,6 @@ pub(crate) fn os_path_getmtime(checker: &Checker, call: &ExprCall, segments: &[& "filename", is_fix_os_path_getmtime_enabled(checker.settings()), OsPathGetmtime, - None, + Applicability::Safe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getsize.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getsize.rs index a945b2224c..7c17e687df 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getsize.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getsize.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; @@ -76,6 +77,6 @@ pub(crate) fn os_path_getsize(checker: &Checker, call: &ExprCall, segments: &[&s "filename", is_fix_os_path_getsize_enabled(checker.settings()), OsPathGetsize, - None, + Applicability::Safe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_isabs.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_isabs.rs index b1c8cb33c3..0fcbdf3f06 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_isabs.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_isabs.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; @@ -71,6 +72,6 @@ pub(crate) fn os_path_isabs(checker: &Checker, call: &ExprCall, segments: &[&str "s", is_fix_os_path_isabs_enabled(checker.settings()), OsPathIsabs, - None, + Applicability::Safe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_isdir.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_isdir.rs index a2c1b8620f..9f0de09476 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_isdir.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_isdir.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; @@ -73,6 +74,6 @@ pub(crate) fn os_path_isdir(checker: &Checker, call: &ExprCall, segments: &[&str "s", is_fix_os_path_isdir_enabled(checker.settings()), OsPathIsdir, - None, + Applicability::Safe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_isfile.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_isfile.rs index d31e39eef7..fc723cbd2f 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_isfile.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_isfile.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; @@ -73,6 +74,6 @@ pub(crate) fn os_path_isfile(checker: &Checker, call: &ExprCall, segments: &[&st "path", is_fix_os_path_isfile_enabled(checker.settings()), OsPathIsfile, - None, + Applicability::Safe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_islink.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_islink.rs index d958a2c19c..f64aa7713b 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_islink.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_islink.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; @@ -73,6 +74,6 @@ pub(crate) fn os_path_islink(checker: &Checker, call: &ExprCall, segments: &[&st "path", is_fix_os_path_islink_enabled(checker.settings()), OsPathIslink, - None, + Applicability::Safe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_samefile.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_samefile.rs index cbf6d7a034..af4ee0b605 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_samefile.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_samefile.rs @@ -1,11 +1,13 @@ +use ruff_diagnostics::Applicability; +use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::ExprCall; + use crate::checkers::ast::Checker; use crate::preview::is_fix_os_path_samefile_enabled; use crate::rules::flake8_use_pathlib::helpers::{ check_os_pathlib_two_arg_calls, has_unknown_keywords_or_starred_expr, }; use crate::{FixAvailability, Violation}; -use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_ast::ExprCall; /// ## What it does /// Checks for uses of `os.path.samefile`. @@ -79,5 +81,6 @@ pub(crate) fn os_path_samefile(checker: &Checker, call: &ExprCall, segments: &[& "f2", fix_enabled, OsPathSamefile, + Applicability::Safe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_readlink.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_readlink.rs index d1df572ed5..1505e62a77 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_readlink.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_readlink.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::{ExprCall, PythonVersion}; @@ -5,6 +6,7 @@ use crate::checkers::ast::Checker; use crate::preview::is_fix_os_readlink_enabled; use crate::rules::flake8_use_pathlib::helpers::{ check_os_pathlib_single_arg_calls, is_keyword_only_argument_non_default, + is_top_level_expression_call, }; use crate::{FixAvailability, Violation}; @@ -38,6 +40,8 @@ use crate::{FixAvailability, Violation}; /// /// ## Fix Safety /// This rule's fix is marked as unsafe if the replacement would remove comments attached to the original expression. +/// Additionally, the fix is marked as unsafe when the return value is used because the type changes +/// from `str` or `bytes` (`AnyStr`) to a `Path` object. /// /// ## References /// - [Python documentation: `Path.readlink`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.readline) @@ -82,6 +86,13 @@ pub(crate) fn os_readlink(checker: &Checker, call: &ExprCall, segments: &[&str]) return; } + let applicability = if !is_top_level_expression_call(checker) { + // Unsafe because the return type changes (str/bytes -> Path) + Applicability::Unsafe + } else { + Applicability::Safe + }; + check_os_pathlib_single_arg_calls( checker, call, @@ -89,6 +100,6 @@ pub(crate) fn os_readlink(checker: &Checker, call: &ExprCall, segments: &[&str]) "path", is_fix_os_readlink_enabled(checker.settings()), OsReadlink, - None, + applicability, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_remove.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_remove.rs index 43852e11e2..c25d52de21 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_remove.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_remove.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; @@ -84,6 +85,6 @@ pub(crate) fn os_remove(checker: &Checker, call: &ExprCall, segments: &[&str]) { "path", is_fix_os_remove_enabled(checker.settings()), OsRemove, - None, + Applicability::Safe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rename.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rename.rs index c5f2293ee9..523eada663 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rename.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rename.rs @@ -1,12 +1,14 @@ +use ruff_diagnostics::Applicability; +use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::ExprCall; + use crate::checkers::ast::Checker; use crate::preview::is_fix_os_rename_enabled; use crate::rules::flake8_use_pathlib::helpers::{ check_os_pathlib_two_arg_calls, has_unknown_keywords_or_starred_expr, - is_keyword_only_argument_non_default, + is_keyword_only_argument_non_default, is_top_level_expression_call, }; use crate::{FixAvailability, Violation}; -use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_ast::ExprCall; /// ## What it does /// Checks for uses of `os.rename`. @@ -38,6 +40,8 @@ use ruff_python_ast::ExprCall; /// /// ## Fix Safety /// This rule's fix is marked as unsafe if the replacement would remove comments attached to the original expression. +/// Additionally, the fix is marked as unsafe when the return value is used because the type changes +/// from `None` to a `Path` object. /// /// ## References /// - [Python documentation: `Path.rename`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.rename) @@ -87,5 +91,22 @@ pub(crate) fn os_rename(checker: &Checker, call: &ExprCall, segments: &[&str]) { &["src", "dst", "src_dir_fd", "dst_dir_fd"], ); - check_os_pathlib_two_arg_calls(checker, call, "rename", "src", "dst", fix_enabled, OsRename); + // Unsafe when the fix would delete comments or change a used return value + let applicability = if !is_top_level_expression_call(checker) { + // Unsafe because the return type changes (None -> Path) + Applicability::Unsafe + } else { + Applicability::Safe + }; + + check_os_pathlib_two_arg_calls( + checker, + call, + "rename", + "src", + "dst", + fix_enabled, + OsRename, + applicability, + ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_replace.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_replace.rs index ef60099467..c1211a24a5 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_replace.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_replace.rs @@ -1,12 +1,14 @@ +use ruff_diagnostics::Applicability; +use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::ExprCall; + use crate::checkers::ast::Checker; use crate::preview::is_fix_os_replace_enabled; use crate::rules::flake8_use_pathlib::helpers::{ check_os_pathlib_two_arg_calls, has_unknown_keywords_or_starred_expr, - is_keyword_only_argument_non_default, + is_keyword_only_argument_non_default, is_top_level_expression_call, }; use crate::{FixAvailability, Violation}; -use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_ast::ExprCall; /// ## What it does /// Checks for uses of `os.replace`. @@ -41,6 +43,8 @@ use ruff_python_ast::ExprCall; /// /// ## Fix Safety /// This rule's fix is marked as unsafe if the replacement would remove comments attached to the original expression. +/// Additionally, the fix is marked as unsafe when the return value is used because the type changes +/// from `None` to a `Path` object. /// /// ## References /// - [Python documentation: `Path.replace`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.replace) @@ -90,6 +94,14 @@ pub(crate) fn os_replace(checker: &Checker, call: &ExprCall, segments: &[&str]) &["src", "dst", "src_dir_fd", "dst_dir_fd"], ); + // Unsafe when the fix would delete comments or change a used return value + let applicability = if !is_top_level_expression_call(checker) { + // Unsafe because the return type changes (None -> Path) + Applicability::Unsafe + } else { + Applicability::Safe + }; + check_os_pathlib_two_arg_calls( checker, call, @@ -98,5 +110,6 @@ pub(crate) fn os_replace(checker: &Checker, call: &ExprCall, segments: &[&str]) "dst", fix_enabled, OsReplace, + applicability, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rmdir.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rmdir.rs index a044e541b9..7d7a72812d 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rmdir.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rmdir.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; @@ -84,6 +85,6 @@ pub(crate) fn os_rmdir(checker: &Checker, call: &ExprCall, segments: &[&str]) { "path", is_fix_os_rmdir_enabled(checker.settings()), OsRmdir, - None, + Applicability::Safe, ); } diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_unlink.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_unlink.rs index 9f49025465..28568cf479 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_unlink.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_unlink.rs @@ -1,3 +1,4 @@ +use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::ExprCall; @@ -84,6 +85,6 @@ pub(crate) fn os_unlink(checker: &Checker, call: &ExprCall, segments: &[&str]) { "path", is_fix_os_unlink_enabled(checker.settings()), OsUnlink, - None, + Applicability::Safe, ); } From f052bd644c6ca86a8b7f3c8d7523ac677f2bd665 Mon Sep 17 00:00:00 2001 From: Dan Parizher <105245560+danparizher@users.noreply.github.com> Date: Mon, 1 Dec 2025 16:57:51 -0500 Subject: [PATCH 55/67] [`flake8-simplify`] Fix truthiness assumption for non-iterable arguments in tuple/list/set calls (`SIM222`, `SIM223`) (#21479) ## Summary Fixes false positives in SIM222 and SIM223 where truthiness was incorrectly assumed for `tuple(x)`, `list(x)`, `set(x)` when `x` is not iterable. Fixes #21473. ## Problem `Truthiness::from_expr` recursively called itself on arguments to iterable initializers (`tuple`, `list`, `set`) without checking if the argument is iterable, causing false positives for cases like `tuple(0) or True` and `tuple("") or True`. ## Approach Added `is_definitely_not_iterable` helper and updated `Truthiness::from_expr` to return `Unknown` for non-iterable arguments (numbers, booleans, None) and string literals when called with iterable initializers, preventing incorrect truthiness assumptions. ## Test Plan Added test cases to `SIM222.py` and `SIM223.py` for `tuple("")`, `tuple(0)`, `tuple(1)`, `tuple(False)`, and `tuple(None)` with `or True` and `and False` patterns. --------- Co-authored-by: Brent Westbrook --- .../test/fixtures/flake8_simplify/SIM222.py | 12 ++++++++++ .../test/fixtures/flake8_simplify/SIM223.py | 12 ++++++++++ ...ke8_simplify__tests__SIM222_SIM222.py.snap | 20 ++++++++++++++++ ...ke8_simplify__tests__SIM223_SIM223.py.snap | 20 ++++++++++++++++ crates/ruff_python_ast/src/helpers.rs | 24 ++++++++++++------- 5 files changed, 80 insertions(+), 8 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM222.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM222.py index 71fc606386..62814c796f 100644 --- a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM222.py +++ b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM222.py @@ -216,3 +216,15 @@ def get_items_list(): def get_items_set(): return tuple({item for item in items}) or None # OK + + +# https://github.com/astral-sh/ruff/issues/21473 +tuple("") or True # SIM222 +tuple(t"") or True # OK +tuple(0) or True # OK +tuple(1) or True # OK +tuple(False) or True # OK +tuple(None) or True # OK +tuple(...) or True # OK +tuple(lambda x: x) or True # OK +tuple(x for x in range(0)) or True # OK diff --git a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM223.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM223.py index 12edbff6bd..abcf2536bb 100644 --- a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM223.py +++ b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM223.py @@ -157,3 +157,15 @@ print(f"{1}{''}" and "bar") # https://github.com/astral-sh/ruff/issues/7127 def f(a: "'' and 'b'"): ... + + +# https://github.com/astral-sh/ruff/issues/21473 +tuple("") and False # SIM223 +tuple(t"") and False # OK +tuple(0) and False # OK +tuple(1) and False # OK +tuple(False) and False # OK +tuple(None) and False # OK +tuple(...) and False # OK +tuple(lambda x: x) and False # OK +tuple(x for x in range(0)) and False # OK diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap index 0e65033b21..a1ca861205 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap @@ -1144,3 +1144,23 @@ help: Replace with `(i for i in range(1))` 208 | # https://github.com/astral-sh/ruff/issues/21136 209 | def get_items(): note: This is an unsafe fix and may change runtime behavior + +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:222:1 + | +221 | # https://github.com/astral-sh/ruff/issues/21473 +222 | tuple("") or True # SIM222 + | ^^^^^^^^^^^^^^^^^ +223 | tuple(t"") or True # OK +224 | tuple(0) or True # OK + | +help: Replace with `True` +219 | +220 | +221 | # https://github.com/astral-sh/ruff/issues/21473 + - tuple("") or True # SIM222 +222 + True # SIM222 +223 | tuple(t"") or True # OK +224 | tuple(0) or True # OK +225 | tuple(1) or True # OK +note: This is an unsafe fix and may change runtime behavior diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap index 4fe01c8146..08f3f48ba2 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap @@ -1025,3 +1025,23 @@ help: Replace with `f"{''}{''}"` 156 | 157 | note: This is an unsafe fix and may change runtime behavior + +SIM223 [*] Use `tuple("")` instead of `tuple("") and ...` + --> SIM223.py:163:1 + | +162 | # https://github.com/astral-sh/ruff/issues/21473 +163 | tuple("") and False # SIM223 + | ^^^^^^^^^^^^^^^^^^^ +164 | tuple(t"") and False # OK +165 | tuple(0) and False # OK + | +help: Replace with `tuple("")` +160 | +161 | +162 | # https://github.com/astral-sh/ruff/issues/21473 + - tuple("") and False # SIM223 +163 + tuple("") # SIM223 +164 | tuple(t"") and False # OK +165 | tuple(0) and False # OK +166 | tuple(1) and False # OK +note: This is an unsafe fix and may change runtime behavior diff --git a/crates/ruff_python_ast/src/helpers.rs b/crates/ruff_python_ast/src/helpers.rs index 66ad66d9b1..4879e04780 100644 --- a/crates/ruff_python_ast/src/helpers.rs +++ b/crates/ruff_python_ast/src/helpers.rs @@ -1322,14 +1322,22 @@ impl Truthiness { && arguments.keywords.is_empty() { // Ex) `list([1, 2, 3])` - // For tuple(generator), we can't determine statically if the result will - // be empty or not, so return Unknown. The generator itself is truthy, but - // tuple(empty_generator) is falsy. ListComp and SetComp are handled by - // recursing into Self::from_expr below, which returns Unknown for them. - if argument.is_generator_expr() { - Self::Unknown - } else { - Self::from_expr(argument, is_builtin) + match argument { + // Return Unknown for types with definite truthiness that might + // result in empty iterables (t-strings and generators) or will + // raise a type error (non-iterable types like numbers, booleans, + // None, etc.). + Expr::NumberLiteral(_) + | Expr::BooleanLiteral(_) + | Expr::NoneLiteral(_) + | Expr::EllipsisLiteral(_) + | Expr::TString(_) + | Expr::Lambda(_) + | Expr::Generator(_) => Self::Unknown, + // Recurse for all other types - collections, comprehensions, variables, etc. + // StringLiteral, FString, and BytesLiteral recurse because Self::from_expr + // correctly handles their truthiness (checking if empty or not). + _ => Self::from_expr(argument, is_builtin), } } else { Self::Unknown From edc6ed5077a2e9c97e0347b345d27b51bf773ac7 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Mon, 1 Dec 2025 17:13:52 -0500 Subject: [PATCH 56/67] Use `npm ci --ignore-scripts` everywhere (#21742) --- .github/workflows/ci.yaml | 2 +- .github/workflows/publish-playground.yml | 2 +- .github/workflows/publish-ty-playground.yml | 2 +- crates/ruff_python_formatter/CONTRIBUTING.md | 2 +- playground/README.md | 2 +- scripts/ty_benchmark/README.md | 2 +- scripts/ty_benchmark/src/benchmark/tool.py | 2 +- scripts/update_schemastore.py | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d77ef83e43..64e5e2163c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -918,7 +918,7 @@ jobs: cache-dependency-path: playground/package-lock.json - uses: jetli/wasm-bindgen-action@20b33e20595891ab1a0ed73145d8a21fc96e7c29 # v0.2.0 - name: "Install Node dependencies" - run: npm ci + run: npm ci --ignore-scripts working-directory: playground - name: "Build playgrounds" run: npm run dev:wasm diff --git a/.github/workflows/publish-playground.yml b/.github/workflows/publish-playground.yml index 8986a6d130..52ecadf000 100644 --- a/.github/workflows/publish-playground.yml +++ b/.github/workflows/publish-playground.yml @@ -37,7 +37,7 @@ jobs: package-manager-cache: false - uses: jetli/wasm-bindgen-action@20b33e20595891ab1a0ed73145d8a21fc96e7c29 # v0.2.0 - name: "Install Node dependencies" - run: npm ci + run: npm ci --ignore-scripts working-directory: playground - name: "Run TypeScript checks" run: npm run check diff --git a/.github/workflows/publish-ty-playground.yml b/.github/workflows/publish-ty-playground.yml index a745e80794..5ab24e4a4f 100644 --- a/.github/workflows/publish-ty-playground.yml +++ b/.github/workflows/publish-ty-playground.yml @@ -41,7 +41,7 @@ jobs: package-manager-cache: false - uses: jetli/wasm-bindgen-action@20b33e20595891ab1a0ed73145d8a21fc96e7c29 # v0.2.0 - name: "Install Node dependencies" - run: npm ci + run: npm ci --ignore-scripts working-directory: playground - name: "Run TypeScript checks" run: npm run check diff --git a/crates/ruff_python_formatter/CONTRIBUTING.md b/crates/ruff_python_formatter/CONTRIBUTING.md index f0e60974a4..b30b628c03 100644 --- a/crates/ruff_python_formatter/CONTRIBUTING.md +++ b/crates/ruff_python_formatter/CONTRIBUTING.md @@ -74,7 +74,7 @@ def f(): # a The other option is to use the playground (also check the playground README): ```shell -cd playground && npm install && npm run dev:wasm && npm run dev +cd playground && npm ci --ignore-scripts && npm run dev:wasm && npm run dev ``` Run`npm run dev:wasm` and reload the page in the browser to refresh. diff --git a/playground/README.md b/playground/README.md index 16c4269a9b..4a5ce1c309 100644 --- a/playground/README.md +++ b/playground/README.md @@ -4,7 +4,7 @@ In-browser playground for Ruff. Available [https://play.ruff.rs/](https://play.r ## Getting started -Install the NPM dependencies with `npm install`, and run the development server with +Install the NPM dependencies with `npm ci --ignore-scripts`, and run the development server with `npm start --workspace ruff-playground` or `npm start --workspace ty-playground`. You may need to restart the server after making changes to Ruff or ty to re-build the WASM module. diff --git a/scripts/ty_benchmark/README.md b/scripts/ty_benchmark/README.md index 68654ac3b5..513ea9e0ad 100644 --- a/scripts/ty_benchmark/README.md +++ b/scripts/ty_benchmark/README.md @@ -7,7 +7,7 @@ 1. Build ty: `cargo build --bin ty --release` 1. `cd` into the benchmark directory: `cd scripts/ty_benchmark` -1. Install Pyright: `npm install` +1. Install Pyright: `npm ci --ignore-scripts` 1. Run benchmarks: `uv run benchmark` Requires hyperfine 1.20 or newer. diff --git a/scripts/ty_benchmark/src/benchmark/tool.py b/scripts/ty_benchmark/src/benchmark/tool.py index 4798dd3fdb..83eb9f510e 100644 --- a/scripts/ty_benchmark/src/benchmark/tool.py +++ b/scripts/ty_benchmark/src/benchmark/tool.py @@ -185,7 +185,7 @@ class Pyright(Tool): if not self.path.exists(): print( - "Pyright executable not found. Did you ran `npm install` in the `ty_benchmark` directory?" + "Pyright executable not found. Did you run `npm ci` in the `ty_benchmark` directory?" ) @override diff --git a/scripts/update_schemastore.py b/scripts/update_schemastore.py index 5394e571be..e19f25f515 100644 --- a/scripts/update_schemastore.py +++ b/scripts/update_schemastore.py @@ -87,9 +87,9 @@ def update_schemastore( cwd=schemastore_path, ) - # Run npm install + # Run npm ci src = schemastore_path / "src" - check_call(["npm", "install"], cwd=schemastore_path) + check_call(["npm", "ci", "--ignore-scripts"], cwd=schemastore_path) # Update the schema and format appropriately schema = json.loads(RUFF_SCHEMA.read_text()) From ec854c7199d524308ab45d203d80cf64675d8644 Mon Sep 17 00:00:00 2001 From: Ibraheem Ahmed Date: Mon, 1 Dec 2025 18:20:13 -0500 Subject: [PATCH 57/67] [ty] Fix subtyping with `type[T]` and unions (#21740) ## Summary Resolves https://github.com/astral-sh/ruff/pull/21685#issuecomment-3591695954. --- .../resources/mdtest/type_of/generics.md | 36 +++++-- crates/ty_python_semantic/src/types.rs | 99 ++++++++++--------- 2 files changed, 81 insertions(+), 54 deletions(-) diff --git a/crates/ty_python_semantic/resources/mdtest/type_of/generics.md b/crates/ty_python_semantic/resources/mdtest/type_of/generics.md index c134e2f533..ee998bbb1b 100644 --- a/crates/ty_python_semantic/resources/mdtest/type_of/generics.md +++ b/crates/ty_python_semantic/resources/mdtest/type_of/generics.md @@ -123,11 +123,11 @@ class A: A class `A` is a subtype of `type[T]` if any instance of `A` is a subtype of `T`. ```py -from typing import Callable, Protocol +from typing import Any, Callable, Protocol from ty_extensions import is_assignable_to, is_subtype_of, is_disjoint_from, static_assert -class IntCallback(Protocol): - def __call__(self, *args, **kwargs) -> int: ... +class Callback[T](Protocol): + def __call__(self, *args, **kwargs) -> T: ... def _[T](_: T): static_assert(not is_subtype_of(type[T], T)) @@ -141,8 +141,11 @@ def _[T](_: T): static_assert(is_assignable_to(type[T], Callable[..., T])) static_assert(not is_disjoint_from(type[T], Callable[..., T])) - static_assert(not is_assignable_to(type[T], IntCallback)) - static_assert(not is_disjoint_from(type[T], IntCallback)) + static_assert(is_assignable_to(type[T], Callable[..., T] | Callable[..., Any])) + static_assert(not is_disjoint_from(type[T], Callable[..., T] | Callable[..., Any])) + + static_assert(not is_assignable_to(type[T], Callback[int])) + static_assert(not is_disjoint_from(type[T], Callback[int])) def _[T: int](_: T): static_assert(not is_subtype_of(type[T], T)) @@ -157,14 +160,23 @@ def _[T: int](_: T): static_assert(is_subtype_of(type[T], type[int])) static_assert(not is_disjoint_from(type[T], type[int])) + static_assert(is_subtype_of(type[T], type[int] | None)) + static_assert(not is_disjoint_from(type[T], type[int] | None)) + static_assert(is_subtype_of(type[T], type[T])) static_assert(not is_disjoint_from(type[T], type[T])) static_assert(is_assignable_to(type[T], Callable[..., T])) static_assert(not is_disjoint_from(type[T], Callable[..., T])) - static_assert(is_assignable_to(type[T], IntCallback)) - static_assert(not is_disjoint_from(type[T], IntCallback)) + static_assert(is_assignable_to(type[T], Callable[..., T] | Callable[..., Any])) + static_assert(not is_disjoint_from(type[T], Callable[..., T] | Callable[..., Any])) + + static_assert(is_assignable_to(type[T], Callback[int])) + static_assert(not is_disjoint_from(type[T], Callback[int])) + + static_assert(is_assignable_to(type[T], Callback[int] | Callback[Any])) + static_assert(not is_disjoint_from(type[T], Callback[int] | Callback[Any])) static_assert(is_subtype_of(type[T], type[T] | None)) static_assert(not is_disjoint_from(type[T], type[T] | None)) @@ -183,8 +195,14 @@ def _[T: (int, str)](_: T): static_assert(is_assignable_to(type[T], Callable[..., T])) static_assert(not is_disjoint_from(type[T], Callable[..., T])) - static_assert(not is_assignable_to(type[T], IntCallback)) - static_assert(not is_disjoint_from(type[T], IntCallback)) + static_assert(is_assignable_to(type[T], Callable[..., T] | Callable[..., Any])) + static_assert(not is_disjoint_from(type[T], Callable[..., T] | Callable[..., Any])) + + static_assert(not is_assignable_to(type[T], Callback[int])) + static_assert(not is_disjoint_from(type[T], Callback[int])) + + static_assert(is_assignable_to(type[T], Callback[int | str])) + static_assert(not is_disjoint_from(type[T], Callback[int] | Callback[str])) static_assert(is_subtype_of(type[T], type[T] | None)) static_assert(not is_disjoint_from(type[T], type[T] | None)) diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 92aa8ae4e8..416e80b5c5 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -2089,18 +2089,25 @@ impl<'db> Type<'db> { // `type[T]` is a subtype of the class object `A` if every instance of `T` is a subtype of an instance // of `A`, and vice versa. (Type::SubclassOf(subclass_of), _) - if subclass_of.is_type_var() - && !matches!(target, Type::Callable(_) | Type::ProtocolInstance(_)) => + if !subclass_of + .into_type_var() + .zip(target.to_instance(db)) + .when_some_and(|(this_instance, other_instance)| { + Type::TypeVar(this_instance).has_relation_to_impl( + db, + other_instance, + inferable, + relation, + relation_visitor, + disjointness_visitor, + ) + }) + .is_never_satisfied(db) => { + // TODO: The repetition here isn't great, but we really need the fallthrough logic, + // where this arm only engages if it returns true. let this_instance = Type::TypeVar(subclass_of.into_type_var().unwrap()); - let other_instance = match target { - Type::Union(union) => Some( - union.map(db, |element| element.to_instance(db).unwrap_or(Type::Never)), - ), - _ => target.to_instance(db), - }; - - other_instance.when_some_and(|other_instance| { + target.to_instance(db).when_some_and(|other_instance| { this_instance.has_relation_to_impl( db, other_instance, @@ -2111,6 +2118,7 @@ impl<'db> Type<'db> { ) }) } + (_, Type::SubclassOf(subclass_of)) if subclass_of.is_type_var() => { let other_instance = Type::TypeVar(subclass_of.into_type_var().unwrap()); self.to_instance(db).when_some_and(|this_instance| { @@ -2647,6 +2655,10 @@ impl<'db> Type<'db> { disjointness_visitor, ), + (Type::SubclassOf(subclass_of), _) if subclass_of.is_type_var() => { + ConstraintSet::from(false) + } + // `Literal[]` is a subtype of `type[B]` if `C` is a subclass of `B`, // since `type[B]` describes all possible runtime subclasses of the class object `B`. (Type::ClassLiteral(class), Type::SubclassOf(target_subclass_ty)) => target_subclass_ty @@ -3081,8 +3093,7 @@ impl<'db> Type<'db> { ConstraintSet::from(false) } - // `type[T]` is disjoint from a callable or protocol instance if its upper bound or - // constraints are. + // `type[T]` is disjoint from a callable or protocol instance if its upper bound or constraints are. (Type::SubclassOf(subclass_of), Type::Callable(_) | Type::ProtocolInstance(_)) | (Type::Callable(_) | Type::ProtocolInstance(_), Type::SubclassOf(subclass_of)) if subclass_of.is_type_var() => @@ -3104,13 +3115,14 @@ impl<'db> Type<'db> { // `type[T]` is disjoint from a class object `A` if every instance of `T` is disjoint from an instance of `A`. (Type::SubclassOf(subclass_of), other) | (other, Type::SubclassOf(subclass_of)) - if subclass_of.is_type_var() => + if subclass_of.is_type_var() + && (other.to_instance(db).is_some() + || other.as_typevar().is_some_and(|type_var| { + type_var.typevar(db).bound_or_constraints(db).is_none() + })) => { let this_instance = Type::TypeVar(subclass_of.into_type_var().unwrap()); let other_instance = match other { - Type::Union(union) => Some( - union.map(db, |element| element.to_instance(db).unwrap_or(Type::Never)), - ), // An unbounded typevar `U` may have instances of type `object` if specialized to // an instance of `type`. Type::TypeVar(typevar) @@ -3464,6 +3476,12 @@ impl<'db> Type<'db> { }) } + (Type::SubclassOf(subclass_of_ty), _) | (_, Type::SubclassOf(subclass_of_ty)) + if subclass_of_ty.is_type_var() => + { + ConstraintSet::from(true) + } + (Type::SubclassOf(subclass_of_ty), Type::ClassLiteral(class_b)) | (Type::ClassLiteral(class_b), Type::SubclassOf(subclass_of_ty)) => { match subclass_of_ty.subclass_of() { @@ -3493,31 +3511,27 @@ impl<'db> Type<'db> { // for `type[Any]`/`type[Unknown]`/`type[Todo]`, we know the type cannot be any larger than `type`, // so although the type is dynamic we can still determine disjointedness in some situations (Type::SubclassOf(subclass_of_ty), other) - | (other, Type::SubclassOf(subclass_of_ty)) - if !subclass_of_ty.is_type_var() => - { - match subclass_of_ty.subclass_of() { - SubclassOfInner::Dynamic(_) => { - KnownClass::Type.to_instance(db).is_disjoint_from_impl( - db, - other, - inferable, - disjointness_visitor, - relation_visitor, - ) - } - SubclassOfInner::Class(class) => { - class.metaclass_instance_type(db).is_disjoint_from_impl( - db, - other, - inferable, - disjointness_visitor, - relation_visitor, - ) - } - SubclassOfInner::TypeVar(_) => unreachable!(), + | (other, Type::SubclassOf(subclass_of_ty)) => match subclass_of_ty.subclass_of() { + SubclassOfInner::Dynamic(_) => { + KnownClass::Type.to_instance(db).is_disjoint_from_impl( + db, + other, + inferable, + disjointness_visitor, + relation_visitor, + ) } - } + SubclassOfInner::Class(class) => { + class.metaclass_instance_type(db).is_disjoint_from_impl( + db, + other, + inferable, + disjointness_visitor, + relation_visitor, + ) + } + SubclassOfInner::TypeVar(_) => unreachable!(), + }, (Type::SpecialForm(special_form), Type::NominalInstance(instance)) | (Type::NominalInstance(instance), Type::SpecialForm(special_form)) => { @@ -3779,11 +3793,6 @@ impl<'db> Type<'db> { relation_visitor, ) } - - (Type::SubclassOf(_), _) | (_, Type::SubclassOf(_)) => { - // All cases should have been handled above. - unreachable!() - } } } From 72304b01ebaff3c6bec7daa28b4c6032a92127a7 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 1 Dec 2025 21:46:58 -0500 Subject: [PATCH 58/67] [ty] Add a diagnostic for prohibited `NamedTuple` attribute overrides (#21717) ## Summary Closes https://github.com/astral-sh/ty/issues/1684. --- crates/ty/docs/rules.md | 142 ++++++++++-------- .../resources/mdtest/named_tuple.md | 110 ++++++++++++++ .../resources/mdtest/override.md | 3 +- .../src/types/diagnostic.rs | 24 ++- .../ty_python_semantic/src/types/overrides.rs | 55 ++++++- ty.schema.json | 2 +- 6 files changed, 269 insertions(+), 67 deletions(-) diff --git a/crates/ty/docs/rules.md b/crates/ty/docs/rules.md index 78f757a6bb..5ac36c4fb9 100644 --- a/crates/ty/docs/rules.md +++ b/crates/ty/docs/rules.md @@ -357,7 +357,7 @@ def test(): -> "Literal[5]": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -387,7 +387,7 @@ class C(A, B): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -502,7 +502,7 @@ an atypical memory layout. Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -529,7 +529,7 @@ func("foo") # error: [invalid-argument-type] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -557,7 +557,7 @@ a: int = '' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -591,7 +591,7 @@ C.instance_var = 3 # error: Cannot assign to instance variable Default level: error · Added in 0.0.1-alpha.19 · Related issues · -View source +View source @@ -627,7 +627,7 @@ asyncio.run(main()) Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -651,7 +651,7 @@ class A(42): ... # error: [invalid-base] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -678,7 +678,7 @@ with 1: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -707,7 +707,7 @@ a: str Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -751,7 +751,7 @@ except ZeroDivisionError: Default level: error · Added in 0.0.1-alpha.28 · Related issues · -View source +View source @@ -793,7 +793,7 @@ class D(A): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -826,7 +826,7 @@ class C[U](Generic[T]): ... Default level: error · Added in 0.0.1-alpha.17 · Related issues · -View source +View source @@ -865,7 +865,7 @@ carol = Person(name="Carol", age=25) # typo! Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -900,7 +900,7 @@ def f(t: TypeVar("U")): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -934,7 +934,7 @@ class B(metaclass=f): ... Default level: error · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -1052,7 +1052,8 @@ Checks for invalidly defined `NamedTuple` classes. **Why is this bad?** An invalidly defined `NamedTuple` class may lead to the type checker -drawing incorrect conclusions. It may also lead to `TypeError`s at runtime. +drawing incorrect conclusions. It may also lead to `TypeError`s or +`AttributeError`s at runtime. **Examples** @@ -1067,13 +1068,34 @@ in a class's bases list. TypeError: can only inherit from a NamedTuple type and Generic ``` +Further, `NamedTuple` field names cannot start with an underscore: + +```pycon +>>> from typing import NamedTuple +>>> class Foo(NamedTuple): +... _bar: int +ValueError: Field names cannot start with an underscore: '_bar' +``` + +`NamedTuple` classes also have certain synthesized attributes (like `_asdict`, `_make`, +`_replace`, etc.) that cannot be overwritten. Attempting to assign to these attributes +without a type annotation will raise an `AttributeError` at runtime. + +```pycon +>>> from typing import NamedTuple +>>> class Foo(NamedTuple): +... x: int +... _asdict = 42 +AttributeError: Cannot overwrite NamedTuple attribute _asdict +``` + ## `invalid-newtype` Default level: error · Preview (since 1.0.0) · Related issues · -View source +View source @@ -1103,7 +1125,7 @@ Baz = NewType("Baz", int | str) # error: invalid base for `typing.NewType` Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1153,7 +1175,7 @@ def foo(x: int) -> int: ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1179,7 +1201,7 @@ def f(a: int = ''): ... Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1244,7 +1266,7 @@ TypeError: Protocols can only inherit from other protocols, got Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1293,7 +1315,7 @@ def g(): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1318,7 +1340,7 @@ def func() -> int: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1376,7 +1398,7 @@ TODO #14889 Default level: error · Added in 0.0.1-alpha.6 · Related issues · -View source +View source @@ -1403,7 +1425,7 @@ NewAlias = TypeAliasType(get_name(), int) # error: TypeAliasType name mus Default level: error · Added in 0.0.1-alpha.29 · Related issues · -View source +View source @@ -1450,7 +1472,7 @@ Bar[int] # error: too few arguments Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1480,7 +1502,7 @@ TYPE_CHECKING = '' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1510,7 +1532,7 @@ b: Annotated[int] # `Annotated` expects at least two arguments Default level: error · Added in 0.0.1-alpha.11 · Related issues · -View source +View source @@ -1544,7 +1566,7 @@ f(10) # Error Default level: error · Added in 0.0.1-alpha.11 · Related issues · -View source +View source @@ -1578,7 +1600,7 @@ class C: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1613,7 +1635,7 @@ T = TypeVar('T', bound=str) # valid bound TypeVar Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1638,7 +1660,7 @@ func() # TypeError: func() missing 1 required positional argument: 'x' Default level: error · Added in 0.0.1-alpha.20 · Related issues · -View source +View source @@ -1671,7 +1693,7 @@ alice["age"] # KeyError Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1700,7 +1722,7 @@ func("string") # error: [no-matching-overload] Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1724,7 +1746,7 @@ Subscripting an object that does not support it will raise a `TypeError` at runt Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1750,7 +1772,7 @@ for i in 34: # TypeError: 'int' object is not iterable Default level: error · Added in 0.0.1-alpha.29 · Related issues · -View source +View source @@ -1783,7 +1805,7 @@ class B(A): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1810,7 +1832,7 @@ f(1, x=2) # Error raised here Default level: error · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -1868,7 +1890,7 @@ def test(): -> "int": Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1898,7 +1920,7 @@ static_assert(int(2.0 * 3.0) == 6) # error: does not have a statically known tr Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1927,7 +1949,7 @@ class B(A): ... # Error raised here Default level: error · Preview (since 0.0.1-alpha.30) · Related issues · -View source +View source @@ -1961,7 +1983,7 @@ class F(NamedTuple): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -1988,7 +2010,7 @@ f("foo") # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2016,7 +2038,7 @@ def _(x: int): Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2062,7 +2084,7 @@ class A: Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2089,7 +2111,7 @@ f(x=1, y=2) # Error raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2117,7 +2139,7 @@ A().foo # AttributeError: 'A' object has no attribute 'foo' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2142,7 +2164,7 @@ import foo # ModuleNotFoundError: No module named 'foo' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2167,7 +2189,7 @@ print(x) # NameError: name 'x' is not defined Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2204,7 +2226,7 @@ b1 < b2 < b1 # exception raised here Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2232,7 +2254,7 @@ A() + A() # TypeError: unsupported operand type(s) for +: 'A' and 'A' Default level: error · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2386,7 +2408,7 @@ a = 20 / 0 # type: ignore Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2446,7 +2468,7 @@ A()[0] # TypeError: 'A' object is not subscriptable Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2478,7 +2500,7 @@ from module import a # ImportError: cannot import name 'a' from 'module' Default level: warn · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2505,7 +2527,7 @@ cast(int, f()) # Redundant Default level: warn · Added in 0.0.1-alpha.1 · Related issues · -View source +View source @@ -2529,7 +2551,7 @@ reveal_type(1) # NameError: name 'reveal_type' is not defined Default level: warn · Added in 0.0.1-alpha.15 · Related issues · -View source +View source @@ -2587,7 +2609,7 @@ def g(): Default level: warn · Added in 0.0.1-alpha.7 · Related issues · -View source +View source @@ -2626,7 +2648,7 @@ class D(C): ... # error: [unsupported-base] Default level: warn · Added in 0.0.1-alpha.22 · Related issues · -View source +View source @@ -2713,7 +2735,7 @@ Dividing by zero raises a `ZeroDivisionError` at runtime. Default level: ignore · Added in 0.0.1-alpha.1 · Related issues · -View source +View source diff --git a/crates/ty_python_semantic/resources/mdtest/named_tuple.md b/crates/ty_python_semantic/resources/mdtest/named_tuple.md index a34e115117..3d1a0ec544 100644 --- a/crates/ty_python_semantic/resources/mdtest/named_tuple.md +++ b/crates/ty_python_semantic/resources/mdtest/named_tuple.md @@ -500,3 +500,113 @@ class Bar(NamedTuple): class Baz(Bar): _whatever: str # `Baz` is not a NamedTuple class, so this is fine ``` + +## Prohibited NamedTuple attributes + +`NamedTuple` classes have certain synthesized attributes that cannot be overwritten. Attempting to +assign to these attributes (without type annotations) will raise an `AttributeError` at runtime. + +```py +from typing import NamedTuple + +class F(NamedTuple): + x: int + + # error: [invalid-named-tuple] "Cannot overwrite NamedTuple attribute `_asdict`" + _asdict = 42 + + # error: [invalid-named-tuple] "Cannot overwrite NamedTuple attribute `_make`" + _make = "foo" + + # error: [invalid-named-tuple] "Cannot overwrite NamedTuple attribute `_replace`" + _replace = lambda self: self + + # error: [invalid-named-tuple] "Cannot overwrite NamedTuple attribute `_fields`" + _fields = () + + # error: [invalid-named-tuple] "Cannot overwrite NamedTuple attribute `_field_defaults`" + _field_defaults = {} + + # error: [invalid-named-tuple] "Cannot overwrite NamedTuple attribute `__new__`" + __new__ = None + + # error: [invalid-named-tuple] "Cannot overwrite NamedTuple attribute `__init__`" + __init__ = None + + # error: [invalid-named-tuple] "Cannot overwrite NamedTuple attribute `__getnewargs__`" + __getnewargs__ = None +``` + +However, other attributes (including those starting with underscores) can be assigned without error: + +```py +from typing import NamedTuple + +class G(NamedTuple): + x: int + + # These are fine (not prohibited attributes) + _custom = 42 + __custom__ = "ok" + regular_attr = "value" +``` + +Note that type-annotated attributes become NamedTuple fields, not attribute overrides. They are not +flagged as prohibited attribute overrides (though field names starting with `_` are caught by the +underscore field name check): + +```py +from typing import NamedTuple + +class H(NamedTuple): + x: int + # This is a field declaration, not an override. It's not flagged as an override, + # but is flagged because field names cannot start with underscores. + # error: [invalid-named-tuple] "NamedTuple field `_asdict` cannot start with an underscore" + _asdict: int = 0 +``` + +The check also applies to assignments within conditional blocks: + +```py +from typing import NamedTuple + +class I(NamedTuple): + x: int + + if True: + # error: [invalid-named-tuple] "Cannot overwrite NamedTuple attribute `_asdict`" + _asdict = 42 +``` + +Method definitions with prohibited names are also flagged: + +```py +from typing import NamedTuple + +class J(NamedTuple): + x: int + + # error: [invalid-named-tuple] "Cannot overwrite NamedTuple attribute `_asdict`" + def _asdict(self): + return {} + + @classmethod + # error: [invalid-named-tuple] "Cannot overwrite NamedTuple attribute `_make`" + def _make(cls, iterable): + return cls(*iterable) +``` + +Classes that inherit from a `NamedTuple` class (but don't directly inherit from `NamedTuple`) are +not subject to these restrictions: + +```py +from typing import NamedTuple + +class Base(NamedTuple): + x: int + +class Child(Base): + # This is fine - Child is not directly a NamedTuple + _asdict = 42 +``` diff --git a/crates/ty_python_semantic/resources/mdtest/override.md b/crates/ty_python_semantic/resources/mdtest/override.md index c1ab23d790..386db9b340 100644 --- a/crates/ty_python_semantic/resources/mdtest/override.md +++ b/crates/ty_python_semantic/resources/mdtest/override.md @@ -283,8 +283,7 @@ class MyNamedTuple(NamedTuple): x: int @override - # TODO: this raises an exception at runtime (which we should emit a diagnostic for). - # It shouldn't be an `invalid-explicit-override` diagnostic, however. + # error: [invalid-named-tuple] "Cannot overwrite NamedTuple attribute `_asdict`" def _asdict(self, /) -> dict[str, Any]: ... class MyNamedTupleParent(NamedTuple): diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index f4f62a0f0b..5a5c990ab1 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -545,7 +545,8 @@ declare_lint! { /// /// ## Why is this bad? /// An invalidly defined `NamedTuple` class may lead to the type checker - /// drawing incorrect conclusions. It may also lead to `TypeError`s at runtime. + /// drawing incorrect conclusions. It may also lead to `TypeError`s or + /// `AttributeError`s at runtime. /// /// ## Examples /// A class definition cannot combine `NamedTuple` with other base classes @@ -558,6 +559,27 @@ declare_lint! { /// >>> class Foo(NamedTuple, object): ... /// TypeError: can only inherit from a NamedTuple type and Generic /// ``` + /// + /// Further, `NamedTuple` field names cannot start with an underscore: + /// + /// ```pycon + /// >>> from typing import NamedTuple + /// >>> class Foo(NamedTuple): + /// ... _bar: int + /// ValueError: Field names cannot start with an underscore: '_bar' + /// ``` + /// + /// `NamedTuple` classes also have certain synthesized attributes (like `_asdict`, `_make`, + /// `_replace`, etc.) that cannot be overwritten. Attempting to assign to these attributes + /// without a type annotation will raise an `AttributeError` at runtime. + /// + /// ```pycon + /// >>> from typing import NamedTuple + /// >>> class Foo(NamedTuple): + /// ... x: int + /// ... _asdict = 42 + /// AttributeError: Cannot overwrite NamedTuple attribute _asdict + /// ``` pub(crate) static INVALID_NAMED_TUPLE = { summary: "detects invalid `NamedTuple` class definitions", status: LintStatus::stable("0.0.1-alpha.19"), diff --git a/crates/ty_python_semantic/src/types/overrides.rs b/crates/ty_python_semantic/src/types/overrides.rs index 517878202a..a56f04d1db 100644 --- a/crates/ty_python_semantic/src/types/overrides.rs +++ b/crates/ty_python_semantic/src/types/overrides.rs @@ -11,20 +11,40 @@ use crate::{ Db, lint::LintId, place::Place, - semantic_index::{place_table, scope::ScopeId, symbol::ScopedSymbolId, use_def_map}, + semantic_index::{ + definition::DefinitionKind, place_table, scope::ScopeId, symbol::ScopedSymbolId, + use_def_map, + }, types::{ ClassBase, ClassLiteral, ClassType, KnownClass, Type, class::CodeGeneratorKind, context::InferContext, diagnostic::{ - INVALID_EXPLICIT_OVERRIDE, INVALID_METHOD_OVERRIDE, OVERRIDE_OF_FINAL_METHOD, - report_invalid_method_override, report_overridden_final_method, + INVALID_EXPLICIT_OVERRIDE, INVALID_METHOD_OVERRIDE, INVALID_NAMED_TUPLE, + OVERRIDE_OF_FINAL_METHOD, report_invalid_method_override, + report_overridden_final_method, }, function::{FunctionDecorators, FunctionType, KnownFunction}, ide_support::{MemberWithDefinition, all_declarations_and_bindings}, }, }; +/// Prohibited `NamedTuple` attributes that cannot be overwritten. +/// See for the list. +const PROHIBITED_NAMEDTUPLE_ATTRS: &[&str] = &[ + "__new__", + "__init__", + "__slots__", + "__getnewargs__", + "_fields", + "_field_defaults", + "_field_types", + "_make", + "_replace", + "_asdict", + "_source", +]; + pub(super) fn check_class<'db>(context: &InferContext<'db, '_>, class: ClassLiteral<'db>) { let db = context.db(); let configuration = OverrideRulesConfig::from(context); @@ -126,6 +146,27 @@ fn check_class_declaration<'db>( let (literal, specialization) = class.class_literal(db); let class_kind = CodeGeneratorKind::from_class(db, literal, specialization); + // Check for prohibited `NamedTuple` attribute overrides. + // + // `NamedTuple` classes have certain synthesized attributes (like `_asdict`, `_make`, etc.) + // that cannot be overwritten. Attempting to assign to these attributes (without type + // annotations) or define methods with these names will raise an `AttributeError` at runtime. + if class_kind == Some(CodeGeneratorKind::NamedTuple) + && configuration.check_prohibited_named_tuple_attrs() + && PROHIBITED_NAMEDTUPLE_ATTRS.contains(&member.name.as_str()) + && !matches!(definition.kind(db), DefinitionKind::AnnotatedAssignment(_)) + && let Some(builder) = context.report_lint( + &INVALID_NAMED_TUPLE, + definition.focus_range(db, context.module()), + ) + { + let mut diagnostic = builder.into_diagnostic(format_args!( + "Cannot overwrite NamedTuple attribute `{}`", + &member.name + )); + diagnostic.info("This will cause the class creation to fail at runtime"); + } + let mut subclass_overrides_superclass_declaration = false; let mut has_dynamic_superclass = false; let mut has_typeddict_in_mro = false; @@ -349,6 +390,7 @@ bitflags! { const LISKOV_METHODS = 1 << 0; const EXPLICIT_OVERRIDE = 1 << 1; const FINAL_METHOD_OVERRIDDEN = 1 << 2; + const PROHIBITED_NAMED_TUPLE_ATTR = 1 << 3; } } @@ -368,6 +410,9 @@ impl From<&InferContext<'_, '_>> for OverrideRulesConfig { if rule_selection.is_enabled(LintId::of(&OVERRIDE_OF_FINAL_METHOD)) { config |= OverrideRulesConfig::FINAL_METHOD_OVERRIDDEN; } + if rule_selection.is_enabled(LintId::of(&INVALID_NAMED_TUPLE)) { + config |= OverrideRulesConfig::PROHIBITED_NAMED_TUPLE_ATTR; + } config } @@ -385,4 +430,8 @@ impl OverrideRulesConfig { const fn check_final_method_overridden(self) -> bool { self.contains(OverrideRulesConfig::FINAL_METHOD_OVERRIDDEN) } + + const fn check_prohibited_named_tuple_attrs(self) -> bool { + self.contains(OverrideRulesConfig::PROHIBITED_NAMED_TUPLE_ATTR) + } } diff --git a/ty.schema.json b/ty.schema.json index e2325d6ac4..5630ec353c 100644 --- a/ty.schema.json +++ b/ty.schema.json @@ -645,7 +645,7 @@ }, "invalid-named-tuple": { "title": "detects invalid `NamedTuple` class definitions", - "description": "## What it does\nChecks for invalidly defined `NamedTuple` classes.\n\n## Why is this bad?\nAn invalidly defined `NamedTuple` class may lead to the type checker\ndrawing incorrect conclusions. It may also lead to `TypeError`s at runtime.\n\n## Examples\nA class definition cannot combine `NamedTuple` with other base classes\nin multiple inheritance; doing so raises a `TypeError` at runtime. The sole\nexception to this rule is `Generic[]`, which can be used alongside `NamedTuple`\nin a class's bases list.\n\n```pycon\n>>> from typing import NamedTuple\n>>> class Foo(NamedTuple, object): ...\nTypeError: can only inherit from a NamedTuple type and Generic\n```", + "description": "## What it does\nChecks for invalidly defined `NamedTuple` classes.\n\n## Why is this bad?\nAn invalidly defined `NamedTuple` class may lead to the type checker\ndrawing incorrect conclusions. It may also lead to `TypeError`s or\n`AttributeError`s at runtime.\n\n## Examples\nA class definition cannot combine `NamedTuple` with other base classes\nin multiple inheritance; doing so raises a `TypeError` at runtime. The sole\nexception to this rule is `Generic[]`, which can be used alongside `NamedTuple`\nin a class's bases list.\n\n```pycon\n>>> from typing import NamedTuple\n>>> class Foo(NamedTuple, object): ...\nTypeError: can only inherit from a NamedTuple type and Generic\n```\n\nFurther, `NamedTuple` field names cannot start with an underscore:\n\n```pycon\n>>> from typing import NamedTuple\n>>> class Foo(NamedTuple):\n... _bar: int\nValueError: Field names cannot start with an underscore: '_bar'\n```\n\n`NamedTuple` classes also have certain synthesized attributes (like `_asdict`, `_make`,\n`_replace`, etc.) that cannot be overwritten. Attempting to assign to these attributes\nwithout a type annotation will raise an `AttributeError` at runtime.\n\n```pycon\n>>> from typing import NamedTuple\n>>> class Foo(NamedTuple):\n... x: int\n... _asdict = 42\nAttributeError: Cannot overwrite NamedTuple attribute _asdict\n```", "default": "error", "oneOf": [ { From 2182c750dbd6cb1243a84b92e4904b0d3a193c47 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Tue, 2 Dec 2025 08:47:47 +0100 Subject: [PATCH 59/67] [ty] Use generator over list comprehension to avoid cast (#21748) --- scripts/ty_benchmark/src/benchmark/lsp_client.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/scripts/ty_benchmark/src/benchmark/lsp_client.py b/scripts/ty_benchmark/src/benchmark/lsp_client.py index bd932e667d..d51f61fa09 100644 --- a/scripts/ty_benchmark/src/benchmark/lsp_client.py +++ b/scripts/ty_benchmark/src/benchmark/lsp_client.py @@ -4,7 +4,7 @@ import asyncio import logging from asyncio import Future from pathlib import Path -from typing import Any, NamedTuple, cast, override +from typing import Any, NamedTuple, override from lsprotocol import types as lsp from pygls.lsp.client import LanguageClient @@ -136,12 +136,7 @@ class LSPClient(LanguageClient): self, files: list[Path] ) -> list[FileDiagnostics]: responses = await asyncio.gather( - *[self.text_document_diagnostics_async(f) for f in files] - ) - - responses = cast( - list[lsp.Diagnostic], - responses, + *(self.text_document_diagnostics_async(f) for f in files) ) return [ From cf4196466c65572e95ee852d95e6f07eef4977e7 Mon Sep 17 00:00:00 2001 From: Douglas Creager Date: Tue, 2 Dec 2025 03:17:29 -0500 Subject: [PATCH 60/67] [ty] Stop testing the (brittle) constraint set display implementation (#21743) The `Display` implementation for constraint sets is brittle, and deserves a rethink. But later! It's perfectly fine for printf debugging; we just shouldn't be writing mdtests that depend on any particular rendering details. Most of these tests can be replaced with an equivalence check that actually validates that the _behavior_ of two constraint sets are identical. --- .../mdtest/generics/specialize_constrained.md | 6 +- .../resources/mdtest/ty_extensions.md | 2 +- .../mdtest/type_properties/constraints.md | 560 ++++++++---------- .../type_properties/implies_subtype_of.md | 130 ++-- .../src/types/constraints.rs | 1 + .../ty_python_semantic/src/types/display.rs | 6 +- .../src/types/infer/builder.rs | 21 +- 7 files changed, 355 insertions(+), 371 deletions(-) diff --git a/crates/ty_python_semantic/resources/mdtest/generics/specialize_constrained.md b/crates/ty_python_semantic/resources/mdtest/generics/specialize_constrained.md index 3b96729086..bd4ee67aaf 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/specialize_constrained.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/specialize_constrained.md @@ -321,9 +321,8 @@ from typing import Never from ty_extensions import ConstraintSet, generic_context def mentions[T, U](): + # (T@mentions ≤ int) ∧ (U@mentions = list[T@mentions]) constraints = ConstraintSet.range(Never, T, int) & ConstraintSet.range(list[T], U, list[T]) - # revealed: ty_extensions.ConstraintSet[((T@mentions ≤ int) ∧ (U@mentions = list[T@mentions]))] - reveal_type(constraints) # revealed: ty_extensions.Specialization[T@mentions = int, U@mentions = list[int]] reveal_type(generic_context(mentions).specialize_constrained(constraints)) ``` @@ -334,9 +333,8 @@ this case. ```py def divergent[T, U](): + # (T@divergent = list[U@divergent]) ∧ (U@divergent = list[T@divergent])) constraints = ConstraintSet.range(list[U], T, list[U]) & ConstraintSet.range(list[T], U, list[T]) - # revealed: ty_extensions.ConstraintSet[((T@divergent = list[U@divergent]) ∧ (U@divergent = list[T@divergent]))] - reveal_type(constraints) # revealed: None reveal_type(generic_context(divergent).specialize_constrained(constraints)) ``` diff --git a/crates/ty_python_semantic/resources/mdtest/ty_extensions.md b/crates/ty_python_semantic/resources/mdtest/ty_extensions.md index 4ff580954e..9cb9ca40f4 100644 --- a/crates/ty_python_semantic/resources/mdtest/ty_extensions.md +++ b/crates/ty_python_semantic/resources/mdtest/ty_extensions.md @@ -398,7 +398,7 @@ the expression `str`: from ty_extensions import TypeOf, is_subtype_of, static_assert # This is incorrect and therefore fails with ... -# error: "Static assertion error: argument of type `ty_extensions.ConstraintSet[never]` is statically known to be falsy" +# error: "Static assertion error: argument of type `ty_extensions.ConstraintSet` is statically known to be falsy" static_assert(is_subtype_of(str, type[str])) # Correct, returns True: diff --git a/crates/ty_python_semantic/resources/mdtest/type_properties/constraints.md b/crates/ty_python_semantic/resources/mdtest/type_properties/constraints.md index 034211f232..f83bee977c 100644 --- a/crates/ty_python_semantic/resources/mdtest/type_properties/constraints.md +++ b/crates/ty_python_semantic/resources/mdtest/type_properties/constraints.md @@ -34,7 +34,7 @@ upper bound. ```py from typing import Any, final, Never, Sequence -from ty_extensions import ConstraintSet +from ty_extensions import ConstraintSet, static_assert class Super: ... class Base(Super): ... @@ -44,8 +44,8 @@ class Sub(Base): ... class Unrelated: ... def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(Sub ≤ T@_ ≤ Super)] - reveal_type(ConstraintSet.range(Sub, T, Super)) + # (Sub ≤ T@_ ≤ Super) + ConstraintSet.range(Sub, T, Super) ``` Every type is a supertype of `Never`, so a lower bound of `Never` is the same as having no lower @@ -53,8 +53,8 @@ bound. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(T@_ ≤ Base)] - reveal_type(ConstraintSet.range(Never, T, Base)) + # (T@_ ≤ Base) + ConstraintSet.range(Never, T, Base) ``` Similarly, every type is a subtype of `object`, so an upper bound of `object` is the same as having @@ -62,8 +62,8 @@ no upper bound. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(Base ≤ T@_)] - reveal_type(ConstraintSet.range(Base, T, object)) + # (Base ≤ T@_) + ConstraintSet.range(Base, T, object) ``` And a range constraint with a lower bound of `Never` and an upper bound of `object` allows the @@ -74,8 +74,8 @@ of `object`. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(T@_ = *)] - reveal_type(ConstraintSet.range(Never, T, object)) + # (T@_ = *) + ConstraintSet.range(Never, T, object) ``` If the lower bound and upper bounds are "inverted" (the upper bound is a subtype of the lower bound) @@ -83,10 +83,8 @@ or incomparable, then there is no type that can satisfy the constraint. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(ConstraintSet.range(Super, T, Sub)) - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(ConstraintSet.range(Base, T, Unrelated)) + static_assert(not ConstraintSet.range(Super, T, Sub)) + static_assert(not ConstraintSet.range(Base, T, Unrelated)) ``` The lower and upper bound can be the same type, in which case the typevar can only be specialized to @@ -94,8 +92,8 @@ that specific type. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(T@_ = Base)] - reveal_type(ConstraintSet.range(Base, T, Base)) + # (T@_ = Base) + ConstraintSet.range(Base, T, Base) ``` Constraints can only refer to fully static types, so the lower and upper bounds are transformed into @@ -103,15 +101,21 @@ their bottom and top materializations, respectively. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(Base ≤ T@_)] - reveal_type(ConstraintSet.range(Base, T, Any)) - # revealed: ty_extensions.ConstraintSet[(Sequence[Base] ≤ T@_ ≤ Sequence[object])] - reveal_type(ConstraintSet.range(Sequence[Base], T, Sequence[Any])) + constraints = ConstraintSet.range(Base, T, Any) + expected = ConstraintSet.range(Base, T, object) + static_assert(constraints == expected) - # revealed: ty_extensions.ConstraintSet[(T@_ ≤ Base)] - reveal_type(ConstraintSet.range(Any, T, Base)) - # revealed: ty_extensions.ConstraintSet[(Sequence[Never] ≤ T@_ ≤ Sequence[Base])] - reveal_type(ConstraintSet.range(Sequence[Any], T, Sequence[Base])) + constraints = ConstraintSet.range(Sequence[Base], T, Sequence[Any]) + expected = ConstraintSet.range(Sequence[Base], T, Sequence[object]) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(Any, T, Base) + expected = ConstraintSet.range(Never, T, Base) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(Sequence[Any], T, Sequence[Base]) + expected = ConstraintSet.range(Sequence[Never], T, Sequence[Base]) + static_assert(constraints == expected) ``` ### Negated range @@ -122,7 +126,7 @@ strict subtype of the lower bound, a strict supertype of the upper bound, or inc ```py from typing import Any, final, Never, Sequence -from ty_extensions import ConstraintSet +from ty_extensions import ConstraintSet, static_assert class Super: ... class Base(Super): ... @@ -132,8 +136,8 @@ class Sub(Base): ... class Unrelated: ... def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[¬(Sub ≤ T@_ ≤ Super)] - reveal_type(~ConstraintSet.range(Sub, T, Super)) + # ¬(Sub ≤ T@_ ≤ Super) + ~ConstraintSet.range(Sub, T, Super) ``` Every type is a supertype of `Never`, so a lower bound of `Never` is the same as having no lower @@ -141,8 +145,8 @@ bound. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[¬(T@_ ≤ Base)] - reveal_type(~ConstraintSet.range(Never, T, Base)) + # ¬(T@_ ≤ Base) + ~ConstraintSet.range(Never, T, Base) ``` Similarly, every type is a subtype of `object`, so an upper bound of `object` is the same as having @@ -150,8 +154,8 @@ no upper bound. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[¬(Base ≤ T@_)] - reveal_type(~ConstraintSet.range(Base, T, object)) + # ¬(Base ≤ T@_) + ~ConstraintSet.range(Base, T, object) ``` And a negated range constraint with _both_ a lower bound of `Never` and an upper bound of `object` @@ -159,8 +163,8 @@ cannot be satisfied at all. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(T@_ ≠ *)] - reveal_type(~ConstraintSet.range(Never, T, object)) + # (T@_ ≠ *) + ~ConstraintSet.range(Never, T, object) ``` If the lower bound and upper bounds are "inverted" (the upper bound is a subtype of the lower bound) @@ -168,10 +172,8 @@ or incomparable, then the negated range constraint can always be satisfied. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(~ConstraintSet.range(Super, T, Sub)) - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(~ConstraintSet.range(Base, T, Unrelated)) + static_assert(~ConstraintSet.range(Super, T, Sub)) + static_assert(~ConstraintSet.range(Base, T, Unrelated)) ``` The lower and upper bound can be the same type, in which case the typevar can be specialized to any @@ -179,8 +181,8 @@ type other than that specific type. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(T@_ ≠ Base)] - reveal_type(~ConstraintSet.range(Base, T, Base)) + # (T@_ ≠ Base) + ~ConstraintSet.range(Base, T, Base) ``` Constraints can only refer to fully static types, so the lower and upper bounds are transformed into @@ -188,15 +190,21 @@ their bottom and top materializations, respectively. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[¬(Base ≤ T@_)] - reveal_type(~ConstraintSet.range(Base, T, Any)) - # revealed: ty_extensions.ConstraintSet[¬(Sequence[Base] ≤ T@_ ≤ Sequence[object])] - reveal_type(~ConstraintSet.range(Sequence[Base], T, Sequence[Any])) + constraints = ~ConstraintSet.range(Base, T, Any) + expected = ~ConstraintSet.range(Base, T, object) + static_assert(constraints == expected) - # revealed: ty_extensions.ConstraintSet[¬(T@_ ≤ Base)] - reveal_type(~ConstraintSet.range(Any, T, Base)) - # revealed: ty_extensions.ConstraintSet[¬(Sequence[Never] ≤ T@_ ≤ Sequence[Base])] - reveal_type(~ConstraintSet.range(Sequence[Any], T, Sequence[Base])) + constraints = ~ConstraintSet.range(Sequence[Base], T, Sequence[Any]) + expected = ~ConstraintSet.range(Sequence[Base], T, Sequence[object]) + static_assert(constraints == expected) + + constraints = ~ConstraintSet.range(Any, T, Base) + expected = ~ConstraintSet.range(Never, T, Base) + static_assert(constraints == expected) + + constraints = ~ConstraintSet.range(Sequence[Any], T, Sequence[Base]) + expected = ~ConstraintSet.range(Sequence[Never], T, Sequence[Base]) + static_assert(constraints == expected) ``` ## Intersection @@ -218,10 +226,10 @@ We cannot simplify the intersection of constraints that refer to different typev ```py def _[T, U]() -> None: - # revealed: ty_extensions.ConstraintSet[((Sub ≤ T@_ ≤ Base) ∧ (Sub ≤ U@_ ≤ Base))] - reveal_type(ConstraintSet.range(Sub, T, Base) & ConstraintSet.range(Sub, U, Base)) - # revealed: ty_extensions.ConstraintSet[(¬(Sub ≤ T@_ ≤ Base) ∧ ¬(Sub ≤ U@_ ≤ Base))] - reveal_type(~ConstraintSet.range(Sub, T, Base) & ~ConstraintSet.range(Sub, U, Base)) + # (Sub ≤ T@_ ≤ Base) ∧ (Sub ≤ U@_ ≤ Base) + ConstraintSet.range(Sub, T, Base) & ConstraintSet.range(Sub, U, Base) + # ¬(Sub ≤ T@_ ≤ Base) ∧ ¬(Sub ≤ U@_ ≤ Base) + ~ConstraintSet.range(Sub, T, Base) & ~ConstraintSet.range(Sub, U, Base) ``` ### Intersection of two ranges @@ -230,7 +238,7 @@ The intersection of two ranges is where the ranges "overlap". ```py from typing import final -from ty_extensions import ConstraintSet +from ty_extensions import ConstraintSet, static_assert class Super: ... class Base(Super): ... @@ -241,24 +249,29 @@ class SubSub(Sub): ... class Unrelated: ... def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(Sub ≤ T@_ ≤ Base)] - reveal_type(ConstraintSet.range(SubSub, T, Base) & ConstraintSet.range(Sub, T, Super)) - # revealed: ty_extensions.ConstraintSet[(Sub ≤ T@_ ≤ Base)] - reveal_type(ConstraintSet.range(SubSub, T, Super) & ConstraintSet.range(Sub, T, Base)) - # revealed: ty_extensions.ConstraintSet[(T@_ = Base)] - reveal_type(ConstraintSet.range(Sub, T, Base) & ConstraintSet.range(Base, T, Super)) - # revealed: ty_extensions.ConstraintSet[(Sub ≤ T@_ ≤ Super)] - reveal_type(ConstraintSet.range(Sub, T, Super) & ConstraintSet.range(Sub, T, Super)) + constraints = ConstraintSet.range(SubSub, T, Base) & ConstraintSet.range(Sub, T, Super) + expected = ConstraintSet.range(Sub, T, Base) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(SubSub, T, Super) & ConstraintSet.range(Sub, T, Base) + expected = ConstraintSet.range(Sub, T, Base) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(Sub, T, Base) & ConstraintSet.range(Base, T, Super) + expected = ConstraintSet.range(Base, T, Base) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(Sub, T, Super) & ConstraintSet.range(Sub, T, Super) + expected = ConstraintSet.range(Sub, T, Super) + static_assert(constraints == expected) ``` If they don't overlap, the intersection is empty. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(ConstraintSet.range(SubSub, T, Sub) & ConstraintSet.range(Base, T, Super)) - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(ConstraintSet.range(SubSub, T, Sub) & ConstraintSet.range(Unrelated, T, object)) + static_assert(not ConstraintSet.range(SubSub, T, Sub) & ConstraintSet.range(Base, T, Super)) + static_assert(not ConstraintSet.range(SubSub, T, Sub) & ConstraintSet.range(Unrelated, T, object)) ``` Expanding on this, when intersecting two upper bounds constraints (`(T ≤ Base) ∧ (T ≤ Other)`), we @@ -267,23 +280,17 @@ satisfy their intersection `T ≤ Base & Other`, and vice versa. ```py from typing import Never -from ty_extensions import Intersection, static_assert +from ty_extensions import Intersection # This is not final, so it's possible for a subclass to inherit from both Base and Other. class Other: ... def upper_bounds[T](): + # (T@upper_bounds ≤ Base & Other) intersection_type = ConstraintSet.range(Never, T, Intersection[Base, Other]) - # revealed: ty_extensions.ConstraintSet[(T@upper_bounds ≤ Base & Other)] - reveal_type(intersection_type) - + # (T@upper_bounds ≤ Base) ∧ (T@upper_bounds ≤ Other) intersection_constraint = ConstraintSet.range(Never, T, Base) & ConstraintSet.range(Never, T, Other) - # revealed: ty_extensions.ConstraintSet[(T@upper_bounds ≤ Base & Other)] - reveal_type(intersection_constraint) - - # The two constraint sets are equivalent; each satisfies the other. - static_assert(intersection_type.satisfies(intersection_constraint)) - static_assert(intersection_constraint.satisfies(intersection_type)) + static_assert(intersection_type == intersection_constraint) ``` For an intersection of two lower bounds constraints (`(Base ≤ T) ∧ (Other ≤ T)`), we union the lower @@ -292,17 +299,11 @@ bounds. Any type that satisfies both `Base ≤ T` and `Other ≤ T` must necessa ```py def lower_bounds[T](): + # (Base | Other ≤ T@lower_bounds) union_type = ConstraintSet.range(Base | Other, T, object) - # revealed: ty_extensions.ConstraintSet[(Base | Other ≤ T@lower_bounds)] - reveal_type(union_type) - + # (Base ≤ T@upper_bounds) ∧ (Other ≤ T@upper_bounds) intersection_constraint = ConstraintSet.range(Base, T, object) & ConstraintSet.range(Other, T, object) - # revealed: ty_extensions.ConstraintSet[(Base | Other ≤ T@lower_bounds)] - reveal_type(intersection_constraint) - - # The two constraint sets are equivalent; each satisfies the other. - static_assert(union_type.satisfies(intersection_constraint)) - static_assert(intersection_constraint.satisfies(union_type)) + static_assert(union_type == intersection_constraint) ``` ### Intersection of a range and a negated range @@ -313,7 +314,7 @@ the intersection as removing the hole from the range constraint. ```py from typing import final, Never -from ty_extensions import ConstraintSet +from ty_extensions import ConstraintSet, static_assert class Super: ... class Base(Super): ... @@ -328,10 +329,8 @@ If the negative range completely contains the positive range, then the intersect ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(ConstraintSet.range(Sub, T, Base) & ~ConstraintSet.range(SubSub, T, Super)) - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(ConstraintSet.range(Sub, T, Base) & ~ConstraintSet.range(Sub, T, Base)) + static_assert(not ConstraintSet.range(Sub, T, Base) & ~ConstraintSet.range(SubSub, T, Super)) + static_assert(not ConstraintSet.range(Sub, T, Base) & ~ConstraintSet.range(Sub, T, Base)) ``` If the negative range is disjoint from the positive range, the negative range doesn't remove @@ -339,12 +338,17 @@ anything; the intersection is the positive range. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(Sub ≤ T@_ ≤ Base)] - reveal_type(ConstraintSet.range(Sub, T, Base) & ~ConstraintSet.range(Never, T, Unrelated)) - # revealed: ty_extensions.ConstraintSet[(SubSub ≤ T@_ ≤ Sub)] - reveal_type(ConstraintSet.range(SubSub, T, Sub) & ~ConstraintSet.range(Base, T, Super)) - # revealed: ty_extensions.ConstraintSet[(Base ≤ T@_ ≤ Super)] - reveal_type(ConstraintSet.range(Base, T, Super) & ~ConstraintSet.range(SubSub, T, Sub)) + constraints = ConstraintSet.range(Sub, T, Base) & ~ConstraintSet.range(Never, T, Unrelated) + expected = ConstraintSet.range(Sub, T, Base) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(SubSub, T, Sub) & ~ConstraintSet.range(Base, T, Super) + expected = ConstraintSet.range(SubSub, T, Sub) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(Base, T, Super) & ~ConstraintSet.range(SubSub, T, Sub) + expected = ConstraintSet.range(Base, T, Super) + static_assert(constraints == expected) ``` Otherwise we clip the negative constraint to the mininum range that overlaps with the positive @@ -352,10 +356,9 @@ range. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[((SubSub ≤ T@_ ≤ Base) ∧ ¬(Sub ≤ T@_ ≤ Base))] - reveal_type(ConstraintSet.range(SubSub, T, Base) & ~ConstraintSet.range(Sub, T, Super)) - # revealed: ty_extensions.ConstraintSet[((SubSub ≤ T@_ ≤ Super) ∧ ¬(Sub ≤ T@_ ≤ Base))] - reveal_type(ConstraintSet.range(SubSub, T, Super) & ~ConstraintSet.range(Sub, T, Base)) + constraints = ConstraintSet.range(SubSub, T, Base) & ~ConstraintSet.range(Sub, T, Super) + expected = ConstraintSet.range(SubSub, T, Base) & ~ConstraintSet.range(Sub, T, Base) + static_assert(constraints == expected) ``` ### Intersection of two negated ranges @@ -365,7 +368,7 @@ smaller constraint. For negated ranges, the smaller constraint is the one with t ```py from typing import final -from ty_extensions import ConstraintSet +from ty_extensions import ConstraintSet, static_assert class Super: ... class Base(Super): ... @@ -376,22 +379,25 @@ class SubSub(Sub): ... class Unrelated: ... def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[¬(SubSub ≤ T@_ ≤ Super)] - reveal_type(~ConstraintSet.range(SubSub, T, Super) & ~ConstraintSet.range(Sub, T, Base)) - # revealed: ty_extensions.ConstraintSet[¬(Sub ≤ T@_ ≤ Super)] - reveal_type(~ConstraintSet.range(Sub, T, Super) & ~ConstraintSet.range(Sub, T, Super)) + constraints = ~ConstraintSet.range(SubSub, T, Super) & ~ConstraintSet.range(Sub, T, Base) + expected = ~ConstraintSet.range(SubSub, T, Super) + static_assert(constraints == expected) + + constraints = ~ConstraintSet.range(Sub, T, Super) & ~ConstraintSet.range(Sub, T, Super) + expected = ~ConstraintSet.range(Sub, T, Super) + static_assert(constraints == expected) ``` Otherwise, the intersection cannot be simplified. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(¬(Base ≤ T@_ ≤ Super) ∧ ¬(Sub ≤ T@_ ≤ Base))] - reveal_type(~ConstraintSet.range(Sub, T, Base) & ~ConstraintSet.range(Base, T, Super)) - # revealed: ty_extensions.ConstraintSet[(¬(Base ≤ T@_ ≤ Super) ∧ ¬(SubSub ≤ T@_ ≤ Sub))] - reveal_type(~ConstraintSet.range(SubSub, T, Sub) & ~ConstraintSet.range(Base, T, Super)) - # revealed: ty_extensions.ConstraintSet[(¬(SubSub ≤ T@_ ≤ Sub) ∧ ¬(Unrelated ≤ T@_))] - reveal_type(~ConstraintSet.range(SubSub, T, Sub) & ~ConstraintSet.range(Unrelated, T, object)) + # ¬(Base ≤ T@_ ≤ Super) ∧ ¬(Sub ≤ T@_ ≤ Base)) + ~ConstraintSet.range(Sub, T, Base) & ~ConstraintSet.range(Base, T, Super) + # ¬(Base ≤ T@_ ≤ Super) ∧ ¬(SubSub ≤ T@_ ≤ Sub)) + ~ConstraintSet.range(SubSub, T, Sub) & ~ConstraintSet.range(Base, T, Super) + # ¬(SubSub ≤ T@_ ≤ Sub) ∧ ¬(Unrelated ≤ T@_) + ~ConstraintSet.range(SubSub, T, Sub) & ~ConstraintSet.range(Unrelated, T, object) ``` In particular, the following does not simplify, even though it seems like it could simplify to @@ -408,8 +414,8 @@ way. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(¬(Sub ≤ T@_ ≤ Super) ∧ ¬(SubSub ≤ T@_ ≤ Base))] - reveal_type(~ConstraintSet.range(SubSub, T, Base) & ~ConstraintSet.range(Sub, T, Super)) + # (¬(Sub ≤ T@_ ≤ Super) ∧ ¬(SubSub ≤ T@_ ≤ Base)) + ~ConstraintSet.range(SubSub, T, Base) & ~ConstraintSet.range(Sub, T, Super) ``` ## Union @@ -431,10 +437,10 @@ We cannot simplify the union of constraints that refer to different typevars. ```py def _[T, U]() -> None: - # revealed: ty_extensions.ConstraintSet[(Sub ≤ T@_ ≤ Base) ∨ (Sub ≤ U@_ ≤ Base)] - reveal_type(ConstraintSet.range(Sub, T, Base) | ConstraintSet.range(Sub, U, Base)) - # revealed: ty_extensions.ConstraintSet[¬(Sub ≤ T@_ ≤ Base) ∨ ¬(Sub ≤ U@_ ≤ Base)] - reveal_type(~ConstraintSet.range(Sub, T, Base) | ~ConstraintSet.range(Sub, U, Base)) + # (Sub ≤ T@_ ≤ Base) ∨ (Sub ≤ U@_ ≤ Base) + ConstraintSet.range(Sub, T, Base) | ConstraintSet.range(Sub, U, Base) + # ¬(Sub ≤ T@_ ≤ Base) ∨ ¬(Sub ≤ U@_ ≤ Base) + ~ConstraintSet.range(Sub, T, Base) | ~ConstraintSet.range(Sub, U, Base) ``` ### Union of two ranges @@ -444,7 +450,7 @@ bounds. ```py from typing import final -from ty_extensions import ConstraintSet +from ty_extensions import ConstraintSet, static_assert class Super: ... class Base(Super): ... @@ -455,22 +461,25 @@ class SubSub(Sub): ... class Unrelated: ... def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(SubSub ≤ T@_ ≤ Super)] - reveal_type(ConstraintSet.range(SubSub, T, Super) | ConstraintSet.range(Sub, T, Base)) - # revealed: ty_extensions.ConstraintSet[(Sub ≤ T@_ ≤ Super)] - reveal_type(ConstraintSet.range(Sub, T, Super) | ConstraintSet.range(Sub, T, Super)) + constraints = ConstraintSet.range(SubSub, T, Super) | ConstraintSet.range(Sub, T, Base) + expected = ConstraintSet.range(SubSub, T, Super) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(Sub, T, Super) | ConstraintSet.range(Sub, T, Super) + expected = ConstraintSet.range(Sub, T, Super) + static_assert(constraints == expected) ``` Otherwise, the union cannot be simplified. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(Base ≤ T@_ ≤ Super) ∨ (Sub ≤ T@_ ≤ Base)] - reveal_type(ConstraintSet.range(Sub, T, Base) | ConstraintSet.range(Base, T, Super)) - # revealed: ty_extensions.ConstraintSet[(Base ≤ T@_ ≤ Super) ∨ (SubSub ≤ T@_ ≤ Sub)] - reveal_type(ConstraintSet.range(SubSub, T, Sub) | ConstraintSet.range(Base, T, Super)) - # revealed: ty_extensions.ConstraintSet[(SubSub ≤ T@_ ≤ Sub) ∨ (Unrelated ≤ T@_)] - reveal_type(ConstraintSet.range(SubSub, T, Sub) | ConstraintSet.range(Unrelated, T, object)) + # (Base ≤ T@_ ≤ Super) ∨ (Sub ≤ T@_ ≤ Base) + ConstraintSet.range(Sub, T, Base) | ConstraintSet.range(Base, T, Super) + # (Base ≤ T@_ ≤ Super) ∨ (SubSub ≤ T@_ ≤ Sub) + ConstraintSet.range(SubSub, T, Sub) | ConstraintSet.range(Base, T, Super) + # (SubSub ≤ T@_ ≤ Sub) ∨ (Unrelated ≤ T@_) + ConstraintSet.range(SubSub, T, Sub) | ConstraintSet.range(Unrelated, T, object) ``` In particular, the following does not simplify, even though it seems like it could simplify to @@ -485,8 +494,8 @@ not include `Sub`. That means it should not be in the union. Since that type _is ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(Sub ≤ T@_ ≤ Super) ∨ (SubSub ≤ T@_ ≤ Base)] - reveal_type(ConstraintSet.range(SubSub, T, Base) | ConstraintSet.range(Sub, T, Super)) + # (Sub ≤ T@_ ≤ Super) ∨ (SubSub ≤ T@_ ≤ Base) + ConstraintSet.range(SubSub, T, Base) | ConstraintSet.range(Sub, T, Super) ``` The union of two upper bound constraints (`(T ≤ Base) ∨ (T ≤ Other)`) is different than the single @@ -496,24 +505,18 @@ that satisfies the union constraint satisfies the union type. ```py from typing import Never -from ty_extensions import static_assert # This is not final, so it's possible for a subclass to inherit from both Base and Other. class Other: ... def union[T](): + # (T@union ≤ Base | Other) union_type = ConstraintSet.range(Never, T, Base | Other) - # revealed: ty_extensions.ConstraintSet[(T@union ≤ Base | Other)] - reveal_type(union_type) - + # (T@union ≤ Base) ∨ (T@union ≤ Other) union_constraint = ConstraintSet.range(Never, T, Base) | ConstraintSet.range(Never, T, Other) - # revealed: ty_extensions.ConstraintSet[(T@union ≤ Base) ∨ (T@union ≤ Other)] - reveal_type(union_constraint) # (T = Base | Other) satisfies (T ≤ Base | Other) but not (T ≤ Base ∨ T ≤ Other) specialization = ConstraintSet.range(Base | Other, T, Base | Other) - # revealed: ty_extensions.ConstraintSet[(T@union = Base | Other)] - reveal_type(specialization) static_assert(specialization.satisfies(union_type)) static_assert(not specialization.satisfies(union_constraint)) @@ -528,18 +531,13 @@ satisfies the union constraint (`(Base ≤ T) ∨ (Other ≤ T)`) but not the un ```py def union[T](): + # (Base | Other ≤ T@union) union_type = ConstraintSet.range(Base | Other, T, object) - # revealed: ty_extensions.ConstraintSet[(Base | Other ≤ T@union)] - reveal_type(union_type) - + # (Base ≤ T@union) ∨ (Other ≤ T@union) union_constraint = ConstraintSet.range(Base, T, object) | ConstraintSet.range(Other, T, object) - # revealed: ty_extensions.ConstraintSet[(Base ≤ T@union) ∨ (Other ≤ T@union)] - reveal_type(union_constraint) # (T = Base) satisfies (Base ≤ T ∨ Other ≤ T) but not (Base | Other ≤ T) specialization = ConstraintSet.range(Base, T, Base) - # revealed: ty_extensions.ConstraintSet[(T@union = Base)] - reveal_type(specialization) static_assert(not specialization.satisfies(union_type)) static_assert(specialization.satisfies(union_constraint)) @@ -556,7 +554,7 @@ the union as filling part of the hole with the types from the range constraint. ```py from typing import final, Never -from ty_extensions import ConstraintSet +from ty_extensions import ConstraintSet, static_assert class Super: ... class Base(Super): ... @@ -571,10 +569,8 @@ If the positive range completely contains the negative range, then the union is ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(~ConstraintSet.range(Sub, T, Base) | ConstraintSet.range(SubSub, T, Super)) - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(~ConstraintSet.range(Sub, T, Base) | ConstraintSet.range(Sub, T, Base)) + static_assert(~ConstraintSet.range(Sub, T, Base) | ConstraintSet.range(SubSub, T, Super)) + static_assert(~ConstraintSet.range(Sub, T, Base) | ConstraintSet.range(Sub, T, Base)) ``` If the negative range is disjoint from the positive range, the positive range doesn't add anything; @@ -582,12 +578,17 @@ the union is the negative range. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[¬(Sub ≤ T@_ ≤ Base)] - reveal_type(~ConstraintSet.range(Sub, T, Base) | ConstraintSet.range(Never, T, Unrelated)) - # revealed: ty_extensions.ConstraintSet[¬(SubSub ≤ T@_ ≤ Sub)] - reveal_type(~ConstraintSet.range(SubSub, T, Sub) | ConstraintSet.range(Base, T, Super)) - # revealed: ty_extensions.ConstraintSet[¬(Base ≤ T@_ ≤ Super)] - reveal_type(~ConstraintSet.range(Base, T, Super) | ConstraintSet.range(SubSub, T, Sub)) + constraints = ~ConstraintSet.range(Sub, T, Base) | ConstraintSet.range(Never, T, Unrelated) + expected = ~ConstraintSet.range(Sub, T, Base) + static_assert(constraints == expected) + + constraints = ~ConstraintSet.range(SubSub, T, Sub) | ConstraintSet.range(Base, T, Super) + expected = ~ConstraintSet.range(SubSub, T, Sub) + static_assert(constraints == expected) + + constraints = ~ConstraintSet.range(Base, T, Super) | ConstraintSet.range(SubSub, T, Sub) + expected = ~ConstraintSet.range(Base, T, Super) + static_assert(constraints == expected) ``` Otherwise we clip the positive constraint to the mininum range that overlaps with the negative @@ -595,10 +596,9 @@ range. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[(Sub ≤ T@_ ≤ Base) ∨ ¬(SubSub ≤ T@_ ≤ Base)] - reveal_type(~ConstraintSet.range(SubSub, T, Base) | ConstraintSet.range(Sub, T, Super)) - # revealed: ty_extensions.ConstraintSet[(Sub ≤ T@_ ≤ Base) ∨ ¬(SubSub ≤ T@_ ≤ Super)] - reveal_type(~ConstraintSet.range(SubSub, T, Super) | ConstraintSet.range(Sub, T, Base)) + constraints = ~ConstraintSet.range(SubSub, T, Base) | ConstraintSet.range(Sub, T, Super) + expected = ~ConstraintSet.range(SubSub, T, Base) | ConstraintSet.range(Sub, T, Base) + static_assert(constraints == expected) ``` ### Union of two negated ranges @@ -607,7 +607,7 @@ The union of two negated ranges has a hole where the ranges "overlap". ```py from typing import final -from ty_extensions import ConstraintSet +from ty_extensions import ConstraintSet, static_assert class Super: ... class Base(Super): ... @@ -618,24 +618,29 @@ class SubSub(Sub): ... class Unrelated: ... def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[¬(Sub ≤ T@_ ≤ Base)] - reveal_type(~ConstraintSet.range(SubSub, T, Base) | ~ConstraintSet.range(Sub, T, Super)) - # revealed: ty_extensions.ConstraintSet[¬(Sub ≤ T@_ ≤ Base)] - reveal_type(~ConstraintSet.range(SubSub, T, Super) | ~ConstraintSet.range(Sub, T, Base)) - # revealed: ty_extensions.ConstraintSet[(T@_ ≠ Base)] - reveal_type(~ConstraintSet.range(Sub, T, Base) | ~ConstraintSet.range(Base, T, Super)) - # revealed: ty_extensions.ConstraintSet[¬(Sub ≤ T@_ ≤ Super)] - reveal_type(~ConstraintSet.range(Sub, T, Super) | ~ConstraintSet.range(Sub, T, Super)) + constraints = ~ConstraintSet.range(SubSub, T, Base) | ~ConstraintSet.range(Sub, T, Super) + expected = ~ConstraintSet.range(Sub, T, Base) + static_assert(constraints == expected) + + constraints = ~ConstraintSet.range(SubSub, T, Super) | ~ConstraintSet.range(Sub, T, Base) + expected = ~ConstraintSet.range(Sub, T, Base) + static_assert(constraints == expected) + + constraints = ~ConstraintSet.range(Sub, T, Base) | ~ConstraintSet.range(Base, T, Super) + expected = ~ConstraintSet.range(Base, T, Base) + static_assert(constraints == expected) + + constraints = ~ConstraintSet.range(Sub, T, Super) | ~ConstraintSet.range(Sub, T, Super) + expected = ~ConstraintSet.range(Sub, T, Super) + static_assert(constraints == expected) ``` If the holes don't overlap, the union is always satisfied. ```py def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(~ConstraintSet.range(SubSub, T, Sub) | ~ConstraintSet.range(Base, T, Super)) - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(~ConstraintSet.range(SubSub, T, Sub) | ~ConstraintSet.range(Unrelated, T, object)) + static_assert(~ConstraintSet.range(SubSub, T, Sub) | ~ConstraintSet.range(Base, T, Super)) + static_assert(~ConstraintSet.range(SubSub, T, Sub) | ~ConstraintSet.range(Unrelated, T, object)) ``` ## Negation @@ -644,21 +649,21 @@ def _[T]() -> None: ```py from typing import Never -from ty_extensions import ConstraintSet +from ty_extensions import ConstraintSet, static_assert class Super: ... class Base(Super): ... class Sub(Base): ... def _[T]() -> None: - # revealed: ty_extensions.ConstraintSet[¬(Sub ≤ T@_ ≤ Base)] - reveal_type(~ConstraintSet.range(Sub, T, Base)) - # revealed: ty_extensions.ConstraintSet[¬(T@_ ≤ Base)] - reveal_type(~ConstraintSet.range(Never, T, Base)) - # revealed: ty_extensions.ConstraintSet[¬(Sub ≤ T@_)] - reveal_type(~ConstraintSet.range(Sub, T, object)) - # revealed: ty_extensions.ConstraintSet[(T@_ ≠ *)] - reveal_type(~ConstraintSet.range(Never, T, object)) + # ¬(Sub ≤ T@_ ≤ Base) + ~ConstraintSet.range(Sub, T, Base) + # ¬(T@_ ≤ Base) + ~ConstraintSet.range(Never, T, Base) + # ¬(Sub ≤ T@_) + ~ConstraintSet.range(Sub, T, object) + # (T@_ ≠ *) + ~ConstraintSet.range(Never, T, object) ``` The union of a range constraint and its negation should always be satisfiable. @@ -666,15 +671,14 @@ The union of a range constraint and its negation should always be satisfiable. ```py def _[T]() -> None: constraint = ConstraintSet.range(Sub, T, Base) - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(constraint | ~constraint) + static_assert(constraint | ~constraint) ``` ### Negation of constraints involving two variables ```py from typing import final, Never -from ty_extensions import ConstraintSet +from ty_extensions import ConstraintSet, static_assert class Base: ... @@ -682,8 +686,8 @@ class Base: ... class Unrelated: ... def _[T, U]() -> None: - # revealed: ty_extensions.ConstraintSet[¬(T@_ ≤ Base) ∨ ¬(U@_ ≤ Base)] - reveal_type(~(ConstraintSet.range(Never, T, Base) & ConstraintSet.range(Never, U, Base))) + # ¬(T@_ ≤ Base) ∨ ¬(U@_ ≤ Base) + ~(ConstraintSet.range(Never, T, Base) & ConstraintSet.range(Never, U, Base)) ``` The union of a constraint and its negation should always be satisfiable. @@ -691,150 +695,91 @@ The union of a constraint and its negation should always be satisfiable. ```py def _[T, U]() -> None: c1 = ConstraintSet.range(Never, T, Base) & ConstraintSet.range(Never, U, Base) - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(c1 | ~c1) - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(~c1 | c1) + static_assert(c1 | ~c1) + static_assert(~c1 | c1) c2 = ConstraintSet.range(Unrelated, T, object) & ConstraintSet.range(Unrelated, U, object) - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(c2 | ~c2) - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(~c2 | c2) + static_assert(c2 | ~c2) + static_assert(~c2 | c2) union = c1 | c2 - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(union | ~union) - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(~union | union) + static_assert(union | ~union) + static_assert(~union | union) ``` ## Typevar ordering Constraints can relate two typevars — i.e., `S ≤ T`. We could encode that in one of two ways: `Never ≤ S ≤ T` or `S ≤ T ≤ object`. In other words, we can decide whether `S` or `T` is the typevar -being constrained. The other is then the lower or upper bound of the constraint. - -To handle this, we enforce an arbitrary ordering on typevars, and always place the constraint on the -"earlier" typevar. For the example above, that does not change how the constraint is displayed, -since we always hide `Never` lower bounds and `object` upper bounds. +being constrained. The other is then the lower or upper bound of the constraint. To handle this, we +enforce an arbitrary ordering on typevars, and always place the constraint on the "earlier" typevar. ```py from typing import Never -from ty_extensions import ConstraintSet +from ty_extensions import ConstraintSet, static_assert def f[S, T](): - # revealed: ty_extensions.ConstraintSet[(S@f ≤ T@f)] - reveal_type(ConstraintSet.range(Never, S, T)) - # revealed: ty_extensions.ConstraintSet[(S@f ≤ T@f)] - reveal_type(ConstraintSet.range(S, T, object)) + # (S@f ≤ T@f) + c1 = ConstraintSet.range(Never, S, T) + c2 = ConstraintSet.range(S, T, object) + static_assert(c1 == c2) def f[T, S](): - # revealed: ty_extensions.ConstraintSet[(S@f ≤ T@f)] - reveal_type(ConstraintSet.range(Never, S, T)) - # revealed: ty_extensions.ConstraintSet[(S@f ≤ T@f)] - reveal_type(ConstraintSet.range(S, T, object)) + # (S@f ≤ T@f) + c1 = ConstraintSet.range(Never, S, T) + c2 = ConstraintSet.range(S, T, object) + static_assert(c1 == c2) ``` Equivalence constraints are similar; internally we arbitrarily choose the "earlier" typevar to be -the constraint, and the other the bound. But we display the result the same way no matter what. +the constraint, and the other the bound. ```py def f[S, T](): - # revealed: ty_extensions.ConstraintSet[(S@f = T@f)] - reveal_type(ConstraintSet.range(T, S, T)) - # revealed: ty_extensions.ConstraintSet[(S@f = T@f)] - reveal_type(ConstraintSet.range(S, T, S)) + # (S@f = T@f) + c1 = ConstraintSet.range(T, S, T) + c2 = ConstraintSet.range(S, T, S) + static_assert(c1 == c2) def f[T, S](): - # revealed: ty_extensions.ConstraintSet[(S@f = T@f)] - reveal_type(ConstraintSet.range(T, S, T)) - # revealed: ty_extensions.ConstraintSet[(S@f = T@f)] - reveal_type(ConstraintSet.range(S, T, S)) + # (S@f = T@f) + c1 = ConstraintSet.range(T, S, T) + c2 = ConstraintSet.range(S, T, S) + static_assert(c1 == c2) ``` But in the case of `S ≤ T ≤ U`, we end up with an ambiguity. Depending on the typevar ordering, that -might display as `S ≤ T ≤ U`, or as `(S ≤ T) ∧ (T ≤ U)`. +might represented internally as `S ≤ T ≤ U`, or as `(S ≤ T) ∧ (T ≤ U)`. However, this should not +affect any uses of the constraint set. ```py def f[S, T, U](): # Could be either of: - # ty_extensions.ConstraintSet[(S@f ≤ T@f ≤ U@f)] - # ty_extensions.ConstraintSet[(S@f ≤ T@f) ∧ (T@f ≤ U@f)] - # reveal_type(ConstraintSet.range(S, T, U)) + # (S@f ≤ T@f ≤ U@f) + # (S@f ≤ T@f) ∧ (T@f ≤ U@f) + ConstraintSet.range(S, T, U) ... ``` ## Other simplifications -### Displaying constraint sets +### Ordering of intersection and union elements -When displaying a constraint set, we transform the internal BDD representation into a DNF formula -(i.e., the logical OR of several clauses, each of which is the logical AND of several constraints). -This section contains several examples that show that we simplify the DNF formula as much as we can -before displaying it. - -```py -from ty_extensions import ConstraintSet - -def f[T, U](): - t1 = ConstraintSet.range(str, T, str) - t2 = ConstraintSet.range(bool, T, bool) - u1 = ConstraintSet.range(str, U, str) - u2 = ConstraintSet.range(bool, U, bool) - - # revealed: ty_extensions.ConstraintSet[(T@f = bool) ∨ (T@f = str)] - reveal_type(t1 | t2) - # revealed: ty_extensions.ConstraintSet[(U@f = bool) ∨ (U@f = str)] - reveal_type(u1 | u2) - # revealed: ty_extensions.ConstraintSet[((T@f = bool) ∧ (U@f = bool)) ∨ ((T@f = bool) ∧ (U@f = str)) ∨ ((T@f = str) ∧ (U@f = bool)) ∨ ((T@f = str) ∧ (U@f = str))] - reveal_type((t1 | t2) & (u1 | u2)) -``` - -We might simplify a BDD so much that we can no longer see the constraints that we used to construct -it! +The ordering of elements in a union or intersection do not affect what types satisfy a constraint +set. ```py from typing import Never -from ty_extensions import static_assert +from ty_extensions import ConstraintSet, Intersection, static_assert def f[T](): - t_int = ConstraintSet.range(Never, T, int) - t_bool = ConstraintSet.range(Never, T, bool) + c1 = ConstraintSet.range(Never, T, str | int) + c2 = ConstraintSet.range(Never, T, int | str) + static_assert(c1 == c2) - # `T ≤ bool` implies `T ≤ int`: if a type satisfies the former, it must always satisfy the - # latter. We can turn that into a constraint set, using the equivalence `p → q == ¬p ∨ q`: - implication = ~t_bool | t_int - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(implication) - static_assert(implication) - - # However, because of that implication, some inputs aren't valid: it's not possible for - # `T ≤ bool` to be true and `T ≤ int` to be false. This is reflected in the constraint set's - # "domain", which maps valid inputs to `true` and invalid inputs to `false`. This means that two - # constraint sets that are both always satisfied will not be identical if they have different - # domains! - always = ConstraintSet.always() - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(always) - static_assert(always) - static_assert(implication != always) -``` - -### Normalized bounds - -The lower and upper bounds of a constraint are normalized, so that we equate unions and -intersections whose elements appear in different orders. - -```py -from typing import Never -from ty_extensions import ConstraintSet - -def f[T](): - # revealed: ty_extensions.ConstraintSet[(T@f ≤ int | str)] - reveal_type(ConstraintSet.range(Never, T, str | int)) - # revealed: ty_extensions.ConstraintSet[(T@f ≤ int | str)] - reveal_type(ConstraintSet.range(Never, T, int | str)) + c1 = ConstraintSet.range(Never, T, Intersection[str, int]) + c2 = ConstraintSet.range(Never, T, Intersection[int, str]) + static_assert(c1 == c2) ``` ### Constraints on the same typevar @@ -846,15 +791,20 @@ static types.) ```py from typing import Never -from ty_extensions import ConstraintSet +from ty_extensions import ConstraintSet, static_assert def same_typevar[T](): - # revealed: ty_extensions.ConstraintSet[(T@same_typevar = *)] - reveal_type(ConstraintSet.range(Never, T, T)) - # revealed: ty_extensions.ConstraintSet[(T@same_typevar = *)] - reveal_type(ConstraintSet.range(T, T, object)) - # revealed: ty_extensions.ConstraintSet[(T@same_typevar = *)] - reveal_type(ConstraintSet.range(T, T, T)) + constraints = ConstraintSet.range(Never, T, T) + expected = ConstraintSet.range(Never, T, object) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(T, T, object) + expected = ConstraintSet.range(Never, T, object) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(T, T, T) + expected = ConstraintSet.range(Never, T, object) + static_assert(constraints == expected) ``` This is also true when the typevar appears in a union in the upper bound, or in an intersection in @@ -865,12 +815,17 @@ as shown above.) from ty_extensions import Intersection def same_typevar[T](): - # revealed: ty_extensions.ConstraintSet[(T@same_typevar = *)] - reveal_type(ConstraintSet.range(Never, T, T | None)) - # revealed: ty_extensions.ConstraintSet[(T@same_typevar = *)] - reveal_type(ConstraintSet.range(Intersection[T, None], T, object)) - # revealed: ty_extensions.ConstraintSet[(T@same_typevar = *)] - reveal_type(ConstraintSet.range(Intersection[T, None], T, T | None)) + constraints = ConstraintSet.range(Never, T, T | None) + expected = ConstraintSet.range(Never, T, object) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(Intersection[T, None], T, object) + expected = ConstraintSet.range(Never, T, object) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(Intersection[T, None], T, T | None) + expected = ConstraintSet.range(Never, T, object) + static_assert(constraints == expected) ``` Similarly, if the lower bound is an intersection containing the _negation_ of the typevar, then the @@ -880,8 +835,11 @@ constraint set can never be satisfied, since every type is disjoint with its neg from ty_extensions import Not def same_typevar[T](): - # revealed: ty_extensions.ConstraintSet[(T@same_typevar ≠ *)] - reveal_type(ConstraintSet.range(Intersection[Not[T], None], T, object)) - # revealed: ty_extensions.ConstraintSet[(T@same_typevar ≠ *)] - reveal_type(ConstraintSet.range(Not[T], T, object)) + constraints = ConstraintSet.range(Intersection[Not[T], None], T, object) + expected = ~ConstraintSet.range(Never, T, object) + static_assert(constraints == expected) + + constraints = ConstraintSet.range(Not[T], T, object) + expected = ~ConstraintSet.range(Never, T, object) + static_assert(constraints == expected) ``` diff --git a/crates/ty_python_semantic/resources/mdtest/type_properties/implies_subtype_of.md b/crates/ty_python_semantic/resources/mdtest/type_properties/implies_subtype_of.md index 1a72da9464..8e8d11ae71 100644 --- a/crates/ty_python_semantic/resources/mdtest/type_properties/implies_subtype_of.md +++ b/crates/ty_python_semantic/resources/mdtest/type_properties/implies_subtype_of.md @@ -50,27 +50,37 @@ question when considering a typevar, by translating the desired relationship int ```py from typing import Any -from ty_extensions import is_assignable_to, is_subtype_of +from ty_extensions import ConstraintSet, is_assignable_to, is_subtype_of, static_assert def assignability[T](): - # TODO: revealed: ty_extensions.ConstraintSet[T@assignability ≤ bool] - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_assignable_to(T, bool)) - # TODO: revealed: ty_extensions.ConstraintSet[T@assignability ≤ int] - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_assignable_to(T, int)) - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(is_assignable_to(T, object)) + constraints = is_assignable_to(T, bool) + # TODO: expected = ConstraintSet.range(Never, T, bool) + expected = ConstraintSet.never() + static_assert(constraints == expected) + + constraints = is_assignable_to(T, int) + # TODO: expected = ConstraintSet.range(Never, T, int) + expected = ConstraintSet.never() + static_assert(constraints == expected) + + constraints = is_assignable_to(T, object) + expected = ConstraintSet.always() + static_assert(constraints == expected) def subtyping[T](): - # TODO: revealed: ty_extensions.ConstraintSet[T@subtyping ≤ bool] - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_subtype_of(T, bool)) - # TODO: revealed: ty_extensions.ConstraintSet[T@subtyping ≤ int] - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_subtype_of(T, int)) - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(is_subtype_of(T, object)) + constraints = is_subtype_of(T, bool) + # TODO: expected = ConstraintSet.range(Never, T, bool) + expected = ConstraintSet.never() + static_assert(constraints == expected) + + constraints = is_subtype_of(T, int) + # TODO: expected = ConstraintSet.range(Never, T, int) + expected = ConstraintSet.never() + static_assert(constraints == expected) + + constraints = is_subtype_of(T, object) + expected = ConstraintSet.always() + static_assert(constraints == expected) ``` When checking assignability with a dynamic type, we use the bottom and top materializations of the @@ -88,50 +98,64 @@ class Contravariant[T]: pass def assignability[T](): - # aka [T@assignability ≤ object], which is always satisfiable - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(is_assignable_to(T, Any)) + constraints = is_assignable_to(T, Any) + expected = ConstraintSet.range(Never, T, object) + static_assert(constraints == expected) - # aka [Never ≤ T@assignability], which is always satisfiable - # revealed: ty_extensions.ConstraintSet[always] - reveal_type(is_assignable_to(Any, T)) + constraints = is_assignable_to(Any, T) + expected = ConstraintSet.range(Never, T, object) + static_assert(constraints == expected) - # TODO: revealed: ty_extensions.ConstraintSet[T@assignability ≤ Covariant[object]] - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_assignable_to(T, Covariant[Any])) - # TODO: revealed: ty_extensions.ConstraintSet[Covariant[Never] ≤ T@assignability] - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_assignable_to(Covariant[Any], T)) + constraints = is_assignable_to(T, Covariant[Any]) + # TODO: expected = ConstraintSet.range(Never, T, Covariant[object]) + expected = ConstraintSet.never() + static_assert(constraints == expected) - # TODO: revealed: ty_extensions.ConstraintSet[T@assignability ≤ Contravariant[Never]] - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_assignable_to(T, Contravariant[Any])) - # TODO: revealed: ty_extensions.ConstraintSet[Contravariant[object] ≤ T@assignability] - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_assignable_to(Contravariant[Any], T)) + constraints = is_assignable_to(Covariant[Any], T) + # TODO: expected = ConstraintSet.range(Covariant[Never], T, object) + expected = ConstraintSet.never() + static_assert(constraints == expected) + + constraints = is_assignable_to(T, Contravariant[Any]) + # TODO: expected = ConstraintSet.range(Never, T, Contravariant[Never]) + expected = ConstraintSet.never() + static_assert(constraints == expected) + + constraints = is_assignable_to(Contravariant[Any], T) + # TODO: expected = ConstraintSet.range(Contravariant[object], T, object) + expected = ConstraintSet.never() + static_assert(constraints == expected) def subtyping[T](): - # aka [T@assignability ≤ object], which is always satisfiable - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_subtype_of(T, Any)) + constraints = is_subtype_of(T, Any) + # TODO: expected = ConstraintSet.range(Never, T, Never) + expected = ConstraintSet.never() + static_assert(constraints == expected) - # aka [Never ≤ T@assignability], which is always satisfiable - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_subtype_of(Any, T)) + constraints = is_subtype_of(Any, T) + # TODO: expected = ConstraintSet.range(object, T, object) + expected = ConstraintSet.never() + static_assert(constraints == expected) - # TODO: revealed: ty_extensions.ConstraintSet[T@subtyping ≤ Covariant[Never]] - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_subtype_of(T, Covariant[Any])) - # TODO: revealed: ty_extensions.ConstraintSet[Covariant[object] ≤ T@subtyping] - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_subtype_of(Covariant[Any], T)) + constraints = is_subtype_of(T, Covariant[Any]) + # TODO: expected = ConstraintSet.range(Never, T, Covariant[Never]) + expected = ConstraintSet.never() + static_assert(constraints == expected) - # TODO: revealed: ty_extensions.ConstraintSet[T@subtyping ≤ Contravariant[object]] - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_subtype_of(T, Contravariant[Any])) - # TODO: revealed: ty_extensions.ConstraintSet[Contravariant[Never] ≤ T@subtyping] - # revealed: ty_extensions.ConstraintSet[never] - reveal_type(is_subtype_of(Contravariant[Any], T)) + constraints = is_subtype_of(Covariant[Any], T) + # TODO: expected = ConstraintSet.range(Covariant[object], T, object) + expected = ConstraintSet.never() + static_assert(constraints == expected) + + constraints = is_subtype_of(T, Contravariant[Any]) + # TODO: expected = ConstraintSet.range(Never, T, Contravariant[object]) + expected = ConstraintSet.never() + static_assert(constraints == expected) + + constraints = is_subtype_of(Contravariant[Any], T) + # TODO: expected = ConstraintSet.range(Contravariant[Never], T, object) + expected = ConstraintSet.never() + static_assert(constraints == expected) ``` At some point, though, we need to resolve a constraint set; at that point, we can no longer punt on diff --git a/crates/ty_python_semantic/src/types/constraints.rs b/crates/ty_python_semantic/src/types/constraints.rs index a64099352b..91a1770141 100644 --- a/crates/ty_python_semantic/src/types/constraints.rs +++ b/crates/ty_python_semantic/src/types/constraints.rs @@ -418,6 +418,7 @@ impl<'db> ConstraintSet<'db> { Self::constrain_typevar(db, typevar, lower, upper, TypeRelation::Assignability) } + #[expect(dead_code)] // Keep this around for debugging purposes pub(crate) fn display(self, db: &'db dyn Db) -> impl Display { self.node.simplify_for_display(db).display(db) } diff --git a/crates/ty_python_semantic/src/types/display.rs b/crates/ty_python_semantic/src/types/display.rs index 217e0f9a7c..e248845034 100644 --- a/crates/ty_python_semantic/src/types/display.rs +++ b/crates/ty_python_semantic/src/types/display.rs @@ -2213,10 +2213,8 @@ impl<'db> FmtDetailed<'db> for DisplayKnownInstanceRepr<'db> { } Ok(()) } - KnownInstanceType::ConstraintSet(tracked_set) => { - let constraints = tracked_set.constraints(self.db); - f.with_type(ty).write_str("ty_extensions.ConstraintSet")?; - write!(f, "[{}]", constraints.display(self.db)) + KnownInstanceType::ConstraintSet(_) => { + f.with_type(ty).write_str("ty_extensions.ConstraintSet") } KnownInstanceType::GenericContext(generic_context) => { f.with_type(ty).write_str("ty_extensions.GenericContext")?; diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index 77f587e2fc..f5870c9b08 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -10573,14 +10573,19 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { ( Type::KnownInstance(KnownInstanceType::ConstraintSet(left)), Type::KnownInstance(KnownInstanceType::ConstraintSet(right)), - ) => match op { - ast::CmpOp::Eq => Some(Ok(Type::BooleanLiteral( - left.constraints(self.db()) == right.constraints(self.db()) - ))), - ast::CmpOp::NotEq => Some(Ok(Type::BooleanLiteral( - left.constraints(self.db()) != right.constraints(self.db()) - ))), - _ => None, + ) => { + let result = match op { + ast::CmpOp::Eq => Some( + left.constraints(self.db()).iff(self.db(), right.constraints(self.db())) + ), + ast::CmpOp::NotEq => Some( + left.constraints(self.db()).iff(self.db(), right.constraints(self.db())).negate(self.db()) + ), + _ => None, + }; + result.map(|constraints| Ok(Type::KnownInstance(KnownInstanceType::ConstraintSet( + TrackedConstraintSet::new(self.db(), constraints) + )))) } ( From 015ab9e576e9ff120333f0ab9f27b5d322cc5eea Mon Sep 17 00:00:00 2001 From: Aria Desires Date: Tue, 2 Dec 2025 06:43:41 -0500 Subject: [PATCH 61/67] [ty] add tests for workspaces (#21741) Here are a bunch of (variously failing and passing) mdtests that reflect the kinds of issues people encounter when running ty over an entire workspace without sufficient hand-holding (especially because in the IDE it is unclear *how* to provide that hand-holding). --- .../resources/mdtest/import/workspaces.md | 660 ++++++++++++++++++ crates/ty_test/src/lib.rs | 16 +- my-script.py | 3 + 3 files changed, 678 insertions(+), 1 deletion(-) create mode 100644 crates/ty_python_semantic/resources/mdtest/import/workspaces.md create mode 100644 my-script.py diff --git a/crates/ty_python_semantic/resources/mdtest/import/workspaces.md b/crates/ty_python_semantic/resources/mdtest/import/workspaces.md new file mode 100644 index 0000000000..430860a562 --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/import/workspaces.md @@ -0,0 +1,660 @@ +# Support for Resolving Imports In Workspaces + +Python packages have fairly rigid structures that we rely on when resolving imports and merging +namespace packages or stub packages. These rules go out the window when analyzing some random local +python file in some random workspace, and so we need to be more tolerant of situations that wouldn't +fly in a published package, cases where we're not configured as well as we'd like, or cases where +two projects in a monorepo have conflicting definitions (but we want to analyze both at once). + +## Invalid Names + +While you can't syntactically refer to a module with an invalid name (i.e. one with a `-`, or that +has the same name as a keyword) there are plenty of situations where a module with an invalid name +can be run. For instance `python my-script.py` and `python my-proj/main.py` both work, even though +we might in the course of analyzing the code compute the module name `my-script` or `my-proj.main`. + +Also, a sufficiently motivated programmer can technically use `importlib.import_module` which takes +strings and does in fact allow syntactically invalid module names. + +### Current File Is Invalid Module Name + +Relative and absolute imports should resolve fine in a file that isn't a valid module name. + +`my-main.py`: + +```py +# TODO: there should be no errors in this file + +# error: [unresolved-import] +from .mod1 import x + +# error: [unresolved-import] +from . import mod2 +import mod3 + +reveal_type(x) # revealed: Unknown +reveal_type(mod2.y) # revealed: Unknown +reveal_type(mod3.z) # revealed: int +``` + +`mod1.py`: + +```py +x: int = 1 +``` + +`mod2.py`: + +```py +y: int = 2 +``` + +`mod3.py`: + +```py +z: int = 2 +``` + +### Current Directory Is Invalid Module Name + +Relative and absolute imports should resolve fine in a dir that isn't a valid module name. + +`my-tests/main.py`: + +```py +# TODO: there should be no errors in this file + +# error: [unresolved-import] +from .mod1 import x + +# error: [unresolved-import] +from . import mod2 +import mod3 + +reveal_type(x) # revealed: Unknown +reveal_type(mod2.y) # revealed: Unknown +reveal_type(mod3.z) # revealed: int +``` + +`my-tests/mod1.py`: + +```py +x: int = 1 +``` + +`my-tests/mod2.py`: + +```py +y: int = 2 +``` + +`mod3.py`: + +```py +z: int = 2 +``` + +### Current Directory Is Invalid Package Name + +Relative and absolute imports should resolve fine in a dir that isn't a valid package name, even if +it contains an `__init__.py`: + +`my-tests/__init__.py`: + +```py +``` + +`my-tests/main.py`: + +```py +# TODO: there should be no errors in this file + +# error: [unresolved-import] +from .mod1 import x + +# error: [unresolved-import] +from . import mod2 +import mod3 + +reveal_type(x) # revealed: Unknown +reveal_type(mod2.y) # revealed: Unknown +reveal_type(mod3.z) # revealed: int +``` + +`my-tests/mod1.py`: + +```py +x: int = 1 +``` + +`my-tests/mod2.py`: + +```py +y: int = 2 +``` + +`mod3.py`: + +```py +z: int = 2 +``` + +## Multiple Projects + +It's common for a monorepo to define many separate projects that may or may not depend on eachother +and are stitched together with a package manager like `uv` or `poetry`, often as editables. In this +case, especially when running as an LSP, we want to be able to analyze all of the projects at once, +allowing us to reuse results between projects, without getting confused about things that only make +sense when analyzing the project separately. + +The following tests will feature two projects, `a` and `b` where the "real" packages are found under +`src/` subdirectories (and we've been configured to understand that), but each project also contains +other python files in their roots or subdirectories that contains python files which relatively +import eachother and also absolutely import the main package of the project. All of these imports +*should* resolve. + +Often the fact that there is both an `a` and `b` project seemingly won't matter, but many possible +solutions will misbehave under these conditions, as e.g. if both define a `main.py` and test code +has `import main`, we need to resolve each project's main as appropriate. + +One key hint we will have in these situations is the existence of a `pyproject.toml`, so the +following examples include them in case they help. + +### Tests Directory With Overlapping Names + +Here we have fairly typical situation where there are two projects `aproj` and `bproj` where the +"real" packages are found under `src/` subdirectories, but each project also contains a `tests/` +directory that contains python files which relatively import eachother and also absolutely import +the package they test. All of these imports *should* resolve. + +```toml +[environment] +# This is similar to what we would compute for installed editables +extra-paths = ["aproj/src/", "bproj/src/"] +``` + +`aproj/tests/test1.py`: + +```py +from .setup import x +from . import setup +from a import y +import a + +reveal_type(x) # revealed: int +reveal_type(setup.x) # revealed: int +reveal_type(y) # revealed: int +reveal_type(a.y) # revealed: int +``` + +`aproj/tests/setup.py`: + +```py +x: int = 1 +``` + +`aproj/pyproject.toml`: + +```text +name = "a" +version = "0.1.0" +``` + +`aproj/src/a/__init__.py`: + +```py +y: int = 10 +``` + +`bproj/tests/test1.py`: + +```py +from .setup import x +from . import setup +from b import y +import b + +reveal_type(x) # revealed: str +reveal_type(setup.x) # revealed: str +reveal_type(y) # revealed: str +reveal_type(b.y) # revealed: str +``` + +`bproj/tests/setup.py`: + +```py +x: str = "2" +``` + +`bproj/pyproject.toml`: + +```text +name = "a" +version = "0.1.0" +``` + +`bproj/src/b/__init__.py`: + +```py +y: str = "20" +``` + +### Tests Directory With Ambiguous Project Directories + +The same situation as the previous test but instead of the project `a` being in a directory `aproj` +to disambiguate, we now need to avoid getting confused about whether `a/` or `a/src/a/` is the +package `a` while still resolving imports. + +```toml +[environment] +# This is similar to what we would compute for installed editables +extra-paths = ["a/src/", "b/src/"] +``` + +`a/tests/test1.py`: + +```py +# TODO: there should be no errors in this file. + +# error: [unresolved-import] +from .setup import x + +# error: [unresolved-import] +from . import setup +from a import y +import a + +reveal_type(x) # revealed: Unknown +reveal_type(setup.x) # revealed: Unknown +reveal_type(y) # revealed: int +reveal_type(a.y) # revealed: int +``` + +`a/tests/setup.py`: + +```py +x: int = 1 +``` + +`a/pyproject.toml`: + +```text +name = "a" +version = "0.1.0" +``` + +`a/src/a/__init__.py`: + +```py +y: int = 10 +``` + +`b/tests/test1.py`: + +```py +# TODO: there should be no errors in this file + +# error: [unresolved-import] +from .setup import x + +# error: [unresolved-import] +from . import setup +from b import y +import b + +reveal_type(x) # revealed: Unknown +reveal_type(setup.x) # revealed: Unknown +reveal_type(y) # revealed: str +reveal_type(b.y) # revealed: str +``` + +`b/tests/setup.py`: + +```py +x: str = "2" +``` + +`b/pyproject.toml`: + +```text +name = "a" +version = "0.1.0" +``` + +`b/src/b/__init__.py`: + +```py +y: str = "20" +``` + +### Tests Package With Ambiguous Project Directories + +The same situation as the previous test but `tests/__init__.py` is also defined, in case that +complicates the situation. + +```toml +[environment] +extra-paths = ["a/src/", "b/src/"] +``` + +`a/tests/test1.py`: + +```py +# TODO: there should be no errors in this file. + +# error: [unresolved-import] +from .setup import x + +# error: [unresolved-import] +from . import setup +from a import y +import a + +reveal_type(x) # revealed: Unknown +reveal_type(setup.x) # revealed: Unknown +reveal_type(y) # revealed: int +reveal_type(a.y) # revealed: int +``` + +`a/tests/__init__.py`: + +```py +``` + +`a/tests/setup.py`: + +```py +x: int = 1 +``` + +`a/pyproject.toml`: + +```text +name = "a" +version = "0.1.0" +``` + +`a/src/a/__init__.py`: + +```py +y: int = 10 +``` + +`b/tests/test1.py`: + +```py +# TODO: there should be no errors in this file + +# error: [unresolved-import] +from .setup import x + +# error: [unresolved-import] +from . import setup +from b import y +import b + +reveal_type(x) # revealed: Unknown +reveal_type(setup.x) # revealed: Unknown +reveal_type(y) # revealed: str +reveal_type(b.y) # revealed: str +``` + +`b/tests/__init__.py`: + +```py +``` + +`b/tests/setup.py`: + +```py +x: str = "2" +``` + +`b/pyproject.toml`: + +```text +name = "a" +version = "0.1.0" +``` + +`b/src/b/__init__.py`: + +```py +y: str = "20" +``` + +### Tests Directory Absolute Importing `main.py` + +Here instead of defining packages we have a couple simple applications with a `main.py` and tests +that `import main` and expect that to work. + +`a/tests/test1.py`: + +```py +# TODO: there should be no errors in this file. + +from .setup import x +from . import setup + +# error: [unresolved-import] +from main import y + +# error: [unresolved-import] +import main + +reveal_type(x) # revealed: int +reveal_type(setup.x) # revealed: int +reveal_type(y) # revealed: Unknown +reveal_type(main.y) # revealed: Unknown +``` + +`a/tests/setup.py`: + +```py +x: int = 1 +``` + +`a/pyproject.toml`: + +```text +name = "a" +version = "0.1.0" +``` + +`a/main.py`: + +```py +y: int = 10 +``` + +`b/tests/test1.py`: + +```py +# TODO: there should be no errors in this file + +from .setup import x +from . import setup + +# error: [unresolved-import] +from main import y + +# error: [unresolved-import] +import main + +reveal_type(x) # revealed: str +reveal_type(setup.x) # revealed: str +reveal_type(y) # revealed: Unknown +reveal_type(main.y) # revealed: Unknown +``` + +`b/tests/setup.py`: + +```py +x: str = "2" +``` + +`b/pyproject.toml`: + +```text +name = "a" +version = "0.1.0" +``` + +`b/main.py`: + +```py +y: str = "20" +``` + +### Tests Package Absolute Importing `main.py` + +The same as the previous case but `tests/__init__.py` exists in case that causes different issues. + +`a/tests/test1.py`: + +```py +# TODO: there should be no errors in this file. + +from .setup import x +from . import setup + +# error: [unresolved-import] +from main import y + +# error: [unresolved-import] +import main + +reveal_type(x) # revealed: int +reveal_type(setup.x) # revealed: int +reveal_type(y) # revealed: Unknown +reveal_type(main.y) # revealed: Unknown +``` + +`a/tests/__init__.py`: + +```py +``` + +`a/tests/setup.py`: + +```py +x: int = 1 +``` + +`a/pyproject.toml`: + +```text +name = "a" +version = "0.1.0" +``` + +`a/main.py`: + +```py +y: int = 10 +``` + +`b/tests/test1.py`: + +```py +# TODO: there should be no errors in this file + +from .setup import x +from . import setup + +# error: [unresolved-import] +from main import y + +# error: [unresolved-import] +import main + +reveal_type(x) # revealed: str +reveal_type(setup.x) # revealed: str +reveal_type(y) # revealed: Unknown +reveal_type(main.y) # revealed: Unknown +``` + +`b/tests/__init__.py`: + +```py +``` + +`b/tests/setup.py`: + +```py +x: str = "2" +``` + +`b/pyproject.toml`: + +```text +name = "a" +version = "0.1.0" +``` + +`b/main.py`: + +```py +y: str = "20" +``` + +### `main.py` absolute importing private package + +In this case each project has a `main.py` that defines a "private" `utils` package and absolute +imports it. + +`a/main.py`: + +```py +# TODO: there should be no errors in this file. + +# error: [unresolved-import] +from utils import x + +# error: [unresolved-import] +import utils + +reveal_type(x) # revealed: Unknown +reveal_type(utils.x) # revealed: Unknown +``` + +`a/utils/__init__.py`: + +```py +x: int = 1 +``` + +`a/pyproject.toml`: + +```text +name = "a" +version = "0.1.0" +``` + +`b/main.py`: + +```py +# TODO: there should be no errors in this file. + +# error: [unresolved-import] +from utils import x + +# error: [unresolved-import] +import utils + +reveal_type(x) # revealed: Unknown +reveal_type(utils.x) # revealed: Unknown +``` + +`b/utils/__init__.py`: + +```py +x: str = "2" +``` + +`b/pyproject.toml`: + +```text +name = "a" +version = "0.1.0" +``` diff --git a/crates/ty_test/src/lib.rs b/crates/ty_test/src/lib.rs index 800d4e4c4d..ad4e7ebe4e 100644 --- a/crates/ty_test/src/lib.rs +++ b/crates/ty_test/src/lib.rs @@ -350,6 +350,20 @@ fn run_test( vec![] }; + // Make any relative extra-paths be relative to src_path + let extra_paths = configuration + .extra_paths() + .unwrap_or_default() + .iter() + .map(|path| { + if path.is_absolute() { + path.clone() + } else { + src_path.join(path) + } + }) + .collect(); + let settings = ProgramSettings { python_version: PythonVersionWithSource { version: python_version, @@ -360,7 +374,7 @@ fn run_test( .unwrap_or(PythonPlatform::Identifier("linux".to_string())), search_paths: SearchPathSettings { src_roots: vec![src_path], - extra_paths: configuration.extra_paths().unwrap_or_default().to_vec(), + extra_paths, custom_typeshed: custom_typeshed_path.map(SystemPath::to_path_buf), site_packages_paths, real_stdlib_path: None, diff --git a/my-script.py b/my-script.py new file mode 100644 index 0000000000..0663824d37 --- /dev/null +++ b/my-script.py @@ -0,0 +1,3 @@ +from __future__ import annotations + +print("hello") From 644096ea8a1e8ccc4d3d1300bcfb0785ec671947 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Tue, 2 Dec 2025 14:37:50 +0100 Subject: [PATCH 62/67] [ty] Fix find-references for import aliases (#21736) --- crates/ty_ide/src/find_references.rs | 148 ++++++++++++++++++ crates/ty_ide/src/goto.rs | 30 ++-- crates/ty_ide/src/rename.rs | 128 +++++++++++---- .../src/semantic_index/builder.rs | 4 + 4 files changed, 264 insertions(+), 46 deletions(-) diff --git a/crates/ty_ide/src/find_references.rs b/crates/ty_ide/src/find_references.rs index a6b60bc6c2..d281dcaf92 100644 --- a/crates/ty_ide/src/find_references.rs +++ b/crates/ty_ide/src/find_references.rs @@ -1722,4 +1722,152 @@ func_alias() | "###); } + + #[test] + fn import_alias() { + let test = CursorTest::builder() + .source( + "main.py", + r#" + import warnings + import warnings as abc + + x = abc + y = warnings + "#, + ) + .build(); + + assert_snapshot!(test.references(), @r" + info[references]: Reference 1 + --> main.py:3:20 + | + 2 | import warnings + 3 | import warnings as abc + | ^^^ + 4 | + 5 | x = abc + | + + info[references]: Reference 2 + --> main.py:5:5 + | + 3 | import warnings as abc + 4 | + 5 | x = abc + | ^^^ + 6 | y = warnings + | + "); + } + + #[test] + fn import_alias_use() { + let test = CursorTest::builder() + .source( + "main.py", + r#" + import warnings + import warnings as abc + + x = abc + y = warnings + "#, + ) + .build(); + + assert_snapshot!(test.references(), @r" + info[references]: Reference 1 + --> main.py:3:20 + | + 2 | import warnings + 3 | import warnings as abc + | ^^^ + 4 | + 5 | x = abc + | + + info[references]: Reference 2 + --> main.py:5:5 + | + 3 | import warnings as abc + 4 | + 5 | x = abc + | ^^^ + 6 | y = warnings + | + "); + } + + #[test] + fn import_from_alias() { + let test = CursorTest::builder() + .source( + "main.py", + r#" + from warnings import deprecated as xyz + from warnings import deprecated + + y = xyz + z = deprecated + "#, + ) + .build(); + + assert_snapshot!(test.references(), @r" + info[references]: Reference 1 + --> main.py:2:36 + | + 2 | from warnings import deprecated as xyz + | ^^^ + 3 | from warnings import deprecated + | + + info[references]: Reference 2 + --> main.py:5:5 + | + 3 | from warnings import deprecated + 4 | + 5 | y = xyz + | ^^^ + 6 | z = deprecated + | + "); + } + + #[test] + fn import_from_alias_use() { + let test = CursorTest::builder() + .source( + "main.py", + r#" + from warnings import deprecated as xyz + from warnings import deprecated + + y = xyz + z = deprecated + "#, + ) + .build(); + + assert_snapshot!(test.references(), @r" + info[references]: Reference 1 + --> main.py:2:36 + | + 2 | from warnings import deprecated as xyz + | ^^^ + 3 | from warnings import deprecated + | + + info[references]: Reference 2 + --> main.py:5:5 + | + 3 | from warnings import deprecated + 4 | + 5 | y = xyz + | ^^^ + 6 | z = deprecated + | + "); + } } diff --git a/crates/ty_ide/src/goto.rs b/crates/ty_ide/src/goto.rs index 3b086b91fd..17df9f11d9 100644 --- a/crates/ty_ide/src/goto.rs +++ b/crates/ty_ide/src/goto.rs @@ -396,13 +396,19 @@ impl GotoTarget<'_> { GotoTarget::ImportSymbolAlias { alias, import_from, .. } => { - let symbol_name = alias.name.as_str(); - Some(definitions_for_imported_symbol( - model, - import_from, - symbol_name, - alias_resolution, - )) + if let Some(asname) = alias.asname.as_ref() + && alias_resolution == ImportAliasResolution::PreserveAliases + { + Some(definitions_for_name(model, asname.as_str(), asname.into())) + } else { + let symbol_name = alias.name.as_str(); + Some(definitions_for_imported_symbol( + model, + import_from, + symbol_name, + alias_resolution, + )) + } } GotoTarget::ImportModuleComponent { @@ -418,12 +424,12 @@ impl GotoTarget<'_> { // Handle import aliases (offset within 'z' in "import x.y as z") GotoTarget::ImportModuleAlias { alias } => { - if alias_resolution == ImportAliasResolution::ResolveAliases { - definitions_for_module(model, Some(alias.name.as_str()), 0) + if let Some(asname) = alias.asname.as_ref() + && alias_resolution == ImportAliasResolution::PreserveAliases + { + Some(definitions_for_name(model, asname.as_str(), asname.into())) } else { - alias.asname.as_ref().map(|name| { - definitions_for_name(model, name.as_str(), AnyNodeRef::Identifier(name)) - }) + definitions_for_module(model, Some(alias.name.as_str()), 0) } } diff --git a/crates/ty_ide/src/rename.rs b/crates/ty_ide/src/rename.rs index 156f38fee4..3ecc474d6d 100644 --- a/crates/ty_ide/src/rename.rs +++ b/crates/ty_ide/src/rename.rs @@ -163,7 +163,7 @@ mod tests { } #[test] - fn test_prepare_rename_parameter() { + fn prepare_rename_parameter() { let test = cursor_test( " def func(value: int) -> int: @@ -178,7 +178,7 @@ value = 0 } #[test] - fn test_rename_parameter() { + fn rename_parameter() { let test = cursor_test( " def func(value: int) -> int: @@ -207,7 +207,7 @@ func(value=42) } #[test] - fn test_rename_function() { + fn rename_function() { let test = cursor_test( " def func(): @@ -235,7 +235,7 @@ x = func } #[test] - fn test_rename_class() { + fn rename_class() { let test = cursor_test( " class MyClass: @@ -265,7 +265,7 @@ cls = MyClass } #[test] - fn test_rename_invalid_name() { + fn rename_invalid_name() { let test = cursor_test( " def func(): @@ -286,7 +286,7 @@ def func(): } #[test] - fn test_multi_file_function_rename() { + fn multi_file_function_rename() { let test = CursorTest::builder() .source( "utils.py", @@ -312,7 +312,7 @@ from utils import helper_function class DataProcessor: def __init__(self): self.multiplier = helper_function - + def process(self, value): return helper_function(value) ", @@ -654,7 +654,7 @@ class DataProcessor: def __init__(self, pos, btn): self.position: int = pos self.button: str = btn - + def my_func(event: Click): match event: case Click(x, button=ab): @@ -685,7 +685,7 @@ class DataProcessor: def __init__(self, pos, btn): self.position: int = pos self.button: str = btn - + def my_func(event: Click): match event: case Click(x, button=ab): @@ -716,7 +716,7 @@ class DataProcessor: def __init__(self, pos, btn): self.position: int = pos self.button: str = btn - + def my_func(event: Click): match event: case Click(x, button=ab): @@ -756,7 +756,7 @@ class DataProcessor: def __init__(self, pos, btn): self.position: int = pos self.button: str = btn - + def my_func(event: Click): match event: case Click(x, button=ab): @@ -880,7 +880,7 @@ class DataProcessor: } #[test] - fn test_cannot_rename_import_module_component() { + fn cannot_rename_import_module_component() { // Test that we cannot rename parts of module names in import statements let test = cursor_test( " @@ -893,7 +893,7 @@ x = os.path.join('a', 'b') } #[test] - fn test_cannot_rename_from_import_module_component() { + fn cannot_rename_from_import_module_component() { // Test that we cannot rename parts of module names in from import statements let test = cursor_test( " @@ -906,7 +906,7 @@ result = join('a', 'b') } #[test] - fn test_cannot_rename_external_file() { + fn cannot_rename_external_file() { // This test verifies that we cannot rename a symbol when it's defined in a file // that's outside the project (like a standard library function) let test = cursor_test( @@ -920,7 +920,7 @@ x = os.path.join('a', 'b') } #[test] - fn test_rename_alias_at_import_statement() { + fn rename_alias_at_import_statement() { let test = CursorTest::builder() .source( "utils.py", @@ -931,8 +931,8 @@ def test(): pass .source( "main.py", " -from utils import test as test_alias -result = test_alias() +from utils import test as alias +result = alias() ", ) .build(); @@ -941,16 +941,16 @@ result = test_alias() info[rename]: Rename symbol (found 2 locations) --> main.py:2:27 | - 2 | from utils import test as test_alias - | ^^^^^^^^^^ - 3 | result = test_alias() - | ---------- + 2 | from utils import test as alias + | ^^^^^ + 3 | result = alias() + | ----- | "); } #[test] - fn test_rename_alias_at_usage_site() { + fn rename_alias_at_usage_site() { // Test renaming an alias when the cursor is on the alias in the usage statement let test = CursorTest::builder() .source( @@ -962,8 +962,8 @@ def test(): pass .source( "main.py", " -from utils import test as test_alias -result = test_alias() +from utils import test as alias +result = alias() ", ) .build(); @@ -972,16 +972,16 @@ result = test_alias() info[rename]: Rename symbol (found 2 locations) --> main.py:2:27 | - 2 | from utils import test as test_alias - | ^^^^^^^^^^ - 3 | result = test_alias() - | ---------- + 2 | from utils import test as alias + | ^^^^^ + 3 | result = alias() + | ----- | "); } #[test] - fn test_rename_across_import_chain_with_mixed_aliases() { + fn rename_across_import_chain_with_mixed_aliases() { // Test renaming a symbol that's imported across multiple files with mixed alias patterns // File 1 (source.py): defines the original function // File 2 (middle.py): imports without alias from source.py @@ -1049,7 +1049,7 @@ value1 = func_alias() } #[test] - fn test_rename_alias_in_import_chain() { + fn rename_alias_in_import_chain() { let test = CursorTest::builder() .source( "file1.py", @@ -1101,7 +1101,7 @@ class App: } #[test] - fn test_cannot_rename_keyword() { + fn cannot_rename_keyword() { // Test that we cannot rename Python keywords like "None" let test = cursor_test( " @@ -1116,7 +1116,7 @@ def process_value(value): } #[test] - fn test_cannot_rename_builtin_type() { + fn cannot_rename_builtin_type() { // Test that we cannot rename Python builtin types like "int" let test = cursor_test( " @@ -1129,7 +1129,7 @@ def convert_to_number(value): } #[test] - fn test_rename_keyword_argument() { + fn rename_keyword_argument() { // Test renaming a keyword argument and its corresponding parameter let test = cursor_test( " @@ -1156,7 +1156,7 @@ result = func(10, y=20) } #[test] - fn test_rename_parameter_with_keyword_argument() { + fn rename_parameter_with_keyword_argument() { // Test renaming a parameter and its corresponding keyword argument let test = cursor_test( " @@ -1181,4 +1181,64 @@ result = func(10, y=20) | "); } + + #[test] + fn import_alias() { + let test = CursorTest::builder() + .source( + "main.py", + r#" + import warnings + import warnings as abc + + x = abc + y = warnings + "#, + ) + .build(); + + assert_snapshot!(test.rename("z"), @r" + info[rename]: Rename symbol (found 2 locations) + --> main.py:3:20 + | + 2 | import warnings + 3 | import warnings as abc + | ^^^ + 4 | + 5 | x = abc + | --- + 6 | y = warnings + | + "); + } + + #[test] + fn import_alias_use() { + let test = CursorTest::builder() + .source( + "main.py", + r#" + import warnings + import warnings as abc + + x = abc + y = warnings + "#, + ) + .build(); + + assert_snapshot!(test.rename("z"), @r" + info[rename]: Rename symbol (found 2 locations) + --> main.py:3:20 + | + 2 | import warnings + 3 | import warnings as abc + | ^^^ + 4 | + 5 | x = abc + | --- + 6 | y = warnings + | + "); + } } diff --git a/crates/ty_python_semantic/src/semantic_index/builder.rs b/crates/ty_python_semantic/src/semantic_index/builder.rs index f7b6da1a0f..b729862f2b 100644 --- a/crates/ty_python_semantic/src/semantic_index/builder.rs +++ b/crates/ty_python_semantic/src/semantic_index/builder.rs @@ -1478,6 +1478,8 @@ impl<'ast> Visitor<'ast> for SemanticIndexBuilder<'_, 'ast> { } let (symbol_name, is_reexported) = if let Some(asname) = &alias.asname { + self.scopes_by_expression + .record_expression(asname, self.current_scope()); (asname.id.clone(), asname.id == alias.name.id) } else { (Name::new(alias.name.id.split('.').next().unwrap()), false) @@ -1651,6 +1653,8 @@ impl<'ast> Visitor<'ast> for SemanticIndexBuilder<'_, 'ast> { } let (symbol_name, is_reexported) = if let Some(asname) = &alias.asname { + self.scopes_by_expression + .record_expression(asname, self.current_scope()); // It's re-exported if it's `from ... import x as x` (&asname.id, asname.id == alias.name.id) } else { From ac2552b11bbab52981797408cf884a52b4d919e2 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 2 Dec 2025 14:45:24 +0000 Subject: [PATCH 63/67] [ty] Move `all_members`, and related types/routines, out of `ide_support.rs` (#21695) --- .../ty_python_semantic/src/semantic_model.rs | 11 +- crates/ty_python_semantic/src/types.rs | 1 + .../ty_python_semantic/src/types/call/bind.rs | 4 +- .../ty_python_semantic/src/types/function.rs | 2 +- .../src/types/ide_support.rs | 512 +---------------- .../src/types/list_members.rs | 516 ++++++++++++++++++ .../ty_python_semantic/src/types/overrides.rs | 5 +- 7 files changed, 533 insertions(+), 518 deletions(-) create mode 100644 crates/ty_python_semantic/src/types/list_members.rs diff --git a/crates/ty_python_semantic/src/semantic_model.rs b/crates/ty_python_semantic/src/semantic_model.rs index 236305cb73..f9ac728c40 100644 --- a/crates/ty_python_semantic/src/semantic_model.rs +++ b/crates/ty_python_semantic/src/semantic_model.rs @@ -11,7 +11,7 @@ use crate::module_resolver::{KnownModule, Module, list_modules, resolve_module}; use crate::semantic_index::definition::Definition; use crate::semantic_index::scope::FileScopeId; use crate::semantic_index::semantic_index; -use crate::types::ide_support::{Member, all_declarations_and_bindings, all_members}; +use crate::types::list_members::{Member, all_members, all_members_of_scope}; use crate::types::{Type, binding_type, infer_scope_types}; use crate::{Db, resolve_real_shadowable_module}; @@ -76,7 +76,7 @@ impl<'db> SemanticModel<'db> { for (file_scope, _) in index.ancestor_scopes(file_scope) { for memberdef in - all_declarations_and_bindings(self.db, file_scope.to_scope_id(self.db, self.file)) + all_members_of_scope(self.db, file_scope.to_scope_id(self.db, self.file)) { members.insert( memberdef.member.name, @@ -221,12 +221,13 @@ impl<'db> SemanticModel<'db> { let mut completions = vec![]; for (file_scope, _) in index.ancestor_scopes(file_scope) { completions.extend( - all_declarations_and_bindings(self.db, file_scope.to_scope_id(self.db, self.file)) - .map(|memberdef| Completion { + all_members_of_scope(self.db, file_scope.to_scope_id(self.db, self.file)).map( + |memberdef| Completion { name: memberdef.member.name, ty: Some(memberdef.member.ty), builtin: false, - }), + }, + ), ); } // Builtins are available in all scopes. diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 416e80b5c5..494f4efa83 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -96,6 +96,7 @@ mod generics; pub mod ide_support; mod infer; mod instance; +pub mod list_members; mod member; mod mro; mod narrow; diff --git a/crates/ty_python_semantic/src/types/call/bind.rs b/crates/ty_python_semantic/src/types/call/bind.rs index dce0c5b7eb..2093f2f377 100644 --- a/crates/ty_python_semantic/src/types/call/bind.rs +++ b/crates/ty_python_semantic/src/types/call/bind.rs @@ -39,7 +39,7 @@ use crate::types::{ DataclassParams, FieldInstance, KnownBoundMethodType, KnownClass, KnownInstanceType, MemberLookupPolicy, NominalInstanceType, PropertyInstanceType, SpecialFormType, TrackedConstraintSet, TypeAliasType, TypeContext, TypeVarVariance, UnionBuilder, UnionType, - WrapperDescriptorKind, enums, ide_support, todo_type, + WrapperDescriptorKind, enums, list_members, todo_type, }; use ruff_db::diagnostic::{Annotation, Diagnostic, SubDiagnostic, SubDiagnosticSeverity}; use ruff_python_ast::{self as ast, ArgOrKeyword, PythonVersion}; @@ -888,7 +888,7 @@ impl<'db> Bindings<'db> { if let [Some(ty)] = overload.parameter_types() { overload.set_return_type(Type::heterogeneous_tuple( db, - ide_support::all_members(db, *ty) + list_members::all_members(db, *ty) .into_iter() .sorted() .map(|member| Type::string_literal(db, &member.name)), diff --git a/crates/ty_python_semantic/src/types/function.rs b/crates/ty_python_semantic/src/types/function.rs index 189520fa52..339689169c 100644 --- a/crates/ty_python_semantic/src/types/function.rs +++ b/crates/ty_python_semantic/src/types/function.rs @@ -74,7 +74,7 @@ use crate::types::diagnostic::{ }; use crate::types::display::DisplaySettings; use crate::types::generics::{GenericContext, InferableTypeVars}; -use crate::types::ide_support::all_members; +use crate::types::list_members::all_members; use crate::types::narrow::ClassInfoConstraintFunction; use crate::types::signatures::{CallableSignature, Signature}; use crate::types::visitor::any_over_type; diff --git a/crates/ty_python_semantic/src/types/ide_support.rs b/crates/ty_python_semantic/src/types/ide_support.rs index 74eab52e72..2c53ea275f 100644 --- a/crates/ty_python_semantic/src/types/ide_support.rs +++ b/crates/ty_python_semantic/src/types/ide_support.rs @@ -1,27 +1,16 @@ -use std::cmp::Ordering; use std::collections::HashMap; -use crate::place::{ - Place, builtins_module_scope, imported_symbol, place_from_bindings, place_from_declarations, -}; +use crate::place::builtins_module_scope; use crate::semantic_index::definition::Definition; use crate::semantic_index::definition::DefinitionKind; -use crate::semantic_index::scope::ScopeId; -use crate::semantic_index::{ - attribute_scopes, global_scope, place_table, semantic_index, use_def_map, -}; +use crate::semantic_index::{attribute_scopes, global_scope, semantic_index, use_def_map}; use crate::types::call::{CallArguments, MatchedArgument}; -use crate::types::generics::Specialization; use crate::types::signatures::Signature; -use crate::types::{CallDunderError, SubclassOfInner, UnionType}; -use crate::types::{ - CallableTypes, ClassBase, ClassLiteral, KnownClass, KnownInstanceType, Type, TypeContext, - TypeVarBoundOrConstraints, class::CodeGeneratorKind, -}; -use crate::{Db, DisplaySettings, HasType, NameKind, SemanticModel}; +use crate::types::{CallDunderError, UnionType}; +use crate::types::{CallableTypes, ClassBase, KnownClass, Type, TypeContext}; +use crate::{Db, DisplaySettings, HasType, SemanticModel}; use ruff_db::files::FileRange; use ruff_db::parsed::parsed_module; -use ruff_python_ast::name::Name; use ruff_python_ast::{self as ast, AnyNodeRef}; use ruff_text_size::{Ranged, TextRange}; use rustc_hash::FxHashSet; @@ -29,497 +18,6 @@ use rustc_hash::FxHashSet; pub use resolve_definition::{ImportAliasResolution, ResolvedDefinition, map_stub_definition}; use resolve_definition::{find_symbol_in_scope, resolve_definition}; -// `__init__`, `__repr__`, `__eq__`, `__ne__` and `__hash__` are always included via `object`, -// so we don't need to list them here. -const SYNTHETIC_DATACLASS_ATTRIBUTES: &[&str] = &[ - "__lt__", - "__le__", - "__gt__", - "__ge__", - "__replace__", - "__setattr__", - "__delattr__", - "__slots__", - "__weakref__", - "__match_args__", - "__dataclass_fields__", - "__dataclass_params__", -]; - -pub(crate) fn all_declarations_and_bindings<'db>( - db: &'db dyn Db, - scope_id: ScopeId<'db>, -) -> impl Iterator> + 'db { - let use_def_map = use_def_map(db, scope_id); - let table = place_table(db, scope_id); - - use_def_map - .all_end_of_scope_symbol_declarations() - .filter_map(move |(symbol_id, declarations)| { - let place_result = place_from_declarations(db, declarations); - let definition = place_result.single_declaration; - place_result - .ignore_conflicting_declarations() - .place - .ignore_possibly_undefined() - .map(|ty| { - let symbol = table.symbol(symbol_id); - let member = Member { - name: symbol.name().clone(), - ty, - }; - MemberWithDefinition { member, definition } - }) - }) - .chain(use_def_map.all_end_of_scope_symbol_bindings().filter_map( - move |(symbol_id, bindings)| { - // It's not clear to AG how to using a bindings - // iterator here to get the correct definition for - // this binding. Below, we look through all bindings - // with a definition and only take one if there is - // exactly one. I don't think this can be wrong, but - // it's probably omitting definitions in some cases. - let mut definition = None; - for binding in bindings.clone() { - if let Some(def) = binding.binding.definition() { - if definition.is_some() { - definition = None; - break; - } - definition = Some(def); - } - } - place_from_bindings(db, bindings) - .ignore_possibly_undefined() - .map(|ty| { - let symbol = table.symbol(symbol_id); - let member = Member { - name: symbol.name().clone(), - ty, - }; - MemberWithDefinition { member, definition } - }) - }, - )) -} - -struct AllMembers<'db> { - members: FxHashSet>, -} - -impl<'db> AllMembers<'db> { - fn of(db: &'db dyn Db, ty: Type<'db>) -> Self { - let mut all_members = Self { - members: FxHashSet::default(), - }; - all_members.extend_with_type(db, ty); - all_members - } - - fn extend_with_type(&mut self, db: &'db dyn Db, ty: Type<'db>) { - match ty { - Type::Union(union) => self.members.extend( - union - .elements(db) - .iter() - .map(|ty| AllMembers::of(db, *ty).members) - .reduce(|acc, members| acc.intersection(&members).cloned().collect()) - .unwrap_or_default(), - ), - - Type::Intersection(intersection) => self.members.extend( - intersection - .positive(db) - .iter() - .map(|ty| AllMembers::of(db, *ty).members) - .reduce(|acc, members| acc.union(&members).cloned().collect()) - .unwrap_or_default(), - ), - - Type::NominalInstance(instance) => { - let (class_literal, specialization) = instance.class(db).class_literal(db); - self.extend_with_instance_members(db, ty, class_literal); - self.extend_with_synthetic_members(db, ty, class_literal, specialization); - } - - Type::NewTypeInstance(newtype) => { - self.extend_with_type(db, Type::instance(db, newtype.base_class_type(db))); - } - - Type::ClassLiteral(class_literal) if class_literal.is_typed_dict(db) => { - self.extend_with_type(db, KnownClass::TypedDictFallback.to_class_literal(db)); - } - - Type::GenericAlias(generic_alias) if generic_alias.is_typed_dict(db) => { - self.extend_with_type(db, KnownClass::TypedDictFallback.to_class_literal(db)); - } - - Type::SubclassOf(subclass_of_type) if subclass_of_type.is_typed_dict(db) => { - self.extend_with_type(db, KnownClass::TypedDictFallback.to_class_literal(db)); - } - - Type::ClassLiteral(class_literal) => { - self.extend_with_class_members(db, ty, class_literal); - self.extend_with_synthetic_members(db, ty, class_literal, None); - if let Type::ClassLiteral(metaclass) = class_literal.metaclass(db) { - self.extend_with_class_members(db, ty, metaclass); - } - } - - Type::GenericAlias(generic_alias) => { - let class_literal = generic_alias.origin(db); - self.extend_with_class_members(db, ty, class_literal); - self.extend_with_synthetic_members(db, ty, class_literal, None); - if let Type::ClassLiteral(metaclass) = class_literal.metaclass(db) { - self.extend_with_class_members(db, ty, metaclass); - } - } - - Type::SubclassOf(subclass_of_type) => match subclass_of_type.subclass_of() { - SubclassOfInner::Dynamic(_) => { - self.extend_with_type(db, KnownClass::Type.to_instance(db)); - } - _ => { - if let Some(class_type) = subclass_of_type.subclass_of().into_class(db) { - let (class_literal, specialization) = class_type.class_literal(db); - self.extend_with_class_members(db, ty, class_literal); - self.extend_with_synthetic_members(db, ty, class_literal, specialization); - if let Type::ClassLiteral(metaclass) = class_literal.metaclass(db) { - self.extend_with_class_members(db, ty, metaclass); - } - } - } - }, - - Type::Dynamic(_) | Type::Never | Type::AlwaysTruthy | Type::AlwaysFalsy => { - self.extend_with_type(db, Type::object()); - } - - Type::TypeAlias(alias) => self.extend_with_type(db, alias.value_type(db)), - - Type::TypeVar(bound_typevar) => { - match bound_typevar.typevar(db).bound_or_constraints(db) { - None => { - self.extend_with_type(db, Type::object()); - } - Some(TypeVarBoundOrConstraints::UpperBound(bound)) => { - self.extend_with_type(db, bound); - } - Some(TypeVarBoundOrConstraints::Constraints(constraints)) => { - self.members.extend( - constraints - .elements(db) - .iter() - .map(|ty| AllMembers::of(db, *ty).members) - .reduce(|acc, members| { - acc.intersection(&members).cloned().collect() - }) - .unwrap_or_default(), - ); - } - } - } - - Type::IntLiteral(_) - | Type::BooleanLiteral(_) - | Type::StringLiteral(_) - | Type::BytesLiteral(_) - | Type::EnumLiteral(_) - | Type::LiteralString - | Type::PropertyInstance(_) - | Type::FunctionLiteral(_) - | Type::BoundMethod(_) - | Type::KnownBoundMethod(_) - | Type::WrapperDescriptor(_) - | Type::DataclassDecorator(_) - | Type::DataclassTransformer(_) - | Type::Callable(_) - | Type::ProtocolInstance(_) - | Type::SpecialForm(_) - | Type::KnownInstance(_) - | Type::BoundSuper(_) - | Type::TypeIs(_) => match ty.to_meta_type(db) { - Type::ClassLiteral(class_literal) => { - self.extend_with_class_members(db, ty, class_literal); - } - Type::SubclassOf(subclass_of) => { - if let Some(class) = subclass_of.subclass_of().into_class(db) { - self.extend_with_class_members(db, ty, class.class_literal(db).0); - } - } - Type::GenericAlias(generic_alias) => { - let class_literal = generic_alias.origin(db); - self.extend_with_class_members(db, ty, class_literal); - } - _ => {} - }, - - Type::TypedDict(_) => { - if let Type::ClassLiteral(class_literal) = ty.to_meta_type(db) { - self.extend_with_class_members(db, ty, class_literal); - } - - if let Type::ClassLiteral(class) = - KnownClass::TypedDictFallback.to_class_literal(db) - { - self.extend_with_instance_members(db, ty, class); - } - } - - Type::ModuleLiteral(literal) => { - self.extend_with_type(db, KnownClass::ModuleType.to_instance(db)); - let module = literal.module(db); - - let Some(file) = module.file(db) else { - return; - }; - - let module_scope = global_scope(db, file); - let use_def_map = use_def_map(db, module_scope); - let place_table = place_table(db, module_scope); - - for (symbol_id, _) in use_def_map.all_end_of_scope_symbol_declarations() { - let symbol_name = place_table.symbol(symbol_id).name(); - let Place::Defined(ty, _, _) = - imported_symbol(db, file, symbol_name, None).place - else { - continue; - }; - - // Filter private symbols from stubs if they appear to be internal types - let is_stub_file = file.path(db).extension() == Some("pyi"); - let is_private_symbol = match NameKind::classify(symbol_name) { - NameKind::Dunder | NameKind::Normal => false, - NameKind::Sunder => true, - }; - if is_private_symbol && is_stub_file { - match ty { - Type::NominalInstance(instance) - if matches!( - instance.known_class(db), - Some( - KnownClass::TypeVar - | KnownClass::TypeVarTuple - | KnownClass::ParamSpec - | KnownClass::UnionType - ) - ) => - { - continue; - } - Type::ClassLiteral(class) if class.is_protocol(db) => continue, - Type::KnownInstance( - KnownInstanceType::TypeVar(_) - | KnownInstanceType::TypeAliasType(_) - | KnownInstanceType::UnionType(_) - | KnownInstanceType::Literal(_) - | KnownInstanceType::Annotated(_), - ) => continue, - _ => {} - } - } - - self.members.insert(Member { - name: symbol_name.clone(), - ty, - }); - } - - self.members - .extend(literal.available_submodule_attributes(db).filter_map( - |submodule_name| { - let ty = literal.resolve_submodule(db, &submodule_name)?; - let name = submodule_name.clone(); - Some(Member { name, ty }) - }, - )); - } - } - } - - /// Add members from `class_literal` (including following its - /// parent classes). - /// - /// `ty` should be the original type that we're adding members for. - /// For example, in: - /// - /// ```text - /// class Meta(type): - /// @property - /// def meta_attr(self) -> int: - /// return 0 - /// - /// class C(metaclass=Meta): ... - /// - /// C. - /// ``` - /// - /// then `class_literal` might be `Meta`, but `ty` should be the - /// type of `C`. This ensures that the descriptor protocol is - /// correctly used (or not used) to get the type of each member of - /// `C`. - fn extend_with_class_members( - &mut self, - db: &'db dyn Db, - ty: Type<'db>, - class_literal: ClassLiteral<'db>, - ) { - for parent in class_literal - .iter_mro(db, None) - .filter_map(ClassBase::into_class) - .map(|class| class.class_literal(db).0) - { - let parent_scope = parent.body_scope(db); - for memberdef in all_declarations_and_bindings(db, parent_scope) { - let result = ty.member(db, memberdef.member.name.as_str()); - let Some(ty) = result.place.ignore_possibly_undefined() else { - continue; - }; - self.members.insert(Member { - name: memberdef.member.name, - ty, - }); - } - } - } - - fn extend_with_instance_members( - &mut self, - db: &'db dyn Db, - ty: Type<'db>, - class_literal: ClassLiteral<'db>, - ) { - for parent in class_literal - .iter_mro(db, None) - .filter_map(ClassBase::into_class) - .map(|class| class.class_literal(db).0) - { - let class_body_scope = parent.body_scope(db); - let file = class_body_scope.file(db); - let index = semantic_index(db, file); - for function_scope_id in attribute_scopes(db, class_body_scope) { - for place_expr in index.place_table(function_scope_id).members() { - let Some(name) = place_expr.as_instance_attribute() else { - continue; - }; - let result = ty.member(db, name); - let Some(ty) = result.place.ignore_possibly_undefined() else { - continue; - }; - self.members.insert(Member { - name: Name::new(name), - ty, - }); - } - } - - // This is very similar to `extend_with_class_members`, - // but uses the type of the class instance to query the - // class member. This gets us the right type for each - // member, e.g., `SomeClass.__delattr__` is not a bound - // method, but `instance_of_SomeClass.__delattr__` is. - for memberdef in all_declarations_and_bindings(db, class_body_scope) { - let result = ty.member(db, memberdef.member.name.as_str()); - let Some(ty) = result.place.ignore_possibly_undefined() else { - continue; - }; - self.members.insert(Member { - name: memberdef.member.name, - ty, - }); - } - } - } - - fn extend_with_synthetic_members( - &mut self, - db: &'db dyn Db, - ty: Type<'db>, - class_literal: ClassLiteral<'db>, - specialization: Option>, - ) { - match CodeGeneratorKind::from_class(db, class_literal, specialization) { - Some(CodeGeneratorKind::NamedTuple) => { - if ty.is_nominal_instance() { - self.extend_with_type(db, KnownClass::NamedTupleFallback.to_instance(db)); - } else { - self.extend_with_type(db, KnownClass::NamedTupleFallback.to_class_literal(db)); - } - } - Some(CodeGeneratorKind::TypedDict) => {} - Some(CodeGeneratorKind::DataclassLike(_)) => { - for attr in SYNTHETIC_DATACLASS_ATTRIBUTES { - if let Place::Defined(synthetic_member, _, _) = ty.member(db, attr).place { - self.members.insert(Member { - name: Name::from(*attr), - ty: synthetic_member, - }); - } - } - } - None => {} - } - } -} - -/// A member of a type with an optional definition. -#[derive(Clone, Debug, Eq, PartialEq, Hash)] -pub struct MemberWithDefinition<'db> { - pub member: Member<'db>, - pub definition: Option>, -} - -/// A member of a type. -/// -/// This represents a single item in (ideally) the list returned by -/// `dir(object)`. -/// -/// The equality, comparison and hashing traits implemented for -/// this type are done so by taking only the name into account. At -/// present, this is because we assume the name is enough to uniquely -/// identify each attribute on an object. This is perhaps complicated -/// by overloads, but they only get represented by one member for -/// now. Moreover, it is convenient to be able to sort collections of -/// members, and a `Type` currently (as of 2025-07-09) has no way to do -/// ordered comparisons. -#[derive(Clone, Debug)] -pub struct Member<'db> { - pub name: Name, - pub ty: Type<'db>, -} - -impl std::hash::Hash for Member<'_> { - fn hash(&self, state: &mut H) { - self.name.hash(state); - } -} - -impl Eq for Member<'_> {} - -impl<'db> PartialEq for Member<'db> { - fn eq(&self, rhs: &Member<'db>) -> bool { - self.name == rhs.name - } -} - -impl<'db> Ord for Member<'db> { - fn cmp(&self, rhs: &Member<'db>) -> Ordering { - self.name.cmp(&rhs.name) - } -} - -impl<'db> PartialOrd for Member<'db> { - fn partial_cmp(&self, rhs: &Member<'db>) -> Option { - Some(self.cmp(rhs)) - } -} - -/// List all members of a given type: anything that would be valid when accessed -/// as an attribute on an object of the given type. -pub fn all_members<'db>(db: &'db dyn Db, ty: Type<'db>) -> FxHashSet> { - AllMembers::of(db, ty).members -} - /// Get the primary definition kind for a name expression within a specific file. /// Returns the first definition kind that is reachable for this name in its scope. /// This is useful for IDE features like semantic tokens. diff --git a/crates/ty_python_semantic/src/types/list_members.rs b/crates/ty_python_semantic/src/types/list_members.rs new file mode 100644 index 0000000000..66b92d69bc --- /dev/null +++ b/crates/ty_python_semantic/src/types/list_members.rs @@ -0,0 +1,516 @@ +//! Routines and types to list all members present on a given type or in a given scope. +//! +//! These two concepts are closely related, since listing all members of a given +//! module-literal type requires listing all members in the module's scope, and +//! listing all members on a nominal-instance type or a class-literal type requires +//! listing all members in the class's body scope. + +use std::cmp::Ordering; + +use ruff_python_ast::name::Name; +use rustc_hash::FxHashSet; + +use crate::{ + Db, NameKind, + place::{Place, imported_symbol, place_from_bindings, place_from_declarations}, + semantic_index::{ + attribute_scopes, definition::Definition, global_scope, place_table, scope::ScopeId, + semantic_index, use_def_map, + }, + types::{ + ClassBase, ClassLiteral, KnownClass, KnownInstanceType, SubclassOfInner, Type, + TypeVarBoundOrConstraints, class::CodeGeneratorKind, generics::Specialization, + }, +}; + +/// Iterate over all declarations and bindings in the given scope. +pub(crate) fn all_members_of_scope<'db>( + db: &'db dyn Db, + scope_id: ScopeId<'db>, +) -> impl Iterator> + 'db { + let use_def_map = use_def_map(db, scope_id); + let table = place_table(db, scope_id); + + use_def_map + .all_end_of_scope_symbol_declarations() + .filter_map(move |(symbol_id, declarations)| { + let place_result = place_from_declarations(db, declarations); + let definition = place_result.single_declaration; + place_result + .ignore_conflicting_declarations() + .place + .ignore_possibly_undefined() + .map(|ty| { + let symbol = table.symbol(symbol_id); + let member = Member { + name: symbol.name().clone(), + ty, + }; + MemberWithDefinition { member, definition } + }) + }) + .chain(use_def_map.all_end_of_scope_symbol_bindings().filter_map( + move |(symbol_id, bindings)| { + // It's not clear to AG how to using a bindings + // iterator here to get the correct definition for + // this binding. Below, we look through all bindings + // with a definition and only take one if there is + // exactly one. I don't think this can be wrong, but + // it's probably omitting definitions in some cases. + let mut definition = None; + for binding in bindings.clone() { + if let Some(def) = binding.binding.definition() { + if definition.is_some() { + definition = None; + break; + } + definition = Some(def); + } + } + place_from_bindings(db, bindings) + .ignore_possibly_undefined() + .map(|ty| { + let symbol = table.symbol(symbol_id); + let member = Member { + name: symbol.name().clone(), + ty, + }; + MemberWithDefinition { member, definition } + }) + }, + )) +} + +// `__init__`, `__repr__`, `__eq__`, `__ne__` and `__hash__` are always included via `object`, +// so we don't need to list them here. +const SYNTHETIC_DATACLASS_ATTRIBUTES: &[&str] = &[ + "__lt__", + "__le__", + "__gt__", + "__ge__", + "__replace__", + "__setattr__", + "__delattr__", + "__slots__", + "__weakref__", + "__match_args__", + "__dataclass_fields__", + "__dataclass_params__", +]; + +struct AllMembers<'db> { + members: FxHashSet>, +} + +impl<'db> AllMembers<'db> { + fn of(db: &'db dyn Db, ty: Type<'db>) -> Self { + let mut all_members = Self { + members: FxHashSet::default(), + }; + all_members.extend_with_type(db, ty); + all_members + } + + fn extend_with_type(&mut self, db: &'db dyn Db, ty: Type<'db>) { + match ty { + Type::Union(union) => self.members.extend( + union + .elements(db) + .iter() + .map(|ty| AllMembers::of(db, *ty).members) + .reduce(|acc, members| acc.intersection(&members).cloned().collect()) + .unwrap_or_default(), + ), + + Type::Intersection(intersection) => self.members.extend( + intersection + .positive(db) + .iter() + .map(|ty| AllMembers::of(db, *ty).members) + .reduce(|acc, members| acc.union(&members).cloned().collect()) + .unwrap_or_default(), + ), + + Type::NominalInstance(instance) => { + let (class_literal, specialization) = instance.class(db).class_literal(db); + self.extend_with_instance_members(db, ty, class_literal); + self.extend_with_synthetic_members(db, ty, class_literal, specialization); + } + + Type::NewTypeInstance(newtype) => { + self.extend_with_type(db, Type::instance(db, newtype.base_class_type(db))); + } + + Type::ClassLiteral(class_literal) if class_literal.is_typed_dict(db) => { + self.extend_with_type(db, KnownClass::TypedDictFallback.to_class_literal(db)); + } + + Type::GenericAlias(generic_alias) if generic_alias.is_typed_dict(db) => { + self.extend_with_type(db, KnownClass::TypedDictFallback.to_class_literal(db)); + } + + Type::SubclassOf(subclass_of_type) if subclass_of_type.is_typed_dict(db) => { + self.extend_with_type(db, KnownClass::TypedDictFallback.to_class_literal(db)); + } + + Type::ClassLiteral(class_literal) => { + self.extend_with_class_members(db, ty, class_literal); + self.extend_with_synthetic_members(db, ty, class_literal, None); + if let Type::ClassLiteral(metaclass) = class_literal.metaclass(db) { + self.extend_with_class_members(db, ty, metaclass); + } + } + + Type::GenericAlias(generic_alias) => { + let class_literal = generic_alias.origin(db); + self.extend_with_class_members(db, ty, class_literal); + self.extend_with_synthetic_members(db, ty, class_literal, None); + if let Type::ClassLiteral(metaclass) = class_literal.metaclass(db) { + self.extend_with_class_members(db, ty, metaclass); + } + } + + Type::SubclassOf(subclass_of_type) => match subclass_of_type.subclass_of() { + SubclassOfInner::Dynamic(_) => { + self.extend_with_type(db, KnownClass::Type.to_instance(db)); + } + _ => { + if let Some(class_type) = subclass_of_type.subclass_of().into_class(db) { + let (class_literal, specialization) = class_type.class_literal(db); + self.extend_with_class_members(db, ty, class_literal); + self.extend_with_synthetic_members(db, ty, class_literal, specialization); + if let Type::ClassLiteral(metaclass) = class_literal.metaclass(db) { + self.extend_with_class_members(db, ty, metaclass); + } + } + } + }, + + Type::Dynamic(_) | Type::Never | Type::AlwaysTruthy | Type::AlwaysFalsy => { + self.extend_with_type(db, Type::object()); + } + + Type::TypeAlias(alias) => self.extend_with_type(db, alias.value_type(db)), + + Type::TypeVar(bound_typevar) => { + match bound_typevar.typevar(db).bound_or_constraints(db) { + None => { + self.extend_with_type(db, Type::object()); + } + Some(TypeVarBoundOrConstraints::UpperBound(bound)) => { + self.extend_with_type(db, bound); + } + Some(TypeVarBoundOrConstraints::Constraints(constraints)) => { + self.members.extend( + constraints + .elements(db) + .iter() + .map(|ty| AllMembers::of(db, *ty).members) + .reduce(|acc, members| { + acc.intersection(&members).cloned().collect() + }) + .unwrap_or_default(), + ); + } + } + } + + Type::IntLiteral(_) + | Type::BooleanLiteral(_) + | Type::StringLiteral(_) + | Type::BytesLiteral(_) + | Type::EnumLiteral(_) + | Type::LiteralString + | Type::PropertyInstance(_) + | Type::FunctionLiteral(_) + | Type::BoundMethod(_) + | Type::KnownBoundMethod(_) + | Type::WrapperDescriptor(_) + | Type::DataclassDecorator(_) + | Type::DataclassTransformer(_) + | Type::Callable(_) + | Type::ProtocolInstance(_) + | Type::SpecialForm(_) + | Type::KnownInstance(_) + | Type::BoundSuper(_) + | Type::TypeIs(_) => match ty.to_meta_type(db) { + Type::ClassLiteral(class_literal) => { + self.extend_with_class_members(db, ty, class_literal); + } + Type::SubclassOf(subclass_of) => { + if let Some(class) = subclass_of.subclass_of().into_class(db) { + self.extend_with_class_members(db, ty, class.class_literal(db).0); + } + } + Type::GenericAlias(generic_alias) => { + let class_literal = generic_alias.origin(db); + self.extend_with_class_members(db, ty, class_literal); + } + _ => {} + }, + + Type::TypedDict(_) => { + if let Type::ClassLiteral(class_literal) = ty.to_meta_type(db) { + self.extend_with_class_members(db, ty, class_literal); + } + + if let Type::ClassLiteral(class) = + KnownClass::TypedDictFallback.to_class_literal(db) + { + self.extend_with_instance_members(db, ty, class); + } + } + + Type::ModuleLiteral(literal) => { + self.extend_with_type(db, KnownClass::ModuleType.to_instance(db)); + let module = literal.module(db); + + let Some(file) = module.file(db) else { + return; + }; + + let module_scope = global_scope(db, file); + let use_def_map = use_def_map(db, module_scope); + let place_table = place_table(db, module_scope); + + for (symbol_id, _) in use_def_map.all_end_of_scope_symbol_declarations() { + let symbol_name = place_table.symbol(symbol_id).name(); + let Place::Defined(ty, _, _) = + imported_symbol(db, file, symbol_name, None).place + else { + continue; + }; + + // Filter private symbols from stubs if they appear to be internal types + let is_stub_file = file.path(db).extension() == Some("pyi"); + let is_private_symbol = match NameKind::classify(symbol_name) { + NameKind::Dunder | NameKind::Normal => false, + NameKind::Sunder => true, + }; + if is_private_symbol && is_stub_file { + match ty { + Type::NominalInstance(instance) + if matches!( + instance.known_class(db), + Some( + KnownClass::TypeVar + | KnownClass::TypeVarTuple + | KnownClass::ParamSpec + | KnownClass::UnionType + ) + ) => + { + continue; + } + Type::ClassLiteral(class) if class.is_protocol(db) => continue, + Type::KnownInstance( + KnownInstanceType::TypeVar(_) + | KnownInstanceType::TypeAliasType(_) + | KnownInstanceType::UnionType(_) + | KnownInstanceType::Literal(_) + | KnownInstanceType::Annotated(_), + ) => continue, + _ => {} + } + } + + self.members.insert(Member { + name: symbol_name.clone(), + ty, + }); + } + + self.members + .extend(literal.available_submodule_attributes(db).filter_map( + |submodule_name| { + let ty = literal.resolve_submodule(db, &submodule_name)?; + let name = submodule_name.clone(); + Some(Member { name, ty }) + }, + )); + } + } + } + + /// Add members from `class_literal` (including following its + /// parent classes). + /// + /// `ty` should be the original type that we're adding members for. + /// For example, in: + /// + /// ```text + /// class Meta(type): + /// @property + /// def meta_attr(self) -> int: + /// return 0 + /// + /// class C(metaclass=Meta): ... + /// + /// C. + /// ``` + /// + /// then `class_literal` might be `Meta`, but `ty` should be the + /// type of `C`. This ensures that the descriptor protocol is + /// correctly used (or not used) to get the type of each member of + /// `C`. + fn extend_with_class_members( + &mut self, + db: &'db dyn Db, + ty: Type<'db>, + class_literal: ClassLiteral<'db>, + ) { + for parent in class_literal + .iter_mro(db, None) + .filter_map(ClassBase::into_class) + .map(|class| class.class_literal(db).0) + { + let parent_scope = parent.body_scope(db); + for memberdef in all_members_of_scope(db, parent_scope) { + let result = ty.member(db, memberdef.member.name.as_str()); + let Some(ty) = result.place.ignore_possibly_undefined() else { + continue; + }; + self.members.insert(Member { + name: memberdef.member.name, + ty, + }); + } + } + } + + fn extend_with_instance_members( + &mut self, + db: &'db dyn Db, + ty: Type<'db>, + class_literal: ClassLiteral<'db>, + ) { + for parent in class_literal + .iter_mro(db, None) + .filter_map(ClassBase::into_class) + .map(|class| class.class_literal(db).0) + { + let class_body_scope = parent.body_scope(db); + let file = class_body_scope.file(db); + let index = semantic_index(db, file); + for function_scope_id in attribute_scopes(db, class_body_scope) { + for place_expr in index.place_table(function_scope_id).members() { + let Some(name) = place_expr.as_instance_attribute() else { + continue; + }; + let result = ty.member(db, name); + let Some(ty) = result.place.ignore_possibly_undefined() else { + continue; + }; + self.members.insert(Member { + name: Name::new(name), + ty, + }); + } + } + + // This is very similar to `extend_with_class_members`, + // but uses the type of the class instance to query the + // class member. This gets us the right type for each + // member, e.g., `SomeClass.__delattr__` is not a bound + // method, but `instance_of_SomeClass.__delattr__` is. + for memberdef in all_members_of_scope(db, class_body_scope) { + let result = ty.member(db, memberdef.member.name.as_str()); + let Some(ty) = result.place.ignore_possibly_undefined() else { + continue; + }; + self.members.insert(Member { + name: memberdef.member.name, + ty, + }); + } + } + } + + fn extend_with_synthetic_members( + &mut self, + db: &'db dyn Db, + ty: Type<'db>, + class_literal: ClassLiteral<'db>, + specialization: Option>, + ) { + match CodeGeneratorKind::from_class(db, class_literal, specialization) { + Some(CodeGeneratorKind::NamedTuple) => { + if ty.is_nominal_instance() { + self.extend_with_type(db, KnownClass::NamedTupleFallback.to_instance(db)); + } else { + self.extend_with_type(db, KnownClass::NamedTupleFallback.to_class_literal(db)); + } + } + Some(CodeGeneratorKind::TypedDict) => {} + Some(CodeGeneratorKind::DataclassLike(_)) => { + for attr in SYNTHETIC_DATACLASS_ATTRIBUTES { + if let Place::Defined(synthetic_member, _, _) = ty.member(db, attr).place { + self.members.insert(Member { + name: Name::from(*attr), + ty: synthetic_member, + }); + } + } + } + None => {} + } + } +} + +/// A member of a type or scope, with an optional definition. +#[derive(Clone, Debug, Eq, PartialEq, Hash)] +pub struct MemberWithDefinition<'db> { + pub member: Member<'db>, + pub definition: Option>, +} + +/// A member of a type or scope. +/// +/// In the context of the [`all_members`] routine, this represents +/// a single item in (ideally) the list returned by `dir(object)`. +/// +/// The equality, comparison and hashing traits implemented for +/// this type are done so by taking only the name into account. At +/// present, this is because we assume the name is enough to uniquely +/// identify each attribute on an object. This is perhaps complicated +/// by overloads, but they only get represented by one member for +/// now. Moreover, it is convenient to be able to sort collections of +/// members, and a [`Type`] currently (as of 2025-07-09) has no way to do +/// ordered comparisons. +#[derive(Clone, Debug)] +pub struct Member<'db> { + pub name: Name, + pub ty: Type<'db>, +} + +impl std::hash::Hash for Member<'_> { + fn hash(&self, state: &mut H) { + self.name.hash(state); + } +} + +impl Eq for Member<'_> {} + +impl<'db> PartialEq for Member<'db> { + fn eq(&self, rhs: &Member<'db>) -> bool { + self.name == rhs.name + } +} + +impl<'db> Ord for Member<'db> { + fn cmp(&self, rhs: &Member<'db>) -> Ordering { + self.name.cmp(&rhs.name) + } +} + +impl<'db> PartialOrd for Member<'db> { + fn partial_cmp(&self, rhs: &Member<'db>) -> Option { + Some(self.cmp(rhs)) + } +} + +/// List all members of a given type: anything that would be valid when accessed +/// as an attribute on an object of the given type. +pub fn all_members<'db>(db: &'db dyn Db, ty: Type<'db>) -> FxHashSet> { + AllMembers::of(db, ty).members +} diff --git a/crates/ty_python_semantic/src/types/overrides.rs b/crates/ty_python_semantic/src/types/overrides.rs index a56f04d1db..683f5549d1 100644 --- a/crates/ty_python_semantic/src/types/overrides.rs +++ b/crates/ty_python_semantic/src/types/overrides.rs @@ -25,7 +25,7 @@ use crate::{ report_overridden_final_method, }, function::{FunctionDecorators, FunctionType, KnownFunction}, - ide_support::{MemberWithDefinition, all_declarations_and_bindings}, + list_members::{MemberWithDefinition, all_members_of_scope}, }, }; @@ -53,8 +53,7 @@ pub(super) fn check_class<'db>(context: &InferContext<'db, '_>, class: ClassLite } let class_specialized = class.identity_specialization(db); - let own_class_members: FxHashSet<_> = - all_declarations_and_bindings(db, class.body_scope(db)).collect(); + let own_class_members: FxHashSet<_> = all_members_of_scope(db, class.body_scope(db)).collect(); for member in own_class_members { check_class_declaration(context, configuration, class_specialized, &member); From 05d053376b73b911b74dcbad647d2ae6a988b505 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 2 Dec 2025 14:48:01 +0000 Subject: [PATCH 64/67] Delete `my-script.py` (#21751) --- my-script.py | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 my-script.py diff --git a/my-script.py b/my-script.py deleted file mode 100644 index 0663824d37..0000000000 --- a/my-script.py +++ /dev/null @@ -1,3 +0,0 @@ -from __future__ import annotations - -print("hello") From 0d2792517d19841804b20dcded4fe805e4c8931e Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Tue, 2 Dec 2025 13:05:26 -0500 Subject: [PATCH 65/67] Use our org-wide Renovate preset (#21759) --- .github/renovate.json5 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/renovate.json5 b/.github/renovate.json5 index eb15fa0792..449ea573f0 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -2,12 +2,11 @@ $schema: "https://docs.renovatebot.com/renovate-schema.json", dependencyDashboard: true, suppressNotifications: ["prEditedNotification"], - extends: ["config:recommended"], + extends: ["github>astral-sh/renovate-config"], labels: ["internal"], schedule: ["before 4am on Monday"], semanticCommits: "disabled", separateMajorMinor: false, - prHourlyLimit: 10, enabledManagers: ["github-actions", "pre-commit", "cargo", "pep621", "pip_requirements", "npm"], cargo: { // See https://docs.renovatebot.com/configuration-options/#rangestrategy @@ -16,7 +15,7 @@ pep621: { // The default for this package manager is to only search for `pyproject.toml` files // found at the repository root: https://docs.renovatebot.com/modules/manager/pep621/#file-matching - fileMatch: ["^(python|scripts)/.*pyproject\\.toml$"], + managerFilePatterns: ["^(python|scripts)/.*pyproject\\.toml$"], }, pip_requirements: { // The default for this package manager is to run on all requirements.txt files: @@ -34,7 +33,7 @@ npm: { // The default for this package manager is to only search for `package.json` files // found at the repository root: https://docs.renovatebot.com/modules/manager/npm/#file-matching - fileMatch: ["^playground/.*package\\.json$"], + managerFilePatterns: ["^playground/.*package\\.json$"], }, "pre-commit": { enabled: true, From 508c0a086181a265ce3f9012b50b6fe513b91776 Mon Sep 17 00:00:00 2001 From: Douglas Creager Date: Tue, 2 Dec 2025 13:15:09 -0500 Subject: [PATCH 66/67] [ty] Don't confuse multiple occurrences of `typing.Self` when binding bound methods (#21754) In the following example, there are two occurrences of `typing.Self`, one for `Foo.foo` and one for `Bar.bar`: ```py from typing import Self, reveal_type class Foo[T]: def foo(self: Self) -> T: raise NotImplementedError class Bar: def bar(self: Self, x: Foo[Self]): # SHOULD BE: bound method Foo[Self@bar].foo() -> Self@bar # revealed: bound method Foo[Self@bar].foo() -> Foo[Self@bar] reveal_type(x.foo) def f[U: Bar](x: Foo[U]): # revealed: bound method Foo[U@f].foo() -> U@f reveal_type(x.foo) ``` When accessing a bound method, we replace any occurrences of `Self` with the bound `self` type. We were doing this correctly for the second reveal. We would first apply the specialization, getting `(self: Self@foo) -> U@F` as the signature of `x.foo`. We would then bind the `self` parameter, substituting `Self@foo` with `Foo[U@F]` as part of that. The return type was already specialized to `U@F`, so that substitution had no further affect on the type that we revealed. In the first reveal, we would follow the same process, but we confused the two occurrences of `Self`. We would first apply the specialization, getting `(self: Self@foo) -> Self@bar` as the method signature. We would then try to bind the `self` parameter, substituting `Self@foo` with `Foo[Self@bar]`. However, because we didn't distinguish the two separate `Self`s, and applied the substitution to the return type as well as to the `self` parameter. The fix is to track which particular `Self` we're trying to substitute when applying the type mapping. Fixes https://github.com/astral-sh/ty/issues/1713 --- .../resources/mdtest/annotations/self.md | 26 +++++++++++++ crates/ty_python_semantic/src/types.rs | 31 +++++++++------ .../src/types/signatures.rs | 38 +++++++++---------- 3 files changed, 64 insertions(+), 31 deletions(-) diff --git a/crates/ty_python_semantic/resources/mdtest/annotations/self.md b/crates/ty_python_semantic/resources/mdtest/annotations/self.md index 4be59a5a63..57690b3dc3 100644 --- a/crates/ty_python_semantic/resources/mdtest/annotations/self.md +++ b/crates/ty_python_semantic/resources/mdtest/annotations/self.md @@ -232,6 +232,32 @@ class C: reveal_type(not_a_method) # revealed: def not_a_method(self) -> Unknown ``` +## Different occurrences of `Self` represent different types + +Here, both `Foo.foo` and `Bar.bar` use `Self`. When accessing a bound method, we replace any +occurrences of `Self` with the bound `self` type. In this example, when we access `x.foo`, we only +want to substitute the occurrences of `Self` in `Foo.foo` — that is, occurrences of `Self@foo`. The +fact that `x` is an instance of `Foo[Self@bar]` (a completely different `Self` type) should not +affect that subtitution. If we blindly substitute all occurrences of `Self`, we would get +`Foo[Self@bar]` as the return type of the bound method. + +```py +from typing import Self + +class Foo[T]: + def foo(self: Self) -> T: + raise NotImplementedError + +class Bar: + def bar(self: Self, x: Foo[Self]): + # revealed: bound method Foo[Self@bar].foo() -> Self@bar + reveal_type(x.foo) + +def f[U: Bar](x: Foo[U]): + # revealed: bound method Foo[U@f].foo() -> U@f + reveal_type(x.foo) +``` + ## typing_extensions ```toml diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 494f4efa83..7c65a4715e 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -7550,10 +7550,9 @@ impl<'db> Type<'db> { // If we are binding `typing.Self`, and this type is what we are binding `Self` to, return // early. This is not just an optimization, it also prevents us from infinitely expanding // the type, if it's something that can contain a `Self` reference. - if let TypeMapping::BindSelf(self_type) = type_mapping - && self == *self_type - { - return self; + match type_mapping { + TypeMapping::BindSelf { self_type, .. } if self == *self_type => return self, + _ => {} } match self { @@ -7568,7 +7567,7 @@ impl<'db> Type<'db> { TypeMapping::Specialization(_) | TypeMapping::PartialSpecialization(_) | TypeMapping::PromoteLiterals(_) | - TypeMapping::BindSelf(_) | + TypeMapping::BindSelf { .. } | TypeMapping::ReplaceSelf { .. } | TypeMapping::Materialize(_) | TypeMapping::ReplaceParameterDefaults | @@ -7744,7 +7743,7 @@ impl<'db> Type<'db> { TypeMapping::Specialization(_) | TypeMapping::PartialSpecialization(_) | TypeMapping::BindLegacyTypevars(_) | - TypeMapping::BindSelf(_) | + TypeMapping::BindSelf { .. } | TypeMapping::ReplaceSelf { .. } | TypeMapping::Materialize(_) | TypeMapping::ReplaceParameterDefaults | @@ -7757,7 +7756,7 @@ impl<'db> Type<'db> { TypeMapping::Specialization(_) | TypeMapping::PartialSpecialization(_) | TypeMapping::BindLegacyTypevars(_) | - TypeMapping::BindSelf(_) | + TypeMapping::BindSelf { .. } | TypeMapping::ReplaceSelf { .. } | TypeMapping::PromoteLiterals(_) | TypeMapping::ReplaceParameterDefaults | @@ -8421,7 +8420,10 @@ pub enum TypeMapping<'a, 'db> { /// being used in. BindLegacyTypevars(BindingContext<'db>), /// Binds any `typing.Self` typevar with a particular `self` class. - BindSelf(Type<'db>), + BindSelf { + self_type: Type<'db>, + binding_context: Option>, + }, /// Replaces occurrences of `typing.Self` with a new `Self` type variable with the given upper bound. ReplaceSelf { new_upper_bound: Type<'db> }, /// Create the top or bottom materialization of a type. @@ -8449,7 +8451,7 @@ impl<'db> TypeMapping<'_, 'db> { | TypeMapping::Materialize(_) | TypeMapping::ReplaceParameterDefaults | TypeMapping::EagerExpansion => context, - TypeMapping::BindSelf(_) => GenericContext::from_typevar_instances( + TypeMapping::BindSelf { .. } => GenericContext::from_typevar_instances( db, context .variables(db) @@ -8482,7 +8484,7 @@ impl<'db> TypeMapping<'_, 'db> { TypeMapping::Specialization(_) | TypeMapping::PartialSpecialization(_) | TypeMapping::BindLegacyTypevars(_) - | TypeMapping::BindSelf(_) + | TypeMapping::BindSelf { .. } | TypeMapping::ReplaceSelf { .. } | TypeMapping::ReplaceParameterDefaults | TypeMapping::EagerExpansion => self.clone(), @@ -9837,8 +9839,13 @@ impl<'db> BoundTypeVarInstance<'db> { TypeMapping::PartialSpecialization(partial) => { partial.get(db, self).unwrap_or(Type::TypeVar(self)) } - TypeMapping::BindSelf(self_type) => { - if self.typevar(db).is_self(db) { + TypeMapping::BindSelf { + self_type, + binding_context, + } => { + if self.typevar(db).is_self(db) + && binding_context.is_none_or(|context| self.binding_context(db) == context) + { *self_type } else { Type::TypeVar(self) diff --git a/crates/ty_python_semantic/src/types/signatures.rs b/crates/ty_python_semantic/src/types/signatures.rs index 738fcfb971..d091b8a53f 100644 --- a/crates/ty_python_semantic/src/types/signatures.rs +++ b/crates/ty_python_semantic/src/types/signatures.rs @@ -29,9 +29,10 @@ use crate::types::generics::{ }; use crate::types::infer::nearest_enclosing_class; use crate::types::{ - ApplyTypeMappingVisitor, BoundTypeVarInstance, ClassLiteral, FindLegacyTypeVarsVisitor, - HasRelationToVisitor, IsDisjointVisitor, IsEquivalentVisitor, KnownClass, MaterializationKind, - NormalizedVisitor, TypeContext, TypeMapping, TypeRelation, VarianceInferable, todo_type, + ApplyTypeMappingVisitor, BindingContext, BoundTypeVarInstance, ClassLiteral, + FindLegacyTypeVarsVisitor, HasRelationToVisitor, IsDisjointVisitor, IsEquivalentVisitor, + KnownClass, MaterializationKind, NormalizedVisitor, TypeContext, TypeMapping, TypeRelation, + VarianceInferable, todo_type, }; use crate::{Db, FxOrderSet}; use ruff_python_ast::{self as ast, name::Name}; @@ -667,19 +668,18 @@ impl<'db> Signature<'db> { let mut parameters = Parameters::new(db, parameters); let mut return_ty = self.return_ty; if let Some(self_type) = self_type { + let self_mapping = TypeMapping::BindSelf { + self_type, + binding_context: self.definition.map(BindingContext::Definition), + }; parameters = parameters.apply_type_mapping_impl( db, - &TypeMapping::BindSelf(self_type), + &self_mapping, TypeContext::default(), &ApplyTypeMappingVisitor::default(), ); - return_ty = return_ty.map(|ty| { - ty.apply_type_mapping( - db, - &TypeMapping::BindSelf(self_type), - TypeContext::default(), - ) - }); + return_ty = return_ty + .map(|ty| ty.apply_type_mapping(db, &self_mapping, TypeContext::default())); } Self { generic_context: self.generic_context, @@ -690,19 +690,19 @@ impl<'db> Signature<'db> { } pub(crate) fn apply_self(&self, db: &'db dyn Db, self_type: Type<'db>) -> Self { + let self_mapping = TypeMapping::BindSelf { + self_type, + binding_context: self.definition.map(BindingContext::Definition), + }; let parameters = self.parameters.apply_type_mapping_impl( db, - &TypeMapping::BindSelf(self_type), + &self_mapping, TypeContext::default(), &ApplyTypeMappingVisitor::default(), ); - let return_ty = self.return_ty.map(|ty| { - ty.apply_type_mapping( - db, - &TypeMapping::BindSelf(self_type), - TypeContext::default(), - ) - }); + let return_ty = self + .return_ty + .map(|ty| ty.apply_type_mapping(db, &self_mapping, TypeContext::default())); Self { generic_context: self.generic_context, definition: self.definition, From 515de2d062c4d2fe7c69ca928d4456cb82fa33f8 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Tue, 2 Dec 2025 20:10:46 +0100 Subject: [PATCH 67/67] Move `Token`, `TokenKind` and `Tokens` to `ruff-python-ast` (#21760) --- crates/ruff_benchmark/benches/lexer.rs | 3 +- crates/ruff_linter/src/checkers/ast/mod.rs | 3 +- .../ruff_linter/src/checkers/logical_lines.rs | 2 +- crates/ruff_linter/src/checkers/tokens.rs | 2 +- crates/ruff_linter/src/directives.rs | 2 +- crates/ruff_linter/src/doc_lines.rs | 2 +- crates/ruff_linter/src/importer/mod.rs | 3 +- .../flake8_commas/rules/trailing_commas.rs | 2 +- .../rules/unnecessary_generator_list.rs | 2 +- .../rules/unnecessary_generator_set.rs | 2 +- .../unnecessary_list_comprehension_set.rs | 2 +- .../rules/implicit.rs | 2 +- .../flake8_pie/rules/unnecessary_spread.rs | 2 +- .../src/rules/flake8_return/rules/function.rs | 2 +- .../ruff_linter/src/rules/isort/annotate.rs | 2 +- crates/ruff_linter/src/rules/isort/helpers.rs | 2 +- crates/ruff_linter/src/rules/isort/mod.rs | 2 +- .../src/rules/isort/rules/organize_imports.rs | 2 +- .../src/rules/pycodestyle/helpers.rs | 2 +- .../rules/pycodestyle/rules/blank_lines.rs | 6 +- .../pycodestyle/rules/compound_statements.rs | 2 +- .../logical_lines/extraneous_whitespace.rs | 2 +- .../rules/logical_lines/indentation.rs | 2 +- .../rules/logical_lines/missing_whitespace.rs | 2 +- .../missing_whitespace_after_keyword.rs | 2 +- .../missing_whitespace_around_operator.rs | 2 +- .../pycodestyle/rules/logical_lines/mod.rs | 2 +- .../logical_lines/redundant_backslash.rs | 2 +- .../logical_lines/space_around_operator.rs | 2 +- ...hitespace_around_named_parameter_equals.rs | 2 +- .../whitespace_before_comment.rs | 2 +- .../whitespace_before_parameters.rs | 2 +- .../rules/too_many_newlines_at_end_of_file.rs | 2 +- .../rules/invalid_literal_comparisons.rs | 2 +- .../rules/pyflakes/rules/unused_variable.rs | 2 +- .../pylint/rules/invalid_string_characters.rs | 2 +- .../ruff_linter/src/rules/pyupgrade/fixes.rs | 2 +- .../pyupgrade/rules/deprecated_import.rs | 2 +- .../pyupgrade/rules/extraneous_parentheses.rs | 2 +- .../src/rules/pyupgrade/rules/f_strings.rs | 2 +- .../rules/printf_string_formatting.rs | 2 +- .../pyupgrade/rules/quoted_annotation.rs | 2 +- .../pyupgrade/rules/redundant_open_modes.rs | 2 +- .../rules/unnecessary_encode_utf8.rs | 2 +- .../explicit_f_string_type_conversion.rs | 2 +- .../src/rules/ruff/rules/needless_else.rs | 2 +- .../src/rules/ruff/rules/sequence_sorting.rs | 2 +- .../src/rules/ruff/rules/starmap_zip.rs | 2 +- crates/ruff_python_ast/src/lib.rs | 1 + crates/ruff_python_ast/src/token.rs | 851 ++++++++++++++++++ crates/ruff_python_ast/src/token/tokens.rs | 520 +++++++++++ crates/ruff_python_codegen/src/stylist.rs | 2 +- crates/ruff_python_formatter/src/context.rs | 2 +- crates/ruff_python_formatter/src/verbatim.rs | 6 +- crates/ruff_python_importer/Cargo.toml | 3 +- crates/ruff_python_importer/src/insertion.rs | 4 +- crates/ruff_python_index/Cargo.toml | 2 +- crates/ruff_python_index/src/indexer.rs | 2 +- .../src/interpolated_string_ranges.rs | 2 +- .../ruff_python_index/src/multiline_ranges.rs | 2 +- crates/ruff_python_parser/src/error.rs | 3 +- crates/ruff_python_parser/src/lexer.rs | 3 +- crates/ruff_python_parser/src/lib.rs | 553 +----------- .../src/parser/expression.rs | 3 +- .../ruff_python_parser/src/parser/helpers.rs | 3 +- crates/ruff_python_parser/src/parser/mod.rs | 3 +- .../ruff_python_parser/src/parser/pattern.rs | 3 +- .../src/parser/statement.rs | 3 +- crates/ruff_python_parser/src/string.rs | 6 +- crates/ruff_python_parser/src/token.rs | 846 +---------------- crates/ruff_python_parser/src/token_set.rs | 4 +- crates/ruff_python_parser/src/token_source.rs | 3 +- crates/ruff_python_parser/tests/fixtures.rs | 3 +- crates/ty_ide/Cargo.toml | 3 +- crates/ty_ide/src/completion.rs | 5 +- crates/ty_ide/src/goto.rs | 2 +- crates/ty_ide/src/importer.rs | 8 +- crates/ty_ide/src/references.rs | 2 +- crates/ty_ide/src/signature_help.rs | 18 +- crates/ty_python_semantic/src/suppression.rs | 2 +- 80 files changed, 1484 insertions(+), 1492 deletions(-) create mode 100644 crates/ruff_python_ast/src/token.rs create mode 100644 crates/ruff_python_ast/src/token/tokens.rs diff --git a/crates/ruff_benchmark/benches/lexer.rs b/crates/ruff_benchmark/benches/lexer.rs index 968ac74b14..3b1a4dafde 100644 --- a/crates/ruff_benchmark/benches/lexer.rs +++ b/crates/ruff_benchmark/benches/lexer.rs @@ -6,7 +6,8 @@ use criterion::{ use ruff_benchmark::{ LARGE_DATASET, NUMPY_CTYPESLIB, NUMPY_GLOBALS, PYDANTIC_TYPES, TestCase, UNICODE_PYPINYIN, }; -use ruff_python_parser::{Mode, TokenKind, lexer}; +use ruff_python_ast::token::TokenKind; +use ruff_python_parser::{Mode, lexer}; #[cfg(target_os = "windows")] #[global_allocator] diff --git a/crates/ruff_linter/src/checkers/ast/mod.rs b/crates/ruff_linter/src/checkers/ast/mod.rs index 5f7f459ba9..8c360448a4 100644 --- a/crates/ruff_linter/src/checkers/ast/mod.rs +++ b/crates/ruff_linter/src/checkers/ast/mod.rs @@ -35,6 +35,7 @@ use ruff_python_ast::helpers::{collect_import_from_member, is_docstring_stmt, to use ruff_python_ast::identifier::Identifier; use ruff_python_ast::name::QualifiedName; use ruff_python_ast::str::Quote; +use ruff_python_ast::token::Tokens; use ruff_python_ast::visitor::{Visitor, walk_except_handler, walk_pattern}; use ruff_python_ast::{ self as ast, AnyParameterRef, ArgOrKeyword, Comprehension, ElifElseClause, ExceptHandler, Expr, @@ -48,7 +49,7 @@ use ruff_python_parser::semantic_errors::{ SemanticSyntaxChecker, SemanticSyntaxContext, SemanticSyntaxError, SemanticSyntaxErrorKind, }; use ruff_python_parser::typing::{AnnotationKind, ParsedAnnotation, parse_type_annotation}; -use ruff_python_parser::{ParseError, Parsed, Tokens}; +use ruff_python_parser::{ParseError, Parsed}; use ruff_python_semantic::all::{DunderAllDefinition, DunderAllFlags}; use ruff_python_semantic::analyze::{imports, typing}; use ruff_python_semantic::{ diff --git a/crates/ruff_linter/src/checkers/logical_lines.rs b/crates/ruff_linter/src/checkers/logical_lines.rs index 5c60a3171a..695fd294aa 100644 --- a/crates/ruff_linter/src/checkers/logical_lines.rs +++ b/crates/ruff_linter/src/checkers/logical_lines.rs @@ -1,6 +1,6 @@ +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_codegen::Stylist; use ruff_python_index::Indexer; -use ruff_python_parser::{TokenKind, Tokens}; use ruff_source_file::LineRanges; use ruff_text_size::{Ranged, TextRange}; diff --git a/crates/ruff_linter/src/checkers/tokens.rs b/crates/ruff_linter/src/checkers/tokens.rs index ce54050f9d..7154c3e16b 100644 --- a/crates/ruff_linter/src/checkers/tokens.rs +++ b/crates/ruff_linter/src/checkers/tokens.rs @@ -4,9 +4,9 @@ use std::path::Path; use ruff_notebook::CellOffsets; use ruff_python_ast::PySourceType; +use ruff_python_ast::token::Tokens; use ruff_python_codegen::Stylist; use ruff_python_index::Indexer; -use ruff_python_parser::Tokens; use crate::Locator; use crate::directives::TodoComment; diff --git a/crates/ruff_linter/src/directives.rs b/crates/ruff_linter/src/directives.rs index a642d57271..ea63f6edfd 100644 --- a/crates/ruff_linter/src/directives.rs +++ b/crates/ruff_linter/src/directives.rs @@ -5,8 +5,8 @@ use std::str::FromStr; use bitflags::bitflags; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_index::Indexer; -use ruff_python_parser::{TokenKind, Tokens}; use ruff_python_trivia::CommentRanges; use ruff_source_file::LineRanges; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; diff --git a/crates/ruff_linter/src/doc_lines.rs b/crates/ruff_linter/src/doc_lines.rs index 7d7367beba..394b50ee70 100644 --- a/crates/ruff_linter/src/doc_lines.rs +++ b/crates/ruff_linter/src/doc_lines.rs @@ -5,8 +5,8 @@ use std::iter::FusedIterator; use std::slice::Iter; use ruff_python_ast::statement_visitor::{StatementVisitor, walk_stmt}; +use ruff_python_ast::token::{Token, TokenKind, Tokens}; use ruff_python_ast::{self as ast, Stmt, Suite}; -use ruff_python_parser::{Token, TokenKind, Tokens}; use ruff_source_file::UniversalNewlineIterator; use ruff_text_size::{Ranged, TextSize}; diff --git a/crates/ruff_linter/src/importer/mod.rs b/crates/ruff_linter/src/importer/mod.rs index de77c384fc..4ffa03d677 100644 --- a/crates/ruff_linter/src/importer/mod.rs +++ b/crates/ruff_linter/src/importer/mod.rs @@ -9,10 +9,11 @@ use anyhow::Result; use libcst_native as cst; use ruff_diagnostics::Edit; +use ruff_python_ast::token::Tokens; use ruff_python_ast::{self as ast, Expr, ModModule, Stmt}; use ruff_python_codegen::Stylist; use ruff_python_importer::Insertion; -use ruff_python_parser::{Parsed, Tokens}; +use ruff_python_parser::Parsed; use ruff_python_semantic::{ ImportedName, MemberNameImport, ModuleNameImport, NameImport, SemanticModel, }; diff --git a/crates/ruff_linter/src/rules/flake8_commas/rules/trailing_commas.rs b/crates/ruff_linter/src/rules/flake8_commas/rules/trailing_commas.rs index 220c15fbed..ce32b163c8 100644 --- a/crates/ruff_linter/src/rules/flake8_commas/rules/trailing_commas.rs +++ b/crates/ruff_linter/src/rules/flake8_commas/rules/trailing_commas.rs @@ -1,6 +1,6 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_index::Indexer; -use ruff_python_parser::{TokenKind, Tokens}; use ruff_text_size::{Ranged, TextRange}; use crate::Locator; diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs index d2b088fadf..5fdc1a37a3 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs @@ -3,7 +3,7 @@ use ruff_python_ast as ast; use ruff_python_ast::ExprGenerator; use ruff_python_ast::comparable::ComparableExpr; use ruff_python_ast::parenthesize::parenthesized_range; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::checkers::ast::Checker; diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs index b2ed05c925..0560935bae 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs @@ -3,7 +3,7 @@ use ruff_python_ast as ast; use ruff_python_ast::ExprGenerator; use ruff_python_ast::comparable::ComparableExpr; use ruff_python_ast::parenthesize::parenthesized_range; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::checkers::ast::Checker; diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs index fd171a58b2..b4fda738e2 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs @@ -1,7 +1,7 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast as ast; use ruff_python_ast::parenthesize::parenthesized_range; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::checkers::ast::Checker; diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/implicit.rs b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/implicit.rs index c33dcccabc..b1639e1f0f 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/implicit.rs +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/implicit.rs @@ -3,8 +3,8 @@ use std::borrow::Cow; use itertools::Itertools; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::StringFlags; +use ruff_python_ast::token::{Token, TokenKind, Tokens}; use ruff_python_index::Indexer; -use ruff_python_parser::{Token, TokenKind, Tokens}; use ruff_source_file::LineRanges; use ruff_text_size::{Ranged, TextLen, TextRange}; diff --git a/crates/ruff_linter/src/rules/flake8_pie/rules/unnecessary_spread.rs b/crates/ruff_linter/src/rules/flake8_pie/rules/unnecessary_spread.rs index 4b99f4e887..a5faff18d8 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/rules/unnecessary_spread.rs +++ b/crates/ruff_linter/src/rules/flake8_pie/rules/unnecessary_spread.rs @@ -1,6 +1,6 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_ast::{self as ast, Expr}; -use ruff_python_parser::{TokenKind, Tokens}; use ruff_text_size::{Ranged, TextLen, TextSize}; use crate::checkers::ast::Checker; diff --git a/crates/ruff_linter/src/rules/flake8_return/rules/function.rs b/crates/ruff_linter/src/rules/flake8_return/rules/function.rs index 018ddd925b..448cbd51a7 100644 --- a/crates/ruff_linter/src/rules/flake8_return/rules/function.rs +++ b/crates/ruff_linter/src/rules/flake8_return/rules/function.rs @@ -4,10 +4,10 @@ use ruff_diagnostics::Applicability; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::helpers::{is_const_false, is_const_true}; use ruff_python_ast::stmt_if::elif_else_range; +use ruff_python_ast::token::TokenKind; use ruff_python_ast::visitor::Visitor; use ruff_python_ast::whitespace::indentation; use ruff_python_ast::{self as ast, Decorator, ElifElseClause, Expr, Stmt}; -use ruff_python_parser::TokenKind; use ruff_python_semantic::SemanticModel; use ruff_python_semantic::analyze::visibility::is_property; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer, is_python_whitespace}; diff --git a/crates/ruff_linter/src/rules/isort/annotate.rs b/crates/ruff_linter/src/rules/isort/annotate.rs index ccbcc84b19..585b58e651 100644 --- a/crates/ruff_linter/src/rules/isort/annotate.rs +++ b/crates/ruff_linter/src/rules/isort/annotate.rs @@ -1,5 +1,5 @@ +use ruff_python_ast::token::Tokens; use ruff_python_ast::{self as ast, Stmt}; -use ruff_python_parser::Tokens; use ruff_source_file::LineRanges; use ruff_text_size::{Ranged, TextRange}; diff --git a/crates/ruff_linter/src/rules/isort/helpers.rs b/crates/ruff_linter/src/rules/isort/helpers.rs index f144a56993..bffc404100 100644 --- a/crates/ruff_linter/src/rules/isort/helpers.rs +++ b/crates/ruff_linter/src/rules/isort/helpers.rs @@ -1,5 +1,5 @@ use ruff_python_ast::Stmt; -use ruff_python_parser::{TokenKind, Tokens}; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_trivia::PythonWhitespace; use ruff_source_file::UniversalNewlines; use ruff_text_size::Ranged; diff --git a/crates/ruff_linter/src/rules/isort/mod.rs b/crates/ruff_linter/src/rules/isort/mod.rs index 28c3c69650..abbff742d4 100644 --- a/crates/ruff_linter/src/rules/isort/mod.rs +++ b/crates/ruff_linter/src/rules/isort/mod.rs @@ -11,8 +11,8 @@ use comments::Comment; use normalize::normalize_imports; use order::order_imports; use ruff_python_ast::PySourceType; +use ruff_python_ast::token::Tokens; use ruff_python_codegen::Stylist; -use ruff_python_parser::Tokens; use settings::Settings; use types::EitherImport::{Import, ImportFrom}; use types::{AliasData, ImportBlock, TrailingComma}; diff --git a/crates/ruff_linter/src/rules/isort/rules/organize_imports.rs b/crates/ruff_linter/src/rules/isort/rules/organize_imports.rs index febe9fc425..2071555c8b 100644 --- a/crates/ruff_linter/src/rules/isort/rules/organize_imports.rs +++ b/crates/ruff_linter/src/rules/isort/rules/organize_imports.rs @@ -1,11 +1,11 @@ use itertools::{EitherOrBoth, Itertools}; use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::token::Tokens; use ruff_python_ast::whitespace::trailing_lines_end; use ruff_python_ast::{PySourceType, PythonVersion, Stmt}; use ruff_python_codegen::Stylist; use ruff_python_index::Indexer; -use ruff_python_parser::Tokens; use ruff_python_trivia::{PythonWhitespace, leading_indentation, textwrap::indent}; use ruff_source_file::{LineRanges, UniversalNewlines}; use ruff_text_size::{Ranged, TextRange}; diff --git a/crates/ruff_linter/src/rules/pycodestyle/helpers.rs b/crates/ruff_linter/src/rules/pycodestyle/helpers.rs index a3ba640560..18047a3263 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/helpers.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/helpers.rs @@ -1,4 +1,4 @@ -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; /// Returns `true` if the name should be considered "ambiguous". pub(super) fn is_ambiguous_name(name: &str) -> bool { diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs index 978806ee95..32795e95d5 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs @@ -8,10 +8,10 @@ use itertools::Itertools; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_notebook::CellOffsets; use ruff_python_ast::PySourceType; +use ruff_python_ast::token::TokenIterWithContext; +use ruff_python_ast::token::TokenKind; +use ruff_python_ast::token::Tokens; use ruff_python_codegen::Stylist; -use ruff_python_parser::TokenIterWithContext; -use ruff_python_parser::TokenKind; -use ruff_python_parser::Tokens; use ruff_python_trivia::PythonWhitespace; use ruff_source_file::{LineRanges, UniversalNewlines}; use ruff_text_size::TextRange; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/compound_statements.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/compound_statements.rs index 8fd4889f3b..2749e35861 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/compound_statements.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/compound_statements.rs @@ -1,8 +1,8 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_notebook::CellOffsets; use ruff_python_ast::PySourceType; +use ruff_python_ast::token::{TokenIterWithContext, TokenKind, Tokens}; use ruff_python_index::Indexer; -use ruff_python_parser::{TokenIterWithContext, TokenKind, Tokens}; use ruff_text_size::{Ranged, TextSize}; use crate::Locator; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs index ff57fca1fe..3f2def0f3f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs @@ -1,5 +1,5 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_text_size::{Ranged, TextRange}; use crate::AlwaysFixableViolation; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/indentation.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/indentation.rs index 5c351f695f..4d2e1dbacd 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/indentation.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/indentation.rs @@ -1,5 +1,5 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_text_size::TextRange; use crate::Violation; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs index 759bbb29d6..999dc2f637 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs @@ -1,5 +1,5 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_text_size::Ranged; use crate::Edit; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_after_keyword.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_after_keyword.rs index c767be0dc8..c3bb8f3422 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_after_keyword.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_after_keyword.rs @@ -1,5 +1,5 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_text_size::Ranged; use crate::checkers::ast::LintContext; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs index 408575fa23..ffe43270b0 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs @@ -1,5 +1,5 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::LintContext; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/mod.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/mod.rs index 9f5c033b9f..bb45d6379a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/mod.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/mod.rs @@ -9,7 +9,7 @@ pub(crate) use missing_whitespace::*; pub(crate) use missing_whitespace_after_keyword::*; pub(crate) use missing_whitespace_around_operator::*; pub(crate) use redundant_backslash::*; -use ruff_python_parser::{TokenKind, Tokens}; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_trivia::is_python_whitespace; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; pub(crate) use space_around_operator::*; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/redundant_backslash.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/redundant_backslash.rs index 2092b63716..e077825712 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/redundant_backslash.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/redundant_backslash.rs @@ -1,6 +1,6 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::token::TokenKind; use ruff_python_index::Indexer; -use ruff_python_parser::TokenKind; use ruff_source_file::LineRanges; use ruff_text_size::{Ranged, TextRange, TextSize}; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs index c806ba46f4..74341c3da8 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs @@ -1,5 +1,5 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::LintContext; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs index bed7da83e1..66c1c95dd3 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs @@ -1,5 +1,5 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::checkers::ast::LintContext; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs index dc9e91dac2..729079c092 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs @@ -1,5 +1,5 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_python_trivia::PythonWhitespace; use ruff_source_file::LineRanges; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs index e176455718..d2595c384f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs @@ -1,5 +1,5 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::checkers::ast::LintContext; diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/too_many_newlines_at_end_of_file.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/too_many_newlines_at_end_of_file.rs index 3a84aad979..cd6b416e5a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/too_many_newlines_at_end_of_file.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/too_many_newlines_at_end_of_file.rs @@ -3,7 +3,7 @@ use std::iter::Peekable; use itertools::Itertools; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_notebook::CellOffsets; -use ruff_python_parser::{Token, TokenKind, Tokens}; +use ruff_python_ast::token::{Token, TokenKind, Tokens}; use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::{AlwaysFixableViolation, Edit, Fix, checkers::ast::LintContext}; diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/invalid_literal_comparisons.rs b/crates/ruff_linter/src/rules/pyflakes/rules/invalid_literal_comparisons.rs index d09d6cd006..9e19625745 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/invalid_literal_comparisons.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/invalid_literal_comparisons.rs @@ -2,8 +2,8 @@ use anyhow::{Error, bail}; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::helpers; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_ast::{CmpOp, Expr}; -use ruff_python_parser::{TokenKind, Tokens}; use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs b/crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs index aa5610620e..810c5742b9 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs @@ -3,8 +3,8 @@ use itertools::Itertools; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::helpers::contains_effect; use ruff_python_ast::parenthesize::parenthesized_range; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_ast::{self as ast, Stmt}; -use ruff_python_parser::{TokenKind, Tokens}; use ruff_python_semantic::Binding; use ruff_text_size::{Ranged, TextRange, TextSize}; diff --git a/crates/ruff_linter/src/rules/pylint/rules/invalid_string_characters.rs b/crates/ruff_linter/src/rules/pylint/rules/invalid_string_characters.rs index 05688f67c7..d197f2c536 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/invalid_string_characters.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/invalid_string_characters.rs @@ -1,5 +1,5 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_parser::{Token, TokenKind}; +use ruff_python_ast::token::{Token, TokenKind}; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use crate::Locator; diff --git a/crates/ruff_linter/src/rules/pyupgrade/fixes.rs b/crates/ruff_linter/src/rules/pyupgrade/fixes.rs index 3e0cdef305..7d26032797 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/fixes.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/fixes.rs @@ -1,5 +1,5 @@ use ruff_python_ast::StmtImportFrom; -use ruff_python_parser::{TokenKind, Tokens}; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_text_size::{Ranged, TextRange}; use crate::Locator; diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_import.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_import.rs index 51c3147a50..12e1b1e039 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_import.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_import.rs @@ -1,10 +1,10 @@ use itertools::Itertools; use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::token::Tokens; use ruff_python_ast::whitespace::indentation; use ruff_python_ast::{Alias, StmtImportFrom, StmtRef}; use ruff_python_codegen::Stylist; -use ruff_python_parser::Tokens; use ruff_text_size::Ranged; use crate::Locator; diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/extraneous_parentheses.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/extraneous_parentheses.rs index 9fe0324c1c..76b3ef86b2 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/extraneous_parentheses.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/extraneous_parentheses.rs @@ -1,7 +1,7 @@ use std::slice::Iter; use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_parser::{Token, TokenKind, Tokens}; +use ruff_python_ast::token::{Token, TokenKind, Tokens}; use ruff_text_size::{Ranged, TextRange}; use crate::Locator; diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/f_strings.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/f_strings.rs index b889c66d8c..9749969691 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/f_strings.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/f_strings.rs @@ -6,11 +6,11 @@ use rustc_hash::{FxHashMap, FxHashSet}; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::helpers::any_over_expr; use ruff_python_ast::str::{leading_quote, trailing_quote}; +use ruff_python_ast::token::TokenKind; use ruff_python_ast::{self as ast, Expr, Keyword, StringFlags}; use ruff_python_literal::format::{ FieldName, FieldNamePart, FieldType, FormatPart, FormatString, FromTemplate, }; -use ruff_python_parser::TokenKind; use ruff_source_file::LineRanges; use ruff_text_size::{Ranged, TextRange}; diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/printf_string_formatting.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/printf_string_formatting.rs index d6de04d355..fc9de0b4bb 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/printf_string_formatting.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/printf_string_formatting.rs @@ -3,12 +3,12 @@ use std::fmt::Write; use std::str::FromStr; use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::token::TokenKind; use ruff_python_ast::{self as ast, AnyStringFlags, Expr, StringFlags, whitespace::indentation}; use ruff_python_codegen::Stylist; use ruff_python_literal::cformat::{ CConversionFlags, CFormatPart, CFormatPrecision, CFormatQuantity, CFormatString, }; -use ruff_python_parser::TokenKind; use ruff_python_stdlib::identifiers::is_identifier; use ruff_source_file::LineRanges; use ruff_text_size::{Ranged, TextRange}; diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/quoted_annotation.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/quoted_annotation.rs index 25a85e0a18..6ea46f23cd 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/quoted_annotation.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/quoted_annotation.rs @@ -1,6 +1,6 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::Stmt; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_python_semantic::SemanticModel; use ruff_source_file::LineRanges; use ruff_text_size::{TextLen, TextRange, TextSize}; diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/redundant_open_modes.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/redundant_open_modes.rs index cf87abc039..ec10105cb1 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/redundant_open_modes.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/redundant_open_modes.rs @@ -1,7 +1,7 @@ use anyhow::Result; use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_ast::{self as ast, Expr}; -use ruff_python_parser::{TokenKind, Tokens}; use ruff_python_stdlib::open_mode::OpenMode; use ruff_text_size::{Ranged, TextSize}; diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs index 12ca46ed4b..01cfe4fb03 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs @@ -1,8 +1,8 @@ use std::fmt::Write as _; use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_ast::{self as ast, Arguments, Expr, Keyword}; -use ruff_python_parser::{TokenKind, Tokens}; use ruff_text_size::{Ranged, TextRange}; use crate::Locator; diff --git a/crates/ruff_linter/src/rules/ruff/rules/explicit_f_string_type_conversion.rs b/crates/ruff_linter/src/rules/ruff/rules/explicit_f_string_type_conversion.rs index 8dcd347fe3..2ba444d6b9 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/explicit_f_string_type_conversion.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/explicit_f_string_type_conversion.rs @@ -4,8 +4,8 @@ use anyhow::Result; use libcst_native::{LeftParen, ParenthesizedNode, RightParen}; use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::token::TokenKind; use ruff_python_ast::{self as ast, Expr, OperatorPrecedence}; -use ruff_python_parser::TokenKind; use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff_linter/src/rules/ruff/rules/needless_else.rs b/crates/ruff_linter/src/rules/ruff/rules/needless_else.rs index a60b6bde2e..f8022372b8 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/needless_else.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/needless_else.rs @@ -2,9 +2,9 @@ use std::cmp::Ordering; use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::helpers::comment_indentation_after; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_ast::whitespace::indentation; use ruff_python_ast::{Stmt, StmtExpr, StmtFor, StmtIf, StmtTry, StmtWhile}; -use ruff_python_parser::{TokenKind, Tokens}; use ruff_source_file::LineRanges; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; diff --git a/crates/ruff_linter/src/rules/ruff/rules/sequence_sorting.rs b/crates/ruff_linter/src/rules/ruff/rules/sequence_sorting.rs index e5881bc0ed..72965e5d25 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/sequence_sorting.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/sequence_sorting.rs @@ -9,8 +9,8 @@ use std::cmp::Ordering; use itertools::Itertools; use ruff_python_ast as ast; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_codegen::Stylist; -use ruff_python_parser::{TokenKind, Tokens}; use ruff_python_stdlib::str::is_cased_uppercase; use ruff_python_trivia::{SimpleTokenKind, first_non_trivia_token, leading_indentation}; use ruff_source_file::LineRanges; diff --git a/crates/ruff_linter/src/rules/ruff/rules/starmap_zip.rs b/crates/ruff_linter/src/rules/ruff/rules/starmap_zip.rs index f814bf980b..e9ed8d31bb 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/starmap_zip.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/starmap_zip.rs @@ -1,7 +1,7 @@ use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_python_ast::PythonVersion; +use ruff_python_ast::token::TokenKind; use ruff_python_ast::{Expr, ExprCall, parenthesize::parenthesized_range}; -use ruff_python_parser::TokenKind; use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; diff --git a/crates/ruff_python_ast/src/lib.rs b/crates/ruff_python_ast/src/lib.rs index 2642572e1b..5efa9a07e7 100644 --- a/crates/ruff_python_ast/src/lib.rs +++ b/crates/ruff_python_ast/src/lib.rs @@ -29,6 +29,7 @@ pub mod statement_visitor; pub mod stmt_if; pub mod str; pub mod str_prefix; +pub mod token; pub mod traversal; pub mod types; pub mod visitor; diff --git a/crates/ruff_python_ast/src/token.rs b/crates/ruff_python_ast/src/token.rs new file mode 100644 index 0000000000..fc1b62a366 --- /dev/null +++ b/crates/ruff_python_ast/src/token.rs @@ -0,0 +1,851 @@ +//! Token kinds for Python source code created by the lexer and consumed by the `ruff_python_parser`. +//! +//! This module defines the tokens that the lexer recognizes. The tokens are +//! loosely based on the token definitions found in the [CPython source]. +//! +//! [CPython source]: https://github.com/python/cpython/blob/dfc2e065a2e71011017077e549cd2f9bf4944c54/Grammar/Tokens + +use std::fmt; + +use bitflags::bitflags; + +use crate::str::{Quote, TripleQuotes}; +use crate::str_prefix::{ + AnyStringPrefix, ByteStringPrefix, FStringPrefix, StringLiteralPrefix, TStringPrefix, +}; +use crate::{AnyStringFlags, BoolOp, Operator, StringFlags, UnaryOp}; +use ruff_text_size::{Ranged, TextRange}; + +mod tokens; + +pub use tokens::{TokenAt, TokenIterWithContext, Tokens}; + +#[derive(Clone, Copy, PartialEq, Eq)] +#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))] +pub struct Token { + /// The kind of the token. + kind: TokenKind, + /// The range of the token. + range: TextRange, + /// The set of flags describing this token. + flags: TokenFlags, +} + +impl Token { + pub fn new(kind: TokenKind, range: TextRange, flags: TokenFlags) -> Token { + Self { kind, range, flags } + } + + /// Returns the token kind. + #[inline] + pub const fn kind(&self) -> TokenKind { + self.kind + } + + /// Returns the token as a tuple of (kind, range). + #[inline] + pub const fn as_tuple(&self) -> (TokenKind, TextRange) { + (self.kind, self.range) + } + + /// Returns `true` if the current token is a triple-quoted string of any kind. + /// + /// # Panics + /// + /// If it isn't a string or any f/t-string tokens. + pub fn is_triple_quoted_string(self) -> bool { + self.unwrap_string_flags().is_triple_quoted() + } + + /// Returns the [`Quote`] style for the current string token of any kind. + /// + /// # Panics + /// + /// If it isn't a string or any f/t-string tokens. + pub fn string_quote_style(self) -> Quote { + self.unwrap_string_flags().quote_style() + } + + /// Returns the [`AnyStringFlags`] style for the current string token of any kind. + /// + /// # Panics + /// + /// If it isn't a string or any f/t-string tokens. + pub fn unwrap_string_flags(self) -> AnyStringFlags { + self.string_flags() + .unwrap_or_else(|| panic!("token to be a string")) + } + + /// Returns true if the current token is a string and it is raw. + pub fn string_flags(self) -> Option { + if self.is_any_string() { + Some(self.flags.as_any_string_flags()) + } else { + None + } + } + + /// Returns `true` if this is any kind of string token - including + /// tokens in t-strings (which do not have type `str`). + const fn is_any_string(self) -> bool { + matches!( + self.kind, + TokenKind::String + | TokenKind::FStringStart + | TokenKind::FStringMiddle + | TokenKind::FStringEnd + | TokenKind::TStringStart + | TokenKind::TStringMiddle + | TokenKind::TStringEnd + ) + } +} + +impl Ranged for Token { + fn range(&self) -> TextRange { + self.range + } +} + +impl fmt::Debug for Token { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?} {:?}", self.kind, self.range)?; + if !self.flags.is_empty() { + f.write_str(" (flags = ")?; + let mut first = true; + for (name, _) in self.flags.iter_names() { + if first { + first = false; + } else { + f.write_str(" | ")?; + } + f.write_str(name)?; + } + f.write_str(")")?; + } + Ok(()) + } +} + +/// A kind of a token. +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)] +#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))] +pub enum TokenKind { + /// Token kind for a name, commonly known as an identifier. + Name, + /// Token kind for an integer. + Int, + /// Token kind for a floating point number. + Float, + /// Token kind for a complex number. + Complex, + /// Token kind for a string. + String, + /// Token kind for the start of an f-string. This includes the `f`/`F`/`fr` prefix + /// and the opening quote(s). + FStringStart, + /// Token kind that includes the portion of text inside the f-string that's not + /// part of the expression part and isn't an opening or closing brace. + FStringMiddle, + /// Token kind for the end of an f-string. This includes the closing quote. + FStringEnd, + /// Token kind for the start of a t-string. This includes the `t`/`T`/`tr` prefix + /// and the opening quote(s). + TStringStart, + /// Token kind that includes the portion of text inside the t-string that's not + /// part of the interpolation part and isn't an opening or closing brace. + TStringMiddle, + /// Token kind for the end of a t-string. This includes the closing quote. + TStringEnd, + /// Token kind for a IPython escape command. + IpyEscapeCommand, + /// Token kind for a comment. These are filtered out of the token stream prior to parsing. + Comment, + /// Token kind for a newline. + Newline, + /// Token kind for a newline that is not a logical line break. These are filtered out of + /// the token stream prior to parsing. + NonLogicalNewline, + /// Token kind for an indent. + Indent, + /// Token kind for a dedent. + Dedent, + EndOfFile, + /// Token kind for a question mark `?`. + Question, + /// Token kind for an exclamation mark `!`. + Exclamation, + /// Token kind for a left parenthesis `(`. + Lpar, + /// Token kind for a right parenthesis `)`. + Rpar, + /// Token kind for a left square bracket `[`. + Lsqb, + /// Token kind for a right square bracket `]`. + Rsqb, + /// Token kind for a colon `:`. + Colon, + /// Token kind for a comma `,`. + Comma, + /// Token kind for a semicolon `;`. + Semi, + /// Token kind for plus `+`. + Plus, + /// Token kind for minus `-`. + Minus, + /// Token kind for star `*`. + Star, + /// Token kind for slash `/`. + Slash, + /// Token kind for vertical bar `|`. + Vbar, + /// Token kind for ampersand `&`. + Amper, + /// Token kind for less than `<`. + Less, + /// Token kind for greater than `>`. + Greater, + /// Token kind for equal `=`. + Equal, + /// Token kind for dot `.`. + Dot, + /// Token kind for percent `%`. + Percent, + /// Token kind for left bracket `{`. + Lbrace, + /// Token kind for right bracket `}`. + Rbrace, + /// Token kind for double equal `==`. + EqEqual, + /// Token kind for not equal `!=`. + NotEqual, + /// Token kind for less than or equal `<=`. + LessEqual, + /// Token kind for greater than or equal `>=`. + GreaterEqual, + /// Token kind for tilde `~`. + Tilde, + /// Token kind for caret `^`. + CircumFlex, + /// Token kind for left shift `<<`. + LeftShift, + /// Token kind for right shift `>>`. + RightShift, + /// Token kind for double star `**`. + DoubleStar, + /// Token kind for double star equal `**=`. + DoubleStarEqual, + /// Token kind for plus equal `+=`. + PlusEqual, + /// Token kind for minus equal `-=`. + MinusEqual, + /// Token kind for star equal `*=`. + StarEqual, + /// Token kind for slash equal `/=`. + SlashEqual, + /// Token kind for percent equal `%=`. + PercentEqual, + /// Token kind for ampersand equal `&=`. + AmperEqual, + /// Token kind for vertical bar equal `|=`. + VbarEqual, + /// Token kind for caret equal `^=`. + CircumflexEqual, + /// Token kind for left shift equal `<<=`. + LeftShiftEqual, + /// Token kind for right shift equal `>>=`. + RightShiftEqual, + /// Token kind for double slash `//`. + DoubleSlash, + /// Token kind for double slash equal `//=`. + DoubleSlashEqual, + /// Token kind for colon equal `:=`. + ColonEqual, + /// Token kind for at `@`. + At, + /// Token kind for at equal `@=`. + AtEqual, + /// Token kind for arrow `->`. + Rarrow, + /// Token kind for ellipsis `...`. + Ellipsis, + + // The keywords should be sorted in alphabetical order. If the boundary tokens for the + // "Keywords" and "Soft keywords" group change, update the related methods on `TokenKind`. + + // Keywords + And, + As, + Assert, + Async, + Await, + Break, + Class, + Continue, + Def, + Del, + Elif, + Else, + Except, + False, + Finally, + For, + From, + Global, + If, + Import, + In, + Is, + Lambda, + None, + Nonlocal, + Not, + Or, + Pass, + Raise, + Return, + True, + Try, + While, + With, + Yield, + + // Soft keywords + Case, + Match, + Type, + + Unknown, +} + +impl TokenKind { + /// Returns `true` if this is an end of file token. + #[inline] + pub const fn is_eof(self) -> bool { + matches!(self, TokenKind::EndOfFile) + } + + /// Returns `true` if this is either a newline or non-logical newline token. + #[inline] + pub const fn is_any_newline(self) -> bool { + matches!(self, TokenKind::Newline | TokenKind::NonLogicalNewline) + } + + /// Returns `true` if the token is a keyword (including soft keywords). + /// + /// See also [`is_soft_keyword`], [`is_non_soft_keyword`]. + /// + /// [`is_soft_keyword`]: TokenKind::is_soft_keyword + /// [`is_non_soft_keyword`]: TokenKind::is_non_soft_keyword + #[inline] + pub fn is_keyword(self) -> bool { + TokenKind::And <= self && self <= TokenKind::Type + } + + /// Returns `true` if the token is strictly a soft keyword. + /// + /// See also [`is_keyword`], [`is_non_soft_keyword`]. + /// + /// [`is_keyword`]: TokenKind::is_keyword + /// [`is_non_soft_keyword`]: TokenKind::is_non_soft_keyword + #[inline] + pub fn is_soft_keyword(self) -> bool { + TokenKind::Case <= self && self <= TokenKind::Type + } + + /// Returns `true` if the token is strictly a non-soft keyword. + /// + /// See also [`is_keyword`], [`is_soft_keyword`]. + /// + /// [`is_keyword`]: TokenKind::is_keyword + /// [`is_soft_keyword`]: TokenKind::is_soft_keyword + #[inline] + pub fn is_non_soft_keyword(self) -> bool { + TokenKind::And <= self && self <= TokenKind::Yield + } + + #[inline] + pub const fn is_operator(self) -> bool { + matches!( + self, + TokenKind::Lpar + | TokenKind::Rpar + | TokenKind::Lsqb + | TokenKind::Rsqb + | TokenKind::Comma + | TokenKind::Semi + | TokenKind::Plus + | TokenKind::Minus + | TokenKind::Star + | TokenKind::Slash + | TokenKind::Vbar + | TokenKind::Amper + | TokenKind::Less + | TokenKind::Greater + | TokenKind::Equal + | TokenKind::Dot + | TokenKind::Percent + | TokenKind::Lbrace + | TokenKind::Rbrace + | TokenKind::EqEqual + | TokenKind::NotEqual + | TokenKind::LessEqual + | TokenKind::GreaterEqual + | TokenKind::Tilde + | TokenKind::CircumFlex + | TokenKind::LeftShift + | TokenKind::RightShift + | TokenKind::DoubleStar + | TokenKind::PlusEqual + | TokenKind::MinusEqual + | TokenKind::StarEqual + | TokenKind::SlashEqual + | TokenKind::PercentEqual + | TokenKind::AmperEqual + | TokenKind::VbarEqual + | TokenKind::CircumflexEqual + | TokenKind::LeftShiftEqual + | TokenKind::RightShiftEqual + | TokenKind::DoubleStarEqual + | TokenKind::DoubleSlash + | TokenKind::DoubleSlashEqual + | TokenKind::At + | TokenKind::AtEqual + | TokenKind::Rarrow + | TokenKind::Ellipsis + | TokenKind::ColonEqual + | TokenKind::Colon + | TokenKind::And + | TokenKind::Or + | TokenKind::Not + | TokenKind::In + | TokenKind::Is + ) + } + + /// Returns `true` if this is a singleton token i.e., `True`, `False`, or `None`. + #[inline] + pub const fn is_singleton(self) -> bool { + matches!(self, TokenKind::False | TokenKind::True | TokenKind::None) + } + + /// Returns `true` if this is a trivia token i.e., a comment or a non-logical newline. + #[inline] + pub const fn is_trivia(&self) -> bool { + matches!(self, TokenKind::Comment | TokenKind::NonLogicalNewline) + } + + /// Returns `true` if this is a comment token. + #[inline] + pub const fn is_comment(&self) -> bool { + matches!(self, TokenKind::Comment) + } + + #[inline] + pub const fn is_arithmetic(self) -> bool { + matches!( + self, + TokenKind::DoubleStar + | TokenKind::Star + | TokenKind::Plus + | TokenKind::Minus + | TokenKind::Slash + | TokenKind::DoubleSlash + | TokenKind::At + ) + } + + #[inline] + pub const fn is_bitwise_or_shift(self) -> bool { + matches!( + self, + TokenKind::LeftShift + | TokenKind::LeftShiftEqual + | TokenKind::RightShift + | TokenKind::RightShiftEqual + | TokenKind::Amper + | TokenKind::AmperEqual + | TokenKind::Vbar + | TokenKind::VbarEqual + | TokenKind::CircumFlex + | TokenKind::CircumflexEqual + | TokenKind::Tilde + ) + } + + /// Returns `true` if the current token is a unary arithmetic operator. + #[inline] + pub const fn is_unary_arithmetic_operator(self) -> bool { + matches!(self, TokenKind::Plus | TokenKind::Minus) + } + + #[inline] + pub const fn is_interpolated_string_end(self) -> bool { + matches!(self, TokenKind::FStringEnd | TokenKind::TStringEnd) + } + + /// Returns the [`UnaryOp`] that corresponds to this token kind, if it is a unary arithmetic + /// operator, otherwise return [None]. + /// + /// Use [`as_unary_operator`] to match against any unary operator. + /// + /// [`as_unary_operator`]: TokenKind::as_unary_operator + #[inline] + pub const fn as_unary_arithmetic_operator(self) -> Option { + Some(match self { + TokenKind::Plus => UnaryOp::UAdd, + TokenKind::Minus => UnaryOp::USub, + _ => return None, + }) + } + + /// Returns the [`UnaryOp`] that corresponds to this token kind, if it is a unary operator, + /// otherwise return [None]. + /// + /// Use [`as_unary_arithmetic_operator`] to match against only an arithmetic unary operator. + /// + /// [`as_unary_arithmetic_operator`]: TokenKind::as_unary_arithmetic_operator + #[inline] + pub const fn as_unary_operator(self) -> Option { + Some(match self { + TokenKind::Plus => UnaryOp::UAdd, + TokenKind::Minus => UnaryOp::USub, + TokenKind::Tilde => UnaryOp::Invert, + TokenKind::Not => UnaryOp::Not, + _ => return None, + }) + } + + /// Returns the [`BoolOp`] that corresponds to this token kind, if it is a boolean operator, + /// otherwise return [None]. + #[inline] + pub const fn as_bool_operator(self) -> Option { + Some(match self { + TokenKind::And => BoolOp::And, + TokenKind::Or => BoolOp::Or, + _ => return None, + }) + } + + /// Returns the binary [`Operator`] that corresponds to the current token, if it's a binary + /// operator, otherwise return [None]. + /// + /// Use [`as_augmented_assign_operator`] to match against an augmented assignment token. + /// + /// [`as_augmented_assign_operator`]: TokenKind::as_augmented_assign_operator + pub const fn as_binary_operator(self) -> Option { + Some(match self { + TokenKind::Plus => Operator::Add, + TokenKind::Minus => Operator::Sub, + TokenKind::Star => Operator::Mult, + TokenKind::At => Operator::MatMult, + TokenKind::DoubleStar => Operator::Pow, + TokenKind::Slash => Operator::Div, + TokenKind::DoubleSlash => Operator::FloorDiv, + TokenKind::Percent => Operator::Mod, + TokenKind::Amper => Operator::BitAnd, + TokenKind::Vbar => Operator::BitOr, + TokenKind::CircumFlex => Operator::BitXor, + TokenKind::LeftShift => Operator::LShift, + TokenKind::RightShift => Operator::RShift, + _ => return None, + }) + } + + /// Returns the [`Operator`] that corresponds to this token kind, if it is + /// an augmented assignment operator, or [`None`] otherwise. + #[inline] + pub const fn as_augmented_assign_operator(self) -> Option { + Some(match self { + TokenKind::PlusEqual => Operator::Add, + TokenKind::MinusEqual => Operator::Sub, + TokenKind::StarEqual => Operator::Mult, + TokenKind::AtEqual => Operator::MatMult, + TokenKind::DoubleStarEqual => Operator::Pow, + TokenKind::SlashEqual => Operator::Div, + TokenKind::DoubleSlashEqual => Operator::FloorDiv, + TokenKind::PercentEqual => Operator::Mod, + TokenKind::AmperEqual => Operator::BitAnd, + TokenKind::VbarEqual => Operator::BitOr, + TokenKind::CircumflexEqual => Operator::BitXor, + TokenKind::LeftShiftEqual => Operator::LShift, + TokenKind::RightShiftEqual => Operator::RShift, + _ => return None, + }) + } +} + +impl From for TokenKind { + #[inline] + fn from(op: BoolOp) -> Self { + match op { + BoolOp::And => TokenKind::And, + BoolOp::Or => TokenKind::Or, + } + } +} + +impl From for TokenKind { + #[inline] + fn from(op: UnaryOp) -> Self { + match op { + UnaryOp::Invert => TokenKind::Tilde, + UnaryOp::Not => TokenKind::Not, + UnaryOp::UAdd => TokenKind::Plus, + UnaryOp::USub => TokenKind::Minus, + } + } +} + +impl From for TokenKind { + #[inline] + fn from(op: Operator) -> Self { + match op { + Operator::Add => TokenKind::Plus, + Operator::Sub => TokenKind::Minus, + Operator::Mult => TokenKind::Star, + Operator::MatMult => TokenKind::At, + Operator::Div => TokenKind::Slash, + Operator::Mod => TokenKind::Percent, + Operator::Pow => TokenKind::DoubleStar, + Operator::LShift => TokenKind::LeftShift, + Operator::RShift => TokenKind::RightShift, + Operator::BitOr => TokenKind::Vbar, + Operator::BitXor => TokenKind::CircumFlex, + Operator::BitAnd => TokenKind::Amper, + Operator::FloorDiv => TokenKind::DoubleSlash, + } + } +} + +impl fmt::Display for TokenKind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let value = match self { + TokenKind::Unknown => "Unknown", + TokenKind::Newline => "newline", + TokenKind::NonLogicalNewline => "NonLogicalNewline", + TokenKind::Indent => "indent", + TokenKind::Dedent => "dedent", + TokenKind::EndOfFile => "end of file", + TokenKind::Name => "name", + TokenKind::Int => "int", + TokenKind::Float => "float", + TokenKind::Complex => "complex", + TokenKind::String => "string", + TokenKind::FStringStart => "FStringStart", + TokenKind::FStringMiddle => "FStringMiddle", + TokenKind::FStringEnd => "FStringEnd", + TokenKind::TStringStart => "TStringStart", + TokenKind::TStringMiddle => "TStringMiddle", + TokenKind::TStringEnd => "TStringEnd", + TokenKind::IpyEscapeCommand => "IPython escape command", + TokenKind::Comment => "comment", + TokenKind::Question => "`?`", + TokenKind::Exclamation => "`!`", + TokenKind::Lpar => "`(`", + TokenKind::Rpar => "`)`", + TokenKind::Lsqb => "`[`", + TokenKind::Rsqb => "`]`", + TokenKind::Lbrace => "`{`", + TokenKind::Rbrace => "`}`", + TokenKind::Equal => "`=`", + TokenKind::ColonEqual => "`:=`", + TokenKind::Dot => "`.`", + TokenKind::Colon => "`:`", + TokenKind::Semi => "`;`", + TokenKind::Comma => "`,`", + TokenKind::Rarrow => "`->`", + TokenKind::Plus => "`+`", + TokenKind::Minus => "`-`", + TokenKind::Star => "`*`", + TokenKind::DoubleStar => "`**`", + TokenKind::Slash => "`/`", + TokenKind::DoubleSlash => "`//`", + TokenKind::Percent => "`%`", + TokenKind::Vbar => "`|`", + TokenKind::Amper => "`&`", + TokenKind::CircumFlex => "`^`", + TokenKind::LeftShift => "`<<`", + TokenKind::RightShift => "`>>`", + TokenKind::Tilde => "`~`", + TokenKind::At => "`@`", + TokenKind::Less => "`<`", + TokenKind::Greater => "`>`", + TokenKind::EqEqual => "`==`", + TokenKind::NotEqual => "`!=`", + TokenKind::LessEqual => "`<=`", + TokenKind::GreaterEqual => "`>=`", + TokenKind::PlusEqual => "`+=`", + TokenKind::MinusEqual => "`-=`", + TokenKind::StarEqual => "`*=`", + TokenKind::DoubleStarEqual => "`**=`", + TokenKind::SlashEqual => "`/=`", + TokenKind::DoubleSlashEqual => "`//=`", + TokenKind::PercentEqual => "`%=`", + TokenKind::VbarEqual => "`|=`", + TokenKind::AmperEqual => "`&=`", + TokenKind::CircumflexEqual => "`^=`", + TokenKind::LeftShiftEqual => "`<<=`", + TokenKind::RightShiftEqual => "`>>=`", + TokenKind::AtEqual => "`@=`", + TokenKind::Ellipsis => "`...`", + TokenKind::False => "`False`", + TokenKind::None => "`None`", + TokenKind::True => "`True`", + TokenKind::And => "`and`", + TokenKind::As => "`as`", + TokenKind::Assert => "`assert`", + TokenKind::Async => "`async`", + TokenKind::Await => "`await`", + TokenKind::Break => "`break`", + TokenKind::Class => "`class`", + TokenKind::Continue => "`continue`", + TokenKind::Def => "`def`", + TokenKind::Del => "`del`", + TokenKind::Elif => "`elif`", + TokenKind::Else => "`else`", + TokenKind::Except => "`except`", + TokenKind::Finally => "`finally`", + TokenKind::For => "`for`", + TokenKind::From => "`from`", + TokenKind::Global => "`global`", + TokenKind::If => "`if`", + TokenKind::Import => "`import`", + TokenKind::In => "`in`", + TokenKind::Is => "`is`", + TokenKind::Lambda => "`lambda`", + TokenKind::Nonlocal => "`nonlocal`", + TokenKind::Not => "`not`", + TokenKind::Or => "`or`", + TokenKind::Pass => "`pass`", + TokenKind::Raise => "`raise`", + TokenKind::Return => "`return`", + TokenKind::Try => "`try`", + TokenKind::While => "`while`", + TokenKind::Match => "`match`", + TokenKind::Type => "`type`", + TokenKind::Case => "`case`", + TokenKind::With => "`with`", + TokenKind::Yield => "`yield`", + }; + f.write_str(value) + } +} + +bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq)] + pub struct TokenFlags: u16 { + /// The token is a string with double quotes (`"`). + const DOUBLE_QUOTES = 1 << 0; + /// The token is a triple-quoted string i.e., it starts and ends with three consecutive + /// quote characters (`"""` or `'''`). + const TRIPLE_QUOTED_STRING = 1 << 1; + + /// The token is a unicode string i.e., prefixed with `u` or `U` + const UNICODE_STRING = 1 << 2; + /// The token is a byte string i.e., prefixed with `b` or `B` + const BYTE_STRING = 1 << 3; + /// The token is an f-string i.e., prefixed with `f` or `F` + const F_STRING = 1 << 4; + /// The token is a t-string i.e., prefixed with `t` or `T` + const T_STRING = 1 << 5; + /// The token is a raw string and the prefix character is in lowercase. + const RAW_STRING_LOWERCASE = 1 << 6; + /// The token is a raw string and the prefix character is in uppercase. + const RAW_STRING_UPPERCASE = 1 << 7; + /// String without matching closing quote(s) + const UNCLOSED_STRING = 1 << 8; + + /// The token is a raw string i.e., prefixed with `r` or `R` + const RAW_STRING = Self::RAW_STRING_LOWERCASE.bits() | Self::RAW_STRING_UPPERCASE.bits(); + + } +} + +#[cfg(feature = "get-size")] +impl get_size2::GetSize for TokenFlags {} + +impl StringFlags for TokenFlags { + fn quote_style(self) -> Quote { + if self.intersects(TokenFlags::DOUBLE_QUOTES) { + Quote::Double + } else { + Quote::Single + } + } + + fn triple_quotes(self) -> TripleQuotes { + if self.intersects(TokenFlags::TRIPLE_QUOTED_STRING) { + TripleQuotes::Yes + } else { + TripleQuotes::No + } + } + + fn prefix(self) -> AnyStringPrefix { + if self.intersects(TokenFlags::F_STRING) { + if self.intersects(TokenFlags::RAW_STRING_LOWERCASE) { + AnyStringPrefix::Format(FStringPrefix::Raw { uppercase_r: false }) + } else if self.intersects(TokenFlags::RAW_STRING_UPPERCASE) { + AnyStringPrefix::Format(FStringPrefix::Raw { uppercase_r: true }) + } else { + AnyStringPrefix::Format(FStringPrefix::Regular) + } + } else if self.intersects(TokenFlags::T_STRING) { + if self.intersects(TokenFlags::RAW_STRING_LOWERCASE) { + AnyStringPrefix::Template(TStringPrefix::Raw { uppercase_r: false }) + } else if self.intersects(TokenFlags::RAW_STRING_UPPERCASE) { + AnyStringPrefix::Template(TStringPrefix::Raw { uppercase_r: true }) + } else { + AnyStringPrefix::Template(TStringPrefix::Regular) + } + } else if self.intersects(TokenFlags::BYTE_STRING) { + if self.intersects(TokenFlags::RAW_STRING_LOWERCASE) { + AnyStringPrefix::Bytes(ByteStringPrefix::Raw { uppercase_r: false }) + } else if self.intersects(TokenFlags::RAW_STRING_UPPERCASE) { + AnyStringPrefix::Bytes(ByteStringPrefix::Raw { uppercase_r: true }) + } else { + AnyStringPrefix::Bytes(ByteStringPrefix::Regular) + } + } else if self.intersects(TokenFlags::RAW_STRING_LOWERCASE) { + AnyStringPrefix::Regular(StringLiteralPrefix::Raw { uppercase: false }) + } else if self.intersects(TokenFlags::RAW_STRING_UPPERCASE) { + AnyStringPrefix::Regular(StringLiteralPrefix::Raw { uppercase: true }) + } else if self.intersects(TokenFlags::UNICODE_STRING) { + AnyStringPrefix::Regular(StringLiteralPrefix::Unicode) + } else { + AnyStringPrefix::Regular(StringLiteralPrefix::Empty) + } + } + + fn is_unclosed(self) -> bool { + self.intersects(TokenFlags::UNCLOSED_STRING) + } +} + +impl TokenFlags { + /// Returns `true` if the token is an f-string. + pub const fn is_f_string(self) -> bool { + self.intersects(TokenFlags::F_STRING) + } + + /// Returns `true` if the token is a t-string. + pub const fn is_t_string(self) -> bool { + self.intersects(TokenFlags::T_STRING) + } + + /// Returns `true` if the token is a t-string. + pub const fn is_interpolated_string(self) -> bool { + self.intersects(TokenFlags::T_STRING.union(TokenFlags::F_STRING)) + } + + /// Returns `true` if the token is a triple-quoted t-string. + pub fn is_triple_quoted_interpolated_string(self) -> bool { + self.intersects(TokenFlags::TRIPLE_QUOTED_STRING) && self.is_interpolated_string() + } + + /// Returns `true` if the token is a raw string. + pub const fn is_raw_string(self) -> bool { + self.intersects(TokenFlags::RAW_STRING) + } +} diff --git a/crates/ruff_python_ast/src/token/tokens.rs b/crates/ruff_python_ast/src/token/tokens.rs new file mode 100644 index 0000000000..edc7e27463 --- /dev/null +++ b/crates/ruff_python_ast/src/token/tokens.rs @@ -0,0 +1,520 @@ +use std::{iter::FusedIterator, ops::Deref}; + +use super::{Token, TokenKind}; +use ruff_python_trivia::CommentRanges; +use ruff_text_size::{Ranged as _, TextRange, TextSize}; + +/// Tokens represents a vector of lexed [`Token`]. +#[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))] +pub struct Tokens { + raw: Vec, +} + +impl Tokens { + pub fn new(tokens: Vec) -> Tokens { + Tokens { raw: tokens } + } + + /// Returns an iterator over all the tokens that provides context. + pub fn iter_with_context(&self) -> TokenIterWithContext<'_> { + TokenIterWithContext::new(&self.raw) + } + + /// Performs a binary search to find the index of the **first** token that starts at the given `offset`. + /// + /// Unlike `binary_search_by_key`, this method ensures that if multiple tokens start at the same offset, + /// it returns the index of the first one. Multiple tokens can start at the same offset in cases where + /// zero-length tokens are involved (like `Dedent` or `Newline` at the end of the file). + pub fn binary_search_by_start(&self, offset: TextSize) -> Result { + let partition_point = self.partition_point(|token| token.start() < offset); + + let after = &self[partition_point..]; + + if after.first().is_some_and(|first| first.start() == offset) { + Ok(partition_point) + } else { + Err(partition_point) + } + } + + /// Returns a slice of [`Token`] that are within the given `range`. + /// + /// The start and end offset of the given range should be either: + /// 1. Token boundary + /// 2. Gap between the tokens + /// + /// For example, considering the following tokens and their corresponding range: + /// + /// | Token | Range | + /// |---------------------|-----------| + /// | `Def` | `0..3` | + /// | `Name` | `4..7` | + /// | `Lpar` | `7..8` | + /// | `Rpar` | `8..9` | + /// | `Colon` | `9..10` | + /// | `Newline` | `10..11` | + /// | `Comment` | `15..24` | + /// | `NonLogicalNewline` | `24..25` | + /// | `Indent` | `25..29` | + /// | `Pass` | `29..33` | + /// + /// Here, for (1) a token boundary is considered either the start or end offset of any of the + /// above tokens. For (2), the gap would be any offset between the `Newline` and `Comment` + /// token which are 12, 13, and 14. + /// + /// Examples: + /// 1) `4..10` would give `Name`, `Lpar`, `Rpar`, `Colon` + /// 2) `11..25` would give `Comment`, `NonLogicalNewline` + /// 3) `12..25` would give same as (2) and offset 12 is in the "gap" + /// 4) `9..12` would give `Colon`, `Newline` and offset 12 is in the "gap" + /// 5) `18..27` would panic because both the start and end offset is within a token + /// + /// ## Note + /// + /// The returned slice can contain the [`TokenKind::Unknown`] token if there was a lexical + /// error encountered within the given range. + /// + /// # Panics + /// + /// If either the start or end offset of the given range is within a token range. + pub fn in_range(&self, range: TextRange) -> &[Token] { + let tokens_after_start = self.after(range.start()); + + Self::before_impl(tokens_after_start, range.end()) + } + + /// Searches the token(s) at `offset`. + /// + /// Returns [`TokenAt::Between`] if `offset` points directly inbetween two tokens + /// (the left token ends at `offset` and the right token starts at `offset`). + pub fn at_offset(&self, offset: TextSize) -> TokenAt { + match self.binary_search_by_start(offset) { + // The token at `index` starts exactly at `offset. + // ```python + // object.attribute + // ^ OFFSET + // ``` + Ok(index) => { + let token = self[index]; + // `token` starts exactly at `offset`. Test if the offset is right between + // `token` and the previous token (if there's any) + if let Some(previous) = index.checked_sub(1).map(|idx| self[idx]) { + if previous.end() == offset { + return TokenAt::Between(previous, token); + } + } + + TokenAt::Single(token) + } + + // No token found that starts exactly at the given offset. But it's possible that + // the token starting before `offset` fully encloses `offset` (it's end range ends after `offset`). + // ```python + // object.attribute + // ^ OFFSET + // # or + // if True: + // print("test") + // ^ OFFSET + // ``` + Err(index) => { + if let Some(previous) = index.checked_sub(1).map(|idx| self[idx]) { + if previous.range().contains_inclusive(offset) { + return TokenAt::Single(previous); + } + } + + TokenAt::None + } + } + } + + /// Returns a slice of tokens before the given [`TextSize`] offset. + /// + /// If the given offset is between two tokens, the returned slice will end just before the + /// following token. In other words, if the offset is between the end of previous token and + /// start of next token, the returned slice will end just before the next token. + /// + /// # Panics + /// + /// If the given offset is inside a token range at any point + /// other than the start of the range. + pub fn before(&self, offset: TextSize) -> &[Token] { + Self::before_impl(&self.raw, offset) + } + + fn before_impl(tokens: &[Token], offset: TextSize) -> &[Token] { + let partition_point = tokens.partition_point(|token| token.start() < offset); + let before = &tokens[..partition_point]; + + if let Some(last) = before.last() { + // If it's equal to the end offset, then it's at a token boundary which is + // valid. If it's greater than the end offset, then it's in the gap between + // the tokens which is valid as well. + assert!( + offset >= last.end(), + "Offset {:?} is inside a token range {:?}", + offset, + last.range() + ); + } + before + } + + /// Returns a slice of tokens after the given [`TextSize`] offset. + /// + /// If the given offset is between two tokens, the returned slice will start from the following + /// token. In other words, if the offset is between the end of previous token and start of next + /// token, the returned slice will start from the next token. + /// + /// # Panics + /// + /// If the given offset is inside a token range at any point + /// other than the start of the range. + pub fn after(&self, offset: TextSize) -> &[Token] { + let partition_point = self.partition_point(|token| token.end() <= offset); + let after = &self[partition_point..]; + + if let Some(first) = after.first() { + // valid. If it's greater than the end offset, then it's in the gap between + // the tokens which is valid as well. + assert!( + offset <= first.start(), + "Offset {:?} is inside a token range {:?}", + offset, + first.range() + ); + } + + after + } +} + +impl<'a> IntoIterator for &'a Tokens { + type Item = &'a Token; + type IntoIter = std::slice::Iter<'a, Token>; + + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + +impl Deref for Tokens { + type Target = [Token]; + + fn deref(&self) -> &Self::Target { + &self.raw + } +} + +/// A token that encloses a given offset or ends exactly at it. +#[derive(Debug, Clone)] +pub enum TokenAt { + /// There's no token at the given offset + None, + + /// There's a single token at the given offset. + Single(Token), + + /// The offset falls exactly between two tokens. E.g. `CURSOR` in `call(arguments)` is + /// positioned exactly between the `call` and `(` tokens. + Between(Token, Token), +} + +impl Iterator for TokenAt { + type Item = Token; + + fn next(&mut self) -> Option { + match *self { + TokenAt::None => None, + TokenAt::Single(token) => { + *self = TokenAt::None; + Some(token) + } + TokenAt::Between(first, second) => { + *self = TokenAt::Single(second); + Some(first) + } + } + } +} + +impl FusedIterator for TokenAt {} + +impl From<&Tokens> for CommentRanges { + fn from(tokens: &Tokens) -> Self { + let mut ranges = vec![]; + for token in tokens { + if token.kind() == TokenKind::Comment { + ranges.push(token.range()); + } + } + CommentRanges::new(ranges) + } +} + +/// An iterator over the [`Token`]s with context. +/// +/// This struct is created by the [`iter_with_context`] method on [`Tokens`]. Refer to its +/// documentation for more details. +/// +/// [`iter_with_context`]: Tokens::iter_with_context +#[derive(Debug, Clone)] +pub struct TokenIterWithContext<'a> { + inner: std::slice::Iter<'a, Token>, + nesting: u32, +} + +impl<'a> TokenIterWithContext<'a> { + fn new(tokens: &'a [Token]) -> TokenIterWithContext<'a> { + TokenIterWithContext { + inner: tokens.iter(), + nesting: 0, + } + } + + /// Return the nesting level the iterator is currently in. + pub const fn nesting(&self) -> u32 { + self.nesting + } + + /// Returns `true` if the iterator is within a parenthesized context. + pub const fn in_parenthesized_context(&self) -> bool { + self.nesting > 0 + } + + /// Returns the next [`Token`] in the iterator without consuming it. + pub fn peek(&self) -> Option<&'a Token> { + self.clone().next() + } +} + +impl<'a> Iterator for TokenIterWithContext<'a> { + type Item = &'a Token; + + fn next(&mut self) -> Option { + let token = self.inner.next()?; + + match token.kind() { + TokenKind::Lpar | TokenKind::Lbrace | TokenKind::Lsqb => self.nesting += 1, + TokenKind::Rpar | TokenKind::Rbrace | TokenKind::Rsqb => { + self.nesting = self.nesting.saturating_sub(1); + } + // This mimics the behavior of re-lexing which reduces the nesting level on the lexer. + // We don't need to reduce it by 1 because unlike the lexer we see the final token + // after recovering from every unclosed parenthesis. + TokenKind::Newline if self.nesting > 0 => { + self.nesting = 0; + } + _ => {} + } + + Some(token) + } +} + +impl FusedIterator for TokenIterWithContext<'_> {} + +#[cfg(test)] +mod tests { + use std::ops::Range; + + use ruff_text_size::TextSize; + + use crate::token::{Token, TokenFlags, TokenKind}; + + use super::*; + + /// Test case containing a "gap" between two tokens. + /// + /// Code: + const TEST_CASE_WITH_GAP: [(TokenKind, Range); 10] = [ + (TokenKind::Def, 0..3), + (TokenKind::Name, 4..7), + (TokenKind::Lpar, 7..8), + (TokenKind::Rpar, 8..9), + (TokenKind::Colon, 9..10), + (TokenKind::Newline, 10..11), + // Gap ||..|| + (TokenKind::Comment, 15..24), + (TokenKind::NonLogicalNewline, 24..25), + (TokenKind::Indent, 25..29), + (TokenKind::Pass, 29..33), + // No newline at the end to keep the token set full of unique tokens + ]; + + /// Helper function to create [`Tokens`] from an iterator of (kind, range). + fn new_tokens(tokens: impl Iterator)>) -> Tokens { + Tokens::new( + tokens + .map(|(kind, range)| { + Token::new( + kind, + TextRange::new(TextSize::new(range.start), TextSize::new(range.end)), + TokenFlags::empty(), + ) + }) + .collect(), + ) + } + + #[test] + fn tokens_after_offset_at_token_start() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let after = tokens.after(TextSize::new(8)); + assert_eq!(after.len(), 7); + assert_eq!(after.first().unwrap().kind(), TokenKind::Rpar); + } + + #[test] + fn tokens_after_offset_at_token_end() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let after = tokens.after(TextSize::new(11)); + assert_eq!(after.len(), 4); + assert_eq!(after.first().unwrap().kind(), TokenKind::Comment); + } + + #[test] + fn tokens_after_offset_between_tokens() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let after = tokens.after(TextSize::new(13)); + assert_eq!(after.len(), 4); + assert_eq!(after.first().unwrap().kind(), TokenKind::Comment); + } + + #[test] + fn tokens_after_offset_at_last_token_end() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let after = tokens.after(TextSize::new(33)); + assert_eq!(after.len(), 0); + } + + #[test] + #[should_panic(expected = "Offset 5 is inside a token range 4..7")] + fn tokens_after_offset_inside_token() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + tokens.after(TextSize::new(5)); + } + + #[test] + fn tokens_before_offset_at_first_token_start() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let before = tokens.before(TextSize::new(0)); + assert_eq!(before.len(), 0); + } + + #[test] + fn tokens_before_offset_after_first_token_gap() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let before = tokens.before(TextSize::new(3)); + assert_eq!(before.len(), 1); + assert_eq!(before.last().unwrap().kind(), TokenKind::Def); + } + + #[test] + fn tokens_before_offset_at_second_token_start() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let before = tokens.before(TextSize::new(4)); + assert_eq!(before.len(), 1); + assert_eq!(before.last().unwrap().kind(), TokenKind::Def); + } + + #[test] + fn tokens_before_offset_at_token_start() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let before = tokens.before(TextSize::new(8)); + assert_eq!(before.len(), 3); + assert_eq!(before.last().unwrap().kind(), TokenKind::Lpar); + } + + #[test] + fn tokens_before_offset_at_token_end() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let before = tokens.before(TextSize::new(11)); + assert_eq!(before.len(), 6); + assert_eq!(before.last().unwrap().kind(), TokenKind::Newline); + } + + #[test] + fn tokens_before_offset_between_tokens() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let before = tokens.before(TextSize::new(13)); + assert_eq!(before.len(), 6); + assert_eq!(before.last().unwrap().kind(), TokenKind::Newline); + } + + #[test] + fn tokens_before_offset_at_last_token_end() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let before = tokens.before(TextSize::new(33)); + assert_eq!(before.len(), 10); + assert_eq!(before.last().unwrap().kind(), TokenKind::Pass); + } + + #[test] + #[should_panic(expected = "Offset 5 is inside a token range 4..7")] + fn tokens_before_offset_inside_token() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + tokens.before(TextSize::new(5)); + } + + #[test] + fn tokens_in_range_at_token_offset() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let in_range = tokens.in_range(TextRange::new(4.into(), 10.into())); + assert_eq!(in_range.len(), 4); + assert_eq!(in_range.first().unwrap().kind(), TokenKind::Name); + assert_eq!(in_range.last().unwrap().kind(), TokenKind::Colon); + } + + #[test] + fn tokens_in_range_start_offset_at_token_end() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let in_range = tokens.in_range(TextRange::new(11.into(), 29.into())); + assert_eq!(in_range.len(), 3); + assert_eq!(in_range.first().unwrap().kind(), TokenKind::Comment); + assert_eq!(in_range.last().unwrap().kind(), TokenKind::Indent); + } + + #[test] + fn tokens_in_range_end_offset_at_token_start() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let in_range = tokens.in_range(TextRange::new(8.into(), 15.into())); + assert_eq!(in_range.len(), 3); + assert_eq!(in_range.first().unwrap().kind(), TokenKind::Rpar); + assert_eq!(in_range.last().unwrap().kind(), TokenKind::Newline); + } + + #[test] + fn tokens_in_range_start_offset_between_tokens() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let in_range = tokens.in_range(TextRange::new(13.into(), 29.into())); + assert_eq!(in_range.len(), 3); + assert_eq!(in_range.first().unwrap().kind(), TokenKind::Comment); + assert_eq!(in_range.last().unwrap().kind(), TokenKind::Indent); + } + + #[test] + fn tokens_in_range_end_offset_between_tokens() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + let in_range = tokens.in_range(TextRange::new(9.into(), 13.into())); + assert_eq!(in_range.len(), 2); + assert_eq!(in_range.first().unwrap().kind(), TokenKind::Colon); + assert_eq!(in_range.last().unwrap().kind(), TokenKind::Newline); + } + + #[test] + #[should_panic(expected = "Offset 5 is inside a token range 4..7")] + fn tokens_in_range_start_offset_inside_token() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + tokens.in_range(TextRange::new(5.into(), 10.into())); + } + + #[test] + #[should_panic(expected = "Offset 6 is inside a token range 4..7")] + fn tokens_in_range_end_offset_inside_token() { + let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); + tokens.in_range(TextRange::new(0.into(), 6.into())); + } +} diff --git a/crates/ruff_python_codegen/src/stylist.rs b/crates/ruff_python_codegen/src/stylist.rs index 8daf9b3a4f..06e5b27407 100644 --- a/crates/ruff_python_codegen/src/stylist.rs +++ b/crates/ruff_python_codegen/src/stylist.rs @@ -5,7 +5,7 @@ use std::cell::OnceCell; use std::ops::Deref; use ruff_python_ast::str::Quote; -use ruff_python_parser::{Token, TokenKind, Tokens}; +use ruff_python_ast::token::{Token, TokenKind, Tokens}; use ruff_source_file::{LineEnding, LineRanges, find_newline}; use ruff_text_size::Ranged; diff --git a/crates/ruff_python_formatter/src/context.rs b/crates/ruff_python_formatter/src/context.rs index 528afc6c71..239edc8d5b 100644 --- a/crates/ruff_python_formatter/src/context.rs +++ b/crates/ruff_python_formatter/src/context.rs @@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut}; use ruff_formatter::{Buffer, FormatContext, GroupId, IndentWidth, SourceCode}; use ruff_python_ast::str::Quote; -use ruff_python_parser::Tokens; +use ruff_python_ast::token::Tokens; use crate::PyFormatOptions; use crate::comments::Comments; diff --git a/crates/ruff_python_formatter/src/verbatim.rs b/crates/ruff_python_formatter/src/verbatim.rs index 9802257248..e0bbf00ad6 100644 --- a/crates/ruff_python_formatter/src/verbatim.rs +++ b/crates/ruff_python_formatter/src/verbatim.rs @@ -5,7 +5,7 @@ use std::slice::Iter; use ruff_formatter::{FormatError, write}; use ruff_python_ast::AnyNodeRef; use ruff_python_ast::Stmt; -use ruff_python_parser::{self as parser, TokenKind}; +use ruff_python_ast::token::{Token as AstToken, TokenKind}; use ruff_python_trivia::lines_before; use ruff_source_file::LineRanges; use ruff_text_size::{Ranged, TextRange, TextSize}; @@ -770,7 +770,7 @@ impl Format> for FormatVerbatimStatementRange { } struct LogicalLinesIter<'a> { - tokens: Iter<'a, parser::Token>, + tokens: Iter<'a, AstToken>, // The end of the last logical line last_line_end: TextSize, // The position where the content to lex ends. @@ -778,7 +778,7 @@ struct LogicalLinesIter<'a> { } impl<'a> LogicalLinesIter<'a> { - fn new(tokens: Iter<'a, parser::Token>, verbatim_range: TextRange) -> Self { + fn new(tokens: Iter<'a, AstToken>, verbatim_range: TextRange) -> Self { Self { tokens, last_line_end: verbatim_range.start(), diff --git a/crates/ruff_python_importer/Cargo.toml b/crates/ruff_python_importer/Cargo.toml index 96070a2400..a563d79e29 100644 --- a/crates/ruff_python_importer/Cargo.toml +++ b/crates/ruff_python_importer/Cargo.toml @@ -14,7 +14,6 @@ license = { workspace = true } ruff_diagnostics = { workspace = true } ruff_python_ast = { workspace = true } ruff_python_codegen = { workspace = true } -ruff_python_parser = { workspace = true } ruff_python_trivia = { workspace = true } ruff_source_file = { workspace = true, features = ["serde"] } ruff_text_size = { workspace = true } @@ -22,6 +21,8 @@ ruff_text_size = { workspace = true } anyhow = { workspace = true } [dev-dependencies] +ruff_python_parser = { workspace = true } + insta = { workspace = true } [features] diff --git a/crates/ruff_python_importer/src/insertion.rs b/crates/ruff_python_importer/src/insertion.rs index 69bd5aa33d..293cec988e 100644 --- a/crates/ruff_python_importer/src/insertion.rs +++ b/crates/ruff_python_importer/src/insertion.rs @@ -5,8 +5,8 @@ use std::ops::Add; use ruff_diagnostics::Edit; use ruff_python_ast::Stmt; use ruff_python_ast::helpers::is_docstring_stmt; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_codegen::Stylist; -use ruff_python_parser::{TokenKind, Tokens}; use ruff_python_trivia::is_python_whitespace; use ruff_python_trivia::{PythonWhitespace, textwrap::indent}; use ruff_source_file::{LineRanges, UniversalNewlineIterator}; @@ -194,7 +194,7 @@ impl<'a> Insertion<'a> { tokens .before(at) .last() - .map(ruff_python_parser::Token::kind), + .map(ruff_python_ast::token::Token::kind), Some(TokenKind::Import) ) { return None; diff --git a/crates/ruff_python_index/Cargo.toml b/crates/ruff_python_index/Cargo.toml index 622a63777b..4ff47bb9ab 100644 --- a/crates/ruff_python_index/Cargo.toml +++ b/crates/ruff_python_index/Cargo.toml @@ -15,12 +15,12 @@ doctest = false [dependencies] ruff_python_ast = { workspace = true } -ruff_python_parser = { workspace = true } ruff_python_trivia = { workspace = true } ruff_source_file = { workspace = true } ruff_text_size = { workspace = true } [dev-dependencies] +ruff_python_parser = { workspace = true } [lints] workspace = true diff --git a/crates/ruff_python_index/src/indexer.rs b/crates/ruff_python_index/src/indexer.rs index 04c44a7c4b..80c0e00e20 100644 --- a/crates/ruff_python_index/src/indexer.rs +++ b/crates/ruff_python_index/src/indexer.rs @@ -2,7 +2,7 @@ //! are omitted from the AST (e.g., commented lines). use ruff_python_ast::Stmt; -use ruff_python_parser::{TokenKind, Tokens}; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_trivia::{ CommentRanges, has_leading_content, has_trailing_content, is_python_whitespace, }; diff --git a/crates/ruff_python_index/src/interpolated_string_ranges.rs b/crates/ruff_python_index/src/interpolated_string_ranges.rs index 45dc7c2765..935f3f08f2 100644 --- a/crates/ruff_python_index/src/interpolated_string_ranges.rs +++ b/crates/ruff_python_index/src/interpolated_string_ranges.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use ruff_python_parser::{Token, TokenKind}; +use ruff_python_ast::token::{Token, TokenKind}; use ruff_text_size::{Ranged, TextRange, TextSize}; /// Stores the ranges of all interpolated strings in a file sorted by [`TextRange::start`]. diff --git a/crates/ruff_python_index/src/multiline_ranges.rs b/crates/ruff_python_index/src/multiline_ranges.rs index 585ff6f1ae..c8f2bc1bac 100644 --- a/crates/ruff_python_index/src/multiline_ranges.rs +++ b/crates/ruff_python_index/src/multiline_ranges.rs @@ -1,4 +1,4 @@ -use ruff_python_parser::{Token, TokenKind}; +use ruff_python_ast::token::{Token, TokenKind}; use ruff_text_size::{Ranged, TextRange}; /// Stores the range of all multiline strings in a file sorted by diff --git a/crates/ruff_python_parser/src/error.rs b/crates/ruff_python_parser/src/error.rs index 8b02546d3b..6dd1dac0d3 100644 --- a/crates/ruff_python_parser/src/error.rs +++ b/crates/ruff_python_parser/src/error.rs @@ -1,9 +1,10 @@ use std::fmt::{self, Display}; use ruff_python_ast::PythonVersion; +use ruff_python_ast::token::TokenKind; use ruff_text_size::{Ranged, TextRange}; -use crate::{TokenKind, string::InterpolatedStringKind}; +use crate::string::InterpolatedStringKind; /// Represents represent errors that occur during parsing and are /// returned by the `parse_*` functions. diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index dc864d71b6..8b4b3a061c 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -14,6 +14,7 @@ use unicode_normalization::UnicodeNormalization; use ruff_python_ast::name::Name; use ruff_python_ast::str_prefix::{AnyStringPrefix, StringLiteralPrefix}; +use ruff_python_ast::token::{TokenFlags, TokenKind}; use ruff_python_ast::{Int, IpyEscapeKind, StringFlags}; use ruff_python_trivia::is_python_whitespace; use ruff_text_size::{TextLen, TextRange, TextSize}; @@ -26,7 +27,7 @@ use crate::lexer::interpolated_string::{ InterpolatedStringContext, InterpolatedStrings, InterpolatedStringsCheckpoint, }; use crate::string::InterpolatedStringKind; -use crate::token::{TokenFlags, TokenKind, TokenValue}; +use crate::token::TokenValue; mod cursor; mod indentation; diff --git a/crates/ruff_python_parser/src/lib.rs b/crates/ruff_python_parser/src/lib.rs index ce409200ae..86bfe56697 100644 --- a/crates/ruff_python_parser/src/lib.rs +++ b/crates/ruff_python_parser/src/lib.rs @@ -63,23 +63,20 @@ //! [lexical analysis]: https://en.wikipedia.org/wiki/Lexical_analysis //! [parsing]: https://en.wikipedia.org/wiki/Parsing //! [lexer]: crate::lexer -use std::iter::FusedIterator; -use std::ops::Deref; pub use crate::error::{ InterpolatedStringErrorType, LexicalErrorType, ParseError, ParseErrorType, UnsupportedSyntaxError, UnsupportedSyntaxErrorKind, }; pub use crate::parser::ParseOptions; -pub use crate::token::{Token, TokenKind}; use crate::parser::Parser; +use ruff_python_ast::token::Tokens; use ruff_python_ast::{ Expr, Mod, ModExpression, ModModule, PySourceType, StringFlags, StringLiteral, Suite, }; -use ruff_python_trivia::CommentRanges; -use ruff_text_size::{Ranged, TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange}; mod error; pub mod lexer; @@ -473,351 +470,6 @@ impl Parsed { } } -/// Tokens represents a vector of lexed [`Token`]. -#[derive(Debug, Clone, PartialEq, Eq, get_size2::GetSize)] -pub struct Tokens { - raw: Vec, -} - -impl Tokens { - pub(crate) fn new(tokens: Vec) -> Tokens { - Tokens { raw: tokens } - } - - /// Returns an iterator over all the tokens that provides context. - pub fn iter_with_context(&self) -> TokenIterWithContext<'_> { - TokenIterWithContext::new(&self.raw) - } - - /// Performs a binary search to find the index of the **first** token that starts at the given `offset`. - /// - /// Unlike `binary_search_by_key`, this method ensures that if multiple tokens start at the same offset, - /// it returns the index of the first one. Multiple tokens can start at the same offset in cases where - /// zero-length tokens are involved (like `Dedent` or `Newline` at the end of the file). - pub fn binary_search_by_start(&self, offset: TextSize) -> Result { - let partition_point = self.partition_point(|token| token.start() < offset); - - let after = &self[partition_point..]; - - if after.first().is_some_and(|first| first.start() == offset) { - Ok(partition_point) - } else { - Err(partition_point) - } - } - - /// Returns a slice of [`Token`] that are within the given `range`. - /// - /// The start and end offset of the given range should be either: - /// 1. Token boundary - /// 2. Gap between the tokens - /// - /// For example, considering the following tokens and their corresponding range: - /// - /// | Token | Range | - /// |---------------------|-----------| - /// | `Def` | `0..3` | - /// | `Name` | `4..7` | - /// | `Lpar` | `7..8` | - /// | `Rpar` | `8..9` | - /// | `Colon` | `9..10` | - /// | `Newline` | `10..11` | - /// | `Comment` | `15..24` | - /// | `NonLogicalNewline` | `24..25` | - /// | `Indent` | `25..29` | - /// | `Pass` | `29..33` | - /// - /// Here, for (1) a token boundary is considered either the start or end offset of any of the - /// above tokens. For (2), the gap would be any offset between the `Newline` and `Comment` - /// token which are 12, 13, and 14. - /// - /// Examples: - /// 1) `4..10` would give `Name`, `Lpar`, `Rpar`, `Colon` - /// 2) `11..25` would give `Comment`, `NonLogicalNewline` - /// 3) `12..25` would give same as (2) and offset 12 is in the "gap" - /// 4) `9..12` would give `Colon`, `Newline` and offset 12 is in the "gap" - /// 5) `18..27` would panic because both the start and end offset is within a token - /// - /// ## Note - /// - /// The returned slice can contain the [`TokenKind::Unknown`] token if there was a lexical - /// error encountered within the given range. - /// - /// # Panics - /// - /// If either the start or end offset of the given range is within a token range. - pub fn in_range(&self, range: TextRange) -> &[Token] { - let tokens_after_start = self.after(range.start()); - - Self::before_impl(tokens_after_start, range.end()) - } - - /// Searches the token(s) at `offset`. - /// - /// Returns [`TokenAt::Between`] if `offset` points directly inbetween two tokens - /// (the left token ends at `offset` and the right token starts at `offset`). - /// - /// - /// ## Examples - /// - /// [Playground](https://play.ruff.rs/f3ad0a55-5931-4a13-96c7-b2b8bfdc9a2e?secondary=Tokens) - /// - /// ``` - /// # use ruff_python_ast::PySourceType; - /// # use ruff_python_parser::{Token, TokenAt, TokenKind}; - /// # use ruff_text_size::{Ranged, TextSize}; - /// - /// let source = r#" - /// def test(arg): - /// arg.call() - /// if True: - /// pass - /// print("true") - /// "#.trim(); - /// - /// let parsed = ruff_python_parser::parse_unchecked_source(source, PySourceType::Python); - /// let tokens = parsed.tokens(); - /// - /// let collect_tokens = |offset: TextSize| { - /// tokens.at_offset(offset).into_iter().map(|t| (t.kind(), &source[t.range()])).collect::>() - /// }; - /// - /// assert_eq!(collect_tokens(TextSize::new(4)), vec! [(TokenKind::Name, "test")]); - /// assert_eq!(collect_tokens(TextSize::new(6)), vec! [(TokenKind::Name, "test")]); - /// // between `arg` and `.` - /// assert_eq!(collect_tokens(TextSize::new(22)), vec! [(TokenKind::Name, "arg"), (TokenKind::Dot, ".")]); - /// assert_eq!(collect_tokens(TextSize::new(36)), vec! [(TokenKind::If, "if")]); - /// // Before the dedent token - /// assert_eq!(collect_tokens(TextSize::new(57)), vec! []); - /// ``` - pub fn at_offset(&self, offset: TextSize) -> TokenAt { - match self.binary_search_by_start(offset) { - // The token at `index` starts exactly at `offset. - // ```python - // object.attribute - // ^ OFFSET - // ``` - Ok(index) => { - let token = self[index]; - // `token` starts exactly at `offset`. Test if the offset is right between - // `token` and the previous token (if there's any) - if let Some(previous) = index.checked_sub(1).map(|idx| self[idx]) { - if previous.end() == offset { - return TokenAt::Between(previous, token); - } - } - - TokenAt::Single(token) - } - - // No token found that starts exactly at the given offset. But it's possible that - // the token starting before `offset` fully encloses `offset` (it's end range ends after `offset`). - // ```python - // object.attribute - // ^ OFFSET - // # or - // if True: - // print("test") - // ^ OFFSET - // ``` - Err(index) => { - if let Some(previous) = index.checked_sub(1).map(|idx| self[idx]) { - if previous.range().contains_inclusive(offset) { - return TokenAt::Single(previous); - } - } - - TokenAt::None - } - } - } - - /// Returns a slice of tokens before the given [`TextSize`] offset. - /// - /// If the given offset is between two tokens, the returned slice will end just before the - /// following token. In other words, if the offset is between the end of previous token and - /// start of next token, the returned slice will end just before the next token. - /// - /// # Panics - /// - /// If the given offset is inside a token range at any point - /// other than the start of the range. - pub fn before(&self, offset: TextSize) -> &[Token] { - Self::before_impl(&self.raw, offset) - } - - fn before_impl(tokens: &[Token], offset: TextSize) -> &[Token] { - let partition_point = tokens.partition_point(|token| token.start() < offset); - let before = &tokens[..partition_point]; - - if let Some(last) = before.last() { - // If it's equal to the end offset, then it's at a token boundary which is - // valid. If it's greater than the end offset, then it's in the gap between - // the tokens which is valid as well. - assert!( - offset >= last.end(), - "Offset {:?} is inside a token range {:?}", - offset, - last.range() - ); - } - before - } - - /// Returns a slice of tokens after the given [`TextSize`] offset. - /// - /// If the given offset is between two tokens, the returned slice will start from the following - /// token. In other words, if the offset is between the end of previous token and start of next - /// token, the returned slice will start from the next token. - /// - /// # Panics - /// - /// If the given offset is inside a token range at any point - /// other than the start of the range. - pub fn after(&self, offset: TextSize) -> &[Token] { - let partition_point = self.partition_point(|token| token.end() <= offset); - let after = &self[partition_point..]; - - if let Some(first) = after.first() { - // valid. If it's greater than the end offset, then it's in the gap between - // the tokens which is valid as well. - assert!( - offset <= first.start(), - "Offset {:?} is inside a token range {:?}", - offset, - first.range() - ); - } - - after - } -} - -impl<'a> IntoIterator for &'a Tokens { - type Item = &'a Token; - type IntoIter = std::slice::Iter<'a, Token>; - - fn into_iter(self) -> Self::IntoIter { - self.iter() - } -} - -impl Deref for Tokens { - type Target = [Token]; - - fn deref(&self) -> &Self::Target { - &self.raw - } -} - -/// A token that encloses a given offset or ends exactly at it. -#[derive(Debug, Clone)] -pub enum TokenAt { - /// There's no token at the given offset - None, - - /// There's a single token at the given offset. - Single(Token), - - /// The offset falls exactly between two tokens. E.g. `CURSOR` in `call(arguments)` is - /// positioned exactly between the `call` and `(` tokens. - Between(Token, Token), -} - -impl Iterator for TokenAt { - type Item = Token; - - fn next(&mut self) -> Option { - match *self { - TokenAt::None => None, - TokenAt::Single(token) => { - *self = TokenAt::None; - Some(token) - } - TokenAt::Between(first, second) => { - *self = TokenAt::Single(second); - Some(first) - } - } - } -} - -impl FusedIterator for TokenAt {} - -impl From<&Tokens> for CommentRanges { - fn from(tokens: &Tokens) -> Self { - let mut ranges = vec![]; - for token in tokens { - if token.kind() == TokenKind::Comment { - ranges.push(token.range()); - } - } - CommentRanges::new(ranges) - } -} - -/// An iterator over the [`Token`]s with context. -/// -/// This struct is created by the [`iter_with_context`] method on [`Tokens`]. Refer to its -/// documentation for more details. -/// -/// [`iter_with_context`]: Tokens::iter_with_context -#[derive(Debug, Clone)] -pub struct TokenIterWithContext<'a> { - inner: std::slice::Iter<'a, Token>, - nesting: u32, -} - -impl<'a> TokenIterWithContext<'a> { - fn new(tokens: &'a [Token]) -> TokenIterWithContext<'a> { - TokenIterWithContext { - inner: tokens.iter(), - nesting: 0, - } - } - - /// Return the nesting level the iterator is currently in. - pub const fn nesting(&self) -> u32 { - self.nesting - } - - /// Returns `true` if the iterator is within a parenthesized context. - pub const fn in_parenthesized_context(&self) -> bool { - self.nesting > 0 - } - - /// Returns the next [`Token`] in the iterator without consuming it. - pub fn peek(&self) -> Option<&'a Token> { - self.clone().next() - } -} - -impl<'a> Iterator for TokenIterWithContext<'a> { - type Item = &'a Token; - - fn next(&mut self) -> Option { - let token = self.inner.next()?; - - match token.kind() { - TokenKind::Lpar | TokenKind::Lbrace | TokenKind::Lsqb => self.nesting += 1, - TokenKind::Rpar | TokenKind::Rbrace | TokenKind::Rsqb => { - self.nesting = self.nesting.saturating_sub(1); - } - // This mimics the behavior of re-lexing which reduces the nesting level on the lexer. - // We don't need to reduce it by 1 because unlike the lexer we see the final token - // after recovering from every unclosed parenthesis. - TokenKind::Newline if self.nesting > 0 => { - self.nesting = 0; - } - _ => {} - } - - Some(token) - } -} - -impl FusedIterator for TokenIterWithContext<'_> {} - /// Control in the different modes by which a source file can be parsed. /// /// The mode argument specifies in what way code must be parsed. @@ -888,204 +540,3 @@ impl std::fmt::Display for ModeParseError { write!(f, r#"mode must be "exec", "eval", "ipython", or "single""#) } } - -#[cfg(test)] -mod tests { - use std::ops::Range; - - use crate::token::TokenFlags; - - use super::*; - - /// Test case containing a "gap" between two tokens. - /// - /// Code: - const TEST_CASE_WITH_GAP: [(TokenKind, Range); 10] = [ - (TokenKind::Def, 0..3), - (TokenKind::Name, 4..7), - (TokenKind::Lpar, 7..8), - (TokenKind::Rpar, 8..9), - (TokenKind::Colon, 9..10), - (TokenKind::Newline, 10..11), - // Gap ||..|| - (TokenKind::Comment, 15..24), - (TokenKind::NonLogicalNewline, 24..25), - (TokenKind::Indent, 25..29), - (TokenKind::Pass, 29..33), - // No newline at the end to keep the token set full of unique tokens - ]; - - /// Helper function to create [`Tokens`] from an iterator of (kind, range). - fn new_tokens(tokens: impl Iterator)>) -> Tokens { - Tokens::new( - tokens - .map(|(kind, range)| { - Token::new( - kind, - TextRange::new(TextSize::new(range.start), TextSize::new(range.end)), - TokenFlags::empty(), - ) - }) - .collect(), - ) - } - - #[test] - fn tokens_after_offset_at_token_start() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let after = tokens.after(TextSize::new(8)); - assert_eq!(after.len(), 7); - assert_eq!(after.first().unwrap().kind(), TokenKind::Rpar); - } - - #[test] - fn tokens_after_offset_at_token_end() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let after = tokens.after(TextSize::new(11)); - assert_eq!(after.len(), 4); - assert_eq!(after.first().unwrap().kind(), TokenKind::Comment); - } - - #[test] - fn tokens_after_offset_between_tokens() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let after = tokens.after(TextSize::new(13)); - assert_eq!(after.len(), 4); - assert_eq!(after.first().unwrap().kind(), TokenKind::Comment); - } - - #[test] - fn tokens_after_offset_at_last_token_end() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let after = tokens.after(TextSize::new(33)); - assert_eq!(after.len(), 0); - } - - #[test] - #[should_panic(expected = "Offset 5 is inside a token range 4..7")] - fn tokens_after_offset_inside_token() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - tokens.after(TextSize::new(5)); - } - - #[test] - fn tokens_before_offset_at_first_token_start() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let before = tokens.before(TextSize::new(0)); - assert_eq!(before.len(), 0); - } - - #[test] - fn tokens_before_offset_after_first_token_gap() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let before = tokens.before(TextSize::new(3)); - assert_eq!(before.len(), 1); - assert_eq!(before.last().unwrap().kind(), TokenKind::Def); - } - - #[test] - fn tokens_before_offset_at_second_token_start() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let before = tokens.before(TextSize::new(4)); - assert_eq!(before.len(), 1); - assert_eq!(before.last().unwrap().kind(), TokenKind::Def); - } - - #[test] - fn tokens_before_offset_at_token_start() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let before = tokens.before(TextSize::new(8)); - assert_eq!(before.len(), 3); - assert_eq!(before.last().unwrap().kind(), TokenKind::Lpar); - } - - #[test] - fn tokens_before_offset_at_token_end() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let before = tokens.before(TextSize::new(11)); - assert_eq!(before.len(), 6); - assert_eq!(before.last().unwrap().kind(), TokenKind::Newline); - } - - #[test] - fn tokens_before_offset_between_tokens() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let before = tokens.before(TextSize::new(13)); - assert_eq!(before.len(), 6); - assert_eq!(before.last().unwrap().kind(), TokenKind::Newline); - } - - #[test] - fn tokens_before_offset_at_last_token_end() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let before = tokens.before(TextSize::new(33)); - assert_eq!(before.len(), 10); - assert_eq!(before.last().unwrap().kind(), TokenKind::Pass); - } - - #[test] - #[should_panic(expected = "Offset 5 is inside a token range 4..7")] - fn tokens_before_offset_inside_token() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - tokens.before(TextSize::new(5)); - } - - #[test] - fn tokens_in_range_at_token_offset() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let in_range = tokens.in_range(TextRange::new(4.into(), 10.into())); - assert_eq!(in_range.len(), 4); - assert_eq!(in_range.first().unwrap().kind(), TokenKind::Name); - assert_eq!(in_range.last().unwrap().kind(), TokenKind::Colon); - } - - #[test] - fn tokens_in_range_start_offset_at_token_end() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let in_range = tokens.in_range(TextRange::new(11.into(), 29.into())); - assert_eq!(in_range.len(), 3); - assert_eq!(in_range.first().unwrap().kind(), TokenKind::Comment); - assert_eq!(in_range.last().unwrap().kind(), TokenKind::Indent); - } - - #[test] - fn tokens_in_range_end_offset_at_token_start() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let in_range = tokens.in_range(TextRange::new(8.into(), 15.into())); - assert_eq!(in_range.len(), 3); - assert_eq!(in_range.first().unwrap().kind(), TokenKind::Rpar); - assert_eq!(in_range.last().unwrap().kind(), TokenKind::Newline); - } - - #[test] - fn tokens_in_range_start_offset_between_tokens() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let in_range = tokens.in_range(TextRange::new(13.into(), 29.into())); - assert_eq!(in_range.len(), 3); - assert_eq!(in_range.first().unwrap().kind(), TokenKind::Comment); - assert_eq!(in_range.last().unwrap().kind(), TokenKind::Indent); - } - - #[test] - fn tokens_in_range_end_offset_between_tokens() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - let in_range = tokens.in_range(TextRange::new(9.into(), 13.into())); - assert_eq!(in_range.len(), 2); - assert_eq!(in_range.first().unwrap().kind(), TokenKind::Colon); - assert_eq!(in_range.last().unwrap().kind(), TokenKind::Newline); - } - - #[test] - #[should_panic(expected = "Offset 5 is inside a token range 4..7")] - fn tokens_in_range_start_offset_inside_token() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - tokens.in_range(TextRange::new(5.into(), 10.into())); - } - - #[test] - #[should_panic(expected = "Offset 6 is inside a token range 4..7")] - fn tokens_in_range_end_offset_inside_token() { - let tokens = new_tokens(TEST_CASE_WITH_GAP.into_iter()); - tokens.in_range(TextRange::new(0.into(), 6.into())); - } -} diff --git a/crates/ruff_python_parser/src/parser/expression.rs b/crates/ruff_python_parser/src/parser/expression.rs index 2ae786ce77..f0e930461a 100644 --- a/crates/ruff_python_parser/src/parser/expression.rs +++ b/crates/ruff_python_parser/src/parser/expression.rs @@ -4,6 +4,7 @@ use bitflags::bitflags; use rustc_hash::{FxBuildHasher, FxHashSet}; use ruff_python_ast::name::Name; +use ruff_python_ast::token::TokenKind; use ruff_python_ast::{ self as ast, AnyStringFlags, AtomicNodeIndex, BoolOp, CmpOp, ConversionFlag, Expr, ExprContext, FString, InterpolatedStringElement, InterpolatedStringElements, IpyEscapeKind, Number, @@ -18,7 +19,7 @@ use crate::string::{ InterpolatedStringKind, StringType, parse_interpolated_string_literal_element, parse_string_literal, }; -use crate::token::{TokenKind, TokenValue}; +use crate::token::TokenValue; use crate::token_set::TokenSet; use crate::{ InterpolatedStringErrorType, Mode, ParseErrorType, UnsupportedSyntaxError, diff --git a/crates/ruff_python_parser/src/parser/helpers.rs b/crates/ruff_python_parser/src/parser/helpers.rs index 819bc9f3b4..8abbb6355a 100644 --- a/crates/ruff_python_parser/src/parser/helpers.rs +++ b/crates/ruff_python_parser/src/parser/helpers.rs @@ -1,7 +1,8 @@ +use ruff_python_ast::token::TokenKind; use ruff_python_ast::{self as ast, CmpOp, Expr, ExprContext, Number}; use ruff_text_size::{Ranged, TextRange}; -use crate::{TokenKind, error::RelaxedDecoratorError}; +use crate::error::RelaxedDecoratorError; /// Set the `ctx` for `Expr::Id`, `Expr::Attribute`, `Expr::Subscript`, `Expr::Starred`, /// `Expr::Tuple` and `Expr::List`. If `expr` is either `Expr::Tuple` or `Expr::List`, diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index 90396cb72d..8d0614b6b9 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -2,6 +2,7 @@ use std::cmp::Ordering; use bitflags::bitflags; +use ruff_python_ast::token::TokenKind; use ruff_python_ast::{AtomicNodeIndex, Mod, ModExpression, ModModule}; use ruff_text_size::{Ranged, TextRange, TextSize}; @@ -12,7 +13,7 @@ use crate::string::InterpolatedStringKind; use crate::token::TokenValue; use crate::token_set::TokenSet; use crate::token_source::{TokenSource, TokenSourceCheckpoint}; -use crate::{Mode, ParseError, ParseErrorType, TokenKind, UnsupportedSyntaxErrorKind}; +use crate::{Mode, ParseError, ParseErrorType, UnsupportedSyntaxErrorKind}; use crate::{Parsed, Tokens}; pub use crate::parser::options::ParseOptions; diff --git a/crates/ruff_python_parser/src/parser/pattern.rs b/crates/ruff_python_parser/src/parser/pattern.rs index 2839a7dcad..f28dc237c9 100644 --- a/crates/ruff_python_parser/src/parser/pattern.rs +++ b/crates/ruff_python_parser/src/parser/pattern.rs @@ -1,4 +1,5 @@ use ruff_python_ast::name::Name; +use ruff_python_ast::token::TokenKind; use ruff_python_ast::{ self as ast, AtomicNodeIndex, Expr, ExprContext, Number, Operator, Pattern, Singleton, }; @@ -7,7 +8,7 @@ use ruff_text_size::{Ranged, TextSize}; use crate::ParseErrorType; use crate::parser::progress::ParserProgress; use crate::parser::{Parser, RecoveryContextKind, SequenceMatchPatternParentheses, recovery}; -use crate::token::{TokenKind, TokenValue}; +use crate::token::TokenValue; use crate::token_set::TokenSet; use super::expression::ExpressionContext; diff --git a/crates/ruff_python_parser/src/parser/statement.rs b/crates/ruff_python_parser/src/parser/statement.rs index 134c9c40fd..07e5816a9c 100644 --- a/crates/ruff_python_parser/src/parser/statement.rs +++ b/crates/ruff_python_parser/src/parser/statement.rs @@ -2,6 +2,7 @@ use compact_str::CompactString; use std::fmt::{Display, Write}; use ruff_python_ast::name::Name; +use ruff_python_ast::token::TokenKind; use ruff_python_ast::{ self as ast, AtomicNodeIndex, ExceptHandler, Expr, ExprContext, IpyEscapeKind, Operator, PythonVersion, Stmt, WithItem, @@ -14,7 +15,7 @@ use crate::parser::progress::ParserProgress; use crate::parser::{ FunctionKind, Parser, RecoveryContext, RecoveryContextKind, WithItemKind, helpers, }; -use crate::token::{TokenKind, TokenValue}; +use crate::token::TokenValue; use crate::token_set::TokenSet; use crate::{Mode, ParseErrorType, UnsupportedSyntaxErrorKind}; diff --git a/crates/ruff_python_parser/src/string.rs b/crates/ruff_python_parser/src/string.rs index 4510934685..4b750865a2 100644 --- a/crates/ruff_python_parser/src/string.rs +++ b/crates/ruff_python_parser/src/string.rs @@ -3,13 +3,11 @@ use bstr::ByteSlice; use std::fmt; +use ruff_python_ast::token::TokenKind; use ruff_python_ast::{self as ast, AnyStringFlags, AtomicNodeIndex, Expr, StringFlags}; use ruff_text_size::{Ranged, TextRange, TextSize}; -use crate::{ - TokenKind, - error::{LexicalError, LexicalErrorType}, -}; +use crate::error::{LexicalError, LexicalErrorType}; #[derive(Debug)] pub(crate) enum StringType { diff --git a/crates/ruff_python_parser/src/token.rs b/crates/ruff_python_parser/src/token.rs index a5790a9597..f2f96e133d 100644 --- a/crates/ruff_python_parser/src/token.rs +++ b/crates/ruff_python_parser/src/token.rs @@ -1,848 +1,4 @@ -//! Token kinds for Python source code created by the lexer and consumed by the `ruff_python_parser`. -//! -//! This module defines the tokens that the lexer recognizes. The tokens are -//! loosely based on the token definitions found in the [CPython source]. -//! -//! [CPython source]: https://github.com/python/cpython/blob/dfc2e065a2e71011017077e549cd2f9bf4944c54/Grammar/Tokens - -use std::fmt; - -use bitflags::bitflags; - -use ruff_python_ast::name::Name; -use ruff_python_ast::str::{Quote, TripleQuotes}; -use ruff_python_ast::str_prefix::{ - AnyStringPrefix, ByteStringPrefix, FStringPrefix, StringLiteralPrefix, TStringPrefix, -}; -use ruff_python_ast::{AnyStringFlags, BoolOp, Int, IpyEscapeKind, Operator, StringFlags, UnaryOp}; -use ruff_text_size::{Ranged, TextRange}; - -#[derive(Clone, Copy, PartialEq, Eq, get_size2::GetSize)] -pub struct Token { - /// The kind of the token. - kind: TokenKind, - /// The range of the token. - range: TextRange, - /// The set of flags describing this token. - flags: TokenFlags, -} - -impl Token { - pub(crate) fn new(kind: TokenKind, range: TextRange, flags: TokenFlags) -> Token { - Self { kind, range, flags } - } - - /// Returns the token kind. - #[inline] - pub const fn kind(&self) -> TokenKind { - self.kind - } - - /// Returns the token as a tuple of (kind, range). - #[inline] - pub const fn as_tuple(&self) -> (TokenKind, TextRange) { - (self.kind, self.range) - } - - /// Returns `true` if the current token is a triple-quoted string of any kind. - /// - /// # Panics - /// - /// If it isn't a string or any f/t-string tokens. - pub fn is_triple_quoted_string(self) -> bool { - self.unwrap_string_flags().is_triple_quoted() - } - - /// Returns the [`Quote`] style for the current string token of any kind. - /// - /// # Panics - /// - /// If it isn't a string or any f/t-string tokens. - pub fn string_quote_style(self) -> Quote { - self.unwrap_string_flags().quote_style() - } - - /// Returns the [`AnyStringFlags`] style for the current string token of any kind. - /// - /// # Panics - /// - /// If it isn't a string or any f/t-string tokens. - pub fn unwrap_string_flags(self) -> AnyStringFlags { - self.string_flags() - .unwrap_or_else(|| panic!("token to be a string")) - } - - /// Returns true if the current token is a string and it is raw. - pub fn string_flags(self) -> Option { - if self.is_any_string() { - Some(self.flags.as_any_string_flags()) - } else { - None - } - } - - /// Returns `true` if this is any kind of string token - including - /// tokens in t-strings (which do not have type `str`). - const fn is_any_string(self) -> bool { - matches!( - self.kind, - TokenKind::String - | TokenKind::FStringStart - | TokenKind::FStringMiddle - | TokenKind::FStringEnd - | TokenKind::TStringStart - | TokenKind::TStringMiddle - | TokenKind::TStringEnd - ) - } -} - -impl Ranged for Token { - fn range(&self) -> TextRange { - self.range - } -} - -impl fmt::Debug for Token { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?} {:?}", self.kind, self.range)?; - if !self.flags.is_empty() { - f.write_str(" (flags = ")?; - let mut first = true; - for (name, _) in self.flags.iter_names() { - if first { - first = false; - } else { - f.write_str(" | ")?; - } - f.write_str(name)?; - } - f.write_str(")")?; - } - Ok(()) - } -} - -/// A kind of a token. -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, get_size2::GetSize)] -pub enum TokenKind { - /// Token kind for a name, commonly known as an identifier. - Name, - /// Token kind for an integer. - Int, - /// Token kind for a floating point number. - Float, - /// Token kind for a complex number. - Complex, - /// Token kind for a string. - String, - /// Token kind for the start of an f-string. This includes the `f`/`F`/`fr` prefix - /// and the opening quote(s). - FStringStart, - /// Token kind that includes the portion of text inside the f-string that's not - /// part of the expression part and isn't an opening or closing brace. - FStringMiddle, - /// Token kind for the end of an f-string. This includes the closing quote. - FStringEnd, - /// Token kind for the start of a t-string. This includes the `t`/`T`/`tr` prefix - /// and the opening quote(s). - TStringStart, - /// Token kind that includes the portion of text inside the t-string that's not - /// part of the interpolation part and isn't an opening or closing brace. - TStringMiddle, - /// Token kind for the end of a t-string. This includes the closing quote. - TStringEnd, - /// Token kind for a IPython escape command. - IpyEscapeCommand, - /// Token kind for a comment. These are filtered out of the token stream prior to parsing. - Comment, - /// Token kind for a newline. - Newline, - /// Token kind for a newline that is not a logical line break. These are filtered out of - /// the token stream prior to parsing. - NonLogicalNewline, - /// Token kind for an indent. - Indent, - /// Token kind for a dedent. - Dedent, - EndOfFile, - /// Token kind for a question mark `?`. - Question, - /// Token kind for an exclamation mark `!`. - Exclamation, - /// Token kind for a left parenthesis `(`. - Lpar, - /// Token kind for a right parenthesis `)`. - Rpar, - /// Token kind for a left square bracket `[`. - Lsqb, - /// Token kind for a right square bracket `]`. - Rsqb, - /// Token kind for a colon `:`. - Colon, - /// Token kind for a comma `,`. - Comma, - /// Token kind for a semicolon `;`. - Semi, - /// Token kind for plus `+`. - Plus, - /// Token kind for minus `-`. - Minus, - /// Token kind for star `*`. - Star, - /// Token kind for slash `/`. - Slash, - /// Token kind for vertical bar `|`. - Vbar, - /// Token kind for ampersand `&`. - Amper, - /// Token kind for less than `<`. - Less, - /// Token kind for greater than `>`. - Greater, - /// Token kind for equal `=`. - Equal, - /// Token kind for dot `.`. - Dot, - /// Token kind for percent `%`. - Percent, - /// Token kind for left bracket `{`. - Lbrace, - /// Token kind for right bracket `}`. - Rbrace, - /// Token kind for double equal `==`. - EqEqual, - /// Token kind for not equal `!=`. - NotEqual, - /// Token kind for less than or equal `<=`. - LessEqual, - /// Token kind for greater than or equal `>=`. - GreaterEqual, - /// Token kind for tilde `~`. - Tilde, - /// Token kind for caret `^`. - CircumFlex, - /// Token kind for left shift `<<`. - LeftShift, - /// Token kind for right shift `>>`. - RightShift, - /// Token kind for double star `**`. - DoubleStar, - /// Token kind for double star equal `**=`. - DoubleStarEqual, - /// Token kind for plus equal `+=`. - PlusEqual, - /// Token kind for minus equal `-=`. - MinusEqual, - /// Token kind for star equal `*=`. - StarEqual, - /// Token kind for slash equal `/=`. - SlashEqual, - /// Token kind for percent equal `%=`. - PercentEqual, - /// Token kind for ampersand equal `&=`. - AmperEqual, - /// Token kind for vertical bar equal `|=`. - VbarEqual, - /// Token kind for caret equal `^=`. - CircumflexEqual, - /// Token kind for left shift equal `<<=`. - LeftShiftEqual, - /// Token kind for right shift equal `>>=`. - RightShiftEqual, - /// Token kind for double slash `//`. - DoubleSlash, - /// Token kind for double slash equal `//=`. - DoubleSlashEqual, - /// Token kind for colon equal `:=`. - ColonEqual, - /// Token kind for at `@`. - At, - /// Token kind for at equal `@=`. - AtEqual, - /// Token kind for arrow `->`. - Rarrow, - /// Token kind for ellipsis `...`. - Ellipsis, - - // The keywords should be sorted in alphabetical order. If the boundary tokens for the - // "Keywords" and "Soft keywords" group change, update the related methods on `TokenKind`. - - // Keywords - And, - As, - Assert, - Async, - Await, - Break, - Class, - Continue, - Def, - Del, - Elif, - Else, - Except, - False, - Finally, - For, - From, - Global, - If, - Import, - In, - Is, - Lambda, - None, - Nonlocal, - Not, - Or, - Pass, - Raise, - Return, - True, - Try, - While, - With, - Yield, - - // Soft keywords - Case, - Match, - Type, - - Unknown, -} - -impl TokenKind { - /// Returns `true` if this is an end of file token. - #[inline] - pub const fn is_eof(self) -> bool { - matches!(self, TokenKind::EndOfFile) - } - - /// Returns `true` if this is either a newline or non-logical newline token. - #[inline] - pub const fn is_any_newline(self) -> bool { - matches!(self, TokenKind::Newline | TokenKind::NonLogicalNewline) - } - - /// Returns `true` if the token is a keyword (including soft keywords). - /// - /// See also [`is_soft_keyword`], [`is_non_soft_keyword`]. - /// - /// [`is_soft_keyword`]: TokenKind::is_soft_keyword - /// [`is_non_soft_keyword`]: TokenKind::is_non_soft_keyword - #[inline] - pub fn is_keyword(self) -> bool { - TokenKind::And <= self && self <= TokenKind::Type - } - - /// Returns `true` if the token is strictly a soft keyword. - /// - /// See also [`is_keyword`], [`is_non_soft_keyword`]. - /// - /// [`is_keyword`]: TokenKind::is_keyword - /// [`is_non_soft_keyword`]: TokenKind::is_non_soft_keyword - #[inline] - pub fn is_soft_keyword(self) -> bool { - TokenKind::Case <= self && self <= TokenKind::Type - } - - /// Returns `true` if the token is strictly a non-soft keyword. - /// - /// See also [`is_keyword`], [`is_soft_keyword`]. - /// - /// [`is_keyword`]: TokenKind::is_keyword - /// [`is_soft_keyword`]: TokenKind::is_soft_keyword - #[inline] - pub fn is_non_soft_keyword(self) -> bool { - TokenKind::And <= self && self <= TokenKind::Yield - } - - #[inline] - pub const fn is_operator(self) -> bool { - matches!( - self, - TokenKind::Lpar - | TokenKind::Rpar - | TokenKind::Lsqb - | TokenKind::Rsqb - | TokenKind::Comma - | TokenKind::Semi - | TokenKind::Plus - | TokenKind::Minus - | TokenKind::Star - | TokenKind::Slash - | TokenKind::Vbar - | TokenKind::Amper - | TokenKind::Less - | TokenKind::Greater - | TokenKind::Equal - | TokenKind::Dot - | TokenKind::Percent - | TokenKind::Lbrace - | TokenKind::Rbrace - | TokenKind::EqEqual - | TokenKind::NotEqual - | TokenKind::LessEqual - | TokenKind::GreaterEqual - | TokenKind::Tilde - | TokenKind::CircumFlex - | TokenKind::LeftShift - | TokenKind::RightShift - | TokenKind::DoubleStar - | TokenKind::PlusEqual - | TokenKind::MinusEqual - | TokenKind::StarEqual - | TokenKind::SlashEqual - | TokenKind::PercentEqual - | TokenKind::AmperEqual - | TokenKind::VbarEqual - | TokenKind::CircumflexEqual - | TokenKind::LeftShiftEqual - | TokenKind::RightShiftEqual - | TokenKind::DoubleStarEqual - | TokenKind::DoubleSlash - | TokenKind::DoubleSlashEqual - | TokenKind::At - | TokenKind::AtEqual - | TokenKind::Rarrow - | TokenKind::Ellipsis - | TokenKind::ColonEqual - | TokenKind::Colon - | TokenKind::And - | TokenKind::Or - | TokenKind::Not - | TokenKind::In - | TokenKind::Is - ) - } - - /// Returns `true` if this is a singleton token i.e., `True`, `False`, or `None`. - #[inline] - pub const fn is_singleton(self) -> bool { - matches!(self, TokenKind::False | TokenKind::True | TokenKind::None) - } - - /// Returns `true` if this is a trivia token i.e., a comment or a non-logical newline. - #[inline] - pub const fn is_trivia(&self) -> bool { - matches!(self, TokenKind::Comment | TokenKind::NonLogicalNewline) - } - - /// Returns `true` if this is a comment token. - #[inline] - pub const fn is_comment(&self) -> bool { - matches!(self, TokenKind::Comment) - } - - #[inline] - pub const fn is_arithmetic(self) -> bool { - matches!( - self, - TokenKind::DoubleStar - | TokenKind::Star - | TokenKind::Plus - | TokenKind::Minus - | TokenKind::Slash - | TokenKind::DoubleSlash - | TokenKind::At - ) - } - - #[inline] - pub const fn is_bitwise_or_shift(self) -> bool { - matches!( - self, - TokenKind::LeftShift - | TokenKind::LeftShiftEqual - | TokenKind::RightShift - | TokenKind::RightShiftEqual - | TokenKind::Amper - | TokenKind::AmperEqual - | TokenKind::Vbar - | TokenKind::VbarEqual - | TokenKind::CircumFlex - | TokenKind::CircumflexEqual - | TokenKind::Tilde - ) - } - - /// Returns `true` if the current token is a unary arithmetic operator. - #[inline] - pub const fn is_unary_arithmetic_operator(self) -> bool { - matches!(self, TokenKind::Plus | TokenKind::Minus) - } - - #[inline] - pub const fn is_interpolated_string_end(self) -> bool { - matches!(self, TokenKind::FStringEnd | TokenKind::TStringEnd) - } - - /// Returns the [`UnaryOp`] that corresponds to this token kind, if it is a unary arithmetic - /// operator, otherwise return [None]. - /// - /// Use [`as_unary_operator`] to match against any unary operator. - /// - /// [`as_unary_operator`]: TokenKind::as_unary_operator - #[inline] - pub const fn as_unary_arithmetic_operator(self) -> Option { - Some(match self { - TokenKind::Plus => UnaryOp::UAdd, - TokenKind::Minus => UnaryOp::USub, - _ => return None, - }) - } - - /// Returns the [`UnaryOp`] that corresponds to this token kind, if it is a unary operator, - /// otherwise return [None]. - /// - /// Use [`as_unary_arithmetic_operator`] to match against only an arithmetic unary operator. - /// - /// [`as_unary_arithmetic_operator`]: TokenKind::as_unary_arithmetic_operator - #[inline] - pub const fn as_unary_operator(self) -> Option { - Some(match self { - TokenKind::Plus => UnaryOp::UAdd, - TokenKind::Minus => UnaryOp::USub, - TokenKind::Tilde => UnaryOp::Invert, - TokenKind::Not => UnaryOp::Not, - _ => return None, - }) - } - - /// Returns the [`BoolOp`] that corresponds to this token kind, if it is a boolean operator, - /// otherwise return [None]. - #[inline] - pub const fn as_bool_operator(self) -> Option { - Some(match self { - TokenKind::And => BoolOp::And, - TokenKind::Or => BoolOp::Or, - _ => return None, - }) - } - - /// Returns the binary [`Operator`] that corresponds to the current token, if it's a binary - /// operator, otherwise return [None]. - /// - /// Use [`as_augmented_assign_operator`] to match against an augmented assignment token. - /// - /// [`as_augmented_assign_operator`]: TokenKind::as_augmented_assign_operator - pub const fn as_binary_operator(self) -> Option { - Some(match self { - TokenKind::Plus => Operator::Add, - TokenKind::Minus => Operator::Sub, - TokenKind::Star => Operator::Mult, - TokenKind::At => Operator::MatMult, - TokenKind::DoubleStar => Operator::Pow, - TokenKind::Slash => Operator::Div, - TokenKind::DoubleSlash => Operator::FloorDiv, - TokenKind::Percent => Operator::Mod, - TokenKind::Amper => Operator::BitAnd, - TokenKind::Vbar => Operator::BitOr, - TokenKind::CircumFlex => Operator::BitXor, - TokenKind::LeftShift => Operator::LShift, - TokenKind::RightShift => Operator::RShift, - _ => return None, - }) - } - - /// Returns the [`Operator`] that corresponds to this token kind, if it is - /// an augmented assignment operator, or [`None`] otherwise. - #[inline] - pub const fn as_augmented_assign_operator(self) -> Option { - Some(match self { - TokenKind::PlusEqual => Operator::Add, - TokenKind::MinusEqual => Operator::Sub, - TokenKind::StarEqual => Operator::Mult, - TokenKind::AtEqual => Operator::MatMult, - TokenKind::DoubleStarEqual => Operator::Pow, - TokenKind::SlashEqual => Operator::Div, - TokenKind::DoubleSlashEqual => Operator::FloorDiv, - TokenKind::PercentEqual => Operator::Mod, - TokenKind::AmperEqual => Operator::BitAnd, - TokenKind::VbarEqual => Operator::BitOr, - TokenKind::CircumflexEqual => Operator::BitXor, - TokenKind::LeftShiftEqual => Operator::LShift, - TokenKind::RightShiftEqual => Operator::RShift, - _ => return None, - }) - } -} - -impl From for TokenKind { - #[inline] - fn from(op: BoolOp) -> Self { - match op { - BoolOp::And => TokenKind::And, - BoolOp::Or => TokenKind::Or, - } - } -} - -impl From for TokenKind { - #[inline] - fn from(op: UnaryOp) -> Self { - match op { - UnaryOp::Invert => TokenKind::Tilde, - UnaryOp::Not => TokenKind::Not, - UnaryOp::UAdd => TokenKind::Plus, - UnaryOp::USub => TokenKind::Minus, - } - } -} - -impl From for TokenKind { - #[inline] - fn from(op: Operator) -> Self { - match op { - Operator::Add => TokenKind::Plus, - Operator::Sub => TokenKind::Minus, - Operator::Mult => TokenKind::Star, - Operator::MatMult => TokenKind::At, - Operator::Div => TokenKind::Slash, - Operator::Mod => TokenKind::Percent, - Operator::Pow => TokenKind::DoubleStar, - Operator::LShift => TokenKind::LeftShift, - Operator::RShift => TokenKind::RightShift, - Operator::BitOr => TokenKind::Vbar, - Operator::BitXor => TokenKind::CircumFlex, - Operator::BitAnd => TokenKind::Amper, - Operator::FloorDiv => TokenKind::DoubleSlash, - } - } -} - -impl fmt::Display for TokenKind { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let value = match self { - TokenKind::Unknown => "Unknown", - TokenKind::Newline => "newline", - TokenKind::NonLogicalNewline => "NonLogicalNewline", - TokenKind::Indent => "indent", - TokenKind::Dedent => "dedent", - TokenKind::EndOfFile => "end of file", - TokenKind::Name => "name", - TokenKind::Int => "int", - TokenKind::Float => "float", - TokenKind::Complex => "complex", - TokenKind::String => "string", - TokenKind::FStringStart => "FStringStart", - TokenKind::FStringMiddle => "FStringMiddle", - TokenKind::FStringEnd => "FStringEnd", - TokenKind::TStringStart => "TStringStart", - TokenKind::TStringMiddle => "TStringMiddle", - TokenKind::TStringEnd => "TStringEnd", - TokenKind::IpyEscapeCommand => "IPython escape command", - TokenKind::Comment => "comment", - TokenKind::Question => "`?`", - TokenKind::Exclamation => "`!`", - TokenKind::Lpar => "`(`", - TokenKind::Rpar => "`)`", - TokenKind::Lsqb => "`[`", - TokenKind::Rsqb => "`]`", - TokenKind::Lbrace => "`{`", - TokenKind::Rbrace => "`}`", - TokenKind::Equal => "`=`", - TokenKind::ColonEqual => "`:=`", - TokenKind::Dot => "`.`", - TokenKind::Colon => "`:`", - TokenKind::Semi => "`;`", - TokenKind::Comma => "`,`", - TokenKind::Rarrow => "`->`", - TokenKind::Plus => "`+`", - TokenKind::Minus => "`-`", - TokenKind::Star => "`*`", - TokenKind::DoubleStar => "`**`", - TokenKind::Slash => "`/`", - TokenKind::DoubleSlash => "`//`", - TokenKind::Percent => "`%`", - TokenKind::Vbar => "`|`", - TokenKind::Amper => "`&`", - TokenKind::CircumFlex => "`^`", - TokenKind::LeftShift => "`<<`", - TokenKind::RightShift => "`>>`", - TokenKind::Tilde => "`~`", - TokenKind::At => "`@`", - TokenKind::Less => "`<`", - TokenKind::Greater => "`>`", - TokenKind::EqEqual => "`==`", - TokenKind::NotEqual => "`!=`", - TokenKind::LessEqual => "`<=`", - TokenKind::GreaterEqual => "`>=`", - TokenKind::PlusEqual => "`+=`", - TokenKind::MinusEqual => "`-=`", - TokenKind::StarEqual => "`*=`", - TokenKind::DoubleStarEqual => "`**=`", - TokenKind::SlashEqual => "`/=`", - TokenKind::DoubleSlashEqual => "`//=`", - TokenKind::PercentEqual => "`%=`", - TokenKind::VbarEqual => "`|=`", - TokenKind::AmperEqual => "`&=`", - TokenKind::CircumflexEqual => "`^=`", - TokenKind::LeftShiftEqual => "`<<=`", - TokenKind::RightShiftEqual => "`>>=`", - TokenKind::AtEqual => "`@=`", - TokenKind::Ellipsis => "`...`", - TokenKind::False => "`False`", - TokenKind::None => "`None`", - TokenKind::True => "`True`", - TokenKind::And => "`and`", - TokenKind::As => "`as`", - TokenKind::Assert => "`assert`", - TokenKind::Async => "`async`", - TokenKind::Await => "`await`", - TokenKind::Break => "`break`", - TokenKind::Class => "`class`", - TokenKind::Continue => "`continue`", - TokenKind::Def => "`def`", - TokenKind::Del => "`del`", - TokenKind::Elif => "`elif`", - TokenKind::Else => "`else`", - TokenKind::Except => "`except`", - TokenKind::Finally => "`finally`", - TokenKind::For => "`for`", - TokenKind::From => "`from`", - TokenKind::Global => "`global`", - TokenKind::If => "`if`", - TokenKind::Import => "`import`", - TokenKind::In => "`in`", - TokenKind::Is => "`is`", - TokenKind::Lambda => "`lambda`", - TokenKind::Nonlocal => "`nonlocal`", - TokenKind::Not => "`not`", - TokenKind::Or => "`or`", - TokenKind::Pass => "`pass`", - TokenKind::Raise => "`raise`", - TokenKind::Return => "`return`", - TokenKind::Try => "`try`", - TokenKind::While => "`while`", - TokenKind::Match => "`match`", - TokenKind::Type => "`type`", - TokenKind::Case => "`case`", - TokenKind::With => "`with`", - TokenKind::Yield => "`yield`", - }; - f.write_str(value) - } -} - -bitflags! { - #[derive(Clone, Copy, Debug, PartialEq, Eq)] - pub(crate) struct TokenFlags: u16 { - /// The token is a string with double quotes (`"`). - const DOUBLE_QUOTES = 1 << 0; - /// The token is a triple-quoted string i.e., it starts and ends with three consecutive - /// quote characters (`"""` or `'''`). - const TRIPLE_QUOTED_STRING = 1 << 1; - - /// The token is a unicode string i.e., prefixed with `u` or `U` - const UNICODE_STRING = 1 << 2; - /// The token is a byte string i.e., prefixed with `b` or `B` - const BYTE_STRING = 1 << 3; - /// The token is an f-string i.e., prefixed with `f` or `F` - const F_STRING = 1 << 4; - /// The token is a t-string i.e., prefixed with `t` or `T` - const T_STRING = 1 << 5; - /// The token is a raw string and the prefix character is in lowercase. - const RAW_STRING_LOWERCASE = 1 << 6; - /// The token is a raw string and the prefix character is in uppercase. - const RAW_STRING_UPPERCASE = 1 << 7; - /// String without matching closing quote(s) - const UNCLOSED_STRING = 1 << 8; - - /// The token is a raw string i.e., prefixed with `r` or `R` - const RAW_STRING = Self::RAW_STRING_LOWERCASE.bits() | Self::RAW_STRING_UPPERCASE.bits(); - - } -} - -impl get_size2::GetSize for TokenFlags {} - -impl StringFlags for TokenFlags { - fn quote_style(self) -> Quote { - if self.intersects(TokenFlags::DOUBLE_QUOTES) { - Quote::Double - } else { - Quote::Single - } - } - - fn triple_quotes(self) -> TripleQuotes { - if self.intersects(TokenFlags::TRIPLE_QUOTED_STRING) { - TripleQuotes::Yes - } else { - TripleQuotes::No - } - } - - fn prefix(self) -> AnyStringPrefix { - if self.intersects(TokenFlags::F_STRING) { - if self.intersects(TokenFlags::RAW_STRING_LOWERCASE) { - AnyStringPrefix::Format(FStringPrefix::Raw { uppercase_r: false }) - } else if self.intersects(TokenFlags::RAW_STRING_UPPERCASE) { - AnyStringPrefix::Format(FStringPrefix::Raw { uppercase_r: true }) - } else { - AnyStringPrefix::Format(FStringPrefix::Regular) - } - } else if self.intersects(TokenFlags::T_STRING) { - if self.intersects(TokenFlags::RAW_STRING_LOWERCASE) { - AnyStringPrefix::Template(TStringPrefix::Raw { uppercase_r: false }) - } else if self.intersects(TokenFlags::RAW_STRING_UPPERCASE) { - AnyStringPrefix::Template(TStringPrefix::Raw { uppercase_r: true }) - } else { - AnyStringPrefix::Template(TStringPrefix::Regular) - } - } else if self.intersects(TokenFlags::BYTE_STRING) { - if self.intersects(TokenFlags::RAW_STRING_LOWERCASE) { - AnyStringPrefix::Bytes(ByteStringPrefix::Raw { uppercase_r: false }) - } else if self.intersects(TokenFlags::RAW_STRING_UPPERCASE) { - AnyStringPrefix::Bytes(ByteStringPrefix::Raw { uppercase_r: true }) - } else { - AnyStringPrefix::Bytes(ByteStringPrefix::Regular) - } - } else if self.intersects(TokenFlags::RAW_STRING_LOWERCASE) { - AnyStringPrefix::Regular(StringLiteralPrefix::Raw { uppercase: false }) - } else if self.intersects(TokenFlags::RAW_STRING_UPPERCASE) { - AnyStringPrefix::Regular(StringLiteralPrefix::Raw { uppercase: true }) - } else if self.intersects(TokenFlags::UNICODE_STRING) { - AnyStringPrefix::Regular(StringLiteralPrefix::Unicode) - } else { - AnyStringPrefix::Regular(StringLiteralPrefix::Empty) - } - } - - fn is_unclosed(self) -> bool { - self.intersects(TokenFlags::UNCLOSED_STRING) - } -} - -impl TokenFlags { - /// Returns `true` if the token is an f-string. - pub(crate) const fn is_f_string(self) -> bool { - self.intersects(TokenFlags::F_STRING) - } - - /// Returns `true` if the token is a t-string. - pub(crate) const fn is_t_string(self) -> bool { - self.intersects(TokenFlags::T_STRING) - } - - /// Returns `true` if the token is a t-string. - pub(crate) const fn is_interpolated_string(self) -> bool { - self.intersects(TokenFlags::T_STRING.union(TokenFlags::F_STRING)) - } - - /// Returns `true` if the token is a triple-quoted t-string. - pub(crate) fn is_triple_quoted_interpolated_string(self) -> bool { - self.intersects(TokenFlags::TRIPLE_QUOTED_STRING) && self.is_interpolated_string() - } - - /// Returns `true` if the token is a raw string. - pub(crate) const fn is_raw_string(self) -> bool { - self.intersects(TokenFlags::RAW_STRING) - } -} +use ruff_python_ast::{Int, IpyEscapeKind, name::Name}; #[derive(Clone, Debug, Default)] pub(crate) enum TokenValue { diff --git a/crates/ruff_python_parser/src/token_set.rs b/crates/ruff_python_parser/src/token_set.rs index 843fe53faa..7ced27a8fb 100644 --- a/crates/ruff_python_parser/src/token_set.rs +++ b/crates/ruff_python_parser/src/token_set.rs @@ -1,4 +1,4 @@ -use crate::TokenKind; +use ruff_python_ast::token::TokenKind; /// A bit-set of `TokenKind`s #[derive(Clone, Copy)] @@ -42,7 +42,7 @@ impl From<[TokenKind; N]> for TokenSet { #[test] fn token_set_works_for_tokens() { - use crate::TokenKind::*; + use ruff_python_ast::token::TokenKind::*; let mut ts = TokenSet::new([EndOfFile, Name]); assert!(ts.contains(EndOfFile)); assert!(ts.contains(Name)); diff --git a/crates/ruff_python_parser/src/token_source.rs b/crates/ruff_python_parser/src/token_source.rs index f24fb4771f..e5755806e3 100644 --- a/crates/ruff_python_parser/src/token_source.rs +++ b/crates/ruff_python_parser/src/token_source.rs @@ -1,10 +1,11 @@ +use ruff_python_ast::token::{Token, TokenFlags, TokenKind}; use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::Mode; use crate::error::LexicalError; use crate::lexer::{Lexer, LexerCheckpoint}; use crate::string::InterpolatedStringKind; -use crate::token::{Token, TokenFlags, TokenKind, TokenValue}; +use crate::token::TokenValue; /// Token source for the parser that skips over any trivia tokens. #[derive(Debug)] diff --git a/crates/ruff_python_parser/tests/fixtures.rs b/crates/ruff_python_parser/tests/fixtures.rs index 2de49e6d68..8f9a2994db 100644 --- a/crates/ruff_python_parser/tests/fixtures.rs +++ b/crates/ruff_python_parser/tests/fixtures.rs @@ -5,13 +5,14 @@ use std::fs; use std::path::Path; use ruff_annotate_snippets::{Level, Renderer, Snippet}; +use ruff_python_ast::token::Token; use ruff_python_ast::visitor::Visitor; use ruff_python_ast::visitor::source_order::{SourceOrderVisitor, TraversalSignal, walk_module}; use ruff_python_ast::{self as ast, AnyNodeRef, Mod, PythonVersion}; use ruff_python_parser::semantic_errors::{ SemanticSyntaxChecker, SemanticSyntaxContext, SemanticSyntaxError, }; -use ruff_python_parser::{Mode, ParseErrorType, ParseOptions, Token, parse_unchecked}; +use ruff_python_parser::{Mode, ParseErrorType, ParseOptions, parse_unchecked}; use ruff_source_file::{LineIndex, OneIndexed, SourceCode}; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; diff --git a/crates/ty_ide/Cargo.toml b/crates/ty_ide/Cargo.toml index 4be5d49fe2..a7665b32ca 100644 --- a/crates/ty_ide/Cargo.toml +++ b/crates/ty_ide/Cargo.toml @@ -19,7 +19,6 @@ ruff_memory_usage = { workspace = true } ruff_python_ast = { workspace = true } ruff_python_codegen = { workspace = true } ruff_python_importer = { workspace = true } -ruff_python_parser = { workspace = true } ruff_python_trivia = { workspace = true } ruff_source_file = { workspace = true } ruff_text_size = { workspace = true } @@ -37,6 +36,8 @@ smallvec = { workspace = true } tracing = { workspace = true } [dev-dependencies] +ruff_python_parser = { workspace = true } + camino = { workspace = true } insta = { workspace = true, features = ["filters"] } diff --git a/crates/ty_ide/src/completion.rs b/crates/ty_ide/src/completion.rs index 811c2f6aef..ae8e75cb9d 100644 --- a/crates/ty_ide/src/completion.rs +++ b/crates/ty_ide/src/completion.rs @@ -5,9 +5,9 @@ use ruff_db::parsed::{ParsedModuleRef, parsed_module}; use ruff_db::source::source_text; use ruff_diagnostics::Edit; use ruff_python_ast::name::Name; +use ruff_python_ast::token::{Token, TokenAt, TokenKind, Tokens}; use ruff_python_ast::{self as ast, AnyNodeRef}; use ruff_python_codegen::Stylist; -use ruff_python_parser::{Token, TokenAt, TokenKind, Tokens}; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use ty_python_semantic::types::UnionType; use ty_python_semantic::{ @@ -1557,7 +1557,8 @@ fn compare_suggestions(c1: &Completion, c2: &Completion) -> Ordering { #[cfg(test)] mod tests { use insta::assert_snapshot; - use ruff_python_parser::{Mode, ParseOptions, TokenKind, Tokens}; + use ruff_python_ast::token::{TokenKind, Tokens}; + use ruff_python_parser::{Mode, ParseOptions}; use ty_python_semantic::ModuleName; use crate::completion::{Completion, completion}; diff --git a/crates/ty_ide/src/goto.rs b/crates/ty_ide/src/goto.rs index 17df9f11d9..359438bca3 100644 --- a/crates/ty_ide/src/goto.rs +++ b/crates/ty_ide/src/goto.rs @@ -8,8 +8,8 @@ use std::borrow::Cow; use crate::find_node::covering_node; use crate::stub_mapping::StubMapper; use ruff_db::parsed::ParsedModuleRef; +use ruff_python_ast::token::{TokenKind, Tokens}; use ruff_python_ast::{self as ast, AnyNodeRef}; -use ruff_python_parser::{TokenKind, Tokens}; use ruff_text_size::{Ranged, TextRange, TextSize}; use ty_python_semantic::ResolvedDefinition; diff --git a/crates/ty_ide/src/importer.rs b/crates/ty_ide/src/importer.rs index 94b2457e74..bf75157147 100644 --- a/crates/ty_ide/src/importer.rs +++ b/crates/ty_ide/src/importer.rs @@ -24,10 +24,10 @@ use ruff_db::source::source_text; use ruff_diagnostics::Edit; use ruff_python_ast as ast; use ruff_python_ast::name::Name; +use ruff_python_ast::token::Tokens; use ruff_python_ast::visitor::source_order::{SourceOrderVisitor, TraversalSignal, walk_stmt}; use ruff_python_codegen::Stylist; use ruff_python_importer::Insertion; -use ruff_python_parser::{Parsed, Tokens}; use ruff_text_size::{Ranged, TextRange, TextSize}; use ty_project::Db; use ty_python_semantic::semantic_index::definition::DefinitionKind; @@ -76,7 +76,7 @@ impl<'a> Importer<'a> { source: &'a str, parsed: &'a ParsedModuleRef, ) -> Self { - let imports = TopLevelImports::find(parsed); + let imports = TopLevelImports::find(parsed.syntax()); Self { db, @@ -749,9 +749,9 @@ struct TopLevelImports<'ast> { impl<'ast> TopLevelImports<'ast> { /// Find all top-level imports from the given AST of a Python module. - fn find(parsed: &'ast Parsed) -> Vec> { + fn find(module: &'ast ast::ModModule) -> Vec> { let mut visitor = TopLevelImports::default(); - visitor.visit_body(parsed.suite()); + visitor.visit_body(&module.body); visitor.imports } } diff --git a/crates/ty_ide/src/references.rs b/crates/ty_ide/src/references.rs index 27f1a3f2cb..d759b1daed 100644 --- a/crates/ty_ide/src/references.rs +++ b/crates/ty_ide/src/references.rs @@ -14,11 +14,11 @@ use crate::find_node::CoveringNode; use crate::goto::GotoTarget; use crate::{Db, NavigationTargets, ReferenceKind, ReferenceTarget}; use ruff_db::files::File; +use ruff_python_ast::token::Tokens; use ruff_python_ast::{ self as ast, AnyNodeRef, visitor::source_order::{SourceOrderVisitor, TraversalSignal}, }; -use ruff_python_parser::Tokens; use ruff_text_size::{Ranged, TextRange}; use ty_python_semantic::{ImportAliasResolution, SemanticModel}; diff --git a/crates/ty_ide/src/signature_help.rs b/crates/ty_ide/src/signature_help.rs index 1f7041eaab..d79f298dd6 100644 --- a/crates/ty_ide/src/signature_help.rs +++ b/crates/ty_ide/src/signature_help.rs @@ -11,8 +11,8 @@ use crate::goto::Definitions; use crate::{Db, find_node::covering_node}; use ruff_db::files::File; use ruff_db::parsed::parsed_module; +use ruff_python_ast::token::TokenKind; use ruff_python_ast::{self as ast, AnyNodeRef}; -use ruff_python_parser::TokenKind; use ruff_text_size::{Ranged, TextRange, TextSize}; use ty_python_semantic::ResolvedDefinition; use ty_python_semantic::SemanticModel; @@ -381,7 +381,7 @@ mod tests { f = func_a else: f = func_b - + f( "#, ); @@ -426,10 +426,10 @@ mod tests { @overload def process(value: int) -> str: ... - + @overload def process(value: str) -> int: ... - + def process(value): if isinstance(value, int): return str(value) @@ -826,10 +826,10 @@ def ab(a: int, *, c: int): r#" class Point: """A simple point class representing a 2D coordinate.""" - + def __init__(self, x: int, y: int): """Initialize a point with x and y coordinates. - + Args: x: The x-coordinate y: The y-coordinate @@ -961,12 +961,12 @@ def ab(a: int, *, c: int): r#" from typing import overload - @overload + @overload def process(value: int) -> str: ... - + @overload def process(value: str, flag: bool) -> int: ... - + def process(value, flag=None): if isinstance(value, int): return str(value) diff --git a/crates/ty_python_semantic/src/suppression.rs b/crates/ty_python_semantic/src/suppression.rs index c0524728a2..fd8df281e0 100644 --- a/crates/ty_python_semantic/src/suppression.rs +++ b/crates/ty_python_semantic/src/suppression.rs @@ -15,7 +15,7 @@ use ruff_db::diagnostic::{ }; use ruff_db::{files::File, parsed::parsed_module, source::source_text}; use ruff_diagnostics::{Edit, Fix}; -use ruff_python_parser::TokenKind; +use ruff_python_ast::token::TokenKind; use ruff_python_trivia::Cursor; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize};