Title: [1.20 regression] reachability in django-modern-rest · Issue #21132 · python/mypy · GitHub
Open Graph Title: [1.20 regression] reachability in django-modern-rest · Issue #21132 · python/mypy
X Title: [1.20 regression] reachability in django-modern-rest · Issue #21132 · python/mypy
Description: Hi! I am facing 150+ errors in my project https://github.com/wemake-services/django-modern-rest after updating mypy to 1.20 from 1.19. Here are the most frequest ones: lru_cache issues dmr/response.py:236: error: Cannot determine type of...
Open Graph Description: Hi! I am facing 150+ errors in my project https://github.com/wemake-services/django-modern-rest after updating mypy to 1.20 from 1.19. Here are the most frequest ones: lru_cache issues dmr/response...
X Description: Hi! I am facing 150+ errors in my project https://github.com/wemake-services/django-modern-rest after updating mypy to 1.20 from 1.19. Here are the most frequest ones: lru_cache issues dmr/response...
Opengraph URL: https://github.com/python/mypy/issues/21132
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[1.20 regression] reachability in django-modern-rest","articleBody":"Hi!\n\nI am facing 150+ errors in my project https://github.com/wemake-services/django-modern-rest after updating mypy to `1.20` from `1.19.`\n\nHere are the most frequest ones:\n\n## lru_cache issues\n\n```\ndmr/response.py:236: error: Cannot determine type of \"resolve_setting\" [has-type]\ndmr/response.py:236: note: Revealed type is \"Any\"\ndmr/response.py:237: error: Cannot determine type of \"resolve_setting\" [has-type]\ndmr/routing.py:108: error: Cannot determine type of \"resolve_setting\" [has-type]\ndmr/routing.py:190: error: Cannot determine type of \"resolve_setting\" [has-type]\ndmr/parsers.py:232: error: Cannot determine type of \"resolve_setting\" [has-type]\ndmr/parsers.py:284: error: Cannot determine type of \"resolve_setting\" [has-type]\n```\n\nFor some reason all code that is using [`resolve_setting`](https://github.com/wemake-services/django-modern-rest/blob/9062072376962f8b9ba6e195244ca702fe3d15e8/dmr/routing.py#L107-L109) fails with this error:\n\n```python\nrenderers_list = (\n resolve_setting(Settings.renderers) if renderers is None else renderers\n)\n```\n\nHere's how [it is defined](https://github.com/wemake-services/django-modern-rest/blob/9062072376962f8b9ba6e195244ca702fe3d15e8/dmr/settings.py#L168):\n\n```python\n@lru_cache(maxsize=MAX_CACHE_SIZE)\ndef resolve_setting(\n setting_name: Settings,\n *,\n import_string: bool = False,\n) -\u003e Any:\n \"\"\"\n Resolves setting by *setting_name*.\n\n The result is cached using ``@lru_cache`` for performance.\n When testing with custom settings, you *must* call\n :func:`clear_settings_cache` before and after modifying\n Django settings to ensure the cache is invalidated properly.\n \"\"\"\n setting = _resolve_defaults().get(\n setting_name,\n _DEFAULTS[setting_name],\n )\n if import_string and isinstance(setting, str):\n return module_loading.import_string(setting)\n return setting # pyright: ignore[reportUnknownVariableType]\n```\n\nMaybe `@lru_cache(maxsize=MAX_CACHE_SIZE)` is the root cause? If I remove this decorator - all errors are gone.\n\nWe also faced a similiar problem in our `django-stubs` PR: https://github.com/typeddjango/django-stubs/pull/3252#discussion_r3018408038\n\n## Unreachable\n\nI have more than 120+ errors that some statements are unreachable.\nExamples:\n\n```\n(.venv) ~/Desktop/django-modern-rest master ✗ 1 ⚠️\n» mypy dmr\ndmr/settings.py:122: error: Statement is unreachable [unreachable]\ndmr/validation/settings.py:41: error: Statement is unreachable [unreachable]\n```\n\n1. https://github.com/wemake-services/django-modern-rest/blob/9062072376962f8b9ba6e195244ca702fe3d15e8/dmr/settings.py#L122\n2. https://github.com/wemake-services/django-modern-rest/blob/9062072376962f8b9ba6e195244ca702fe3d15e8/dmr/validation/settings.py#L41\n\nThese are two different module-level definitions. Not sure what is the root cause here :(\n","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2026-04-01T08:51:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/21132/mypy/issues/21132"}
| 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:664ed7b9-7e6d-752b-5ff9-819e835924d0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED9A:15719E:5581A:7C9AF:6A58A169 |
| html-safe-nonce | 953270f2f23ae5a110a6f70bacc980145f1157bc370c5b7abcf7494f5a57546e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDlBOjE1NzE5RTo1NTgxQTo3QzlBRjo2QTU4QTE2OSIsInZpc2l0b3JfaWQiOiIzMDk0MzgxNzYyMjQ5NzkzODk3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | eaef02f2f8e0902684c4aa44e56c2f2c09154ff602108be4c912a90be5f1c198 |
| hovercard-subject-tag | issue:4185263013 |
| 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/21132/issue_layout |
| twitter:image | https://opengraph.githubassets.com/922c3b323dd2616fe6681d409f0508da8e9365dc14ed0d28b81ddf1dfacf958d/python/mypy/issues/21132 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/922c3b323dd2616fe6681d409f0508da8e9365dc14ed0d28b81ddf1dfacf958d/python/mypy/issues/21132 |
| og:image:alt | Hi! I am facing 150+ errors in my project https://github.com/wemake-services/django-modern-rest after updating mypy to 1.20 from 1.19. Here are the most frequest ones: lru_cache issues dmr/response... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sobolevn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| 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 | 7d699f0c51c1f58938601870a21967b74eaad94d |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width