Skip to content

Support for dataclass_transform converters #972

@AdrianSosic

Description

@AdrianSosic

Summary

The following code throws a false-positive:

from attrs import define, field


@define
class C:
    x: float = field(converter=float)


C("1")
error[invalid-argument-type]: Argument is incorrect
 --> baybe/ty.py:9:3
  |
9 | C("1")
  |   ^^^ Expected `int | float`, found `Literal["1"]`
  |
info: rule `invalid-argument-type` is enabled by default

The issue is that attrs converters don't seem to be supported yet, which are handled via the attrs plugin in mypy. I'm aware that there is already a PR to enable dataclass support (#111) but since converters are not available via dataclasses, I think this is probably a separate issue.

Version

No response

Metadata

Metadata

Assignees

Labels

dataclassesIssues relating to dataclasses and dataclass_transform

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions