17 lines
587 B
Plaintext
17 lines
587 B
Plaintext
![]() |
=== On 2021-05-12T00:45:18.345Z Mike Heyns Wrote:
|
||
|
This rule does not appear to be working for https://docs.python.org/3/library/dataclasses.html#init-only-variables[Dataclass Init-Only variables]:
|
||
|
|
||
|
|
||
|
----
|
||
|
@dataclass
|
||
|
class Book:
|
||
|
name: str
|
||
|
condition: InitVar[str] = ''
|
||
|
----
|
||
|
|
||
|
____Assign to "condition" a value of type "InitVar[str]" instead of "str" or update its type hint.____
|
||
|
|
||
|
|
||
|
In fact, most examples including the official documentation use ``++None++`` as the default for init-only arguments. Attempting to use ``++InitVar[Optional[str]]++`` has the same effect as above.
|
||
|
|