PynamoDB
PynamoDB copied to clipboard
Proper way to specify type annotation of a MapAttribute subclass?
Supposed I define a MapAttribute
subclass like follows:
class MyMapAttribute(MapAttribute):
pass
When I run pre-commit's (rev 2.1.0) mypy hook (rev 0.701), I run into the following error:
error: Missing type parameters for generic type
I am using pynamodb==4.0.0
.
This is happening because the disallow_any_generics
is enabled in your mypy conf. The way we currently type MapAttribute
s is flawed due to it behaving differently depending on whether you subclass it or instantiate it directly. So basically this is a bug in our type information, but not easy to fix today.
@jpinner-lyft do you think it's worth creating a new issue to track the Model/MapAttribute changes that you had lined up?
Do you have any hints on how to type result = MapAttribute(…)
? Edit: Separate issue
@l0b0 would you mind creating a separate issue with more context?