chadrik commented on a change in pull request #13004:
URL: https://github.com/apache/beam/pull/13004#discussion_r499907209
##########
File path: sdks/python/apache_beam/transforms/stats.py
##########
@@ -426,14 +432,15 @@ def __next__(self):
return QuantileBufferIterator(self.elements, self.weighted, self.weight)
-class _QuantileState(object):
+class _QuantileState(Generic[T]):
"""
Compact summarization of a collection on which quantiles can be estimated.
"""
- min_val = None # Holds smallest item in the list
- max_val = None # Holds largest item in the list
+ min_val = None # type: Any # Holds smallest item in the list
Review comment:
Short answer: true.
Long answer: everywhere that I've typed this as `T` is actually
`Union[Tuple[T, float], T]`. I just tried fully typing this module and it's a
quagmire, because this module has several classes that vary their types based
on an attribute (`weighted`). Furthermore, we can't distinguish between the
types using `isinstance` (because it's always a list, it's just the element
type that varies). So typing this properly either involves lots of
`typing.cast` or breaking these classes into weighted and non-weighted
subclasses. I'd like to defer this until later.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]