xinrong-meng commented on code in PR #37219:
URL: https://github.com/apache/spark/pull/37219#discussion_r923851884
##########
python/pyspark/sql/types.py:
##########
@@ -136,14 +136,15 @@ def fromInternal(self, obj: Any) -> Any:
class DataTypeSingleton(type):
"""Metaclass for DataType"""
- _instances: ClassVar[Dict[Type["DataTypeSingleton"], "DataTypeSingleton"]]
= {}
+ _instances: ClassVar[Dict[Tuple, "DataTypeSingleton"]] = {}
- def __call__(cls: Type[T]) -> T: # type: ignore[override]
- if cls not in cls._instances: # type: ignore[attr-defined]
- cls._instances[cls] = super( # type: ignore[misc, attr-defined]
+ def __call__(cls: Type[T], *args: Any, **kwargs: Any) -> T: # type:
ignore[override]
+ key = (cls, args, str(kwargs))
Review Comment:
Strict matching of arguments is expected to reuse the same instance.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]