Skip to content

[red-knot] Assignability for subclasses of Any and Unknown #17557

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

Merged
merged 3 commits into from
Apr 23, 2025

Conversation

sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Apr 22, 2025

Summary

Allow (instances of) subclasses of Any and Unknown to be assignable to (instances of) other classes, unless they are final. This allows us to get rid of ~1000 false positives, mostly when mock-objects like unittest.mock.MagicMock are assigned to various targets.

Test Plan

Adapted and new Markdown tests.

@sharkdp sharkdp added the ty Multi-file analysis & type inference label Apr 22, 2025
Copy link
Contributor

github-actions bot commented Apr 22, 2025

mypy_primer results

Changes were detected when running on open source projects
bandersnatch (https://github.com/pypa/bandersnatch)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/bandersnatch/src/bandersnatch/master.py:183:19: Cannot raise object of type `XmlRpcError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/bandersnatch/src/bandersnatch/tests/test_verify.py:170:71: Argument to this function is incorrect: Expected `Namespace`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/bandersnatch/src/bandersnatch/tests/test_mirror.py:80:42: Argument to this function is incorrect: Expected `Master`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/bandersnatch/src/bandersnatch/tests/test_mirror.py:91:36: Argument to this function is incorrect: Expected `Master`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/bandersnatch/src/bandersnatch/tests/test_mirror.py:101:36: Argument to this function is incorrect: Expected `Master`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/bandersnatch/src/bandersnatch/tests/test_mirror.py:114:36: Argument to this function is incorrect: Expected `Master`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/bandersnatch/src/bandersnatch/tests/test_mirror.py:130:36: Argument to this function is incorrect: Expected `Master`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/bandersnatch/src/bandersnatch/tests/test_mirror.py:155:36: Argument to this function is incorrect: Expected `Master`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/bandersnatch/src/bandersnatch/tests/test_mirror.py:179:36: Argument to this function is incorrect: Expected `Master`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/bandersnatch/src/bandersnatch/tests/test_mirror.py:193:32: Argument to this function is incorrect: Expected `Master`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/bandersnatch/src/bandersnatch/tests/test_mirror.py:205:32: Argument to this function is incorrect: Expected `Master`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/bandersnatch/src/bandersnatch/tests/test_mirror.py:217:32: Argument to this function is incorrect: Expected `Master`, found `Mock`
- Found 176 diagnostics
+ Found 164 diagnostics

sockeye (https://github.com/awslabs/sockeye)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/sockeye/test/unit/test_fixed_param_strategy.py:382:57: Argument to this function is incorrect: Expected `ModelConfig`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/sockeye/test/unit/test_translate.py:44:42: Argument to this function is incorrect: Expected `Translator`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/sockeye/test/unit/test_translate.py:44:70: Argument to this function is incorrect: Expected `OutputHandler`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/sockeye/test/unit/test_translate.py:52:46: Argument to this function is incorrect: Expected `Translator`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/sockeye/test/unit/test_translate.py:52:74: Argument to this function is incorrect: Expected `OutputHandler`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/sockeye/test/unit/test_translate.py:67:42: Argument to this function is incorrect: Expected `Translator`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/sockeye/test/unit/test_translate.py:68:42: Argument to this function is incorrect: Expected `OutputHandler`, found `Mock`
- Found 378 diagnostics
+ Found 371 diagnostics

pip (https://github.com/pypa/pip)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/adapters.py:682:19: Cannot raise object of type `ConnectionError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/adapters.py:688:27: Cannot raise object of type `ConnectTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/adapters.py:691:23: Cannot raise object of type `RetryError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/adapters.py:694:23: Cannot raise object of type `ProxyError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/adapters.py:698:23: Cannot raise object of type `SSLError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/adapters.py:700:19: Cannot raise object of type `ConnectionError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/adapters.py:703:19: Cannot raise object of type `ConnectionError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/adapters.py:706:19: Cannot raise object of type `ProxyError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/adapters.py:711:23: Cannot raise object of type `SSLError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/adapters.py:713:23: Cannot raise object of type `ReadTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/utils.py:1092:19: Cannot raise object of type `UnrewindableBodyError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/utils.py:1096:15: Cannot raise object of type `UnrewindableBodyError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/sessions.py:191:23: Cannot raise object of type `TooManyRedirects` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/models.py:512:23: Cannot raise object of type `InvalidJSONError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/models.py:822:27: Cannot raise object of type `ChunkedEncodingError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/models.py:826:27: Cannot raise object of type `ConnectionError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/models.py:828:27: Cannot raise object of type `SSLError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/pip/src/pip/_vendor/requests/models.py:1024:19: Cannot raise object of type `HTTPError` (must be a `BaseException` subclass or instance)
- Found 1190 diagnostics
+ Found 1172 diagnostics

flake8 (https://github.com/pycqa/flake8)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/flake8/tests/integration/test_checker.py:105:13: Argument to this function is incorrect: Expected `Namespace`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/flake8/tests/integration/test_checker.py:273:31: Argument to this function is incorrect: Expected `StyleGuideManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/flake8/tests/integration/test_checker.py:339:9: Argument to this function is incorrect: Expected `Namespace`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/flake8/tests/unit/test_legacy_api.py:16:34: Argument to this function is incorrect: Expected `Application`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/flake8/tests/unit/test_legacy_api.py:24:34: Argument to this function is incorrect: Expected `Application`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/flake8/tests/unit/test_legacy_api.py:32:34: Argument to this function is incorrect: Expected `Application`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/flake8/tests/unit/test_legacy_api.py:56:34: Argument to this function is incorrect: Expected `Application`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/flake8/tests/unit/test_legacy_api.py:65:34: Argument to this function is incorrect: Expected `Application`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/flake8/tests/unit/test_legacy_api.py:75:34: Argument to this function is incorrect: Expected `Application`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/flake8/tests/unit/test_legacy_api.py:90:34: Argument to this function is incorrect: Expected `Application`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/flake8/tests/unit/test_legacy_api.py:99:25: Argument to this function is incorrect: Expected `Application`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/flake8/tests/unit/test_legacy_api.py:110:25: Argument to this function is incorrect: Expected `Application`, found `Mock`
- Found 89 diagnostics
+ Found 77 diagnostics

aiohttp-devtools (https://github.com/aio-libs/aiohttp-devtools)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_logs.py:24:16: Argument to this function is incorrect: Expected `BaseRequest`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_logs.py:24:25: Argument to this function is incorrect: Expected `StreamResponse`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_logs.py:46:16: Argument to this function is incorrect: Expected `BaseRequest`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_logs.py:46:25: Argument to this function is incorrect: Expected `StreamResponse`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_logs.py:69:16: Argument to this function is incorrect: Expected `BaseRequest`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_logs.py:69:25: Argument to this function is incorrect: Expected `StreamResponse`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_logs.py:92:16: Argument to this function is incorrect: Expected `BaseRequest`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_logs.py:92:25: Argument to this function is incorrect: Expected `StreamResponse`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_logs.py:110:16: Argument to this function is incorrect: Expected `BaseRequest`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_logs.py:110:25: Argument to this function is incorrect: Expected `StreamResponse`, found `MagicMock`
+ warning[lint:unused-ignore-comment] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_serve.py:143:35: Unused blanket `type: ignore` directive
+ warning[lint:unused-ignore-comment] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_serve.py:157:35: Unused blanket `type: ignore` directive
+ warning[lint:unused-ignore-comment] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_serve.py:169:35: Unused blanket `type: ignore` directive
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_watch.py:40:24: Argument to this function is incorrect: Expected `Config`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_watch.py:44:26: Argument to this function is incorrect: Expected `Application`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_watch.py:60:24: Argument to this function is incorrect: Expected `Config`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_watch.py:65:26: Argument to this function is incorrect: Expected `Application`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_watch.py:83:24: Argument to this function is incorrect: Expected `Config`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_watch.py:118:24: Argument to this function is incorrect: Expected `Config`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_watch.py:133:22: Argument to this function is incorrect: Expected `Application`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_watch.py:146:22: Argument to this function is incorrect: Expected `Application`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_watch.py:156:24: Argument to this function is incorrect: Expected `Config`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_watch.py:169:24: Argument to this function is incorrect: Expected `Config`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_watch.py:181:24: Argument to this function is incorrect: Expected `Config`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/aiohttp-devtools/tests/test_runserver_watch.py:195:24: Argument to this function is incorrect: Expected `Config`, found `MagicMock`
- Found 87 diagnostics
+ Found 68 diagnostics

urllib3 (https://github.com/urllib3/urllib3)
- error[lint:no-matching-overload] /tmp/mypy_primer/projects/urllib3/test/test_ssl.py:91:9: No overload of function `ssl_wrap_socket` matches arguments
- error[lint:no-matching-overload] /tmp/mypy_primer/projects/urllib3/test/test_ssl.py:105:9: No overload of function `ssl_wrap_socket` matches arguments
- error[lint:no-matching-overload] /tmp/mypy_primer/projects/urllib3/test/test_ssl.py:120:9: No overload of function `ssl_wrap_socket` matches arguments
- error[lint:no-matching-overload] /tmp/mypy_primer/projects/urllib3/test/test_ssl.py:128:17: No overload of function `ssl_wrap_socket` matches arguments
- error[lint:no-matching-overload] /tmp/mypy_primer/projects/urllib3/test/test_util.py:998:9: No overload of function `ssl_wrap_socket` matches arguments
- error[lint:no-matching-overload] /tmp/mypy_primer/projects/urllib3/test/test_util.py:1009:9: No overload of function `ssl_wrap_socket` matches arguments
- error[lint:no-matching-overload] /tmp/mypy_primer/projects/urllib3/test/test_util.py:1016:9: No overload of function `ssl_wrap_socket` matches arguments
- error[lint:no-matching-overload] /tmp/mypy_primer/projects/urllib3/test/test_util.py:1024:9: No overload of function `ssl_wrap_socket` matches arguments
- error[lint:no-matching-overload] /tmp/mypy_primer/projects/urllib3/test/test_util.py:1034:9: No overload of function `ssl_wrap_socket` matches arguments
- error[lint:no-matching-overload] /tmp/mypy_primer/projects/urllib3/test/test_util.py:1046:13: No overload of function `ssl_wrap_socket` matches arguments
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/urllib3/test/test_ssltransport.py:527:13: Argument to this function is incorrect: Expected `socket`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/urllib3/test/test_ssltransport.py:539:13: Argument to this function is incorrect: Expected `socket`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/urllib3/test/test_ssltransport.py:558:13: Argument to this function is incorrect: Expected `socket`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/urllib3/test/test_ssltransport.py:568:13: Argument to this function is incorrect: Expected `socket`, found `Mock`
- Found 462 diagnostics
+ Found 448 diagnostics

poetry (https://github.com/python-poetry/poetry)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/poetry/src/poetry/utils/env/python/installer.py:83:19: Cannot raise object of type `PoetryRuntimeError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/poetry/tests/packages/test_direct_origin.py:44:34: Argument to this function is incorrect: Expected `ArtifactCache`, found `MagicMock`
- error[lint:invalid-raise] /tmp/mypy_primer/projects/poetry/src/poetry/console/commands/group_command.py:124:19: Cannot raise object of type `GroupNotFoundError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/poetry/tests/mixology/version_solver/test_dependency_cache.py:74:29: Argument to this function is incorrect: Expected `Provider`, found `Mock`
- error[lint:invalid-raise] /tmp/mypy_primer/projects/poetry/src/poetry/installation/chooser.py:242:19: Cannot raise object of type `PoetryRuntimeError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/poetry/src/poetry/toml/file.py:34:19: Cannot raise object of type `TOMLError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/poetry/src/poetry/vcs/git/backend.py:264:19: Cannot raise object of type `PoetryRuntimeError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/poetry/src/poetry/vcs/git/backend.py:281:19: Cannot raise object of type `PoetryRuntimeError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/poetry/src/poetry/vcs/git/backend.py:316:19: Cannot raise object of type `PoetryRuntimeError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/poetry/src/poetry/vcs/git/backend.py:329:19: Cannot raise object of type `PoetryRuntimeError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/poetry/src/poetry/vcs/git/backend.py:373:19: Cannot raise object of type `PoetryRuntimeError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/poetry/src/poetry/utils/authenticator.py:256:27: Cannot raise object of type `PoetryRuntimeError` (must be a `BaseException` subclass or instance)
- Found 1126 diagnostics
+ Found 1114 diagnostics

tornado (https://github.com/tornadoweb/tornado)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/tornado/tornado/http1connection.py:457:34: Argument to this function is incorrect: Expected `type | BaseException`, found `StreamClosedError`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/tornado/tornado/curl_httpclient.py:304:21: Argument to this function is incorrect: Expected `BaseException | None`, found `CurlError | None`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/tornado/tornado/simple_httpclient.py:245:13: Argument to this function is incorrect: Expected `BaseException | None`, found `HTTPTimeoutError`
- error[lint:invalid-assignment] /tmp/mypy_primer/projects/tornado/tornado/simple_httpclient.py:552:21: Object of type `HTTPStreamClosedError` is not assignable to `BaseException | None`
- error[lint:invalid-raise] /tmp/mypy_primer/projects/tornado/tornado/simple_httpclient.py:584:23: Cannot raise object of type `HTTPStreamClosedError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/tornado/tornado/iostream.py:998:19: Cannot raise object of type `StreamClosedError` (must be a `BaseException` subclass or instance)
- Found 388 diagnostics
+ Found 382 diagnostics

cki-lib (https://gitlab.com/cki-project/cki-lib)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/cki-lib/cki_lib/kcidb/validate.py:83:15: Cannot raise object of type `ValidationError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/cki-lib/cki_lib/kcidb/validate.py:111:15: Cannot raise object of type `ValidationError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/cki-lib/cki_lib/yaml.py:212:15: Cannot raise object of type `ValidationError` (must be a `BaseException` subclass or instance)
- Found 175 diagnostics
+ Found 172 diagnostics

dragonchain (https://github.com/dragonchain/dragonchain)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/lib/callback_utest.py:38:37: Argument to this function is incorrect: Expected `TransactionModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/lib/callback_utest.py:46:37: Argument to this function is incorrect: Expected `TransactionModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/lib/callback_utest.py:54:37: Argument to this function is incorrect: Expected `TransactionModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/lib/callback_utest.py:62:37: Argument to this function is incorrect: Expected `TransactionModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/lib/dao/api_key_dao_utest.py:75:34: Argument to this function is incorrect: Expected `APIKeyModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/webserver/lib/transactions_utest.py:68:54: Argument to this function is incorrect: Expected `APIKeyModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/webserver/lib/transactions_utest.py:79:77: Argument to this function is incorrect: Expected `APIKeyModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_1_actions_utest.py:122:42: Argument to this function is incorrect: Expected `TransactionModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_1_actions_utest.py:141:36: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_1_actions_utest.py:149:36: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_1_actions_utest.py:161:36: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_1_actions_utest.py:176:36: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/webserver/lib/interchain_utest.py:30:43: Argument to this function is incorrect: Expected `InterchainModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/webserver/lib/interchain_utest.py:44:43: Argument to this function is incorrect: Expected `InterchainModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/lib/dao/interchain_dao_utest.py:31:47: Argument to this function is incorrect: Expected `InterchainModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/scheduler/scheduler_utest.py:75:48: Argument to this function is incorrect: Expected `SmartContractModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_4_actions_utest.py:81:51: Argument to this function is incorrect: Expected `L3BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_4_actions_utest.py:92:51: Argument to this function is incorrect: Expected `L3BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_4_actions_utest.py:103:51: Argument to this function is incorrect: Expected `L3BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_4_actions_utest.py:127:35: Argument to this function is incorrect: Expected `L4BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_4_actions_utest.py:197:36: Argument to this function is incorrect: Expected `L4BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_4_actions_utest.py:208:36: Argument to this function is incorrect: Expected `L4BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/lib/dao/transaction_dao_utest.py:30:41: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_5_actions_utest.py:176:44: Argument to this function is incorrect: Expected `L5BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_5_actions_utest.py:241:51: Argument to this function is incorrect: Expected `L5BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_5_actions_utest.py:329:40: Argument to this function is incorrect: Expected `L5BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_5_actions_utest.py:383:50: Argument to this function is incorrect: Expected `L5BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:100:38: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:100:50: Argument to this function is incorrect: Expected `DCKeys`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:112:45: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:112:57: Argument to this function is incorrect: Expected `DCKeys`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:125:45: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:125:57: Argument to this function is incorrect: Expected `DCKeys`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:133:35: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:144:63: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:157:63: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:170:63: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:184:38: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:194:38: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:203:49: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:220:49: Argument to this function is incorrect: Expected `L1BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:252:36: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_2_actions_utest.py:263:36: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:82:35: Argument to this function is incorrect: Expected `L3BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:94:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:94:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:94:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:94:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:94:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:106:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:106:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:106:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:106:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:106:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:118:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:118:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:118:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:118:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:118:72: Argument to this function is incorrect: Expected `L2BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:210:36: Argument to this function is incorrect: Expected `L3BlockModel`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/dragonchain/dragonchain/transaction_processor/level_3_actions_utest.py:221:36: Argument to this function is incorrect: Expected `L3BlockModel`, found `MagicMock`
- Found 402 diagnostics
+ Found 341 diagnostics

comtypes (https://github.com/enthought/comtypes)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/comtypes/comtypes/test/test_comserver.py:186:55: Argument to this function is incorrect: Expected `COMObject`, found `TestComServer`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/comtypes/comtypes/test/test_server_register.py:212:28: Argument to this function is incorrect: Expected `type`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/comtypes/comtypes/test/test_server_register.py:224:30: Argument to this function is incorrect: Expected `type`, found `Mock`
- Found 714 diagnostics
+ Found 711 diagnostics

psycopg (https://github.com/psycopg/psycopg)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/base.py:143:23: Cannot raise object of type `PoolClosed` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/base.py:145:23: Cannot raise object of type `PoolClosed` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/null_pool_async.py:87:19: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/null_pool_async.py:97:19: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/null_pool_async.py:105:23: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/null_pool_async.py:110:19: Cannot raise object of type `TooManyRequests` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/null_pool.py:92:19: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/null_pool.py:102:19: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/null_pool.py:110:23: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/null_pool.py:114:19: Cannot raise object of type `TooManyRequests` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/pool.py:148:19: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/pool.py:203:19: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/pool.py:229:23: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/pool.py:268:19: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/pool.py:278:19: Cannot raise object of type `TooManyRequests` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/pool_async.py:175:19: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/pool_async.py:231:19: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/pool_async.py:257:23: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/pool_async.py:296:19: Cannot raise object of type `PoolTimeout` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/psycopg/psycopg_pool/psycopg_pool/pool_async.py:306:19: Cannot raise object of type `TooManyRequests` (must be a `BaseException` subclass or instance)
- Found 1319 diagnostics
+ Found 1299 diagnostics

mkdocs (https://github.com/mkdocs/mkdocs)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/config/defaults.py:91:9: Argument to this function is incorrect: Expected `BaseConfigOption | None`, found `Type`
+ warning[lint:unused-ignore-comment] /tmp/mypy_primer/projects/mkdocs/mkdocs/config/defaults.py:41:42: Unused blanket `type: ignore` directive
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:101:37: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:106:37: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:111:37: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:116:37: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:121:37: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:126:37: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:212:37: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:218:37: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:228:71: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:241:73: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:252:78: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:266:75: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:282:61: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:290:69: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:302:65: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/build_tests.py:314:65: Argument to this function is incorrect: Expected `Navigation`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/config/config_options_legacy_tests.py:207:30: Argument to this function is incorrect: Expected `BaseConfigOption | None`, found `Type`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/config/config_options_legacy_tests.py:220:30: Argument to this function is incorrect: Expected `BaseConfigOption | None`, found `Type`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/config/config_options_legacy_tests.py:243:35: Argument to this function is incorrect: Expected `BaseConfigOption | None`, found `Type`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/config/config_options_tests.py:190:30: Argument to this function is incorrect: Expected `BaseConfigOption | None`, found `Type`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/config/config_options_tests.py:203:30: Argument to this function is incorrect: Expected `BaseConfigOption | None`, found `Type`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/config/config_options_tests.py:226:35: Argument to this function is incorrect: Expected `BaseConfigOption | None`, found `Type`
- Found 200 diagnostics
+ Found 178 diagnostics

jinja (https://github.com/pallets/jinja)
+ warning[lint:unused-ignore-comment] /tmp/mypy_primer/projects/jinja/src/jinja2/environment.py:1072:41: Unused blanket `type: ignore` directive
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:36:19: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:99:15: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:209:19: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:380:23: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:395:23: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:451:15: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:494:19: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:528:19: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:540:19: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:555:19: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:590:15: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:604:15: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/loaders.py:679:23: Cannot raise object of type `TemplateNotFound` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/jinja/src/jinja2/environment.py:1059:19: Cannot raise object of type `TemplatesNotFound` (must be a `BaseException` subclass or instance)
- Found 429 diagnostics
+ Found 416 diagnostics

beartype (https://github.com/beartype/beartype)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/beartype/beartype/_check/convert/_reduce/redhint.py:456:33: Argument to this function is incorrect: Expected `AbstractSet`, found `Unknown | frozenset`
- Found 576 diagnostics
+ Found 575 diagnostics

werkzeug (https://github.com/pallets/werkzeug)
- error[lint:invalid-return-type] /tmp/mypy_primer/projects/werkzeug/src/werkzeug/serving.py:935:16: Return type does not match returned value: Expected `BaseWSGIServer`, found `ForkingWSGIServer`
- Found 501 diagnostics
+ Found 500 diagnostics

mitmproxy (https://github.com/mitmproxy/mitmproxy)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/addons/test_next_layer.py:421:27: Argument to this function is incorrect: Expected `NextLayer`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/addons/test_next_layer.py:426:27: Argument to this function is incorrect: Expected `NextLayer`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/addons/test_next_layer.py:433:27: Argument to this function is incorrect: Expected `NextLayer`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_events.py:24:38: Argument to this function is incorrect: Expected `StartHook`, found `Mock`
- error[lint:invalid-raise] /tmp/mypy_primer/projects/mitmproxy/mitmproxy/tools/web/app.py:291:19: Cannot raise object of type `APIError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/mitmproxy/mitmproxy/tools/web/app.py:295:19: Cannot raise object of type `APIError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/mitmproxy/mitmproxy/tools/web/app.py:324:19: Cannot raise object of type `APIError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/mitmproxy/mitmproxy/tools/web/app.py:349:19: Cannot raise object of type `APIError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/mitmproxy/mitmproxy/tools/web/app.py:414:19: Cannot raise object of type `APIError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/mitmproxy/mitmproxy/tools/web/app.py:506:35: Cannot raise object of type `APIError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/mitmproxy/mitmproxy/tools/web/app.py:529:35: Cannot raise object of type `APIError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/mitmproxy/mitmproxy/tools/web/app.py:535:27: Cannot raise object of type `APIError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/mitmproxy/mitmproxy/tools/web/app.py:633:23: Cannot raise object of type `APIError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/mitmproxy/mitmproxy/tools/web/app.py:712:19: Cannot raise object of type `APIError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/mitmproxy/mitmproxy/tools/web/app.py:767:19: Cannot raise object of type `APIError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/layers/quic/test__stream_layers.py:227:37: Argument to this function is incorrect: Expected `MasterSecretLogger`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:26:43: Argument to this function is incorrect: Expected `ServerManager`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:36:42: Argument to this function is incorrect: Expected `ServerManager`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:45:49: Argument to this function is incorrect: Expected `ServerManager`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:61:60: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:71:60: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:84:59: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:115:63: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:167:73: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:207:61: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:229:61: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:239:62: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:250:70: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:267:65: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:274:49: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:283:60: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:295:55: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:316:80: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:320:63: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:347:45: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:372:55: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:397:41: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:428:37: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:458:46: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:480:52: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:490:52: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:493:52: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:504:61: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/test_mode_servers.py:510:61: Argument to this function is incorrect: Expected `ServerManager`, found `MagicMock`
+ warning[lint:unused-ignore-comment] /tmp/mypy_primer/projects/mitmproxy/mitmproxy/net/http/url.py:49:47: Unused blanket `type: ignore` directive
- Found 1364 diagnostics
+ Found 1321 diagnostics

scrapy (https://github.com/scrapy/scrapy)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/scrapy/tests/test_downloadermiddleware_robotstxt.py:199:38: Argument to this function is incorrect: Expected `RobotParser | None`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/scrapy/tests/test_utils_misc/__init__.py:198:35: Argument to this function is incorrect: Expected `Crawler`, found `MagicMock`
- error[lint:invalid-assignment] /tmp/mypy_primer/projects/scrapy/tests/test_command_check.py:160:9: Object of type `Mock` is not assignable to attribute `crawler_process` of type `CrawlerProcess | None`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/scrapy/tests/test_command_check.py:172:32: Argument to this function is incorrect: Expected `Namespace`, found `Mock`
- error[lint:invalid-assignment] /tmp/mypy_primer/projects/scrapy/tests/test_command_check.py:185:9: Object of type `Mock` is not assignable to attribute `crawler_process` of type `CrawlerProcess | None`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/scrapy/tests/test_command_check.py:196:32: Argument to this function is incorrect: Expected `Namespace`, found `Mock`
- error[lint:invalid-return-type] /tmp/mypy_primer/projects/scrapy/scrapy/utils/deprecate.py:131:12: Return type does not match returned value: Expected `type`, found `DeprecatedClass`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/scrapy/tests/test_pipeline_files.py:570:17: Argument to this function is incorrect: Expected `BytesIO`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/scrapy/tests/test_pipeline_files.py:660:23: Argument to this function is incorrect: Expected `BytesIO`, found `Mock`
- error[lint:invalid-raise] /tmp/mypy_primer/projects/scrapy/scrapy/core/http2/protocol.py:280:19: Cannot raise object of type `MethodNotAllowed405` (must be a `BaseException` subclass or instance)
- Found 1510 diagnostics
+ Found 1500 diagnostics

cloud-init (https://github.com/canonical/cloud-init)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_wireguard.py:89:23: Cannot raise object of type `ProcessExecutionError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/cloud-init/tests/unittests/net/test_ephemeral.py:238:23: Cannot raise object of type `UrlError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_install_hotplug.py:62:30: Argument to this function is incorrect: Expected `Cloud`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_install_hotplug.py:85:26: Argument to this function is incorrect: Expected `Cloud`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_install_hotplug.py:97:26: Argument to this function is incorrect: Expected `Cloud`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_install_hotplug.py:108:26: Argument to this function is incorrect: Expected `Cloud`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_install_hotplug.py:128:26: Argument to this function is incorrect: Expected `Cloud`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_install_hotplug.py:145:30: Argument to this function is incorrect: Expected `Cloud`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_chef.py:50:47: Argument to this function is incorrect: Expected `Distro`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_chef.py:76:43: Argument to this function is incorrect: Expected `Distro`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_chef.py:82:55: Argument to this function is incorrect: Expected `Distro`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_chef.py:85:25: Argument to this function is incorrect: Expected `Distro`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_chef.py:108:43: Argument to this function is incorrect: Expected `Distro`, found `Mock`
- error[lint:invalid-raise] /tmp/mypy_primer/projects/cloud-init/tests/unittests/test_dmi.py:47:23: Cannot raise object of type `ProcessExecutionError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/cloud-init/tests/unittests/test_dmi.py:65:23: Cannot raise object of type `ProcessExecutionError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/cloud-init/tests/unittests/test_dmi.py:80:23: Cannot raise object of type `ProcessExecutionError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_grub_dpkg.py:256:16: Argument to this function is incorrect: Expected `str`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_grub_dpkg.py:256:34: Argument to this function is incorrect: Expected `Cloud`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_grub_dpkg.py:256:47: Argument to this function is incorrect: Expected `list`, found `Mock`
- error[lint:invalid-raise] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_package_update_upgrade_install.py:247:23: Cannot raise object of type `ProcessExecutionError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_package_update_upgrade_install.py:271:27: Cannot raise object of type `ProcessExecutionError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-raise] /tmp/mypy_primer/projects/cloud-init/cloudinit/config/cc_mounts.py:235:19: Cannot raise object of type `ProcessExecutionError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/test_stages.py:53:13: Argument to this function is incorrect: Expected `DataSource`, found `MagicMock`
- error[lint:invalid-raise] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_ubuntu_pro.py:411:23: Cannot raise object of type `ProcessExecutionError` (must be a `BaseException` subclass or instance)
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_ubuntu_pro.py:1268:36: Argument to this function is incorrect: Expected `Cloud`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_ubuntu_pro.py:1276:32: Argument to this function is incorrect: Expected `Cloud`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/net/test_network_state.py:231:13: Argument to this function is incorrect: Expected `Renderer | None`, found `MagicMock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_modules.py:107:13: Argument to this function is incorrect: Expected `Init`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_modules.py:155:13: Argument to this function is incorrect: Expected `Init`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_modules.py:189:13: Argument to this function is incorrect: Expected `Init`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_growpart.py:186:30: Argument to this function is incorrect: Expected `Distro`, found `Mock`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/cloud-init/tests/unittests/config/test_cc_growpart.py:212:30: Argument to this function is incor...*[Comment body truncated]*

@sharkdp sharkdp marked this pull request as ready for review April 22, 2025 17:31
@AlexWaygood AlexWaygood changed the title [red-knot] Assignability for subtypes of 'Any' [red-knot] Assignability for subclasses of 'Any' Apr 22, 2025
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, though I'd also include Unknown, and I think making some exceptions for @final classes does make sense.

It's unrelated to your PR, but while we're here: I find the comment at the top of this is_assignable_to method slightly confusing. I'm not sure what it's trying to say (or why); I'd be inclined to just delete it?

sharkdp added a commit that referenced this pull request Apr 23, 2025
## Summary

We currently emit a diagnostic for code like the following:
```py
from typing import Any

# error: Invalid class base with type `GenericAlias` (all bases must be a class, `Any`, `Unknown` or `Todo`)
class C(tuple[Any, ...]): ...
```

The changeset here silences this diagnostic by recognizing instances of
`GenericAlias` in `ClassBase::try_from_type`, and inferring a `@Todo`
type for them. This is a change in preparation for #17557, because `C`
previously had `Unknown` in its MRO …
```py
reveal_type(C.__mro__)  # tuple[Literal[C], Unknown, Literal[object]]
```
… which would cause us to think that `C` is assignable to everything.

The changeset also removes some false positive `invalid-base`
diagnostics across the ecosystem.

## Test Plan

Updated Markdown tests.
@sharkdp sharkdp force-pushed the david/subtype-of-any-assignability branch from 79df46c to d457975 Compare April 23, 2025 09:00
@sharkdp sharkdp changed the title [red-knot] Assignability for subclasses of 'Any' [red-knot] Assignability for subclasses of Any and Unknown Apr 23, 2025
@sharkdp
Copy link
Contributor Author

sharkdp commented Apr 23, 2025

With the new changes, we also allow subclasses of Unknown to be assigned to other non-final classes. This removes another batch of false positives, which can be summarized by this example

# This is a union with Unknown, because `IOError` is a
# simple `IOError = OSError` type alias in typeshed
reveal_type(IOError)  # Unknown | Literal[OSError]

class MyError(IOError): ...

reveal_type(MyError.__mro__)  # tuple[Literal[MyError], Unknown, Literal[object]]

raise MyError()  # no invalid-raise diagnostic anymore

we still raise "Invalid class base with type Unknown | Literal[OSError]" for the class definition. I am attempting to address this in #17577.

@sharkdp sharkdp merged commit 99fa850 into main Apr 23, 2025
34 checks passed
@sharkdp sharkdp deleted the david/subtype-of-any-assignability branch April 23, 2025 09:37
dcreager added a commit that referenced this pull request Apr 23, 2025
* main: (28 commits)
  [red-knot] Make `BoundMethodType` a salsa interned (#17581)
  [red-knot] Emit a diagnostic if a non-protocol is passed to `get_protocol_members` (#17551)
  [red-knot] Add more tests for protocol members (#17550)
  [red-knot] Assignability for subclasses of `Any` and `Unknown` (#17557)
  [red-knot] mypy_primer: add strawberry, print compilation errors to stderr (#17578)
  [red-knot] GenericAlias instances as a base class (#17575)
  Remove redundant `type_to_visitor_function` entries (#17564)
  Fixes how the checker visits `typing.cast`/`typing.NewType` arguments (#17538)
  [red-knot] Class literal `__new__` function callable subtyping (#17533)
  [red-knot] Surround intersections with `()` in potentially ambiguous contexts (#17568)
  [minor] Delete outdated TODO comment (#17565)
  [red-knot] add regression test for fixed cycle panic (#17535)
  [red-knot] fix unions of literals, again (#17534)
  red_knot_python_semantic: remove last vestige of old diagnostics!
  red_knot_python_semantic: migrate `types` to new diagnostics
  red_knot_python_semantic: migrate `types/diagnostic` to new diagnostics
  red_knot_python_semantic: migrate `types/call/bind` to new diagnostics
  red_knot_python_semantic: migrate `types/string_annotation` to new diagnostics
  red_knot_python_semantic: migrate `types/infer` to new diagnostic model
  red_knot_python_semantic: migrate INVALID_ASSIGNMENT for inference
  ...
dcreager added a commit that referenced this pull request Apr 23, 2025
…var-instance

* dcreager/generic-constructor: (29 commits)
  We don't need this
  [red-knot] Make `BoundMethodType` a salsa interned (#17581)
  [red-knot] Emit a diagnostic if a non-protocol is passed to `get_protocol_members` (#17551)
  [red-knot] Add more tests for protocol members (#17550)
  [red-knot] Assignability for subclasses of `Any` and `Unknown` (#17557)
  [red-knot] mypy_primer: add strawberry, print compilation errors to stderr (#17578)
  [red-knot] GenericAlias instances as a base class (#17575)
  Remove redundant `type_to_visitor_function` entries (#17564)
  Fixes how the checker visits `typing.cast`/`typing.NewType` arguments (#17538)
  [red-knot] Class literal `__new__` function callable subtyping (#17533)
  [red-knot] Surround intersections with `()` in potentially ambiguous contexts (#17568)
  [minor] Delete outdated TODO comment (#17565)
  [red-knot] add regression test for fixed cycle panic (#17535)
  [red-knot] fix unions of literals, again (#17534)
  red_knot_python_semantic: remove last vestige of old diagnostics!
  red_knot_python_semantic: migrate `types` to new diagnostics
  red_knot_python_semantic: migrate `types/diagnostic` to new diagnostics
  red_knot_python_semantic: migrate `types/call/bind` to new diagnostics
  red_knot_python_semantic: migrate `types/string_annotation` to new diagnostics
  red_knot_python_semantic: migrate `types/infer` to new diagnostic model
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ty Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants