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
Not sure if this is a mypy issue or attrs or both.
I have an attrs class that defines a field with a converter that coerces the input value to a custom dict subclass.
It works fine when creating a new object, I pass in a dict and the field gets converted to the my dict subclass. I think #710 is responsible for inferring __init__ annotations from the converters'.
Now I would like to do the same with on_setattr, by using attrs.setters.convert: i.e. I want to set the field to a plain dict and have it converted automatically using the field converter to my dict subclass.
This works fine at runtime, but when I run mypy on my code, it complains that Incompatible types in assignment (expression has type Dict[...], variable has type "...") when I do that.
Even without the on_setattr feature, just using a plain property setter decorator that calls the converter, I get the same error from mypy about Incompatible types in assignment.
Not sure if this is a mypy issue or attrs or both.
I have an attrs class that defines a field with a converter that coerces the input value to a custom dict subclass.
It works fine when creating a new object, I pass in a dict and the field gets converted to the my dict subclass. I think #710 is responsible for inferring
__init__
annotations from the converters'.Now I would like to do the same with
on_setattr
, by usingattrs.setters.convert
: i.e. I want to set the field to a plain dict and have it converted automatically using the field converter to my dict subclass.This works fine at runtime, but when I run mypy on my code, it complains that
Incompatible types in assignment (expression has type Dict[...], variable has type "...")
when I do that.Here's a made up example:
Is there a way around this besides an ugly
# type: ignore
on every line I use the attrs generated setter-cum-converter?thanks in advance
The text was updated successfully, but these errors were encountered: