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

1.12 regression related to TypedDictType #17958

Closed
torarvid opened this issue Oct 15, 2024 · 2 comments
Closed

1.12 regression related to TypedDictType #17958

torarvid opened this issue Oct 15, 2024 · 2 comments
Labels

Comments

@torarvid
Copy link

Crash Report

Ran mypy as normal: uv run mypy --show-error-codes --show-column-numbers, and got an INTERNAL_ERROR. Never seen it before, so was surprised.

Traceback

❯ uv run mypy --show-error-codes --show-column-numbers --show-traceback
src/hamon/users/managers.py:15: 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.12.0
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 5847, in accept
  File "mypy/nodes.py", line 1969, in accept
  File "mypy/checkexpr.py", line 480, in visit_call_expr
  File "mypy/checkexpr.py", line 614, in visit_call_expr_inner
  File "mypy/checkexpr.py", line 1471, in check_call_expr_with_callee_type
  File "mypy/checkexpr.py", line 1565, in check_call
  File "mypy/checkexpr.py", line 1811, in check_callable_call
  File "mypy/checkexpr.py", line 1262, in apply_function_plugin
  File "/Users/torarvid/oda/hardware-monitoring/.venv/lib/python3.12/site-packages/mypy_django_plugin/transformers/querysets.py", line 278, in extract_proper_type_queryset_annotate
    fields_dict = helpers.make_typeddict(api, fields=field_types, required_keys=set(field_types.keys()))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/torarvid/oda/hardware-monitoring/.venv/lib/python3.12/site-packages/mypy_django_plugin/lib/helpers.py", line 405, in make_typeddict
    typed_dict_type = TypedDictType(fields, required_keys=required_keys, fallback=fallback_type)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: __init__() missing required argument 'readonly_keys' (pos 3)

To Reproduce

Sorry, this is in a company repo, so I don't think I'm allowed to just paste in the code. Hope the traceback is enough to help you find it.

Your Environment

  • Mypy version used: 1.12
  • Mypy command-line flags: uv run mypy --show-error-codes --show-column-numbers --show-traceback
  • Mypy configuration options from mypy.ini (and other config files):
[tool.mypy]
python_version = "3.12"
plugins = [
    "mypy_django_plugin.main",
    "pydantic.mypy",
    "strawberry.ext.mypy_plugin",
]
files = ["./src/cli", "./src/hamon", "./src/shared"]
ignore_missing_imports = true
follow_imports = "normal"
strict = true

# Disable typing in migration files generated by Django
[[tool.mypy.overrides]]
module = "hamon.*.migrations.*"
ignore_errors = true
  • Python version used: 3.12.6
  • Operating system and version: macOS 15.0.1
@torarvid torarvid added the crash label Oct 15, 2024
@brianschubert
Copy link
Collaborator

brianschubert commented Oct 15, 2024

The exception is coming from mypy_django_plugin, so this is likely an issue with that plugin and not mypy itself.

Looks like this issue was already reported on their tracker: typeddjango/django-stubs#2405

edit: taking a closer look, this looks related to a change in the representation of TypedDictType in #17644. That might qualify as a change in the “implicit plugin API”, so this should perhaps be documented in #6617

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 15, 2024

Documented the change to the implicit plugin API: #6617 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants