| from typing import Any
|
| from dataclasses import dataclass, field
|
|
|
| @dataclass
|
| class D:
|
| # why no mypy warning on incompatible type assignment?
|
| # i want to achieve something similiar like this for my custom `dataclass`-like class.`
|
| t: int = field(default=0)
|
|
|
|
|
|
|
| class MyField:
|
| def __init__(self, **kwargs: Any) -> None:
|
| pass
|
|
|
| class F:
|
| # error: Incompatible types in assignment (expression has type "MyField", variable has type "int") [assignment]
|
| t: int = MyField(default=0)
|