Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: __init__() missing required argument 'default' (pos 6) #15485

Closed
romulorosa opened this issue Jun 21, 2023 · 9 comments
Closed

TypeError: __init__() missing required argument 'default' (pos 6) #15485

romulorosa opened this issue Jun 21, 2023 · 9 comments
Labels
crash topic-plugins The plugin API and ideas for new plugins

Comments

@romulorosa
Copy link

Crash Report
I tried to run mypy --show-traceback since it is breaking on version 1.4.0 (I was using version 1.3.0 before)
(Tell us what happened.)

Traceback

Traceback (most recent call last):
  File "mypy/semanal.py", line 6451, in accept
  File "mypy/nodes.py", line 1139, in accept
  File "mypy/semanal.py", line 1582, in visit_class_def
  File "mypy/semanal.py", line 1667, in analyze_class
  File "mypy/semanal.py", line 1694, in analyze_class_body_common
  File "mypy/semanal.py", line 1777, in apply_class_plugin_hooks
  File "pydantic/mypy.py", line 129, in pydantic.mypy.PydanticPlugin._pydantic_model_class_maker_callback
  File "pydantic/mypy.py", line 262, in pydantic.mypy.PydanticModelTransformer.transform
  File "pydantic/mypy.py", line 441, in pydantic.mypy.PydanticModelTransformer.add_construct_method
TypeError: __init__() missing required argument 'default' (pos 6)

/Users/rrosa/env/lib/python3.11/site-packages/pydantic/env_settings.py:22: 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.4.0
/Users/rrosa/env/lib/python3.11/site-packages/pydantic/env_settings.py:22: : note: use --pdb to drop into pdb

To Reproduce

(Write what you did to reproduce the crash. Full source code is
appreciated. We also very much appreciate it if you try to narrow the
source down to a small stand-alone example.)

Your Environment

  • Mypy version used: 1.4.0
  • Mypy command-line flags: mypy
  • Mypy configuration options from mypy.ini (and other config files):
[mypy]
python_version = 3.11
files = my_project/**/*.py
plugins = pydantic.mypy
disallow_untyped_defs = true
warn_no_return = false
ignore_missing_imports = true
  • Python version used: 3.11.3
  • Operating system and version: MacOS Ventura 13.4 (M1 Pro)
@AlexWaygood
Copy link
Member

The traceback indicates that this is an issue in pydantic's mypy plugin rather than mypy itself.

Are you using the latest version of pydantic? If not, does it still reproduce with the latest version?

@cdce8p
Copy link
Collaborator

cdce8p commented Jun 21, 2023

Please update pydantic to version 1.10.9 or newer. That does resolve the crash.
https://github.com/pydantic/pydantic/releases/tag/v1.10.9

@AlexWaygood
Copy link
Member

Closing based on what @cdce8p says. If there's still a problem with the latest version of pydantic, best to open an issue over at the pydantic repo, since this is a problem with the pydantic mypy plugin rather than with core mypy :)

@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2023
@cdce8p
Copy link
Collaborator

cdce8p commented Jun 21, 2023

If there's still a problem with the latest version of pydantic, best to open an issue over at the pydantic repo, since this is a problem with the pydantic mypy plugin rather than with core mypy :)

Technically, one of my mypy PR broke it. 😅 But, at least for pydantic, I already contributed the fix.

@AlexWaygood
Copy link
Member

Technically, one of my mypy PR broke it. 😅 But, at least for pydantic, I already contributed the fix.

Ah -- worth posting in #6617, perhaps? :)

@cdce8p
Copy link
Collaborator

cdce8p commented Jun 21, 2023

Technically, one of my mypy PR broke it. 😅 But, at least for pydantic, I already contributed the fix.

Ah -- worth posting in #6617, perhaps? :)

I didn't change the API, only added a new required argument to TypeVarType / TypeVarExpr. Will do that though.

@AlexWaygood
Copy link
Member

I didn't change the API, only added a new required argument to TypeVarType / TypeVarExpr. Will do that though.

Yup. Still might be nice to do so as a courtesy to plugin authors, though, if there's a chance it might break other plugins 👍

@AlexWaygood AlexWaygood added the topic-plugins The plugin API and ideas for new plugins label Jun 21, 2023
@cdce8p
Copy link
Collaborator

cdce8p commented Jun 21, 2023

I didn't change the API, only added a new required argument to TypeVarType / TypeVarExpr. Will do that though.

Yup. Still might be nice to do so as a courtesy to plugin authors, though, if there's a chance it might break other plugins 👍

Done #6617 (comment)

@AlexWaygood
Copy link
Member

Thank you <3

Gandalf-the-Grey pushed a commit to openhive-network/schemas that referenced this issue Jul 7, 2023
This one resolves the issue with pydantic
not being comaptible with newest version
of mypy (1.4.1):
python/mypy#15485 (comment)
Gandalf-the-Grey pushed a commit to openhive-network/schemas that referenced this issue Jul 11, 2023
This one resolves the issue with pydantic
not being comaptible with newest version
of mypy (1.4.1):
python/mypy#15485 (comment)
Gandalf-the-Grey pushed a commit to openhive-network/schemas that referenced this issue Jul 24, 2023
This one resolves the issue with pydantic
not being comaptible with newest version
of mypy (1.4.1):
python/mypy#15485 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash topic-plugins The plugin API and ideas for new plugins
Projects
None yet
Development

No branches or pull requests

3 participants