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
I'm reporting the issue here because I think it's a problem with pydantic's mypy plugin. It was working fine before updating, more specifically it worked with pydantic-core==2.14.6 and pydantic==2.5.3.
Now, the error occurs only when both of these settings are specified in pyproject.toml:
When trying to parse a pydantic model with optional fields, mypy crashes as follows:
testo.py:4: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.8.0
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "mypy\semanal.py", line 6539, in accept
File "mypy\nodes.py", line 1142, in accept
File "mypy\semanal.py", line 1612, in visit_class_def
File "mypy\semanal.py", line 1697, in analyze_class
File "mypy\semanal.py", line 1731, in analyze_class_body_common
File "mypy\semanal.py", line 1816, in apply_class_plugin_hooks
File "C:\Users\arico\venv2\Lib\site-packages\pydantic\mypy.py", line 187, in _pydantic_model_class_maker_callback
return transformer.transform()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\arico\venv2\Lib\site-packages\pydantic\mypy.py", line 478, in transform
self.add_initializer(fields, config, is_settings, is_root_model)
File "C:\Users\arico\venv2\Lib\site-packages\pydantic\mypy.py", line 856, in add_initializer
args = self.get_field_arguments(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\arico\venv2\Lib\site-packages\pydantic\mypy.py", line 1039, in get_field_arguments
field.to_argument(
File "C:\Users\arico\venv2\Lib\site-packages\pydantic\mypy.py", line 346, in to_argument
variable=self.to_var(current_info, use_alias),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\arico\venv2\Lib\site-packages\pydantic\mypy.py", line 373, in to_var
return Var(name, self.expand_type(current_info))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\arico\venv2\Lib\site-packages\pydantic\mypy.py", line 362, in expand_type
raise _DeferAnalysis()
_DeferAnalysis:
@kikones34 thanks for reporting, I've opened a PR that I believe fixes it — #8666. It would be great if you could confirm whether that resolves your issues.
Yep, this was introduced in #7411 and it's obvious that the change I made there was not handling all possible scenarios under which the _DeferAnalysis error I introduced could be raised, but also that #8666 fixes that.
Initial Checks
Description
I'm reporting the issue here because I think it's a problem with pydantic's mypy plugin. It was working fine before updating, more specifically it worked with
pydantic-core==2.14.6
andpydantic==2.5.3
.Now, the error occurs only when both of these settings are specified in
pyproject.toml
:When trying to parse a pydantic model with optional fields, mypy crashes as follows:
Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: