-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
Description
Hi, this is a copy of an issue originally opened in the attrs
repo, where it was pointed out that the limitation really comes from the mypy plugin. While the below is just a toy example, the problem was originally noticed in real production-ready code base of mine. It would be great if the use case could be supported in the future!
Feature
from __future__ import annotations
from attrs import define, field
@define
class LeContainer:
attr: int
@classmethod
def make(cls, a: int) -> LeContainer:
return LeContainer(a)
@define
class LeClass:
# x: LeContainer = field(converter=LeContainer) <-- This works
x: LeContainer = field(converter=LeContainer.make) # <-- This makes mypy complain
Error Message:
error: Unsupported converter, only named functions, types and lambdas are currently supported [misc]
Pitch
Extending the allowed converter types and thus getting rid of this limitation would allow for a broader / more flexible use of converters.