Title: AssertionError raised after #19248 · Issue #19425 · python/mypy · GitHub
Open Graph Title: AssertionError raised after #19248 · Issue #19425 · python/mypy
X Title: AssertionError raised after #19248 · Issue #19425 · python/mypy
Description: Bug Report After upgrading to 1.16.1 we are seeing occasional AssertionErrors being logged: $ mypy mypy 1.16.1 (compiled: yes) Exception ignored in PyObject_HasAttr(); consider using PyObject_HasAttrWithError(), PyObject_GetOptionalAttr(...
Open Graph Description: Bug Report After upgrading to 1.16.1 we are seeing occasional AssertionErrors being logged: $ mypy mypy 1.16.1 (compiled: yes) Exception ignored in PyObject_HasAttr(); consider using PyObject_HasAt...
X Description: Bug Report After upgrading to 1.16.1 we are seeing occasional AssertionErrors being logged: $ mypy mypy 1.16.1 (compiled: yes) Exception ignored in PyObject_HasAttr(); consider using PyObject_HasAt...
Opengraph URL: https://github.com/python/mypy/issues/19425
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AssertionError raised after #19248","articleBody":"\u003c!--\nIf you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form instead.\nPlease consider:\n\n- checking our common issues page: https://mypy.readthedocs.io/en/stable/common_issues.html\n- searching our issue tracker: https://github.com/python/mypy/issues to see if it's already been reported\n- asking on gitter chat: https://gitter.im/python/typing\n-->\n\n**Bug Report**\n\n\u003c!--\nIf you're reporting a problem with a specific library function, the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues\n\nIf the project you encountered the issue in is open source, please provide a link to the project.\n-->\n\nAfter upgrading to 1.16.1 we are seeing occasional `AssertionError`s being logged:\n\n```console\n$ mypy\nmypy 1.16.1 (compiled: yes)\nException ignored in PyObject_HasAttr(); consider using PyObject_HasAttrWithError(), PyObject_GetOptionalAttr() or PyObject_GetAttr():\nTraceback (most recent call last):\n File \"mypy/nodes.py\", line 615, in setter\nAssertionError: \n... (repeated many times)\n```\n\nIt seems like the code introduced in https://github.com/python/mypy/pull/19248 to fix https://github.com/python/mypy/issues/19224 makes an assert which is not always true. It seems like the worry expressed in a [comment](https://github.com/python/mypy/pull/19248#pullrequestreview-2907639889) on that PR was justified ;).\n\n**To Reproduce**\n\nWe haven't managed to find a reliable reproducer yet. Switching between branches in our repo and invoking `mypy`, sometimes triggers it, but sometimes doesn't.\n\n**Expected Behavior**\n\n\u003c!--\nHow did you expect mypy to behave? It’s fine if you’re not sure your understanding is correct.\nWrite down what you thought would happen. If you expected no errors, delete this section.\n-->\n\nNo errors.\n\n**Actual Behavior**\n\n\u003c!-- What went wrong? Paste mypy's output. -->\n\nErrors.\n\n**Your Environment**\n\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\n\n- Mypy version used: 1.6.1\n- Mypy command-line flags: `dmypy run -- --cache-dir .mypy_cache/not_recently_touched \u003cexplicitly specified list of .py files>`\n- Mypy configuration options from `mypy.ini` (and other config files):\n```toml\n[tool.mypy]\nplugins = [\n \"pydantic.mypy\",\n \"pydantic.v1.mypy\",\n \"sqlalchemy.ext.mypy.plugin\",\n \"mypy.plugins.proper_plugin\", \n \u003ca custom mypy plugin>\n]\npython_version = \"3.13\"\nshow_error_codes = true\nstrict = true\n\nenable_error_code = [\n \"ignore-without-code\",\n \"redundant-expr\",\n \"redundant-self\",\n \"truthy-bool\",\n \"truthy-iterable\",\n]\nno_implicit_optional = true\nwarn_unreachable = true\n\n[[tool.mypy.overrides]]\nignore_missing_imports = true\nmodule = [\n \"asyncpg.*\",\n]\n```\n- Python version used:\n\n```console\n$ python --version\nPython 3.13.3\n```","author":{"url":"https://github.com/SemMulder","@type":"Person","name":"SemMulder"},"datePublished":"2025-07-11T12:45:04Z","url":"https://github.com/python/mypy/issues/19425"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a4aa2102-76ee-eae1-1d8a-d4bdf1fb4b6e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E7D0:3204C8:2EB336D:3D9F557:6B00241A |
| html-safe-nonce | 0ac14571dd050bde053a78a7bf9b713b1fb55a32a46ee2cf6f68e58dc411e8cd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0QwOjMyMDRDODoyRUIzMzZEOjNEOUY1NTc6NkIwMDI0MUEiLCJ2aXNpdG9yX2lkIjoiOTIxMTgyNTg2NTE4MzIwODQ3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c0e0e8e8d3042a2a1d9cafdb5a49eb08b0939fd8264fff850e5cc93fa4efcc24 |
| hovercard-subject-tag | issue:3222797318 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/19425/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7c1fbf5379c77337277265999736631a079d643f4dc49fa0acb35ff930f39e87/python/mypy/issues/19425 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7c1fbf5379c77337277265999736631a079d643f4dc49fa0acb35ff930f39e87/python/mypy/issues/19425 |
| og:image:alt | Bug Report After upgrading to 1.16.1 we are seeing occasional AssertionErrors being logged: $ mypy mypy 1.16.1 (compiled: yes) Exception ignored in PyObject_HasAttr(); consider using PyObject_HasAt... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SemMulder |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width