Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer unions for ternary expressions #17427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ilevkivskyi
Copy link
Member

Ref #12056

cc @JukkaL

Again, let's check the primer...

Copy link
Contributor

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

mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ mitmproxy/proxy/layers/quic.py:664: error: Incompatible types in assignment (expression has type "Connection", variable has type "Client | Server")  [assignment]

psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/waiting.py:67: error: Incompatible types in assignment (expression has type "Any | None", variable has type "RV")  [assignment]
+ psycopg/psycopg/waiting.py:102: error: Incompatible types in assignment (expression has type "Any | None", variable has type "RV")  [assignment]
+ psycopg/psycopg/waiting.py:163: error: Incompatible types in assignment (expression has type "Any | None", variable has type "RV")  [assignment]
+ psycopg/psycopg/waiting.py:221: error: Incompatible types in assignment (expression has type "Any | None", variable has type "RV")  [assignment]
+ psycopg/psycopg/waiting.py:258: error: Incompatible types in assignment (expression has type "Any | None", variable has type "RV")  [assignment]
+ psycopg/psycopg/waiting.py:314: error: Incompatible types in assignment (expression has type "Any | None", variable has type "RV")  [assignment]
+ psycopg/psycopg/waiting.py:362: error: Incompatible types in assignment (expression has type "Any | None", variable has type "RV")  [assignment]

dragonchain (https://github.com/dragonchain/dragonchain)
+ dragonchain/webserver/lib/verifications.py:85:12: error: Incompatible return value type (got "Optional[Any]", expected "str")  [return-value]
- dragonchain/job_processor/contract_job.py:307:24: error: Cannot call function of unknown type  [operator]
- dragonchain/job_processor/contract_job.py:344:20: error: Cannot call function of unknown type  [operator]

pylint (https://github.com/pycqa/pylint)
+ pylint/checkers/deprecated.py:140: error: Unsupported operand types for in ("Any | None" and "Iterable[str]")  [operator]
+ pylint/checkers/spelling.py:64: error: Unused "type: ignore" comment  [unused-ignore]

steam.py (https://github.com/Gobot1234/steam.py)
- steam/trade.py:295: error: "object" has no attribute "__aenter__"  [attr-defined]
- steam/trade.py:295: error: "object" has no attribute "__aexit__"  [attr-defined]
+ steam/gateway.py:554: error: Incompatible types in assignment (expression has type "PollAuthSessionStatusResponse | None", variable has type "PollAuthSessionStatusResponse")  [assignment]
- steam/gateway.py:538: error: Value of type variable "_FT" of "wait" cannot be "object"  [type-var]
- steam/gateway.py:551: error: "object" has no attribute "cancel"  [attr-defined]
- steam/gateway.py:552: error: No overload variant of "gather" matches argument types "set[object]", "bool"  [call-overload]
- steam/gateway.py:552: note: Possible overload variants:
- steam/gateway.py:552: note:     def [_T1] gather(Future[_T1] | Generator[Any, None, _T1] | Awaitable[_T1], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1]]
- steam/gateway.py:552: note:     def [_T1, _T2] gather(Future[_T1] | Generator[Any, None, _T1] | Awaitable[_T1], Future[_T2] | Generator[Any, None, _T2] | Awaitable[_T2], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2]]
- steam/gateway.py:552: note:     def [_T1, _T2, _T3] gather(Future[_T1] | Generator[Any, None, _T1] | Awaitable[_T1], Future[_T2] | Generator[Any, None, _T2] | Awaitable[_T2], Future[_T3] | Generator[Any, None, _T3] | Awaitable[_T3], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3]]
- steam/gateway.py:552: note:     def [_T1, _T2, _T3, _T4] gather(Future[_T1] | Generator[Any, None, _T1] | Awaitable[_T1], Future[_T2] | Generator[Any, None, _T2] | Awaitable[_T2], Future[_T3] | Generator[Any, None, _T3] | Awaitable[_T3], Future[_T4] | Generator[Any, None, _T4] | Awaitable[_T4], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4]]
- steam/gateway.py:552: note:     def [_T1, _T2, _T3, _T4, _T5] gather(Future[_T1] | Generator[Any, None, _T1] | Awaitable[_T1], Future[_T2] | Generator[Any, None, _T2] | Awaitable[_T2], Future[_T3] | Generator[Any, None, _T3] | Awaitable[_T3], Future[_T4] | Generator[Any, None, _T4] | Awaitable[_T4], Future[_T5] | Generator[Any, None, _T5] | Awaitable[_T5], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]
- steam/gateway.py:552: note:     def [_T1, _T2, _T3, _T4, _T5, _T6] gather(Future[_T1] | Generator[Any, None, _T1] | Awaitable[_T1], Future[_T2] | Generator[Any, None, _T2] | Awaitable[_T2], Future[_T3] | Generator[Any, None, _T3] | Awaitable[_T3], Future[_T4] | Generator[Any, None, _T4] | Awaitable[_T4], Future[_T5] | Generator[Any, None, _T5] | Awaitable[_T5], Future[_T6] | Generator[Any, None, _T6] | Awaitable[_T6], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]
- steam/gateway.py:552: note:     def [_T] gather(*coros_or_futures: Future[_T] | Generator[Any, None, _T] | Awaitable[_T], return_exceptions: Literal[False] = ...) -> Future[list[_T]]
- steam/gateway.py:552: note:     def [_T1] gather(Future[_T1] | Generator[Any, None, _T1] | Awaitable[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]
- steam/gateway.py:552: note:     def [_T1, _T2] gather(Future[_T1] | Generator[Any, None, _T1] | Awaitable[_T1], Future[_T2] | Generator[Any, None, _T2] | Awaitable[_T2], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]
- steam/gateway.py:552: note:     def [_T1, _T2, _T3] gather(Future[_T1] | Generator[Any, None, _T1] | Awaitable[_T1], Future[_T2] | Generator[Any, None, _T2] | Awaitable[_T2], Future[_T3] | Generator[Any, None, _T3] | Awaitable[_T3], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]
- steam/gateway.py:552: note:     def [_T1, _T2, _T3, _T4] gather(Future[_T1] | Generator[Any, None, _T1] | Awaitable[_T1], Future[_T2] | Generator[Any, None, _T2] | Awaitable[_T2], Future[_T3] | Generator[Any, None, _T3] | Awaitable[_T3], Future[_T4] | Generator[Any, None, _T4] | Awaitable[_T4], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]
- steam/gateway.py:552: note:     def [_T1, _T2, _T3, _T4, _T5] gather(Future[_T1] | Generator[Any, None, _T1] | Awaitable[_T1], Future[_T2] | Generator[Any, None, _T2] | Awaitable[_T2], Future[_T3] | Generator[Any, None, _T3] | Awaitable[_T3], Future[_T4] | Generator[Any, None, _T4] | Awaitable[_T4], Future[_T5] | Generator[Any, None, _T5] | Awaitable[_T5], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]]
- steam/gateway.py:552: note:     def [_T1, _T2, _T3, _T4, _T5, _T6] gather(Future[_T1] | Generator[Any, None, _T1] | Awaitable[_T1], Future[_T2] | Generator[Any, None, _T2] | Awaitable[_T2], Future[_T3] | Generator[Any, None, _T3] | Awaitable[_T3], Future[_T4] | Generator[Any, None, _T4] | Awaitable[_T4], Future[_T5] | Generator[Any, None, _T5] | Awaitable[_T5], Future[_T6] | Generator[Any, None, _T6] | Awaitable[_T6], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException, _T6 | BaseException]]
- steam/gateway.py:552: note:     def [_T] gather(*coros_or_futures: Future[_T] | Generator[Any, None, _T] | Awaitable[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]
- steam/gateway.py:554: error: Incompatible types in "await" (actual type "object", expected type "Awaitable[Any]")  [misc]
- steam/_gc/client.py:34: error: Incompatible return value type (got "object", expected "Inventory[Item[Self], Self]")  [return-value]
+ steam/_gc/client.py:34: error: Incompatible return value type (got "Inventory[Item[ClientUser], ClientUser]", expected "Inventory[Item[Self], Self]")  [return-value]

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/dtypes/dtypes.py:2099: error: Argument 1 to "np_find_common_type" has incompatible type "*Generator[Any | dtype[Any] | ExtensionDtype, None, None]"; expected "dtype[Any]"  [arg-type]
+ pandas/core/nanops.py:828: error: Incompatible types in assignment (expression has type "Any | float", variable has type "ndarray[Any, dtype[Any]]")  [assignment]
+ pandas/core/computation/ops.py:81: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/plotting/_core.py:1038: error: Argument 1 to "len" has incompatible type "Any | bool"; expected "Sized"  [arg-type]
+ pandas/core/indexing.py:913: error: Item "_LocationIndexer" of "_LocationIndexer | Any" has no attribute "_setitem_with_indexer"  [union-attr]
+ pandas/core/generic.py:7987: error: Unsupported operand type for ~ ("ExtensionArray | ndarray[Any, Any] | Any")  [operator]
+ pandas/core/indexes/interval.py:559: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/plotting/_matplotlib/hist.py:143: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/plotting/_matplotlib/boxplot.py:204: error: Unused "type: ignore" comment  [unused-ignore]

sympy (https://github.com/sympy/sympy)
+ sympy/core/exprtools.py:281: error: Incompatible return value type (got "Any | tuple[Expr, int]", expected "tuple[Expr, Rational]")  [return-value]

manticore (https://github.com/trailofbits/manticore)
+ manticore/core/workspace.py:149: error: Unused "type: ignore" comment  [unused-ignore]
+ manticore/native/manticore.py:296: error: Incompatible types in assignment (expression has type "Callable[[Any, Any], Any]", variable has type "Callable[[Any, Any, Any], Any] | Callable[[Any, Any, Any, Any], Any]")  [assignment]

openlibrary (https://github.com/internetarchive/openlibrary)
+ openlibrary/core/lending.py: note: In function "get_ocaid":
+ openlibrary/core/lending.py:462: error: Need type annotation for "ocaids" (hint: "ocaids: list[<type>] = ...")  [var-annotated]
+ openlibrary/core/vendors.py: note: In function "_get_betterworldbooks_metadata":
+ openlibrary/core/vendors.py:544: error: Incompatible types in assignment (expression has type "Any | None", variable has type "list[Any]")  [assignment]

bandersnatch (https://github.com/pypa/bandersnatch)
+ src/bandersnatch_storage_plugins/swift.py: note: In member "open_file" of class "SwiftStorage":
+ src/bandersnatch_storage_plugins/swift.py:782: error: Argument 1 to "StringIO" has incompatible type "str | bytes"; expected "str | None"  [arg-type]
+ src/bandersnatch_storage_plugins/swift.py:782: error: Argument 1 to "BytesIO" has incompatible type "str | bytes"; expected "Buffer"  [arg-type]

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/search/__init__.py: note: In member "dispatch_visit" of class "WordCollector":
+ sphinx/search/__init__.py:235:38: error: Argument 1 to "append" of "list" has incompatible type "tuple[str, Optional[Any]]"; expected "tuple[str, str]"  [arg-type]
+ sphinx/search/__init__.py:507:42: error: Argument 1 to "append" of "list" has incompatible type "tuple[str, Optional[Any]]"; expected "tuple[str, str]"  [arg-type]

dulwich (https://github.com/dulwich/dulwich)
+ dulwich/repo.py:1570: error: Argument 3 to "_set_default_branch" has incompatible type "Any | None"; expected "bytes"  [arg-type]

vision (https://github.com/pytorch/vision)
+ torchvision/utils.py:615: error: Item "int" of "Any | int | tuple[int, int, int]" has no attribute "__iter__" (not iterable)  [union-attr]
+ torchvision/utils.py:616: error: Incompatible return value type (got "list[Any | int | tuple[int, int, int]]", expected "list[tuple[int, int, int]]")  [return-value]
+ torchvision/datasets/cityscapes.py:195: error: Incompatible types in assignment (expression has type "tuple[Any, ...] | Any", variable has type "dict[str, Any]")  [assignment]

spack (https://github.com/spack/spack)
+ lib/spack/spack/util/elf.py:218: error: Unused "type: ignore" comment  [unused-ignore]
+ lib/spack/spack/util/elf.py:223: error: Unused "type: ignore" comment  [unused-ignore]
+ lib/spack/spack/util/elf.py:224: error: Unused "type: ignore" comment  [unused-ignore]
+ lib/spack/spack/util/elf.py:226: error: Unused "type: ignore" comment  [unused-ignore]
+ lib/spack/spack/util/elf.py:227: error: Unused "type: ignore" comment  [unused-ignore]
+ lib/spack/spack/util/elf.py:228: error: Unused "type: ignore" comment  [unused-ignore]
+ lib/spack/spack/util/elf.py:231: error: Unused "type: ignore" comment  [unused-ignore]
+ lib/spack/spack/util/elf.py:232: error: Unused "type: ignore" comment  [unused-ignore]
+ lib/spack/spack/util/elf.py:233: error: Unused "type: ignore" comment  [unused-ignore]
+ lib/spack/spack/solver/asp.py:3012: error: Argument "target" to "KnownCompiler" has incompatible type "Any | None"; expected "str"  [arg-type]

rich (https://github.com/Textualize/rich)
- rich/pretty.py:65: error: Returning Any from function declared to return "Sequence[Attribute[Any]]"  [no-any-return]

jax (https://github.com/google/jax)
+ jax/_src/core.py:3311: error: Unused "type: ignore" comment  [unused-ignore]
+ jax/_src/pjit.py:778: error: List comprehension has incompatible type List[Any | None]; expected List[Tracer]  [misc]
+ jax/_src/pjit.py:1528: error: Argument 1 to "is_single_device_sharding" has incompatible type "Any | UnspecifiedValue"; expected "Sharding"  [arg-type]
+ jax/_src/pjit.py:1564: error: Item "UnspecifiedValue" of "Any | UnspecifiedValue" has no attribute "_to_xla_hlo_sharding"  [union-attr]
+ jax/_src/interpreters/pxla.py:1791: error: Incompatible types in assignment (expression has type "Sequence[Device?] | Any", variable has type "tuple[Any, ...]")  [assignment]

graphql-core (https://github.com/graphql-python/graphql-core)
+ src/graphql/pyutils/async_reduce.py:40: error: Incompatible return value type (got "Any | Awaitable[U] | U", expected "U")  [return-value]
+ src/graphql/execution/incremental_publisher.py:477: error: Incompatible types in assignment (expression has type "Any | Awaitable[dict[str, Any] | None] | dict[str, Any] | None", variable has type "dict[str, Any] | None")  [assignment]
+ src/graphql/execution/incremental_publisher.py:478: error: Incompatible return value type (got "Any | Awaitable[dict[str, Any] | None] | dict[str, Any] | None", expected "dict[str, Any] | None")  [return-value]
+ src/graphql/execution/incremental_publisher.py:547: error: Incompatible types in assignment (expression has type "Any | Awaitable[list[Any] | None] | list[Any] | None", variable has type "list[str] | None")  [assignment]
+ src/graphql/execution/incremental_publisher.py:549: error: Incompatible return value type (got "Any | Awaitable[list[Any] | None] | list[Any] | None", expected "list[str] | None")  [return-value]
+ src/graphql/language/visitor.py:292: error: Incompatible types in assignment (expression has type "Any | tuple[str, ...]", variable has type "tuple[Node, ...]")  [assignment]
+ src/graphql/language/parser.py:474: error: Incompatible types in assignment (expression has type "Callable[[], ArgumentNode]", variable has type "Callable[[], ConstArgumentNode] | Callable[[bool], ArgumentNode]")  [assignment]
+ src/graphql/execution/execute.py:548: error: Unused "type: ignore" comment  [unused-ignore]
+ tests/execution/test_abstract.py:44: error: Unused "type: ignore" comment  [unused-ignore]

pandera (https://github.com/pandera-dev/pandera)
+ pandera/backends/pandas/checks.py:60: error: Key expression in dictionary comprehension has incompatible type "bool | Any"; expected type "str"  [misc]

alerta (https://github.com/alerta/alerta)
- alerta/models/alert.py:43: error: Unused "type: ignore" comment  [unused-ignore]

spark (https://github.com/apache/spark)
+ python/pyspark/pandas/typedef/typehints.py:826: error: Incompatible types in assignment (expression has type "type[Any] | Any", variable has type "None")  [assignment]
+ python/pyspark/pandas/typedef/typehints.py:839: error: Incompatible types in assignment (expression has type "type[Any] | Any", variable has type "None")  [assignment]
+ python/pyspark/pandas/groupby.py:2203: error: Incompatible return value type (got "tuple[DataFrame[Any], list[tuple[Any, ...]], list[tuple[Any, ...] | Any]]", expected "tuple[DataFrame[Any], list[tuple[Any, ...]], list[str]]")  [return-value]
+ python/pyspark/ml/tuning.py:118: error: Incompatible return value type (got "tuple[int, float, Any | None]", expected "tuple[int, float, Transformer]")  [return-value]

schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/schemas.py:262: error: Unused "type: ignore" comment  [unused-ignore]
+ src/schemathesis/cli/__init__.py: note: At top level:
+ src/schemathesis/cli/__init__.py:1235: error: Unused "type: ignore" comment  [unused-ignore]
+ src/schemathesis/cli/__init__.py:1240: error: Unused "type: ignore" comment  [unused-ignore]
+ src/schemathesis/cli/__init__.py:1241: error: Unused "type: ignore" comment  [unused-ignore]
+ src/schemathesis/extra/pytest_plugin.py: note: In member "_parametrize" of class "SchemathesisCase":
+ src/schemathesis/extra/pytest_plugin.py:210: error: Item "None" of "Optional[Any]" has no attribute "pytest_generate_tests"  [union-attr]
+ src/schemathesis/extra/pytest_plugin.py: note: At top level:

pyinstrument (https://github.com/joerick/pyinstrument)
- pyinstrument/renderers/console.py:105: error: "type[object]" has no attribute "faint"  [attr-defined]
- pyinstrument/renderers/console.py:105: error: "type[object]" has no attribute "end"  [attr-defined]
- pyinstrument/renderers/console.py:174: error: "type[object]" has no attribute "end"  [attr-defined]
- pyinstrument/renderers/console.py:182: error: "type[object]" has no attribute "end"  [attr-defined]
- pyinstrument/renderers/console.py:184: error: "type[object]" has no attribute "faint"  [attr-defined]
- pyinstrument/renderers/console.py:184: error: "type[object]" has no attribute "end"  [attr-defined]
- pyinstrument/renderers/console.py:195: error: "type[object]" has no attribute "red"  [attr-defined]
- pyinstrument/renderers/console.py:197: error: "type[object]" has no attribute "yellow"  [attr-defined]
- pyinstrument/renderers/console.py:199: error: "type[object]" has no attribute "green"  [attr-defined]
- pyinstrument/renderers/console.py:201: error: "type[object]" has no attribute "bright_green"  [attr-defined]
- pyinstrument/renderers/console.py:201: error: "type[object]" has no attribute "faint"  [attr-defined]
- pyinstrument/renderers/console.py:205: error: "type[object]" has no attribute "bg_dark_blue_255"  [attr-defined]
- pyinstrument/renderers/console.py:205: error: "type[object]" has no attribute "white_255"  [attr-defined]

ignite (https://github.com/pytorch/ignite)
+ ignite/metrics/fbeta.py:154: error: Unused "type: ignore" comment  [unused-ignore]
+ ignite/metrics/fbeta.py:163: error: Unused "type: ignore" comment  [unused-ignore]
+ ignite/handlers/time_profilers.py:420: error: Incompatible types in string interpolation (expression has type "str", placeholder has type "int | float")  [str-format]

kornia (https://github.com/kornia/kornia)
- kornia/feature/loftr/loftr_module/transformer.py:54: error: "object" not callable  [operator]

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/routing/rules.py:772: error: Incompatible return value type (got "list[stmt | Constant]", expected "list[AST]")  [return-value]
+ src/werkzeug/routing/rules.py:772: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
+ src/werkzeug/routing/rules.py:772: note: Consider using "Sequence" instead, which is covariant
+ src/werkzeug/routing/rules.py:772: note: Perhaps you need a type annotation for "ret"? Suggestion: "list[AST]"

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/http_parser.py:661:40: error: Argument 2 to "feed_data" of "HttpParser" has incompatible type "Literal[b'\\r\\n', b'\\n'] | None"; expected "Literal[b'\\r\\n', b'\\n']"  [arg-type]

speedrun.com_global_scoreboard_webapp (https://github.com/Avasam/speedrun.com_global_scoreboard_webapp)
- backend/models/core_models.py:381: error: "type" has no attribute "query"  [attr-defined]
- backend/models/core_models.py:383: error: "type" has no attribute "owner_id"  [attr-defined]

pwndbg (https://github.com/pwndbg/pwndbg)
+ pwndbg/gdblib/heap/ptmalloc.py:455: error: Unused "type: ignore" comment  [unused-ignore]

ibis (https://github.com/ibis-project/ibis)
+ ibis/common/patterns.py:1697: error: Incompatible return value type (got "type[NoMatch] | Any", expected "ibis.common.patterns.Any")  [return-value]
- ibis/expr/datatypes/value.py:131: error: Unsupported operand types for + ("tuple[UInt8 | UInt16 | UInt32 | UInt64, ...]" and "tuple[Int8, Int16, Int32, Int64]")  [operator]
+ ibis/expr/datatypes/value.py:131: error: Incompatible types in assignment (expression has type "tuple[UInt8 | UInt16 | UInt32 | UInt64 | SignedInteger, ...]", variable has type "tuple[UInt8, UInt16, UInt32, UInt64] | tuple[()]")  [assignment]
- ibis/selectors.py:406: error: Incompatible types in assignment (expression has type "frozenset[Any]", variable has type "tuple[str | Column, ...]")  [assignment]
+ ibis/selectors.py:406: error: Incompatible types in assignment (expression has type "frozenset[str | Column | Any]", variable has type "tuple[str | Column, ...]")  [assignment]
+ ibis/expr/types/arrays.py:145: error: Argument 2 to "ArraySlice" has incompatible type "Any | int"; expected "Value[Integer, Any]"  [arg-type]
+ ibis/expr/api.py:511: error: Argument "schema" to "InMemoryTable" has incompatible type "Any | Schema | Mapping[str, str | DataType] | Iterable[tuple[str, str | DataType]]"; expected "Schema"  [arg-type]
+ ibis/expr/api.py:532: error: Argument "schema" to "InMemoryTable" has incompatible type "Any | Schema | Mapping[str, str | DataType] | Iterable[tuple[str, str | DataType]]"; expected "Schema"  [arg-type]
+ ibis/expr/api.py:557: error: Argument "schema" to "InMemoryTable" has incompatible type "Any | Schema | Mapping[str, str | DataType] | Iterable[tuple[str, str | DataType]]"; expected "Schema"  [arg-type]
+ ibis/backends/bigquery/__init__.py:455: error: Argument 1 to "parse_project_and_dataset" has incompatible type "str | Any | None"; expected "str"  [arg-type]

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ src/hydra_zen/structured_configs/_implementations.py:3221: error: List comprehension has incompatible type List[tuple[str, Any | <typing special form>, Any | Field[Any]]]; expected List[tuple[str, type] | tuple[str, type, Any]]  [misc]
- src/hydra_zen/wrapper/_implementations.py:416: error: "object" not callable  [operator]

discord.py (https://github.com/Rapptz/discord.py)
- discord/colour.py:245: error: "object" has no attribute "random"  [attr-defined]
- discord/backoff.py:75: error: Incompatible types in assignment (expression has type "function", variable has type "Callable[..., int | float]")  [assignment]
- discord/ext/commands/context.py:1078: error: Incompatible types in assignment (expression has type "InteractionMessage", variable has type "WebhookMessage")  [assignment]
+ discord/ext/commands/context.py:1075: error: No overload variant of "send" of "Webhook" matches argument types "dict[str, Poll | bool | str | Any | Embed | Sequence[Embed] | File | Sequence[File] | AllowedMentions | View | None]", "bool"  [call-overload]
+ discord/ext/commands/context.py:1075: note: Possible overload variants:
+ discord/ext/commands/context.py:1075: note:     def send(self, content: str = ..., *, username: str = ..., avatar_url: Any = ..., tts: bool = ..., ephemeral: bool = ..., file: File = ..., files: Sequence[File] = ..., embed: Embed = ..., embeds: Sequence[Embed] = ..., allowed_mentions: AllowedMentions = ..., view: View = ..., thread: Snowflake = ..., thread_name: str = ..., wait: Literal[True], suppress_embeds: bool = ..., silent: bool = ..., applied_tags: list[ForumTag] = ..., poll: Poll = ...) -> Coroutine[Any, Any, WebhookMessage]
+ discord/ext/commands/context.py:1075: note:     def send(self, content: str = ..., *, username: str = ..., avatar_url: Any = ..., tts: bool = ..., ephemeral: bool = ..., file: File = ..., files: Sequence[File] = ..., embed: Embed = ..., embeds: Sequence[Embed] = ..., allowed_mentions: AllowedMentions = ..., view: View = ..., thread: Snowflake = ..., thread_name: str = ..., wait: Literal[False] = ..., suppress_embeds: bool = ..., silent: bool = ..., applied_tags: list[ForumTag] = ..., poll: Poll = ...) -> Coroutine[Any, Any, None]
+ discord/ext/commands/context.py:1077: error: Argument 1 to "send_message" of "InteractionResponse" has incompatible type "**dict[str, Poll | bool | str | Any | Embed | Sequence[Embed] | File | Sequence[File] | AllowedMentions | View | None]"; expected "Embed"  [arg-type]
+ discord/ext/commands/context.py:1077: error: Argument 1 to "send_message" of "InteractionResponse" has incompatible type "**dict[str, Poll | bool | str | Any | Embed | Sequence[Embed] | File | Sequence[File] | AllowedMentions | View | None]"; expected "Sequence[Embed]"  [arg-type]
+ discord/ext/commands/context.py:1077: error: Argument 1 to "send_message" of "InteractionResponse" has incompatible type "**dict[str, Poll | bool | str | Any | Embed | Sequence[Embed] | File | Sequence[File] | AllowedMentions | View | None]"; expected "File"  [arg-type]
+ discord/ext/commands/context.py:1077: error: Argument 1 to "send_message" of "InteractionResponse" has incompatible type "**dict[str, Poll | bool | str | Any | Embed | Sequence[Embed] | File | Sequence[File] | AllowedMentions | View | None]"; expected "Sequence[File]"  [arg-type]
+ discord/ext/commands/context.py:1077: error: Argument 1 to "send_message" of "InteractionResponse" has incompatible type "**dict[str, Poll | bool | str | Any | Embed | Sequence[Embed] | File | Sequence[File] | AllowedMentions | View | None]"; expected "View"  [arg-type]
+ discord/ext/commands/context.py:1077: error: Argument 1 to "send_message" of "InteractionResponse" has incompatible type "**dict[str, Poll | bool | str | Any | Embed | Sequence[Embed] | File | Sequence[File] | AllowedMentions | View | None]"; expected "bool"  [arg-type]
+ discord/ext/commands/context.py:1077: error: Argument 1 to "send_message" of "InteractionResponse" has incompatible type "**dict[str, Poll | bool | str | Any | Embed | Sequence[Embed] | File | Sequence[File] | AllowedMentions | View | None]"; expected "AllowedMentions"  [arg-type]
+ discord/ext/commands/context.py:1077: error: Argument 1 to "send_message" of "InteractionResponse" has incompatible type "**dict[str, Poll | bool | str | Any | Embed | Sequence[Embed] | File | Sequence[File] | AllowedMentions | View | None]"; expected "float | None"  [arg-type]
+ discord/ext/commands/context.py:1077: error: Argument 1 to "send_message" of "InteractionResponse" has incompatible type "**dict[str, Poll | bool | str | Any | Embed | Sequence[Embed] | File | Sequence[File] | AllowedMentions | View | None]"; expected "Poll"  [arg-type]

urllib3 (https://github.com/urllib3/urllib3)
+ test/with_dummyserver/test_proxy_poolmanager.py:52: error: Item "None" of "Any | None" has no attribute "proxy_is_verified"  [union-attr]
+ test/with_dummyserver/test_proxy_poolmanager.py:53: error: Item "None" of "Any | None" has no attribute "is_verified"  [union-attr]

pydantic (https://github.com/samuelcolvin/pydantic)
- pydantic/_internal/_model_construction.py:446: error: "object" not callable  [operator]
- pydantic/_internal/_model_construction.py:452: error: "object" not callable  [operator]

@ilevkivskyi
Copy link
Member Author

OK, so almost every new error is because join(Any, X) = Any, what is interesting, more that half of those are join(Any, None), that now became Any | None.

There are couple suspicious errors, I will look at them later, but in general I think this looks very good.

@cdce8p
Copy link
Collaborator

cdce8p commented Jun 24, 2024

Did a full run for Home Assistant. The new errors looked reasonable and were easy to fix. home-assistant/core#120297

@JelleZijlstra
Copy link
Member

Examples like https://github.com/home-assistant/core/pull/120297/files#diff-09a2c41aad7e388792de6ad131f08c70232e778d0d02d37d0682d15633406f1c are pretty compelling; previously mypy missed a clear typing violation because join(Any, int) = Any.

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.

None yet

3 participants