PynamoDB icon indicating copy to clipboard operation
PynamoDB copied to clipboard

How to type annotate `foo = MapAttribute(…)`?

Open l0b0 opened this issue 4 years ago • 0 comments

Given strict mypy settings, in particular disallow_any_generics, and a requirement to pass pylint, how should I type annotate a MapAttribute?

  • details: MapAttribute[str, str] = MapAttribute(null=True) results in "E1136: Value 'MapAttribute' is unsubscriptable (unsubscriptable-object)" from pylint
  • details: MapAttribute = MapAttribute(null=True) instead results in 'Missing type parameters for generic type "MapAttribute" [type-arg]' from mypy

Workaround: Use the second version above with a # type: ignore[type-arg] annotation.

l0b0 avatar Mar 16 '21 02:03 l0b0