Skip to content

don't add redundant types to unions to prevent unnecessary unknown/any errors#447

Draft
DetachHead wants to merge 9 commits intomainfrom
fix-unknown-error-after-narrowing
Draft

don't add redundant types to unions to prevent unnecessary unknown/any errors#447
DetachHead wants to merge 9 commits intomainfrom
fix-unknown-error-after-narrowing

Conversation

@DetachHead
Copy link
Owner

fixes #71

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from a1c2a7f to ea424af Compare June 25, 2024 12:56
@DetachHead DetachHead changed the title don't add narrowed type from if statement to union after the statement is over because it has no effect other than creating unknown/any errors unnecessarily don't add redundant types to unions to prevent unnecessary unknown/any errors Jun 25, 2024
@github-actions

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch 2 times, most recently from d519876 to 4289d78 Compare June 29, 2024 03:06
@github-actions

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from 4289d78 to d779f74 Compare June 29, 2024 04:53
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from e95fd17 to 3a9ab80 Compare June 30, 2024 04:21
@github-actions

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from 3a9ab80 to 43d9ac5 Compare June 30, 2024 06:32
@github-actions

This comment has been minimized.

@DetachHead DetachHead marked this pull request as draft June 30, 2024 10:11
@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from 43d9ac5 to 2926479 Compare May 23, 2025 09:41
@github-actions

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from e678835 to eeaa6cb Compare May 24, 2025 03:04
@DetachHead DetachHead marked this pull request as ready for review May 24, 2025 03:05
@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from d086245 to ccfcfe4 Compare May 24, 2025 03:38
@github-actions

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from ccfcfe4 to 15f69b1 Compare May 25, 2025 07:16
… if statement as they can lead to unnecessary `reportUnknown...` errors
@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from 15f69b1 to 409a891 Compare May 25, 2025 07:48
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch 5 times, most recently from 132f854 to 78159e7 Compare May 28, 2025 11:12
@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from 78159e7 to 64671c1 Compare May 28, 2025 11:18
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

