Skip to content

Conversation

@fangyi-zhou
Copy link
Contributor

@fangyi-zhou fangyi-zhou commented Jan 8, 2026

Summary

  • Add typing.Mapping as a special export
  • Recongnise that subscript in typing.Mapping to be a type alias

This fix is targeted to the failing conformance test suite (although I guess recursive aliases are still not working since recursive types are not supported afaik). Nonetheless, I think we need a longer term solution since there are other related "special exports" (e.g. collections.abc.Mapping, typing.MutableMapping, typing.Sequence).

Test Plan

python test.py

@meta-cla meta-cla bot added the cla signed label Jan 8, 2026
@fangyi-zhou fangyi-zhou changed the title Allow typing.Mapping to form recursive aliases Allow typing.Mapping to form type aliases Jan 8, 2026
@github-actions

This comment has been minimized.

Copy link
Contributor

@stroxler stroxler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, but I think there's a rebase conflict preventing me from importing. Could you try rebasing on main, and ping me when you're done so I can rerun the import?

@fangyi-zhou fangyi-zhou force-pushed the allow-recursive-alias-typing-mapping branch from f11f0f0 to 68f6418 Compare January 10, 2026 11:22
- Add `typing.Mapping` as a special export
- Recongnise that subscript in `typing.Mapping` to be a type alias

This fix is targeted to the failing conformance test suite. I think we
need a longer term solution since there are other related "special
exports" (e.g. `collections.abc.Mapping`, `typing.MutableMapping`,
`typing.Sequence`).
@fangyi-zhou fangyi-zhou force-pushed the allow-recursive-alias-typing-mapping branch from 68f6418 to d6115d5 Compare January 10, 2026 11:24
@fangyi-zhou
Copy link
Contributor Author

Regenerated the conformance test results, should be good now @stroxler

@meta-codesync
Copy link

meta-codesync bot commented Jan 10, 2026

@stroxler has imported this pull request. If you are a Meta employee, you can view this in D90433864.

@github-actions
Copy link

Diff from mypy_primer, showing the effect of this PR on open source code:

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
- ERROR src/scikit_build_core/_logging.py:19:31-38: Expected a type form, got instance of `Literal['Style']` [not-a-type]
- ::error file=src/scikit_build_core/_logging.py,line=19,col=31,endLine=19,endColumn=38,title=Pyrefly not-a-type::Expected a type form, got instance of `Literal['Style']`

discord.py (https://github.com/Rapptz/discord.py)
- ERROR discord/http.py:801:44-52: Unpacked keyword argument `str` is not assignable to parameter `cookies` with type `BaseCookie[str] | Iterable[tuple[str, str | Unknown]] | Mapping[str, str | Unknown] | None` in function `aiohttp.client.ClientSession.get` [bad-argument-type]
+ ERROR discord/http.py:801:44-52: Unpacked keyword argument `str` is not assignable to parameter `cookies` with type `BaseCookie[str] | Iterable[tuple[str, str | Unknown]] | Mapping[str, BaseCookie[str] | Morsel[Any] | str] | None` in function `aiohttp.client.ClientSession.get` [bad-argument-type]
- ::error file=discord/http.py,line=801,col=44,endLine=801,endColumn=52,title=Pyrefly bad-argument-type::Unpacked keyword argument `str` is not assignable to parameter `cookies` with type `BaseCookie[str] | Iterable[tuple[str, str | Unknown]] | Mapping[str, str | Unknown] | None` in function `aiohttp.client.ClientSession.get`
+ ::error file=discord/http.py,line=801,col=44,endLine=801,endColumn=52,title=Pyrefly bad-argument-type::Unpacked keyword argument `str` is not assignable to parameter `cookies` with type `BaseCookie[str] | Iterable[tuple[str, str | Unknown]] | Mapping[str, BaseCookie[str] | Morsel[Any] | str] | None` in function `aiohttp.client.ClientSession.get`

@stroxler stroxler self-assigned this Jan 11, 2026
Copy link
Contributor

@yangdanny97 yangdanny97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync
Copy link

meta-codesync bot commented Jan 13, 2026

@stroxler merged this pull request in ae3cf27.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants