S5890: Dataclass InitVar Type annotations warning

This rule does not appear to be working for 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.

Hello @mheynz,

Thank you for your feedback. Indeed the rule should not raise issues in such case.

I created SONARPY-856 to track this.

Regards,
Guillaume