René's URL Explorer Experiment


Title: Crash on forward references in pydantic and django plugins · Issue #18579 · python/mypy · GitHub

Open Graph Title: Crash on forward references in pydantic and django plugins · Issue #18579 · python/mypy

X Title: Crash on forward references in pydantic and django plugins · Issue #18579 · python/mypy

Description: Crash Report Mypy was working fine on my django project until about a week ago, when I started getting this error. I'm not sure what caused it. My python code used to be in the root directory of my project and now I moved it to the backe...

Open Graph Description: Crash Report Mypy was working fine on my django project until about a week ago, when I started getting this error. I'm not sure what caused it. My python code used to be in the root directory of my...

X Description: Crash Report Mypy was working fine on my django project until about a week ago, when I started getting this error. I'm not sure what caused it. My python code used to be in the root directory o...

Opengraph URL: https://github.com/python/mypy/issues/18579

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash on forward references in pydantic and django plugins","articleBody":"**Crash Report**\n\nMypy was working fine on my django project until about a week ago, when I started getting this error. I'm not sure what caused it. My python code used to be in the root directory of my project and now I moved it to the `backend/` directory, and the problem started around then, but I'm not sure whether that is related.\n\nI am using [pre-commit](https://github.com/pre-commit/pre-commit) and have mypy set up in my .pre-commit-config.yaml. The error actually only happens when I run mypy as part of pre-commit. If I just run `mypy .` from the command line, it works fine.\n\nPresently, whenever I run pre-commit, I get an INTERNAL ERROR (details below).\n\n**Traceback**\n\n```\n/home/travis/Repos/bethpage/backend/bethpage/models.py:23: error: INTERNAL ERROR -- Please try using mypy master on GitHub:\nhttps://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build\nPlease report a bug at https://github.com/python/mypy/issues\nversion: 1.16.0+dev.23e2d0f8cbaa2f4874d8f6a6bee3756922c78407\nTraceback (most recent call last):\n  File \"/home/travis/Repos/bethpage/.tox/py312/bin/mypy\", line 8, in \u003cmodule>\n    sys.exit(console_entry())\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/__main__.py\", line 15, in console_entry\n    main()\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/main.py\", line 119, in main\n    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/main.py\", line 203, in run_build\n    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/build.py\", line 191, in build\n    result = _build(\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/build.py\", line 267, in _build\n    graph = dispatch(sources, manager, stdout)\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/build.py\", line 2937, in dispatch\n    process_graph(graph, manager)\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/build.py\", line 3335, in process_graph\n    process_stale_scc(graph, scc, manager)\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/build.py\", line 3430, in process_stale_scc\n    mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/semanal_main.py\", line 94, in semantic_analysis_for_scc\n    process_functions(graph, scc, patches)\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/semanal_main.py\", line 252, in process_functions\n    process_top_level_function(\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/semanal_main.py\", line 291, in process_top_level_function\n    deferred, incomplete, progress = semantic_analyze_target(\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/semanal_main.py\", line 351, in semantic_analyze_target\n    analyzer.refresh_partial(\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/semanal.py\", line 655, in refresh_partial\n    self.accept(node)\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/semanal.py\", line 7254, in accept\n    node.accept(self)\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/nodes.py\", line 811, in accept\n    return visitor.visit_func_def(self)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/semanal.py\", line 913, in visit_func_def\n    self.analyze_func_def(defn)\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/semanal.py\", line 958, in analyze_func_def\n    self.defer(defn)\n  File \"/home/travis/Repos/bethpage/.tox/py312/lib/python3.12/site-packages/mypy/semanal.py\", line 6900, in defer\n    assert not self.final_iteration, \"Must not defer during final iteration\"\n           ^^^^^^^^^^^^^^^^^^^^^^^^\nAssertionError: Must not defer during final iteration\n/home/travis/Repos/bethpage/backend/bethpage/models.py:23: : note: use --pdb to drop into pdb\n```\n\n**To Reproduce**\n\nThis crash happens any time I change any file in my `backend/` directory and then run `git add -A; pre-commit`.\n\nIt _does not_ happen if I just run `cd backend; mypy .`\n\nIf I use the `--no-incremental` flag or delete the cache directory, the problem still persists.\n\nIf I open up `backend/bethpage/models.py` and add a line that just says \"pass\" somewhere above line 23 (the line cited in the error), then run `git add -A; pre-commit`, it actually works fine and completes without errors. The next time I need to commit something, I'll get the error again, but I can just remove that \"pass\" line and once again, the error goes away.\n\nHere is the beginning of that `/backend/bethpage/models.py` file:\n\n```\nimport uuid\nfrom typing import (\n    Any,\n    ClassVar,\n    Dict,\n    Generic,\n    Iterable,\n    List,\n    Mapping,\n    Optional,\n    Self,\n    Tuple,\n    TypeVar,\n)\n\nfrom django.db import models, transaction\nfrom django.db.models.fields.reverse_related import ForeignObjectRel\nfrom django.utils import timezone\n\nT = TypeVar(\"T\", bound=\"BaseModel\")\n\n\nclass BaseQuerySet(models.QuerySet[T], Generic[T]):\n\n    def bulk_create(self, objs: Iterable[T], *args: Any, **kwargs: Any) -> List[T]:\n        for obj in objs:\n            obj.full_clean()\n        return super().bulk_create(objs, *args, **kwargs)\n...etc...\n```\n\n**Your Environment**\n\n- Mypy version used: I have tried versions of mypy from 1.0.0 to 1.14.1 and have also tried using the master branch on github, always with the same error.\n- Python version used: 3.12\n- Operating system: Arch Linux\n\n.pre-commit-config.yaml\n```\nrepos:\n  - repo: local\n    hooks:\n      - id: mypy\n        name: mypy\n        entry: mypy\n        language: system\n        types: [python]\n        args:\n          - --config-file=backend/mypy.ini\n          - --show-traceback\n...etc...\n```\n\nmypy.ini\n```\n[mypy]\npython_version = 3.12\nmypy_path = backend\nplugins =\n  mypy_django_plugin.main,\n  mypy_drf_plugin.main\nstrict = True\nshow_error_codes = True\ndisallow_untyped_calls = True\ndisallow_untyped_defs = True\ndisallow_incomplete_defs = True\ndisallow_any_unimported = True\ncheck_untyped_defs = True\nno_implicit_optional = True\nwarn_unused_ignores = True\nwarn_return_any = True\nwarn_unreachable = True\n\n[mypy.plugins.django-stubs]\ndjango_settings_module = bethpage.settings\n```","author":{"url":"https://github.com/TravisHardman","@type":"Person","name":"TravisHardman"},"datePublished":"2025-01-31T22:20:13Z","url":"https://github.com/python/mypy/issues/18579"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0fe1e93b-2923-2d57-f7cd-2250b363bad2
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8742:1D7BA0:34EAF2:477AD9:6B0027EA
html-safe-nonce97c878c13accc66454a5103665030a81b9dcbad18749cea7e0573aa81c19481b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzQyOjFEN0JBMDozNEVBRjI6NDc3QUQ5OjZCMDAyN0VBIiwidmlzaXRvcl9pZCI6IjE3NjY0NjA1NDM4NjgwODYyNTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac76ed3ce51d3910b13fd0f592baeea91756e66322d2db3e77a1742ffbc67ed572
hovercard-subject-tagissue:2824494581
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/18579/issue_layout
twitter:imagehttps://opengraph.githubassets.com/fd3055d14761f6800fb7fcc7dc922afdf8f9a481745ec2b469a590dbb5a82a91/python/mypy/issues/18579
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/fd3055d14761f6800fb7fcc7dc922afdf8f9a481745ec2b469a590dbb5a82a91/python/mypy/issues/18579
og:image:altCrash Report Mypy was working fine on my django project until about a week ago, when I started getting this error. I'm not sure what caused it. My python code used to be in the root directory of my...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameTravisHardman
hostnamegithub.com
expected-hostnamegithub.com
None4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0
turbo-cache-controlno-preview
go-importgithub.com/python/mypy git https://github.com/python/mypy.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id7053637
octolytics-dimension-repository_nwopython/mypy
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id7053637
octolytics-dimension-repository_network_root_nwopython/mypy
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release44c658b24abf00491fb7ae5f56d42c9f38cbeab2
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/18579#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F18579
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F18579
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fmypy
Reloadhttps://github.com/python/mypy/issues/18579
Reloadhttps://github.com/python/mypy/issues/18579
Reloadhttps://github.com/python/mypy/issues/18579
pythonhttps://github.com/python
mypyhttps://github.com/python/mypy
Codehttps://github.com/python/mypy
Issues2.7k (2.7k)https://github.com/python/mypy/issues
Pull requests547 (547)https://github.com/python/mypy/pulls
Actionshttps://github.com/python/mypy/actions
Projectshttps://github.com/python/mypy/projects
Wikihttps://github.com/python/mypy/wiki
Security and qualityhttps://github.com/python/mypy/security
Insightshttps://github.com/python/mypy/insights
https://github.com/python/mypy
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/18579
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/18579
Crash on forward references in pydantic and django pluginshttps://github.com/python/mypy/issues/18579#top
crashhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22crash%22
priority-0-highhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-0-high%22
https://github.com/TravisHardman
TravisHardmanhttps://github.com/TravisHardman
on Jan 31, 2025https://github.com/python/mypy/issues/18579#issue-2824494581
pre-commithttps://github.com/pre-commit/pre-commit
TravisHardmanhttps://github.com/TravisHardman
crashhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22crash%22
on Jan 31, 2025https://github.com/python/mypy/issues/18579#event-16146403279
https://github.com/A5rocks
A5rockshttps://github.com/A5rocks
on Feb 1, 2025https://github.com/python/mypy/issues/18579#issuecomment-2628651313
https://github.com/TravisHardman
TravisHardmanhttps://github.com/TravisHardman
on Feb 3, 2025https://github.com/python/mypy/issues/18579#issuecomment-2631307315
https://github.com/A5rocks
A5rockshttps://github.com/A5rocks
on Feb 3, 2025https://github.com/python/mypy/issues/18579#issuecomment-2631458972
@sobolevnhttps://github.com/sobolevn
https://github.com/TravisHardman
TravisHardmanhttps://github.com/TravisHardman
on Feb 3, 2025https://github.com/python/mypy/issues/18579#issuecomment-2631484243
https://github.com/A5rocks
A5rockshttps://github.com/A5rocks
on Feb 3, 2025https://github.com/python/mypy/issues/18579#issuecomment-2631513362
https://github.com/sobolevn
sobolevnhttps://github.com/sobolevn
on Feb 3, 2025https://github.com/python/mypy/issues/18579#issuecomment-2631558447
https://github.com/TravisHardman
TravisHardmanhttps://github.com/TravisHardman
on Feb 3, 2025https://github.com/python/mypy/issues/18579#issuecomment-2631710119
@A5rockshttps://github.com/A5rocks
@sobolevnhttps://github.com/sobolevn
#18579 (comment)https://github.com/python/mypy/issues/18579#issuecomment-2631307315
https://github.com/sterliakov
sterliakovhttps://github.com/sterliakov
on Feb 4, 2025https://github.com/python/mypy/issues/18579#issuecomment-2632690874
https://github.com/sterliakov
sterliakovhttps://github.com/sterliakov
on Feb 4, 2025https://github.com/python/mypy/issues/18579#issuecomment-2632693363
https://github.com/sobolevn
sobolevnhttps://github.com/sobolevn
on Feb 4, 2025https://github.com/python/mypy/issues/18579#issuecomment-2633149452
https://github.com/wyattscarpenter
wyattscarpenterhttps://github.com/wyattscarpenter
on Sep 21, 2025https://github.com/python/mypy/issues/18579#issuecomment-3316202647
#15927https://github.com/python/mypy/issues/15927
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Jan 29, 2026https://github.com/python/mypy/issues/18579#issuecomment-3819095242
ilevkivskyihttps://github.com/ilevkivskyi
priority-0-highhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-0-high%22
on Jan 29, 2026https://github.com/python/mypy/issues/18579#event-22383204131
ilevkivskyihttps://github.com/ilevkivskyi
on Jan 29, 2026https://github.com/python/mypy/issues/18579#event-22383217250
ilevkivskyihttps://github.com/ilevkivskyi
Mypy crashes with pydantic plugin enabled: Must not defer during final iteration #15927https://github.com/python/mypy/issues/15927
on Jan 29, 2026https://github.com/python/mypy/issues/18579#event-22383290791
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Jan 29, 2026https://github.com/python/mypy/issues/18579#issuecomment-3819133338
ilevkivskyihttps://github.com/ilevkivskyi
Crash: Must not defer during final iteration #20486https://github.com/python/mypy/issues/20486
on Jan 29, 2026https://github.com/python/mypy/issues/18579#event-22383325290
ilevkivskyihttps://github.com/ilevkivskyi
AssertionError: Must not defer during final iteration on large codebase #15723https://github.com/python/mypy/issues/15723
on Jan 29, 2026https://github.com/python/mypy/issues/18579#event-22383355085
ilevkivskyihttps://github.com/ilevkivskyi
mypy crash trying to analyze library code (when only asked to analyze my own code) #17745https://github.com/python/mypy/issues/17745
on Jan 29, 2026https://github.com/python/mypy/issues/18579#event-22383415711
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Jan 29, 2026https://github.com/python/mypy/issues/18579#issuecomment-3819221769
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Oct 19, 2026https://github.com/python/mypy/issues/18579#issuecomment-6271692636
Crash on forward references in pydantic and django plugins #18579 (comment)https://github.com/python/mypy/issues/18579#issuecomment-2632690874
@sobolevnhttps://github.com/sobolevn
Announcement issue for plugin API changes #6617https://github.com/python/mypy/issues/6617
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Oct 19, 2026https://github.com/python/mypy/issues/18579#issuecomment-6275070697
ilevkivskyihttps://github.com/ilevkivskyi
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 19, 2026https://github.com/python/mypy/issues/18579#event-33676428359
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/18579
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/18579
crashhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22crash%22
priority-0-highhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-0-high%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.