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
Copy link

github-actions bot commented Jan 8, 2026

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`

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

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.

2 participants