SNOW-922952: mypy possible overload variant
Please answer these questions before submitting your issue. Thanks!
-
What version of Python are you using?
Python 3.9.18
-
What operating system and processor architecture are you using?
macOS-12.5.1-x86_64-i386-64bit
-
What are the component versions in the environment (
pip freeze)?
mypy==1.5.1 mypy-extensions==1.0.0 snowflake-connector-python==3.3.0b1 snowflake-snowpark-python==1.8.0
-
What did you do?
Code:
from snowflake.snowpark import DataFrame
def store_table(df: DataFrame, destination: str):
df.write.saveAsTable(destination)
Running mypy store_table.pyon the command line gives the following output
store_table.py: note: In function "store_table":
store_table.py:5:5: error: No overload variant matches argument type "str" [call-overload]
df.write.saveAsTable(destination)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
store_table.py:5:5: note: Possible overload variants:
store_table.py:5:5: note: def (table_name: Union[str, Iterable[str]], *, mode: Optional[str] = ..., column_order: str = ..., create_temp_table: bool = ..., table_type: Literal['', 'temp', 'temporary', 'transient'] = ..., clustering_keys: Iterable[Column], statement_params: Optional[dict[str, str]] = ..., block: bool = ...) -> None
store_table.py:5:5: note: def (table_name: Union[str, Iterable[str]], *, mode: Optional[str] = ..., column_order: str = ..., create_temp_table: bool = ..., table_type: Literal['', 'temp', 'temporary', 'transient'] = ..., clustering_keys: Iterable[Column], statement_params: Optional[dict[str, str]] = ..., block: bool = ...) -> AsyncJob
Found 1 error in 1 file (checked 1 source file)
- What did you expect to see?
Success: no issues found
I ran into this issue with Pylance. There seems to be an inconsistency between the type signature and the actual source code definition. The type signature shows clustering_keys as a mandatory parameter with no default value, whereas the source code has the parameter defined as Optional and with the default value of None.