Title: [1.20 regression] _Environ.get(key, default) returns str | None when default is an alias to Any · Issue #21344 · python/mypy · GitHub
Open Graph Title: [1.20 regression] _Environ.get(key, default) returns str | None when default is an alias to Any · Issue #21344 · python/mypy
X Title: [1.20 regression] _Environ.get(key, default) returns str | None when default is an alias to Any · Issue #21344 · python/mypy
Description: Since mypy 1.20, passing a value whose type is an alias to Any (e.g. Incomplete: TypeAlias = Any) as the default argument of os.environ.get causes mypy to infer str | None instead of Any, producing a spurious [arg-type] error at the use ...
Open Graph Description: Since mypy 1.20, passing a value whose type is an alias to Any (e.g. Incomplete: TypeAlias = Any) as the default argument of os.environ.get causes mypy to infer str | None instead of Any, producing...
X Description: Since mypy 1.20, passing a value whose type is an alias to Any (e.g. Incomplete: TypeAlias = Any) as the default argument of os.environ.get causes mypy to infer str | None instead of Any, producing...
Opengraph URL: https://github.com/python/mypy/issues/21344
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[1.20 regression] _Environ.get(key, default) returns str | None when default is an alias to Any","articleBody":"Since mypy 1.20, passing a value whose type is an alias to `Any` (e.g. `Incomplete: TypeAlias = Any`) as the `default` argument of `os.environ.get` causes mypy to infer `str | None` instead of `Any`, producing a spurious `[arg-type]` error at the use site.\n\nReproducer: https://mypy-play.net/?gist=7a79f64ac9733542b571cc358f6d3165\n\n```python\nimport os\nfrom pathlib import Path\nfrom typing import Any\nfrom typing_extensions import TypeAlias\n\nIncomplete: TypeAlias = Any\n\nA: Incomplete = Path()\nreveal_type(A) # Any (good)\n\nB = os.environ.get('TEST', A)\nreveal_type(B) # str | None (bad) (expected: Any)\n\nC = Path(B) # error: Argument 1 to \"Path\" has incompatible\n # type \"str | None\"; expected \"str | PathLike[str]\"\n```\n\nBisected to `30260ca57` which added explicit `_Environ.get`/`pop` overloads where the first overload is `def get(self, key, default: None = None) -> AnyStr | None`. Before that sync, `_Environ` inherited `Mapping.get`, whose first overload took no `default` argument, so 2-arg calls couldn't match it. \n\nVersions: broken on mypy ≥ 1.20.0; works on mypy ≤ 1.19.1.","author":{"url":"https://github.com/pablogsal","@type":"Person","name":"pablogsal"},"datePublished":"2026-04-27T14:06:56Z","url":"https://github.com/python/mypy/issues/21344"}
| 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:c14a204c-d3f8-9e0a-e73f-813851bdc536 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D21A:3B60C0:406AF8:568DDE:6B002AA6 |
| html-safe-nonce | b71d7b5647ffcc0461ee0d7d23f504a88eaad2715c90123d220ee94aa75f0426 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjFBOjNCNjBDMDo0MDZBRjg6NTY4RERFOjZCMDAyQUE2IiwidmlzaXRvcl9pZCI6IjQ1NTE1Nzk1ODUwMDI2MTM0MTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5b52dd63fa1f36d5f014d42ab3afe8ca76913032fa09bea7ce4aebb75e76e331 |
| hovercard-subject-tag | issue:4336348267 |
| 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/21344/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b6a6aa87879664c9ff7b6e6ae53ea5435c38d061c398fc1dac7dc4f1aaf73e57/python/mypy/issues/21344 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b6a6aa87879664c9ff7b6e6ae53ea5435c38d061c398fc1dac7dc4f1aaf73e57/python/mypy/issues/21344 |
| og:image:alt | Since mypy 1.20, passing a value whose type is an alias to Any (e.g. Incomplete: TypeAlias = Any) as the default argument of os.environ.get causes mypy to infer str | None instead of Any, producing... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pablogsal |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width