在PyCharm中,如果使用pyspark.sql.DataFrame
代替pandas.DataFrame
,则类型提示似乎不会触发警告。
例如以下代码根本不会产生任何警告:
from pyspark.sql import DataFrame as SparkDataFrame
from pandas import DataFrame as PandasDataFrame
def test_pandas_to_spark(a: PandasDataFrame) -> SparkDataFrame:
return a
def test_spark_to_pandas(b: SparkDataFrame) -> PandasDataFrame:
return b.toPandas()
test_spark_to_pandas(PandasDataFrame({'a': [1, 2, 3]}))
这是否已知/可以解决?
顺便说一句:我确实安装了pyspark存根:pyspark-stubs==2.4.0.post2