Skip to content
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

Add signature for dataclasses.replace #14849

Merged
merged 49 commits into from
Jun 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6dbaf9c
Add signature for dataclasses.replace
ikonst Mar 7, 2023
4dcbe44
add ClassVar
ikonst Mar 7, 2023
7ed3741
prevent misleading note
ikonst Mar 7, 2023
89257b5
stash in a secret class-private
ikonst Mar 8, 2023
32b1d47
fix typing
ikonst Mar 8, 2023
1f08816
docs and naming
ikonst Mar 8, 2023
c456a5f
inst -> obj
ikonst Mar 8, 2023
8118d29
add the secret symbol to deps.test
ikonst Mar 8, 2023
789cb2b
language
ikonst Mar 8, 2023
9f0974c
nit
ikonst Mar 8, 2023
a37e406
nit
ikonst Mar 8, 2023
367c0e9
Merge branch 'master' into 2023-03-06-dataclasses-replace
ikonst Mar 9, 2023
0e84c4f
make obj positional-only
ikonst Mar 14, 2023
9cfc081
Merge branch '2023-03-06-dataclasses-replace' of https://github.com/i…
ikonst Mar 14, 2023
7b907cf
add pythoneval test
ikonst Mar 14, 2023
985db60
use py3.7 syntax
ikonst Mar 14, 2023
15dbb7b
Merge branch 'master' into 2023-03-06-dataclasses-replace
ikonst Mar 17, 2023
3227fde
Fix lint
ikonst Mar 17, 2023
2dbf249
use syntactically invalid name for symbol
ikonst Mar 30, 2023
b32881c
Merge branch '2023-03-06-dataclasses-replace' of https://github.com/i…
ikonst Mar 30, 2023
26056a4
Merge remote-tracking branch 'origin/master' into 2023-03-06-dataclas…
ikonst Mar 30, 2023
40315b7
mypy-replace must use name mangling prefix
ikonst Mar 30, 2023
c005895
Generic dataclass support
ikonst Mar 30, 2023
d71bc21
add fine-grained test
ikonst Mar 30, 2023
d914b94
disable for arbitrary transforms
ikonst Mar 31, 2023
2cb6dee
Merge branch 'master' into 2023-03-06-dataclasses-replace
ikonst Apr 6, 2023
5735726
fix testDataclassTransformReplace
ikonst Apr 7, 2023
d38897e
better error message for generics
ikonst Apr 7, 2023
04f0ee3
add support for typevars
ikonst Apr 8, 2023
f402b86
streamline
ikonst Apr 8, 2023
306c3f3
self-check
ikonst Apr 8, 2023
9b491f5
Merge remote-tracking branch 'origin/master' into 2023-03-06-dataclas…
ikonst Apr 21, 2023
283fe3d
Add improved union support from #15050
ikonst Apr 21, 2023
29780e9
Merge branch 'master' into 2023-03-06-dataclasses-replace
ikonst May 1, 2023
9c43ab6
Merge branch 'master' into 2023-03-06-dataclasses-replace
ikonst May 3, 2023
94024ba
Merge branch 'master' into 2023-03-06-dataclasses-replace
ikonst May 9, 2023
70240c4
Merge branch 'master' into 2023-03-06-dataclasses-replace
ikonst May 16, 2023
99bf973
Merge branch 'master' into 2023-03-06-dataclasses-replace
ikonst May 17, 2023
8fe75a7
add to testReplaceUnion
ikonst May 22, 2023
bea50e8
testReplaceUnion: fix B.y to be int
ikonst May 22, 2023
cd35951
rename testcase replace to testReplace
ikonst May 22, 2023
d71a7c0
Merge remote-tracking branch 'origin/master' into 2023-03-06-dataclas…
ikonst May 22, 2023
957744e
Merge branch 'master' into 2023-03-06-dataclasses-replace
ikonst Jun 2, 2023
6abf6ff
Merge remote-tracking branch 'origin/master' into pr/ikonst/14849
ikonst Jun 12, 2023
4c4fc94
remove get_expression_type hack
ikonst Jun 12, 2023
be4a290
assert isinstance(replace_sig, ProperType)
ikonst Jun 17, 2023
ee0ae21
add a TODO for _meet_replace_sigs
ikonst Jun 17, 2023
3f656f8
Merge remote-tracking branch 'origin/master' into 2023-03-06-dataclas…
ikonst Jun 17, 2023
65d6e89
Merge remote-tracking branch 'origin/master' into 2023-03-06-dataclas…
ikonst Jun 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test-data/unit/lib-stub/dataclasses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ def field(*,

class Field(Generic[_T]): pass

def replace(obj: _T, **changes: Any) -> _T: ...
def replace(obj: _T, /, **changes: Any) -> _T: ...
ikonst marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 20 additions & 0 deletions test-data/unit/pythoneval.test
Original file line number Diff line number Diff line change
Expand Up @@ -1984,3 +1984,23 @@ def good9(foo1: Foo[Concatenate[int, P]], foo2: Foo[[int, str, bytes]], *args: P

[out]
_testStrictEqualitywithParamSpec.py:11: error: Non-overlapping equality check (left operand type: "Foo[[int]]", right operand type: "Bar[[int]]")

[case testDataclassReplace]
from dataclasses import dataclass, replace

@dataclass
class A:
x: int


a = A(x=42)
a2 = replace(a, x=42)
reveal_type(a2)
a2 = replace()
a2 = replace(a, x='spam')
a2 = replace(a, x=42, q=42)
[out]
_testDataclassReplace.py:10: note: Revealed type is "_testDataclassReplace.A"
_testDataclassReplace.py:11: error: Too few arguments for "replace"
_testDataclassReplace.py:12: error: Argument "x" to "replace" of "A" has incompatible type "str"; expected "int"
_testDataclassReplace.py:13: error: Unexpected keyword argument "q" for "replace" of "A"