ueshin commented on a change in pull request #32968:
URL: https://github.com/apache/spark/pull/32968#discussion_r655799358



##########
File path: python/pyspark/pandas/base.py
##########
@@ -58,11 +57,16 @@
 from pyspark.pandas.frame import DataFrame
 
 if TYPE_CHECKING:
+    from pyspark.pandas.data_type_ops.base import DataTypeOps  # noqa: F401 
(SPARK-34943)
     from pyspark.pandas.indexes import Index  # noqa: F401 (SPARK-34943)
     from pyspark.pandas.series import Series  # noqa: F401 (SPARK-34943)
 
 
-def should_alignment_for_column_op(self: "IndexOpsMixin", other: 
"IndexOpsMixin") -> bool:
+T_IndexOps = TypeVar("T_IndexOps", bound="IndexOpsMixin")

Review comment:
       This is used for self-type annotation.
   
https://www.python.org/dev/peps/pep-0484/#annotating-instance-and-class-methods
   
   ```py
   T = TypeVar('T', bound='Copyable')
   class Copyable:
       def copy(self: T) -> T:
           # return a copy of self
   
   class C(Copyable): ...
   c = C()
   c2 = c.copy()  # type here should be C
   ```

##########
File path: python/pyspark/pandas/base.py
##########
@@ -58,11 +57,16 @@
 from pyspark.pandas.frame import DataFrame
 
 if TYPE_CHECKING:
+    from pyspark.pandas.data_type_ops.base import DataTypeOps  # noqa: F401 
(SPARK-34943)
     from pyspark.pandas.indexes import Index  # noqa: F401 (SPARK-34943)
     from pyspark.pandas.series import Series  # noqa: F401 (SPARK-34943)
 
 
-def should_alignment_for_column_op(self: "IndexOpsMixin", other: 
"IndexOpsMixin") -> bool:
+T_IndexOps = TypeVar("T_IndexOps", bound="IndexOpsMixin")

Review comment:
       Ah, I see. I saw some similar examples in the built-in `typing.py`.
   
   ```py
   T_co = TypeVar('T_co', covariant=True)  # Any type covariant containers.
   V_co = TypeVar('V_co', covariant=True)  # Any type covariant containers.
   VT_co = TypeVar('VT_co', covariant=True)  # Value type covariant containers.
   T_contra = TypeVar('T_contra', contravariant=True)  # Ditto contravariant.
   # Internal type variable used for Type[].
   CT_co = TypeVar('CT_co', covariant=True, bound=type)
   ```




-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to