File: fine-grained-dataclass.test

package info (click to toggle)
mypy 1.19.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,412 kB
  • sloc: python: 114,754; ansic: 13,343; cpp: 11,380; makefile: 257; sh: 28
file content (25 lines) | stat: -rw-r--r-- 460 bytes parent folder | download | duplicates (2)
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
[case testReplace]
[file model.py]
from dataclasses import dataclass

@dataclass
class Model:
    x: int = 0
[file replace.py]
from dataclasses import replace
from model import Model

m = Model()
replace(m, x=42)

[file model.py.2]
from dataclasses import dataclass

@dataclass
class Model:
    x: str = 'hello'

[builtins fixtures/dataclasses.pyi]
[out]
==
replace.py:5: error: Argument "x" to "replace" of "Model" has incompatible type "int"; expected "str"