-
Notifications
You must be signed in to change notification settings - Fork 259
Allow typing.Mapping to form type aliases
#2031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow typing.Mapping to form type aliases
#2031
Conversation
typing.Mapping to form recursive aliasestyping.Mapping to form type aliases
This comment has been minimized.
This comment has been minimized.
stroxler
left a comment
There was a problem hiding this 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?
f11f0f0 to
68f6418
Compare
- 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`).
68f6418 to
d6115d5
Compare
|
Regenerated the conformance test results, should be good now @stroxler |
|
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`
|
yangdanny97
left a comment
There was a problem hiding this 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.
Summary
typing.Mappingas a special exporttyping.Mappingto be a type aliasThis 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