starlette (https://github.com/encode/starlette)
+   ...:73:55 - error: Argument of type "str | None" cannot be assigned to parameter "name" of type "str" in function "url_for"
+     Type "str | None" is not assignable to type "str"
+       "None" is not assignable to "str" (reportArgumentType)
+   ...:90:55 - error: Argument of type "str | None" cannot be assigned to parameter "name" of type "str" in function "url_for"
+     Type "str | None" is not assignable to type "str"
+       "None" is not assignable to "str" (reportArgumentType)
+   ...:159:27 - error: Invalid exception class or object
+     "None" does not derive from BaseException (reportGeneralTypeIssues)
- 184 errors, 4145 warnings, 0 notes
+ 187 errors, 4145 warnings, 0 notes

paasta (https://github.com/yelp/paasta)
+   ...:284:14 - error: "config" is not a known attribute of "None" (reportOptionalMemberAccess)
+   ...:74:18 - error: "log_line" is not a known attribute of "None" (reportOptionalMemberAccess)
-   ...:822:5 - warning: Return type, "Unknown | Literal[0, 3]", is partially unknown (reportUnknownParameterType)
+   ...:822:5 - warning: Return type, "Unknown | int", is partially unknown (reportUnknownParameterType)
-   ...:1105:12 - warning: Return type, "Unknown | Literal[0, 3]", is partially unknown (reportUnknownVariableType)
+   ...:1105:12 - warning: Return type, "Unknown | int", is partially unknown (reportUnknownVariableType)
-   ...:1265:12 - warning: Return type, "Unknown | Literal[0, 3]", is partially unknown (reportUnknownVariableType)
+   ...:1265:12 - warning: Return type, "Unknown | int", is partially unknown (reportUnknownVariableType)
+   ...:245:24 - error: "events" is not a known attribute of "None" (reportOptionalMemberAccess)
+   ...:249:34 - error: "create_counter" is not a known attribute of "None" (reportOptionalMemberAccess)
+   ...:270:10 - error: "config" is not a known attribute of "None" (reportOptionalMemberAccess)
-   ...:857:27 - error: Argument of type "list[Unknown] | dict[Unknown, Unknown] | Unknown | int | float" cannot be assigned to parameter "string" of type "ReadableBuffer" in function "search"
+   ...:857:27 - error: Argument of type "Unknown | int | float" cannot be assigned to parameter "string" of type "ReadableBuffer" in function "search"
-     Type "list[Unknown] | dict[Unknown, Unknown] | Unknown | int | float" is not assignable to type "ReadableBuffer"
+     Type "Unknown | int | float" is not assignable to type "ReadableBuffer"
-   ...:1467:12 - warning: Return type, "list[Unknown] | dict[Unknown, Unknown] | Unknown", is partially unknown (reportUnknownVariableType)
+   ...:1467:12 - warning: Return type is unknown (reportUnknownVariableType)
-   ...:32:9 - warning: Type of "token" is unknown (reportUnknownMemberType)
-   ...:36:12 - warning: Type of "token" is unknown (reportUnknownMemberType)
-   ...:54:12 - warning: Type of "token" is unknown (reportUnknownMemberType)
- 1559 errors, 24200 warnings, 0 notes
+ 1564 errors, 24197 warnings, 0 notes

jinja (https://github.com/pallets/jinja)
+   ...:43:23 - error: Type "str | Undefined | None" is not assignable to declared type "str | None"
+     Type "str | Undefined | None" is not assignable to type "str | None"
+       Type "Undefined" is not assignable to type "str | None"
+         "Undefined" is not assignable to "str"
+         "Undefined" is not assignable to "None" (reportAssignmentType)
+   ...:79:20 - error: Object of type "None" cannot be called (reportOptionalCall)
+   ...:118:26 - error: Object of type "None" cannot be called (reportOptionalCall)
- 46 errors, 15 warnings, 0 notes
+ 49 errors, 15 warnings, 0 notes

setuptools (https://github.com/pypa/setuptools)
+ ...
+   ...:25:13 - error: Object of type "None" cannot be called (reportOptionalCall)
+   ...:407:24 - error: Object of type "None" cannot be called (reportOptionalCall)
- 0 errors, 415 warnings, 0 notes
+ 2 errors, 415 warnings, 0 notes

poetry (https://github.com/python-poetry/poetry)
+   ...:196:13 - warning: Type of "build_system_version" is partially unknown
+     Type of "build_system_version" is "str | Unknown" (reportUnknownVariableType)
+   ...:196:36 - error: Operator "+" not supported for types "Literal['>=']" and "str | None"
+     Operator "+" not supported for types "Literal['>=']" and "None" (reportOperatorIssue)
+   ...:199:17 - warning: Type of "build_system_version" is partially unknown
+     Type of "build_system_version" is "str | Unknown" (reportUnknownVariableType)
+   ...:200:13 - warning: Type of "build_system_version" is partially unknown
+     Type of "build_system_version" is "str | Unknown" (reportUnknownVariableType)
+   ...:200:37 - error: Operator "+" not supported for types "Literal['<']" and "str | None"
+     Operator "+" not supported for types "Literal['<']" and "None" (reportOperatorIssue)
- 1241 errors, 21473 warnings, 0 notes
+ 1243 errors, 21476 warnings, 0 notes

mkosi (https://github.com/systemd/mkosi)
+   ...:675:12 - error: Type "bool | None" is not assignable to return type "bool"
+     Type "bool | None" is not assignable to type "bool"
+       "None" is not assignable to "bool" (reportReturnType)
+   ...:1148:26 - error: Argument of type "((T@config_make_list_parser) -> Any) | None" cannot be assigned to parameter "key" of type "(T@config_make_list_parser) -> SupportsRichComparison" in function "sort"
+     Type "((T@config_make_list_parser) -> Any) | None" is not assignable to type "(T@config_make_list_parser) -> SupportsRichComparison"
+       Type "None" is not assignable to type "(T@config_make_list_parser) -> SupportsRichComparison" (reportArgumentType)
+   ...:371:9 - error: Type "list[Path | str | None]" is not assignable to declared type "list[PathString]"
+     Type "Path | None" is not assignable to type "PathString"
+       Type "None" is not assignable to type "PathString"
+         "None" is not assignable to "Path"
+         "None" is not assignable to "str" (reportAssignmentType)
- 13 errors, 1337 warnings, 0 notes
+ 16 errors, 1337 warnings, 0 notes

ibis (https://github.com/ibis-project/ibis)
+   ...:122:29 - error: Object of type "None" cannot be called (reportOptionalCall)
+   ...:132:54 - error: Object of type "None" cannot be called (reportOptionalCall)
+   ...:33:26 - error: Object of type "None" cannot be called (reportOptionalCall)
-   ...:53:22 - warning: Argument type is partially unknown
+   ...:53:22 - warning: Argument type is unknown
-     Argument corresponds to parameter "iterable" in function "join"
+     Argument corresponds to parameter "iterable" in function "join" (reportUnknownArgumentType)
-     Argument type is "str | Unknown" (reportUnknownArgumentType)
-   ...:176:39 - warning: Argument type is partially unknown
+   ...:176:39 - warning: Argument type is unknown
-     Argument corresponds to parameter "name" in function "getattr"
+     Argument corresponds to parameter "name" in function "getattr" (reportUnknownArgumentType)
-     Argument type is "Unknown | Literal['tumble']" (reportUnknownArgumentType)
+   ...:355:20 - warning: Argument type is unknown
+     Argument corresponds to parameter "o" in function "getattr" (reportUnknownArgumentType)
+   ...:92:41 - warning: Argument type is unknown
+     Argument corresponds to parameter "how" in function "check_eq" (reportUnknownArgumentType)
-   ...:158:59 - warning: Argument type is partially unknown
+   ...:158:59 - warning: Argument type is unknown
-     Argument corresponds to parameter "dialect" in function "to_sql"
+     Argument corresponds to parameter "dialect" in function "to_sql" (reportUnknownArgumentType)
-     Argument type is "Unknown | Literal['snowflake']" (reportUnknownArgumentType)
-   ...:325:16 - error: Argument of type "SchemaLike | <subclass of Schema and type> | <subclass of Mapping[str, str | DataType] and type> | <subclass of Iterable[tuple[str, str | DataType]] and type> | None" cannot be assigned to parameter "schema" of type "Schema" in function "__init__"
-     Type "SchemaLike | <subclass of Schema and type> | <subclass of Mapping[str, str | DataType] and type> | <subclass of Iterable[tuple[str, str | DataType]] and type> | None" is not assignable to type "Schema"
+   ...:325:16 - error: Argument of type "SchemaLike | None" cannot be assigned to parameter "schema" of type "Schema" in function "__init__"
+     Type "SchemaLike | None" is not assignable to type "Schema"
-   ...:262:28 - warning: Type of "schema" is partially unknown
-     Type of "schema" is "Schema | Unknown" (reportUnknownMemberType)
+   ...:262:28 - warning: Type of "schema" is unknown (reportUnknownMemberType)
+   ...:262:28 - warning: Argument type is unknown
+     Argument corresponds to parameter "schema" in function "render_schema" (reportUnknownArgumentType)
-   ...:860:20 - error: Argument of type "ArrayValue | Sequence[str | StringValue]" cannot be assigned to parameter "arg" of type "Value[Array[String], Any]" in function "__init__"
+   ...:860:20 - error: Argument of type "Sequence[str | StringValue] | ArrayValue" cannot be assigned to parameter "arg" of type "Value[Array[String], Any]" in function "__init__"
-     Type "ArrayValue | Sequence[str | StringValue]" is not assignable to type "Value[Array[String], Any]"
+     Type "Sequence[str | StringValue] | ArrayValue" is not assignable to type "Value[Array[String], Any]"
-   ...:860:20 - error: Argument of type "ArrayValue | Sequence[str | StringValue]" cannot be assigned to parameter "arg" of type "VarTuple[Value[String, Any]]" in function "__init__"
+   ...:860:20 - error: Argument of type "Sequence[str | StringValue] | ArrayValue" cannot be assigned to parameter "arg" of type "VarTuple[Value[String, Any]]" in function "__init__"
-     Type "ArrayValue | Sequence[str | StringValue]" is not assignable to type "VarTuple[Value[String, Any]]"
+     Type "Sequence[str | StringValue] | ArrayValue" is not assignable to type "VarTuple[Value[String, Any]]"
-   ...:163:53 - error: Argument of type "Node | Relation" cannot be assigned to parameter of type "Node"
+   ...:163:53 - error: Argument of type "Node" cannot be assigned to parameter of type "Node"
-     Type "Node | Relation" is not assignable to type "Node"
-       "ibis.common.graph.Node" is not assignable to "ibis.expr.operations.core.Node" (reportArgumentType)
+     "ibis.common.graph.Node" is not assignable to "ibis.expr.operations.core.Node" (reportArgumentType)
-     Argument type is "tuple[type[Sequence[object]]* | type[Mapping[Unknown, object]]* | type[AbstractSet[object]]* | type[object]*, tuple[object, ...]* | tuple[tuple[Unknown, object], ...] | frozenset[object]* | int*]" (reportUnknownArgumentType)
+     Argument type is "tuple[type[object]*, tuple[object, ...]* | tuple[tuple[Unknown, object], ...] | frozenset[object]* | int*]" (reportUnknownArgumentType)
-   ...:620:32 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "o" in function "__init__"
-     Argument type is "Sequence[object]* | Mapping[Unknown, object]* | AbstractSet[object]* | object*" (reportUnknownArgumentType)
- 8275 errors, 109672 warnings, 0 notes
+ 8278 errors, 109674 warnings, 0 notes

psycopg (https://github.com/psycopg/psycopg)
+   ...:366:33 - warning: Argument type is unknown
+     Argument corresponds to parameter "name" in function "getattr" (reportUnknownArgumentType)
+   ...:372:33 - warning: Argument type is unknown
+     Argument corresponds to parameter "name" in function "getattr" (reportUnknownArgumentType)
+   ...:91:19 - error: "group" is not a known attribute of "None" (reportOptionalMemberAccess)
+   ...:92:16 - error: "group" is not a known attribute of "None" (reportOptionalMemberAccess)
+   ...:93:49 - error: "groups" is not a known attribute of "None" (reportOptionalMemberAccess)
- 1818 errors, 35314 warnings, 0 notes
+ 1821 errors, 35316 warnings, 0 notes

mkdocs (https://github.com/mkdocs/mkdocs)
-   ...:145:39 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "value" in function "run_validation"
-     Argument type is "dict[Unknown, Unknown] | object" (reportUnknownArgumentType)
+   ...:440:31 - error: "encode" is not a known attribute of "None" (reportOptionalMemberAccess)
+   ...:464:31 - error: "decode" is not a known attribute of "None" (reportOptionalMemberAccess)
-   ...:234:17 - error: Cannot access attribute "children" for class "object*"
-     Attribute "children" is unknown (reportAttributeAccessIssue)
-   ...:235:42 - error: Cannot access attribute "children" for class "object*"
-     Attribute "children" is unknown (reportAttributeAccessIssue)
- 326 errors, 5181 warnings, 0 notes
+ 326 errors, 5180 warnings, 0 notes

AutoSplit (https://github.com/Toufool/AutoSplit)
+   ...:996:23 - error: "accept" is not a known attribute of "None" (reportOptionalMemberAccess)
- 1145 errors, 23 warnings, 7 notes
+ 1146 errors, 23 warnings, 7 notes

sympy (https://github.com/sympy/sympy)
-     Type of "var" is "(names: Unknown, **args: Unknown) -> (<subclass of tuple[Symbol, ...] and Basic> | <subclass of tuple[Symbol, ...] and FunctionClass> | tuple[Symbol, ...])" (reportUnknownVariableType)
+     Type of "var" is "(names: Unknown, **args: Unknown) -> tuple[Symbol, ...]" (reportUnknownVariableType)
-     Type of "postorder_traversal" is "(node: Unknown, keys: Unknown | None = None) -> Generator[Unknown | Basic, Unknown, None]" (reportUnknownVariableType)
+     Type of "postorder_traversal" is "(node: Unknown, keys: Unknown | None = None) -> Generator[Unknown, Unknown, None]" (reportUnknownVariableType)
-     Type of "trigsimp" is "(expr: Unknown, inverse: bool = False, **opts: Unknown) -> (Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType)" (reportUnknownVariableType)
+     Type of "trigsimp" is "(expr: Unknown, inverse: bool = False, **opts: Unknown) -> (Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType)" (reportUnknownVariableType)
-     Type of "imageset" is "(*args: Unknown) -> (Unknown | Basic | ImageSet | FiniteSet)" (reportUnknownVariableType)
+     Type of "imageset" is "(*args: Unknown) -> (Unknown | Basic | FiniteSet | ImageSet)" (reportUnknownVariableType)
-     Type of "derive_by_array" is "(expr: Unknown, dx: Unknown) -> (Any | ImmutableDenseNDimArray | ImmutableSparseNDimArray | ArrayDerivative | Unknown | Derivative)" (reportUnknownVariableType)
+     Type of "derive_by_array" is "(expr: Unknown, dx: Unknown) -> (Any | ImmutableDenseNDimArray | ArrayDerivative | Unknown | Derivative)" (reportUnknownVariableType)
-     Type of "interactive_traversal" is "(expr: Unknown) -> (Unknown | Basic)" (reportUnknownVariableType)
+     Type of "interactive_traversal" is "(expr: Unknown) -> Unknown" (reportUnknownVariableType)
-     Type of "trigsimp" is "(expr: Unknown, inverse: bool = False, **opts: Unknown) -> (Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType)" (reportUnknownVariableType)
+     Type of "trigsimp" is "(expr: Unknown, inverse: bool = False, **opts: Unknown) -> (Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType)" (reportUnknownVariableType)
-   ...:375:9 - warning: Return type, "Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType", is partially unknown (reportUnknownParameterType)
+   ...:375:9 - warning: Return type, "Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType", is partially unknown (reportUnknownParameterType)
-   ...:434:20 - warning: Return type, "Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType", is partially unknown (reportUnknownVariableType)
+   ...:434:20 - warning: Return type, "Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType", is partially unknown (reportUnknownVariableType)
-   ...:436:20 - warning: Return type, "Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType", is partially unknown (reportUnknownVariableType)
+   ...:436:20 - warning: Return type, "Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType", is partially unknown (reportUnknownVariableType)
+   ...:697:9 - error: Method "diff" overrides class "Expr" in an incompatible manner
+     Return type mismatch: base method returns type "ArrayDerivative | Derivative", override returns type "Quaternion"
+       Type "Quaternion" is not assignable to type "ArrayDerivative | Derivative"
+         "Quaternion" is not assignable to "ArrayDerivative"
+         "Quaternion" is not assignable to "Derivative" (reportIncompatibleMethodOverride)
-     Type of "v" is "tuple[Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType]" (reportUnknownVariableType)
+     Type of "v" is "tuple[Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType]" (reportUnknownVariableType)
-     Type of "angle" is "Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType" (reportUnknownVariableType)
+     Type of "angle" is "Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType" (reportUnknownVariableType)
-   ...:1146:9 - warning: Return type, "tuple[tuple[Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType], Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType]", is partially unknown (reportUnknownParameterType)
+   ...:1146:9 - warning: Return type, "tuple[tuple[Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType], Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType]", is partially unknown (reportUnknownParameterType)
-     Type of "angle" is "Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType" (reportUnknownVariableType)
+     Type of "angle" is "Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType" (reportUnknownVariableType)
-     Type of "x" is "Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType" (reportUnknownVariableType)
+     Type of "x" is "Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType" (reportUnknownVariableType)
-     Type of "y" is "Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType" (reportUnknownVariableType)
+     Type of "y" is "Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType" (reportUnknownVariableType)
-     Type of "z" is "Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType" (reportUnknownVariableType)
+     Type of "z" is "Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType" (reportUnknownVariableType)
-     Type of "v" is "tuple[Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType]" (reportUnknownVariableType)
+     Type of "v" is "tuple[Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType]" (reportUnknownVariableType)
-     Type of "t" is "tuple[tuple[Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType, Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType], Any | Unknown | Expr | Basic | atan2 | ComplexInfinity | NaN | Rational | Zero | Infinity | NegativeInfinity | Float | _NotImplementedType]" (reportUnknownVariableType)

... (truncated 8902 lines) ...

koda-validate (https://github.com/keithasaurus/koda-validate)
+   ...:249:58 - error: "validate_async" is not a known attribute of "None" (reportOptionalMemberAccess)
+   ...:312:35 - error: Object of type "None" cannot be called (reportOptionalCall)
-   ...:341:36 - warning: Argument type is partially unknown
+   ...:341:36 - warning: Argument type is Any
-     Argument corresponds to parameter "val" in function "__call__"
+     Argument corresponds to parameter "val" in function "__call__" (reportAny)
-     Argument type is "Any | tuple[Unknown, ...]" (reportUnknownArgumentType)
- 125 errors, 1667 warnings, 0 notes
+ 127 errors, 1667 warnings, 0 notes

rich (https://github.com/Textualize/rich)
+     Argument corresponds to parameter "obj" in function "callable" (reportAny)
+   ...:166:40 - warning: Argument type is Any
+     Argument corresponds to parameter "object" in function "isclass" (reportAny)
+   ...:166:57 - warning: Argument type is Any
- 454 errors, 4414 warnings, 0 notes
+ 454 errors, 4416 warnings, 0 notes

mitmproxy (https://github.com/mitmproxy/mitmproxy)
-   ...:321:36 - warning: Argument type is partially unknown
+   ...:321:36 - warning: Argument type is unknown
-     Argument corresponds to parameter "name" in function "__setattr__"
+     Argument corresponds to parameter "name" in function "__setattr__" (reportUnknownArgumentType)
-     Argument type is "Unknown | Literal['address', 'via']" (reportUnknownArgumentType)
+   ...:38:28 - warning: Type of "upper" is unknown (reportUnknownMemberType)
-   ...:38:28 - warning: Type of "upper" is partially unknown
-     Type of "upper" is "Unknown | Overload[() -> LiteralString, () -> str]" (reportUnknownMemberType)
+   ...:161:37 - error: Argument of type "MasterSecretLogger | None" cannot be assigned to parameter "callback" of type "(Connection, bytes) -> object" in function "set_keylog_callback"
+     Type "MasterSecretLogger | None" is not assignable to type "(Connection, bytes) -> object"
+       Type "None" is not assignable to type "(Connection, bytes) -> object" (reportArgumentType)
+   ...:104:31 - error: Object of type "None" cannot be called (reportOptionalCall)
-   ...:571:5 - warning: Type of "needs_more_data_before_open" is partially unknown
-     Type of "needs_more_data_before_open" is "Unknown | bool" (reportUnknownVariableType)
+   ...:571:5 - warning: Type of "needs_more_data_before_open" is unknown (reportUnknownVariableType)
+   ...:507:50 - error: Cannot assign to attribute "alpn_protocols" for class "QuicTlsSettings"
+     Type "str | None" is not assignable to type "str"
+       "None" is not assignable to "str" (reportAttributeAccessIssue)
+   ...:523:50 - error: Cannot assign to attribute "alpn_protocols" for class "QuicTlsSettings"
+     Type "str | None" is not assignable to type "str"
+       "None" is not assignable to "str" (reportAttributeAccessIssue)
+   ...:237:42 - error: Argument of type "list[bytes | None]" cannot be assigned to parameter "protos" of type "Sequence[bytes]" in function "set_alpn_protos"
+     Type "bytes | None" is not assignable to type "bytes"
+       "None" is not assignable to "bytes" (reportArgumentType)
-     Argument type is "OpenConnectionCompleted | ConnectionClosed | Unknown | Event" (reportUnknownArgumentType)
+     Argument type is "OpenConnectionCompleted | Unknown | Event" (reportUnknownArgumentType)
-     Argument type is "OpenConnectionCompleted | ConnectionClosed | Unknown | Event" (reportUnknownArgumentType)
+     Argument type is "OpenConnectionCompleted | Unknown | Event" (reportUnknownArgumentType)
- 3194 errors, 31338 warnings, 0 notes
+ 3199 errors, 31338 warnings, 0 notes

hydpy (https://github.com/hydpy-dev/hydpy)
-   ...:1191:71 - warning: Argument type is partially unknown
+   ...:1191:71 - warning: Argument type is unknown
-     Argument corresponds to parameter "self" in function "description"
+     Argument corresponds to parameter "self" in function "description" (reportUnknownArgumentType)
-     Argument type is "FunctionType | type[Any] | Unknown" (reportUnknownArgumentType)
+   ...:751:39 - error: "__name__" is not a known attribute of "None" (reportOptionalMemberAccess)
+   ...:755:35 - error: "__name__" is not a known attribute of "None" (reportOptionalMemberAccess)
-   ...:2408:9 - warning: Code is unreachable (reportUnreachable)
-     Argument corresponds to parameter "nc" in function "_summarize" (reportUnknownArgumentType)
-   ...:436:23 - warning: Argument type is unknown
-     Argument type is "tuple[Unknown] | tuple[()]" (reportUnknownArgumentType)
+     Argument type is "tuple[()] | tuple[Unknown]" (reportUnknownArgumentType)
-     Argument type is "tuple[Unknown] | tuple[()]" (reportUnknownArgumentType)
+     Argument type is "tuple[()] | tuple[Unknown]" (reportUnknownArgumentType)
- 2037 errors, 23001 warnings, 0 notes
+ 2039 errors, 22999 warnings, 0 notes

black (https://github.com/psf/black)
-     Argument type is "Unknown | Any | Literal[53, 54, 5, 6, 61] | None" (reportUnknownArgumentType)
+     Argument type is "Unknown | Any | Literal[53, 54, 61] | None" (reportUnknownArgumentType)

bokeh (https://github.com/bokeh/bokeh)
-   ...:650:61 - warning: Argument type is Any
-     Argument corresponds to parameter "initializer" in function "__new__" (reportAny)
+   ...:650:40 - error: No overloads for "__new__" match the provided arguments (reportCallIssue)
+   ...:650:51 - error: Argument of type "str | None" cannot be assigned to parameter "typecode" of type "str" in function "__new__"
+     Type "str | None" is not assignable to type "str"
+       "None" is not assignable to "str" (reportArgumentType)
+   ...:80:48 - error: Argument of type "int | str | Issue" cannot be assigned to parameter "code" of type "int" in function "get_by_code"
+     Type "int | str | Issue" is not assignable to type "int"
+       "Issue" is not assignable to "int" (reportArgumentType)
+   ...:85:25 - error: Type "int | str | Issue" is not assignable to declared type "Issue"
+     Type "int | str | Issue" is not assignable to type "Issue"
+       "int" is not assignable to "Issue" (reportAssignmentType)
+   ...:201:17 - error: Object of type "None" cannot be called (reportOptionalCall)
+   ...:634:20 - error: Object of type "None" cannot be called (reportOptionalCall)
+   ...:254:40 - error: "received" is not a known attribute of "None" (reportOptionalMemberAccess)
+   ...:283:36 - error: "sent" is not a known attribute of "None" (reportOptionalMemberAccess)
+   ...:339:45 - error: Argument of type "str | None" cannot be assigned to parameter "new" of type "str" in function "replace"
+     Type "str | None" is not assignable to type "str"
+       "None" is not assignable to "str" (reportArgumentType)
+   ...:65:36 - error: Argument of type "Handler | None" cannot be assigned to parameter "hdlr" of type "Handler" in function "removeHandler"
+     Type "Handler | None" is not assignable to type "Handler"
+       "None" is not assignable to "Handler" (reportArgumentType)

... (truncated 3048 lines) ...```

@DetachHead DetachHead marked this pull request as draft May 31, 2025 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

isinstance check incorrectly changes type to include list[Any] outside of the narrowed block

1 participant