snowflakedb / snowpark-python

Snowflake Snowpark Python API
Apache License 2.0
256 stars 106 forks source link

SNOW-922952: mypy possible overload variant #1058

Open sortmanns opened 11 months ago

sortmanns commented 11 months ago

Please answer these questions before submitting your issue. Thanks!

  1. What version of Python are you using?

    Python 3.9.18

  2. What operating system and processor architecture are you using?

    macOS-12.5.1-x86_64-i386-64bit

  3. 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

  1. 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.py`on 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)


5. What did you expect to see?

  `Success: no issues found`
padhia commented 11 months ago

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.