Mypy: Recognize dynamic creation of named tuples.

Created on 9 Jun 2017  路  4Comments  路  Source: python/mypy

This appeared in https://github.com/python/typing/issues/427

We can support something like this:

base_fields = [('x', int), ('y', int)]
label = [('label', str)]
LabeledPoint3D = NamedTuple('LabeledPoint3D', base_fields + [('z', int)] + label)
feature topic-named-tuple

All 4 comments

We can also do similar things for TypedDict and Enum functional APIs.

Adding this would also fix #4287.

Currently dynamically created enums also show errors, because mypy cannot resolve variants.

I don't think we'll do this

Was this page helpful?
0 / 5 - 0 ratings