You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Specific single dispatch crashes on mypy 0.910. I've tried breaking the code out to reproduce but that doesn't trigger the error.
Traceback
Traceback (most recent call last):
File "/app/venv/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/app/venv/lib/python3.9/site-packages/mypy/__main__.py", line 11, in console_entry
main(None, sys.stdout, sys.stderr)
File "mypy/main.py", line 87, in main
File "mypy/main.py", line 165, in run_build
File "mypy/build.py", line 179, in build
File "mypy/build.py", line 254, in _build
File "mypy/build.py", line 2697, in dispatch
File "mypy/build.py", line 3021, in process_graph
File "mypy/build.py", line 3138, in process_stale_scc
File "mypy/build.py", line 2288, in write_cache
File "mypy/build.py", line 1476, in write_cache
File "mypy/build.py", line 1428, in json_dumps
File "/usr/local/lib/python3.9/json/__init__.py", line 234, in dumps
return cls(
File "/usr/local/lib/python3.9/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/local/lib/python3.9/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/local/lib/python3.9/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type AnyType is not JSON serializable
To Reproduce
Update: The below probably has nothing to do with this error. I believe the crash occurs only when there are no errors to report by mypy. This is from a large sized project and pinning down the code that causes this will be challenging ...
This function used to be typed like this which passed on mypy 0.812 (even though I realize accuracy might not have been as high as I expected):
T=TypeVar("T", bound=object)
@singledispatchdefserialize(value: T, _config: SerializerConfig) ->T:
returnvalue@serialize.register# Followed by a bunch of implementations.def_serialize_enum(value: enum.Enum, _config: SerializerConfig) ->str: ...
But when upgrading to 0.910 this started giving errors like this. I don't know if it is a new requirement or not that the return value of registered functions are subtypes of the return value of the "main" function?
src/utils/schema.py:73: error: Argument 1 to "register" of "_SingleDispatchCallable" has incompatible type "Callable[[Enum, SerializerConfig], str]"; expected "Callable[..., T]" [arg-type]
@serialize.register
So to remedy I tried altering the function to this which gives triggers the error (I've also tried with Any and an internal JSONSerializable type which give the same result):
Hmm, actually replacing the function doesn't make the error go away, and I'm starting to doubt if it's even related to this module. It might be that the error "always" occurs when there are no type errors to report ...
Crash Report
Specific single dispatch crashes on mypy 0.910. I've tried breaking the code out to reproduce but that doesn't trigger the error.
Traceback
To Reproduce
Update: The below probably has nothing to do with this error. I believe the crash occurs only when there are no errors to report by mypy. This is from a large sized project and pinning down the code that causes this will be challenging ...
This function used to be typed like this which passed on mypy 0.812 (even though I realize accuracy might not have been as high as I expected):
But when upgrading to 0.910 this started giving errors like this. I don't know if it is a new requirement or not that the return value of registered functions are subtypes of the return value of the "main" function?
So to remedy I tried altering the function to this which gives triggers the error (I've also tried with
Any
and an internalJSONSerializable
type which give the same result):I've tried replacing the function and all its definitions with just
def serialize(*args, **kwargs): ...
and that makes the error go away.Your Environment
mypy.ini
(and other config files):python:3.9.6-buster
in CI.The text was updated successfully, but these errors were encountered: