Skip to content

fix Feature suggestion: special case _replace in NamedTuple #3960#3971

Open
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:3960
Open

fix Feature suggestion: special case _replace in NamedTuple #3960#3971
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:3960

Conversation

@asukaminato0721

Copy link
Copy Markdown
Contributor

Summary

Fixes #3960

Implemented synthesized _replace support for NamedTuple, static named tuples now get optional keyword-only params typed from their fields,

reject unknown kwargs, reject positional replacements, and return Self.

Dynamic-field named tuples keep permissive **kwargs: Any.

Test Plan

add test

@github-actions

Copy link
Copy Markdown

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

pip (https://github.com/pypa/pip)
+ ERROR src/pip/_vendor/requests/sessions.py:232:51-68: Argument `bytes | str` is not assignable to parameter `fragment` with type `str` in function `urllib.parse.ParseResult._replace` [bad-argument-type]

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.

Feature suggestion: special case _replace in NamedTuple

1 participant