mypy crashes when running it on our internal package. this started happening with v1.18.1, it works with v1.17.1
Traceback
.venv/lib/python3.12/site-packages/pydantic/env_settings.py:23: 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.18.1
Traceback (most recent call last):
File "mypy/semanal.py", line 7350, in accept
File "mypy/nodes.py", line 1440, in accept
File "mypy/semanal.py", line 1775, in visit_class_def
File "mypy/semanal.py", line 1991, in analyze_class
File "mypy/semanal.py", line 2038, in analyze_class_body_common
File "mypy/semanal.py", line 2123, in apply_class_plugin_hooks
File "pydantic/mypy.py", line 156, in pydantic.mypy.PydanticPlugin._pydantic_model_class_maker_callback
File "pydantic/mypy.py", line 319, in pydantic.mypy.PydanticModelTransformer.transform
File "pydantic/mypy.py", line 529, in pydantic.mypy.PydanticModelTransformer.add_construct_method
File "pydantic/mypy.py", line 868, in pydantic.mypy.add_methodTypeError: tuple object expected; got list
Hm, it looks like this is caused by #19768 cc @JukkaL I would say type attribute setter type is technically private API, as types should be considered immutable by plugins (and .copy_modified() should be used instead). But can totally see how some people think this is public API. So even if we will not revert this, we need to mention such changes in the plugin announcement issue #6617
Btw I see this was already fixed in Pydantic main branch pydantic/pydantic#12209 and see people already talking there about backporting this to v1.x
@mlubej Does this also happen with Pydantic v2.x latest?
@mlubej Does this also happen with Pydantic v2.x latest?
I'm sorry, I wouldn't know, and I can't update pydantic to v2 because there are significant changes we'd need to implement, which we will in due time, but don't have resources right now
We have successfully applied the patches from the PR @ilevkivskyi linked to pydantic in our environment. This did fix the issue for us.
It is quite a bit of work, but this should be filed against pydantic. Although perhaps more as another request to release the fix, as they have already committed a fix. mypy can't do much.
Uhhh, weird. I definitely did not intentionally re-open this issue. I am extremely confused how this could have happened. Perhaps some stray keyboard input re-opened without me realizing? Guess I should go rotate my credentials just in case...
Activity
ilevkivskyi commented on Sep 12, 2025
Hm, it looks like this is caused by #19768 cc @JukkaL I would say type attribute setter type is technically private API, as types should be considered immutable by plugins (and .copy_modified() should be used instead). But can totally see how some people think this is public API. So even if we will not revert this, we need to mention such changes in the plugin announcement issue #6617
Btw I see this was already fixed in Pydantic main branch pydantic/pydantic#12209 and see people already talking there about backporting this to v1.x
@mlubej Does this also happen with Pydantic v2.x latest?
mlubej commented on Sep 12, 2025
I'm sorry, I wouldn't know, and I can't update pydantic to v2 because there are significant changes we'd need to implement, which we will in due time, but don't have resources right now
DanielNoord commented on Sep 12, 2025
We have successfully applied the patches from the PR @ilevkivskyi linked to pydantic in our environment. This did fix the issue for us.
It is quite a bit of work, but this should be filed against pydantic. Although perhaps more as another request to release the fix, as they have already committed a fix. mypy can't do much.
JukkaL commented on Sep 12, 2025
Wrote a comment in the plugin API issue about the change in CallableType: #6617 (comment)
cdce8p commented on Sep 13, 2025
Pydantic released new versions today which resolve the issue. Going to close this one.
https://github.com/pydantic/pydantic/releases/tag/v1.10.23
https://github.com/pydantic/pydantic/releases/tag/v2.11.9
cdce8p commented on Sep 13, 2025
@emmatyping I think this can be closed now or is there a reason to keep it open?
emmatyping commented on Sep 13, 2025
Uhhh, weird. I definitely did not intentionally re-open this issue. I am extremely confused how this could have happened. Perhaps some stray keyboard input re-opened without me realizing? Guess I should go rotate my credentials just in case...