Provide a better fallback value for the python_version option by cdce8p · Pull Request #19162 · python/mypy
Diff from mypy_primer, showing the effect of this PR on open source code:
pip (https://github.com/pypa/pip): 1.15x faster (51.4s -> 44.8s in single noisy sample) nox (https://github.com/wntrblm/nox): 1.42x slower (24.1s -> 34.3s in single noisy sample) typeshed-stats (https://github.com/AlexWaygood/typeshed-stats): 1.55x slower (59.8s -> 92.6s in single noisy sample) PyWinCtl (https://github.com/Kalmat/PyWinCtl) - src/pywinctl/_pywinctl_linux.py:805: error: Returning Any from function declared to return "int | None" [no-any-return] + src/pywinctl/_pywinctl_linux.py:805: error: Returning Any from function declared to return "Optional[int]" [no-any-return] materialize (https://github.com/MaterializeInc/materialize): 1.06x slower (130.1s -> 138.0s in single noisy sample) boostedblob (https://github.com/hauntsaninja/boostedblob) - boostedblob/boost.py:330: error: Value of type variable "_FT" of "wait" cannot be "Awaitable[T]" [type-var] scikit-build-core (https://github.com/scikit-build/scikit-build-core): 1.14x slower (37.4s -> 42.5s in single noisy sample) - src/scikit_build_core/settings/sources.py:591: error: Unused "type: ignore" comment [unused-ignore] - src/scikit_build_core/settings/sources.py:604: error: Unused "type: ignore" comment [unused-ignore] packaging (https://github.com/pypa/packaging) - src/packaging/tags.py:564: error: Unused "type: ignore" comment [unused-ignore] paasta (https://github.com/yelp/paasta) - paasta_tools/paastaapi/model/instance_status_kubernetes.py:227: SyntaxWarning: invalid escape sequence '\&' - evicted_count (int): Number of pods with status reason \"Evicted\". [optional] # noqa: E501 - paasta_tools/metrics/metastatus_lib.py:617: error: Argument "key" to "sorted" has incompatible type "Callable[[Any], Sequence[tuple[str, str]]]"; expected "Callable[[_SlaveT], SupportsDunderLT[Any] | SupportsDunderGT[Any]]" [arg-type] + paasta_tools/metrics/metastatus_lib.py:617: error: Argument "key" to "sorted" has incompatible type "Callable[[Any], Sequence[tuple[str, str]]]"; expected "Callable[[_SlaveT], Union[SupportsDunderLT[Any], SupportsDunderGT[Any]]]" [arg-type] - paasta_tools/metrics/metastatus_lib.py:617: error: Argument "key" to "sorted" has incompatible type "Callable[[Any], Sequence[tuple[str, str]]]"; expected "Callable[[Any], SupportsDunderLT[Any] | SupportsDunderGT[Any]]" [arg-type] + paasta_tools/metrics/metastatus_lib.py:617: error: Argument "key" to "sorted" has incompatible type "Callable[[Any], Sequence[tuple[str, str]]]"; expected "Callable[[Any], Union[SupportsDunderLT[Any], SupportsDunderGT[Any]]]" [arg-type] - paasta_tools/instance/kubernetes.py:688: error: Argument 2 to "get_pod_status_tasks_by_sha_and_readiness" has incompatible type "Task[set[str]] | None"; expected "Future[dict[str, Any]]" [arg-type] + paasta_tools/instance/kubernetes.py:688: error: Argument 2 to "get_pod_status_tasks_by_sha_and_readiness" has incompatible type "Optional[Task[set[str]]]"; expected "Future[dict[str, Any]]" [arg-type] - paasta_tools/instance/kubernetes.py:707: error: Argument 2 to "get_pod_status_tasks_by_replicaset" has incompatible type "Task[set[str]] | None"; expected "Future[dict[str, Any]]" [arg-type] + paasta_tools/instance/kubernetes.py:707: error: Argument 2 to "get_pod_status_tasks_by_replicaset" has incompatible type "Optional[Task[set[str]]]"; expected "Future[dict[str, Any]]" [arg-type] - paasta_tools/instance/kubernetes.py:1160: error: Argument 1 to "create_task" has incompatible type "Awaitable[Sequence[Any]]"; expected "Coroutine[Any, Any, Never]" [arg-type] + paasta_tools/instance/kubernetes.py:1160: error: Argument 1 to "create_task" has incompatible type "Awaitable[Sequence[Any]]"; expected "Union[Generator[Any, None, Never], Coroutine[Any, Any, Never]]" [arg-type] - paasta_tools/instance/kubernetes.py:1338: error: Argument 1 to "create_task" has incompatible type "Awaitable[Sequence[Any]]"; expected "Coroutine[Any, Any, Never]" [arg-type] + paasta_tools/instance/kubernetes.py:1338: error: Argument 1 to "create_task" has incompatible type "Awaitable[Sequence[Any]]"; expected "Union[Generator[Any, None, Never], Coroutine[Any, Any, Never]]" [arg-type] - paasta_tools/cli/cmds/local_run.py:980: error: Argument 1 to "write" of "_TextIOBase" has incompatible type "str | bytes"; expected "str" [arg-type] + paasta_tools/cli/cmds/local_run.py:980: error: Argument 1 to "write" of "_TextIOBase" has incompatible type "Union[str, bytes]"; expected "str" [arg-type] - paasta_tools/cli/cmds/local_run.py:985: error: Argument 1 to "write" of "BufferedWriter" has incompatible type "str | bytes"; expected "Buffer" [arg-type] + paasta_tools/cli/cmds/local_run.py:985: error: Argument 1 to "write" of "BufferedWriter" has incompatible type "Union[str, bytes]"; expected "Buffer" [arg-type] SinbadCogs (https://github.com/mikeshardmind/SinbadCogs) - rolemanagement/utils.py:61: error: Argument 2 of "update_roles_atomically" is incompatible with supertype "MixinMeta"; supertype defines the argument type as "list[Any] | None" [override] + rolemanagement/utils.py:61: error: Argument 2 of "update_roles_atomically" is incompatible with supertype "MixinMeta"; supertype defines the argument type as "Optional[list[Any]]" [override] - rolemanagement/utils.py:62: error: Argument 3 of "update_roles_atomically" is incompatible with supertype "MixinMeta"; supertype defines the argument type as "list[Any] | None" [override] + rolemanagement/utils.py:62: error: Argument 3 of "update_roles_atomically" is incompatible with supertype "MixinMeta"; supertype defines the argument type as "Optional[list[Any]]" [override] - rolemanagement/core.py:420: error: Item "str" of "Any | str" has no attribute "id" [union-attr] + rolemanagement/core.py:420: error: Item "str" of "Union[Any, str]" has no attribute "id" [union-attr] - rolemanagement/core.py:492: error: Item "str" of "Any | str" has no attribute "id" [union-attr] + rolemanagement/core.py:492: error: Item "str" of "Union[Any, str]" has no attribute "id" [union-attr] discord.py (https://github.com/Rapptz/discord.py): 1.09x faster (299.9s -> 275.3s in single noisy sample) dragonchain (https://github.com/dragonchain/dragonchain) - dragonchain/lib/database/redis.py:399:36: error: Argument 2 to "zadd" of "SortedSetCommands" has incompatible type "dict[str, int]"; expected "Mapping[str | bytes, bytes | float | int | str]" [arg-type] + dragonchain/lib/database/redis.py:399:36: error: Argument 2 to "zadd" of "SortedSetCommands" has incompatible type "dict[str, int]"; expected "Mapping[Union[str, bytes], Union[bytes, float, int, str]]" [arg-type] - dragonchain/lib/database/redis_utest.py:102:9: error: "Callable[[str | bytes, bytes | float | int | str, float | timedelta | None, float | timedelta | None, bool, bool, bool, bool, Any | None, Any | None], bool | None]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:106:9: error: "Callable[[str | bytes, bytes | float | int | str, float | timedelta | None, float | timedelta | None, bool, bool, bool, bool, Any | None, Any | None], bool | None]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:102:9: error: "Callable[[Union[str, bytes], Union[bytes, float, int, str], Union[float, timedelta, None], Union[float, timedelta, None], bool, bool, bool, bool, Optional[Any], Optional[Any]], Optional[bool]]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:106:9: error: "Callable[[Union[str, bytes], Union[bytes, float, int, str], Union[float, timedelta, None], Union[float, timedelta, None], bool, bool, bool, bool, Optional[Any], Optional[Any]], Optional[bool]]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:110:9: error: "Callable[[str | bytes], Any | None]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:110:9: error: "Callable[[Union[str, bytes]], Optional[Any]]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:114:9: error: "Callable[[VarArg(str | bytes)], int]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:114:9: error: "Callable[[VarArg(Union[str, bytes])], int]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:122:9: error: "Callable[[bool, KwArg(Any | Any)], bool]" has no attribute "assert_called_once" [attr-defined] + dragonchain/lib/database/redis_utest.py:122:9: error: "Callable[[bool, KwArg(Union[Any, Any])], bool]" has no attribute "assert_called_once" [attr-defined] - dragonchain/lib/database/redis_utest.py:126:9: error: "Callable[[str | bytes, VarArg(str | bytes)], int]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:126:9: error: "Callable[[Union[str, bytes], VarArg(Union[str, bytes])], int]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:130:9: error: "Callable[[bytes | float | int | str, VarArg(bytes | float | int | str)], int]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:130:9: error: "Callable[[Union[bytes, float, int, str], VarArg(Union[bytes, float, int, str])], int]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:134:9: error: "Callable[[bytes | float | int | str, VarArg(bytes | float | int | str)], int]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:134:9: error: "Callable[[Union[bytes, float, int, str], VarArg(Union[bytes, float, int, str])], int]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:138:9: error: "Callable[[VarArg(str | bytes)], int]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:138:9: error: "Callable[[VarArg(Union[str, bytes])], int]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:150:9: error: "Callable[[Any, Any, int | None], Any]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:150:9: error: "Callable[[Any, Any, Optional[int]], Any]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:154:9: error: "Callable[[str | bytes], Any | None]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:154:9: error: "Callable[[Union[str, bytes]], Optional[Any]]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:158:9: error: "Callable[[str | bytes, int], Any | None]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:158:9: error: "Callable[[Union[str, bytes], int], Optional[Any]]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:162:9: error: "Callable[[str | bytes, bytes | float | int | str, float | timedelta | None, float | timedelta | None, bool, bool, bool, bool, Any | None, Any | None], bool | None]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:162:9: error: "Callable[[Union[str, bytes], Union[bytes, float, int, str], Union[float, timedelta, None], Union[float, timedelta, None], bool, bool, bool, bool, Optional[Any], Optional[Any]], Optional[bool]]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:166:9: error: "Callable[[str | bytes, int, int], bool]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:166:9: error: "Callable[[Union[str, bytes], int, int], bool]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:170:9: error: "Callable[[str | bytes, str | bytes], Any | None]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:170:9: error: "Callable[[Union[str, bytes], Union[str, bytes]], Optional[Any]]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:174:9: error: "Callable[[str | bytes, VarArg(bytes | float | int | str)], int]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:174:9: error: "Callable[[Union[str, bytes], VarArg(Union[bytes, float, int, str])], int]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:178:9: error: "Callable[[str | bytes, bytes | float | int | str], bool]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:178:9: error: "Callable[[Union[str, bytes], Union[bytes, float, int, str]], bool]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:182:9: error: "Callable[[str | bytes], set[Any]]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:182:9: error: "Callable[[Union[str, bytes]], set[Any]]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:186:9: error: "Callable[[str | bytes, VarArg(bytes | float | int | str)], int]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:186:9: error: "Callable[[Union[str, bytes], VarArg(Union[bytes, float, int, str])], int]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:190:9: error: "Callable[[str | bytes, int, int], list[Any]]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:190:9: error: "Callable[[Union[str, bytes], int, int], list[Any]]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:198:9: error: "Callable[[str | bytes], int]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:198:9: error: "Callable[[Union[str, bytes]], int]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:206:9: error: "Callable[[Any, int | None], Any]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:206:9: error: "Callable[[Any, Optional[int]], Any]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:210:9: error: "Callable[[str | bytes], dict[Any, Any]]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:210:9: error: "Callable[[Union[str, bytes]], dict[Any, Any]]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:214:9: error: "Callable[[str | bytes, str | bytes], bool]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:214:9: error: "Callable[[Union[str, bytes], Union[str, bytes]], bool]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/database/redis_utest.py:218:9: error: "Callable[[str | bytes, Mapping[str | bytes, bytes | float | int | str], bool, bool, bool, bool, Any | None, Any | None], int]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/database/redis_utest.py:218:9: error: "Callable[[Union[str, bytes], Mapping[Union[str, bytes], Union[bytes, float, int, str]], bool, bool, bool, bool, Optional[Any], Optional[Any]], int]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/lib/interfaces/storage_utest.py:83:9: error: "Callable[[str, str | bytes, int | None, str], bool]" has no attribute "assert_called_once_with" [attr-defined] + dragonchain/lib/interfaces/storage_utest.py:83:9: error: "Callable[[str, Union[str, bytes], Optional[int], str], bool]" has no attribute "assert_called_once_with" [attr-defined] - dragonchain/broadcast_processor/broadcast_functions.py:95:32: error: Item "None" of "Match[str] | None" has no attribute "group" [union-attr] + dragonchain/broadcast_processor/broadcast_functions.py:95:32: error: Item "None" of "Optional[Match[str]]" has no attribute "group" [union-attr] - dragonchain/lib/authorization.py:315:19: error: Item "None" of "Match[str] | None" has no attribute "group" [union-attr] + dragonchain/lib/authorization.py:315:19: error: Item "None" of "Optional[Match[str]]" has no attribute "group" [union-attr] - dragonchain/lib/authorization.py:317:25: error: Item "None" of "Match[str] | None" has no attribute "group" [union-attr] + dragonchain/lib/authorization.py:317:25: error: Item "None" of "Optional[Match[str]]" has no attribute "group" [union-attr] - dragonchain/lib/authorization.py:340:31: error: Item "None" of "Match[str] | None" has no attribute "group" [union-attr] + dragonchain/lib/authorization.py:340:31: error: Item "None" of "Optional[Match[str]]" has no attribute "group" [union-attr] - dragonchain/webserver/lib/verifications.py:85:12: error: Incompatible return value type (got "Any | None", expected "str") [return-value] + dragonchain/webserver/lib/verifications.py:85:12: error: Incompatible return value type (got "Optional[Any]", expected "str") [return-value] - dragonchain/webserver/lib/api_keys_utest.py:48:87: error: Argument "permissions_document" to "create_api_key_v1" has incompatible type "dict[str, str]"; expected "permissions_doc | None" [arg-type] + dragonchain/webserver/lib/api_keys_utest.py:48:87: error: Argument "permissions_document" to "create_api_key_v1" has incompatible type "dict[str, str]"; expected "Optional[permissions_doc]" [arg-type] - dragonchain/webserver/lib/api_keys_utest.py:91:59: error: Argument 3 to "update_api_key_v1" has incompatible type "dict[str, str]"; expected "permissions_doc | None" [arg-type] + dragonchain/webserver/lib/api_keys_utest.py:91:59: error: Argument 3 to "update_api_key_v1" has incompatible type "dict[str, str]"; expected "Optional[permissions_doc]" [arg-type] - dragonchain/job_processor/contract_job_utest.py:269:13: error: "Callable[[str | ContractState, str], None]" has no attribute "assert_called_once" [attr-defined] + dragonchain/job_processor/contract_job_utest.py:269:13: error: "Callable[[Union[str, ContractState], str], None]" has no attribute "assert_called_once" [attr-defined] manticore (https://github.com/trailofbits/manticore) - tests/wasm/json2mc.py:103: error: Invalid index type "int | None" for "list[Module]"; expected type "SupportsIndex" [index] + tests/wasm/json2mc.py:103: error: Invalid index type "Optional[int]" for "list[Module]"; expected type "SupportsIndex" [index] - tests/wasm/json2mc.py:159: error: Invalid index type "int | None" for "list[Module]"; expected type "SupportsIndex" [index] + tests/wasm/json2mc.py:159: error: Invalid index type "Optional[int]" for "list[Module]"; expected type "SupportsIndex" [index] - tests/wasm/json2mc.py:161: error: Invalid index type "int | None" for "list[Module]"; expected type "SupportsIndex" [index] + tests/wasm/json2mc.py:161: error: Invalid index type "Optional[int]" for "list[Module]"; expected type "SupportsIndex" [index] - manticore/platforms/linux.py:1767: error: Unsupported operand type for unary - ("int | None") [operator] + manticore/platforms/linux.py:1767: error: Unsupported operand type for unary - ("Optional[int]") [operator] - manticore/platforms/linux.py:1780: error: Unsupported operand type for unary - ("int | None") [operator] + manticore/platforms/linux.py:1780: error: Unsupported operand type for unary - ("Optional[int]") [operator] - manticore/platforms/linux.py:1810: error: Unsupported operand type for unary - ("int | None") [operator] + manticore/platforms/linux.py:1810: error: Unsupported operand type for unary - ("Optional[int]") [operator] - manticore/platforms/linux.py:2340: error: Unsupported operand type for unary - ("int | None") [operator] + manticore/platforms/linux.py:2340: error: Unsupported operand type for unary - ("Optional[int]") [operator] - manticore/platforms/linux.py:3201: error: Need type annotation for "procid" [var-annotated] - manticore/platforms/linux.py:3201: error: Argument 1 has incompatible type "set[int]"; expected "Sequence[Never]" [arg-type] - manticore/platforms/linux.py:3212: error: Need type annotation for "procid" [var-annotated] - manticore/platforms/linux.py:3212: error: Argument 1 has incompatible type "set[int]"; expected "Sequence[Never]" [arg-type] - manticore/platforms/linux.py:3512: error: Unsupported operand type for unary - ("int | None") [operator] + manticore/platforms/linux.py:3512: error: Unsupported operand type for unary - ("Optional[int]") [operator] - manticore/platforms/linux.py:3525: error: Unsupported operand type for unary - ("int | None") [operator] + manticore/platforms/linux.py:3525: error: Unsupported operand type for unary - ("Optional[int]") [operator] - manticore/platforms/linux.py:3560: error: Unsupported operand type for unary - ("int | None") [operator] + manticore/platforms/linux.py:3560: error: Unsupported operand type for unary - ("Optional[int]") [operator] - manticore/platforms/linux.py:3578: error: Unsupported operand type for unary - ("int | None") [operator] + manticore/platforms/linux.py:3578: error: Unsupported operand type for unary - ("Optional[int]") [operator] - manticore/platforms/linux.py:3590: error: Unsupported operand type for unary - ("int | None") [operator] + manticore/platforms/linux.py:3590: error: Unsupported operand type for unary - ("Optional[int]") [operator] - manticore/platforms/linux.py:3668: error: Unsupported operand type for unary - ("int | None") [operator] + manticore/platforms/linux.py:3668: error: Unsupported operand type for unary - ("Optional[int]") [operator] - manticore/platforms/linux.py:3681: error: Unsupported operand type for unary - ("int | None") [operator] + manticore/platforms/linux.py:3681: error: Unsupported operand type for unary - ("Optional[int]") [operator] - 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] + manticore/native/manticore.py:296: error: Incompatible types in assignment (expression has type "Callable[[Any, Any], Any]", variable has type "Union[Callable[[Any, Any, Any], Any], Callable[[Any, Any, Any, Any], Any]]") [assignment]