Skip to content

Fix ArrayType Type Wrapped Type Annotation

While developing using the Singer SDK, I noticed a few odd mypy errors when running static type checking on a few of our taps that leverage the SDK:

METRIC_LISTING_REP: Final[List[Property]] = [
    Property("tags", th.ArrayType(th.StringType), required=True),
]
tap_launch_darkly/schemas.py:53: error: Value of type variable "W" of "ArrayType" cannot be "Type[StringType]"

It seems like this is because the current typing SDK code has the wrapped_type argument of ArrayType.__init__() annotated as W, which will instruct the type checker to expect an instance of generic type W. However, it should also anticipate receiving a Type, such as th.StringType (similar to the type annotations of the Property.wrapped attribute).

This MR proposes updating the type annotations of the ArrayType class to fix the aforementioned issues during static type checking.

Edited by David Wallace

Merge request reports