Skip to content

2.8.0 breaks mypy #549

Closed
Closed
@sparkiegeek

Description

@sparkiegeek

Our CI pulled in pydantic-settings 2.8.0 and it triggered an internal error in mypy.

We invoke mypy using --install-types --non-interactive and are using mypy 1.15.0

Traceback (most recent call last):
  File "mypy/semanal.py", line 7240, in accept
  File "mypy/nodes.py", line 1177, in accept
  File "mypy/semanal.py", line 1728, in visit_class_def
  File "mypy/semanal.py", line 1944, in analyze_class
  File "mypy/semanal.py", line 1991, in analyze_class_body_common
  File "mypy/semanal.py", line 2076, in apply_class_plugin_hooks
  File "/usr/local/lib/python3.11/site-packages/pydantic/mypy.py", line 184, in _pydantic_model_class_maker_callback
    return transformer.transform()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydantic/mypy.py", line 527, in transform
    self.add_initializer(fields, config, is_settings, is_root_model)
  File "/usr/local/lib/python3.11/site-packages/pydantic/mypy.py", line 927, in add_initializer
    if arg_name.startswith('__') or not arg_name.startswith('_'):
       ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'startswith'

Pinning to < 2.8.0 doesn't hit the issue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions