You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I just noticed a typing problem when using factory classmethods as converters. The following code works properly with mypy when calling the constructor directly, but causes problems when calling the equivalent factory method. Perhaps some type hints are too strict?
from __future__ importannotationsfromattrsimportdefine, field@defineclassLeContainer:
attr: int@classmethoddefmake(cls, a: int) ->LeContainer:
returnLeContainer(a)
@defineclassLeClass:
# x: LeContainer = field(converter=LeContainer) <-- This worksx: LeContainer=field(converter=LeContainer.make) # <-- This makes mypy complain
Error message:
error: Unsupported converter, only named functions, types and lambdas are currently supported [misc]
The text was updated successfully, but these errors were encountered:
Hi, I just noticed a typing problem when using factory classmethods as converters. The following code works properly with mypy when calling the constructor directly, but causes problems when calling the equivalent factory method. Perhaps some type hints are too strict?
Error message:
The text was updated successfully, but these errors were encountered: