-
Notifications
You must be signed in to change notification settings - Fork 74
Closed
Labels
priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
As per an internal doc, subscripting a container that does not inherit from typing.Generic can cause errors. In particular, a MutableSequence indexed by enums causes an error of the form
TypeError: Parameters to generic types must be types. This can be triggered, for example, by code of the form
days_of_week: MutableSequence[dayofweek_pb2.DayOfWeek] = proto.RepeatedField(
proto.ENUM,
number=2,
enum=dayofweek_pb2.DayOfWeek,
)
which we are seeing in the internal part of our publishing pipeline.
Either of these fixes by itself works:
- Quoting the type:
MutableSequence['dayofweek_pb2.DayOfWeek'] - Adding
from __future__ import annotationsat the top of the file. As per an internal reference, this seems to be related to PEP563, which has a status ofAcceptedas of 2017, so it's not clear why we would need a fix in the first place.
We should decide and implement the right fix.
Metadata
Metadata
Assignees
Labels
priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.