Open bersbersbers opened 1 month ago
Yes, this is impossible to reproduce consistently. When I hit the issue, I can run mypy
repeatedly, and it reproduces the same error many times. But as soon as I run mypy --cache-dir=nul
, the issue is gone.
fwiw, ran into the same, reverting to 1.9.0 resolved it for me.
Ran into the same issue and also resolved by reverting to 1.9
I get it as well but it repro's every time.
@jabbera can you construct a reproducer?
@hauntsaninja famous last words. Went to repro today and it didn't happen.
So, I could repro this occasionally, if I remove/add the #type: ignore[assignment, method-assign
in a code that looks like this:
@pytest.fixture(name="mocked_service")
def fixture_mocked_service(
mocker: pytest_mock.MockerFixture,
) -> services.SomeService:
some_svc: services.SomeService = mocker.MagicMock(spec=services.SomeService)
some_svc.process_something = mocker.MagicMock(
side_effect=lambda _, something: models.Something( # type: ignore[assignment, method-assign]
id=uuid.uuid4(),
state=something.state,
remote_url=something.remote_url,
name=something.name,
hash=something.hash,
size=something.size,
mime_type=something.mime_type,
)
)
return some_svc
Unfortunately, this only fails if I run mypy on the entire project, so I cannot share a reproducible example since the code is proprietary.
If I run mypy without the # type: ignore
, I get the proper error, then when I run it after I add the # type: ignore
it crashes.
The stacktrace is a bit different but fails at the same place
File "/workspaces/hub-2/.venv/bin/mypy", line 8, in <module>
sys.exit(console_entry())
^^^^^^^^^^^^^^^
File "/workspaces/hub-2/.venv/lib/python3.11/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "mypy/main.py", line 100, in main
File "mypy/main.py", line 182, in run_build
File "mypy/build.py", line 192, in build
File "mypy/build.py", line 266, in _build
File "mypy/build.py", line 2942, in dispatch
File "mypy/build.py", line 3333, in process_graph
File "mypy/build.py", line 3411, in process_fresh_modules
File "mypy/build.py", line 2099, in load_tree
File "mypy/nodes.py", line 399, in deserialize
File "mypy/nodes.py", line 3945, in deserialize
File "mypy/nodes.py", line 3886, in deserialize
File "mypy/nodes.py", line 260, in deserialize
File "mypy/nodes.py", line 824, in deserialize
File "mypy/types.py", line 224, in deserialize_type
def gi_code(self):
File "mypy/types.py", line 2266, in deserialize
KeyError: 'type_is'
This happens even if I annotate the fixture with @typing.no_type_check
.
Crash Report
mypy crashes.
Traceback
To Reproduce
I am sorry I do not have reproduction steps. This happened about 5 times across two days, and when it happened, it always fixed itself by running
mypy
2 or 3 more times. (Maybe that invalidates the cache?)Your Environment
mypy.ini
(and other config files):