-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathcheck-dataclass-transform.test
More file actions
692 lines (544 loc) · 19.6 KB
/
check-dataclass-transform.test
File metadata and controls
692 lines (544 loc) · 19.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
[case testDataclassTransformReusesDataclassLogic]
# flags: --python-version 3.11
from typing import dataclass_transform, Type
@dataclass_transform()
def my_dataclass(cls: Type) -> Type:
return cls
@my_dataclass
class Person:
name: str
age: int
def summary(self):
return "%s is %d years old." % (self.name, self.age)
reveal_type(Person) # N: Revealed type is "def (name: builtins.str, age: builtins.int) -> __main__.Person"
Person('John', 32)
Person('Jonh', 21, None) # E: Too many arguments for "Person"
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformIsFoundInTypingExtensions]
# flags: --python-version 3.7
from typing import Type
from typing_extensions import dataclass_transform
@dataclass_transform()
def my_dataclass(cls: Type) -> Type:
return cls
@my_dataclass
class Person:
name: str
age: int
def summary(self):
return "%s is %d years old." % (self.name, self.age)
reveal_type(Person) # N: Revealed type is "def (name: builtins.str, age: builtins.int) -> __main__.Person"
Person('John', 32)
Person('Jonh', 21, None) # E: Too many arguments for "Person"
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformParametersAreApplied]
# flags: --python-version 3.11
from typing import dataclass_transform, Callable, Type
@dataclass_transform()
def my_dataclass(*, eq: bool, order: bool) -> Callable[[Type], Type]:
def transform(cls: Type) -> Type:
return cls
return transform
@my_dataclass(eq=False, order=True) # E: "eq" must be True if "order" is True
class Person:
name: str
age: int
reveal_type(Person) # N: Revealed type is "def (name: builtins.str, age: builtins.int) -> __main__.Person"
Person('John', 32)
Person('John', 21, None) # E: Too many arguments for "Person"
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformParametersMustBeBoolLiterals]
# flags: --python-version 3.11
from typing import dataclass_transform, Callable, Type
@dataclass_transform()
def my_dataclass(*, eq: bool = True, order: bool = False) -> Callable[[Type], Type]:
def transform(cls: Type) -> Type:
return cls
return transform
@dataclass_transform()
class BaseClass:
def __init_subclass__(cls, *, eq: bool): ...
@dataclass_transform()
class Metaclass(type): ...
BOOL_CONSTANT = True
@my_dataclass(eq=BOOL_CONSTANT) # E: "eq" argument must be a True or False literal
class A: ...
@my_dataclass(order=not False) # E: "order" argument must be a True or False literal
class B: ...
class C(BaseClass, eq=BOOL_CONSTANT): ... # E: "eq" argument must be a True or False literal
class D(metaclass=Metaclass, order=not False): ... # E: "order" argument must be a True or False literal
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformDefaultParamsMustBeLiterals]
# flags: --python-version 3.11
from typing import dataclass_transform, Type, Final
BOOLEAN_CONSTANT = True
FINAL_BOOLEAN: Final = True
@dataclass_transform(eq_default=BOOLEAN_CONSTANT) # E: "eq_default" argument must be a True or False literal
def foo(cls: Type) -> Type:
return cls
@dataclass_transform(eq_default=(not True)) # E: "eq_default" argument must be a True or False literal
def bar(cls: Type) -> Type:
return cls
@dataclass_transform(eq_default=FINAL_BOOLEAN) # E: "eq_default" argument must be a True or False literal
def baz(cls: Type) -> Type:
return cls
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformUnrecognizedParamsAreErrors]
# flags: --python-version 3.11
from typing import dataclass_transform, Type
BOOLEAN_CONSTANT = True
@dataclass_transform(nonexistant=True) # E: Unrecognized dataclass_transform parameter "nonexistant"
def foo(cls: Type) -> Type:
return cls
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformDefaultParams]
# flags: --python-version 3.11
from typing import dataclass_transform, Type, Callable
@dataclass_transform(eq_default=False)
def no_eq(*, order: bool = False) -> Callable[[Type], Type]:
return lambda cls: cls
@no_eq()
class Foo: ...
@no_eq(order=True) # E: "eq" must be True if "order" is True
class Bar: ...
@dataclass_transform(kw_only_default=True)
def always_use_kw(cls: Type) -> Type:
return cls
@always_use_kw
class Baz:
x: int
Baz(x=5)
Baz(5) # E: Too many positional arguments for "Baz"
@dataclass_transform(order_default=True)
def ordered(*, eq: bool = True) -> Callable[[Type], Type]:
return lambda cls: cls
@ordered()
class A:
x: int
A(1) > A(2)
@dataclass_transform(frozen_default=True)
def frozen(cls: Type) -> Type:
return cls
@frozen
class B:
x: int
b = B(x=1)
b.x = 2 # E: Property "x" defined in "B" is read-only
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformDefaultsCanBeOverridden]
# flags: --python-version 3.11
from typing import dataclass_transform, Callable, Type
@dataclass_transform(kw_only_default=True)
def my_dataclass(*, kw_only: bool = True) -> Callable[[Type], Type]:
return lambda cls: cls
@my_dataclass()
class KwOnly:
x: int
@my_dataclass(kw_only=False)
class KwOptional:
x: int
KwOnly(5) # E: Too many positional arguments for "KwOnly"
KwOptional(5)
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformFieldSpecifiersDefaultsToEmpty]
# flags: --python-version 3.11
from dataclasses import field, dataclass
from typing import dataclass_transform, Type
@dataclass_transform()
def my_dataclass(cls: Type) -> Type:
return cls
@my_dataclass
class Foo:
foo: int = field(kw_only=True)
# Does not cause a type error because `dataclasses.field` is not a recognized field specifier by
# default
Foo(5)
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformFieldSpecifierRejectMalformed]
# flags: --python-version 3.11
from typing import dataclass_transform, Any, Callable, Final, Type
def some_type() -> Type: ...
def some_function() -> Callable[[], None]: ...
def field(*args, **kwargs): ...
def fields_tuple() -> tuple[type | Callable[..., Any], ...]: return (field,)
CONSTANT: Final = (field,)
@dataclass_transform(field_specifiers=(some_type(),)) # E: "field_specifiers" must only contain identifiers
def bad_dataclass1() -> None: ...
@dataclass_transform(field_specifiers=(some_function(),)) # E: "field_specifiers" must only contain identifiers
def bad_dataclass2() -> None: ...
@dataclass_transform(field_specifiers=CONSTANT) # E: "field_specifiers" argument must be a tuple literal
def bad_dataclass3() -> None: ...
@dataclass_transform(field_specifiers=fields_tuple()) # E: "field_specifiers" argument must be a tuple literal
def bad_dataclass4() -> None: ...
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformFieldSpecifierParams]
# flags: --python-version 3.11
from typing import dataclass_transform, Any, Callable, Type, Final
def field(
*,
init: bool = True,
kw_only: bool = False,
alias: str | None = None,
default: Any | None = None,
default_factory: Callable[[], Any] | None = None,
factory: Callable[[], Any] | None = None,
): ...
@dataclass_transform(field_specifiers=(field,))
def my_dataclass(cls: Type) -> Type:
return cls
B: Final = 'b_'
@my_dataclass
class Foo:
a: int = field(alias='a_')
b: int = field(alias=B)
# cannot be passed as a positional
kwonly: int = field(kw_only=True, default=0)
# Safe to omit from constructor, error to pass
noinit: int = field(init=False, default=1)
# It should be safe to call the constructor without passing any of these
unused1: int = field(default=0)
unused2: int = field(factory=lambda: 0)
unused3: int = field(default_factory=lambda: 0)
Foo(a=5, b_=1) # E: Unexpected keyword argument "a" for "Foo"
Foo(a_=1, b_=1, noinit=1) # E: Unexpected keyword argument "noinit" for "Foo"
Foo(1, 2, 3) # E: Too many positional arguments for "Foo"
foo = Foo(1, 2, kwonly=3)
reveal_type(foo.noinit) # N: Revealed type is "builtins.int"
reveal_type(foo.unused1) # N: Revealed type is "builtins.int"
Foo(a_=5, b_=1, unused1=2, unused2=3, unused3=4)
def some_str() -> str: ...
def some_bool() -> bool: ...
@my_dataclass
class Bad:
bad1: int = field(alias=some_str()) # E: "alias" argument to dataclass field must be a string literal
bad2: int = field(kw_only=some_bool()) # E: "kw_only" argument must be a boolean literal
reveal_type(Foo.__dataclass_fields__) # N: Revealed type is "builtins.dict[builtins.str, Any]"
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformFieldSpecifierExtraArgs]
# flags: --python-version 3.11
from typing import dataclass_transform
def field(extra1, *, kw_only=False, extra2=0): ...
@dataclass_transform(field_specifiers=(field,))
def my_dataclass(cls):
return cls
@my_dataclass
class Good:
a: int = field(5)
b: int = field(5, extra2=1)
c: int = field(5, kw_only=True)
@my_dataclass
class Bad:
a: int = field(kw_only=True) # E: Missing positional argument "extra1" in call to "field"
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformMultipleFieldSpecifiers]
# flags: --python-version 3.11
from typing import dataclass_transform
def field1(*, default: int) -> int: ...
def field2(*, default: str) -> str: ...
@dataclass_transform(field_specifiers=(field1, field2))
def my_dataclass(cls): return cls
@my_dataclass
class Foo:
a: int = field1(default=0)
b: str = field2(default='hello')
reveal_type(Foo) # N: Revealed type is "def (a: builtins.int =, b: builtins.str =) -> __main__.Foo"
Foo()
Foo(a=1, b='bye')
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformOverloadsDecoratorOnOverload]
# flags: --python-version 3.11
from typing import dataclass_transform, overload, Any, Callable, Type, Literal
@overload
def my_dataclass(*, foo: str) -> Callable[[Type], Type]: ...
@overload
@dataclass_transform(frozen_default=True)
def my_dataclass(*, foo: int) -> Callable[[Type], Type]: ...
def my_dataclass(*, foo: Any) -> Callable[[Type], Type]:
return lambda cls: cls
@my_dataclass(foo="hello")
class A:
a: int
@my_dataclass(foo=5)
class B:
b: int
reveal_type(A) # N: Revealed type is "def (a: builtins.int) -> __main__.A"
reveal_type(B) # N: Revealed type is "def (b: builtins.int) -> __main__.B"
A(1, "hello") # E: Too many arguments for "A"
a = A(1)
a.a = 2 # E: Property "a" defined in "A" is read-only
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformOverloadsDecoratorOnImpl]
# flags: --python-version 3.11
from typing import dataclass_transform, overload, Any, Callable, Type, Literal
@overload
def my_dataclass(*, foo: str) -> Callable[[Type], Type]: ...
@overload
def my_dataclass(*, foo: int) -> Callable[[Type], Type]: ...
@dataclass_transform(frozen_default=True)
def my_dataclass(*, foo: Any) -> Callable[[Type], Type]:
return lambda cls: cls
@my_dataclass(foo="hello")
class A:
a: int
@my_dataclass(foo=5)
class B:
b: int
reveal_type(A) # N: Revealed type is "def (a: builtins.int) -> __main__.A"
reveal_type(B) # N: Revealed type is "def (b: builtins.int) -> __main__.B"
A(1, "hello") # E: Too many arguments for "A"
a = A(1)
a.a = 2 # E: Property "a" defined in "A" is read-only
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformViaBaseClass]
# flags: --python-version 3.11
from typing import dataclass_transform
@dataclass_transform(frozen_default=True)
class Dataclass:
def __init_subclass__(cls, *, kw_only: bool = False): ...
class Person(Dataclass, kw_only=True):
name: str
age: int
reveal_type(Person) # N: Revealed type is "def (*, name: builtins.str, age: builtins.int) -> __main__.Person"
Person('Jonh', 21) # E: Too many positional arguments for "Person"
person = Person(name='John', age=32)
person.name = "John Smith" # E: Property "name" defined in "Person" is read-only
class Contact(Person):
email: str
reveal_type(Contact) # N: Revealed type is "def (email: builtins.str, *, name: builtins.str, age: builtins.int) -> __main__.Contact"
Contact('john@john.com', name='John', age=32)
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformViaMetaclass]
# flags: --python-version 3.11
from typing import dataclass_transform
@dataclass_transform(frozen_default=True)
class Dataclass(type): ...
class Person(metaclass=Dataclass, kw_only=True):
name: str
age: int
reveal_type(Person) # N: Revealed type is "def (*, name: builtins.str, age: builtins.int) -> __main__.Person"
Person('Jonh', 21) # E: Too many positional arguments for "Person"
person = Person(name='John', age=32)
person.name = "John Smith" # E: Property "name" defined in "Person" is read-only
class Contact(Person):
email: str
reveal_type(Contact) # N: Revealed type is "def (email: builtins.str, *, name: builtins.str, age: builtins.int) -> __main__.Contact"
Contact('john@john.com', name='John', age=32)
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformViaSubclassOfMetaclass]
# flags: --python-version 3.11
from typing import dataclass_transform
@dataclass_transform(frozen_default=True)
class BaseMeta(type): ...
class SubMeta(BaseMeta): ...
# MyPy does *not* recognize this as a dataclass because the metaclass is not directly decorated with
# dataclass_transform
class Foo(metaclass=SubMeta):
foo: int
reveal_type(Foo) # N: Revealed type is "def () -> __main__.Foo"
Foo(1) # E: Too many arguments for "Foo"
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformTypeCheckingInFunction]
# flags: --python-version 3.11
from typing import dataclass_transform, Type, TYPE_CHECKING
@dataclass_transform()
def model(cls: Type) -> Type:
return cls
@model
class FunctionModel:
if TYPE_CHECKING:
string_: str
integer_: int
else:
string_: tuple
integer_: tuple
FunctionModel(string_="abc", integer_=1)
FunctionModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "FunctionModel" has incompatible type "Tuple[<nothing>, ...]"; expected "int"
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformNegatedTypeCheckingInFunction]
# flags: --python-version 3.11
from typing import dataclass_transform, Type, TYPE_CHECKING
@dataclass_transform()
def model(cls: Type) -> Type:
return cls
@model
class FunctionModel:
if not TYPE_CHECKING:
string_: tuple
integer_: tuple
else:
string_: str
integer_: int
FunctionModel(string_="abc", integer_=1)
FunctionModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "FunctionModel" has incompatible type "Tuple[<nothing>, ...]"; expected "int"
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformTypeCheckingInBaseClass]
# flags: --python-version 3.11
from typing import dataclass_transform, TYPE_CHECKING
@dataclass_transform()
class ModelBase:
...
class BaseClassModel(ModelBase):
if TYPE_CHECKING:
string_: str
integer_: int
else:
string_: tuple
integer_: tuple
BaseClassModel(string_="abc", integer_=1)
BaseClassModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "BaseClassModel" has incompatible type "Tuple[<nothing>, ...]"; expected "int"
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformNegatedTypeCheckingInBaseClass]
# flags: --python-version 3.11
from typing import dataclass_transform, TYPE_CHECKING
@dataclass_transform()
class ModelBase:
...
class BaseClassModel(ModelBase):
if not TYPE_CHECKING:
string_: tuple
integer_: tuple
else:
string_: str
integer_: int
BaseClassModel(string_="abc", integer_=1)
BaseClassModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "BaseClassModel" has incompatible type "Tuple[<nothing>, ...]"; expected "int"
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformTypeCheckingInMetaClass]
# flags: --python-version 3.11
from typing import dataclass_transform, Type, TYPE_CHECKING
@dataclass_transform()
class ModelMeta(type):
...
class ModelBaseWithMeta(metaclass=ModelMeta):
...
class MetaClassModel(ModelBaseWithMeta):
if TYPE_CHECKING:
string_: str
integer_: int
else:
string_: tuple
integer_: tuple
MetaClassModel(string_="abc", integer_=1)
MetaClassModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "MetaClassModel" has incompatible type "Tuple[<nothing>, ...]"; expected "int"
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformNegatedTypeCheckingInMetaClass]
# flags: --python-version 3.11
from typing import dataclass_transform, Type, TYPE_CHECKING
@dataclass_transform()
class ModelMeta(type):
...
class ModelBaseWithMeta(metaclass=ModelMeta):
...
class MetaClassModel(ModelBaseWithMeta):
if not TYPE_CHECKING:
string_: tuple
integer_: tuple
else:
string_: str
integer_: int
MetaClassModel(string_="abc", integer_=1)
MetaClassModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "MetaClassModel" has incompatible type "Tuple[<nothing>, ...]"; expected "int"
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformStaticConditionalAttributes]
# flags: --python-version 3.11 --always-true TRUTH
from typing import dataclass_transform, Type, TYPE_CHECKING
TRUTH = False # Is set to --always-true
@dataclass_transform()
def model(cls: Type) -> Type:
return cls
@model
class FunctionModel:
if TYPE_CHECKING:
present_1: int
else:
skipped_1: int
if True:
present_2: int
if False:
present_3: int
if not TRUTH:
skipped_2: int
else:
present_4: int
FunctionModel(
present_1=1,
present_2=2,
present_3=3,
present_4=4,
)
FunctionModel() # E: Missing positional arguments "present_1", "present_2", "present_3", "present_4" in call to "FunctionModel"
FunctionModel( # E: Unexpected keyword argument "skipped_1" for "FunctionModel"
present_1=1,
present_2=2,
present_3=3,
present_4=4,
skipped_1=5,
)
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformFunctionConditionalAttributes]
# flags: --python-version 3.11
from typing import dataclass_transform, Type
@dataclass_transform()
def model(cls: Type) -> Type:
return cls
def condition() -> bool:
return True
@model
class FunctionModel:
if condition():
x: int
y: int
z1: int
else:
x: str # E: Name "x" already defined on line 14
y: int # E: Name "y" already defined on line 15
z2: int
FunctionModel(x=1, y=2, z1=3, z2=4)
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
[case testDataclassTransformNegatedFunctionConditionalAttributes]
# flags: --python-version 3.11
from typing import dataclass_transform, Type
@dataclass_transform()
def model(cls: Type) -> Type:
return cls
def condition() -> bool:
return True
@model
class FunctionModel:
if not condition():
x: int
y: int
z1: int
else:
x: str # E: Name "x" already defined on line 14
y: int # E: Name "y" already defined on line 15
z2: int
FunctionModel(x=1, y=2, z1=3, z2=4)
[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]