diff --git a/python-sdk/src/astro/files/base.py b/python-sdk/src/astro/files/base.py index 350286005..686fdb094 100644 --- a/python-sdk/src/astro/files/base.py +++ b/python-sdk/src/astro/files/base.py @@ -114,7 +114,9 @@ def is_pattern(self) -> bool: """ return not pathlib.PosixPath(self.path).suffix - def create_from_dataframe(self, df: pd.DataFrame, store_as_dataframe: bool = True, export_options: dict | None = None) -> None: + def create_from_dataframe( + self, df: pd.DataFrame, store_as_dataframe: bool = True, export_options: dict | None = None + ) -> None: """Create a file in the desired location using the values of a dataframe. :param store_as_dataframe: Whether the data should later be deserialized as a dataframe or as a file containing diff --git a/python-sdk/src/astro/files/types/csv.py b/python-sdk/src/astro/files/types/csv.py index 2aae0bf7e..e830206ee 100644 --- a/python-sdk/src/astro/files/types/csv.py +++ b/python-sdk/src/astro/files/types/csv.py @@ -38,7 +38,9 @@ def export_to_dataframe( return PandasDataframe.from_pandas_df(df) # We need skipcq because it's a method overloading so we don't want to make it a static method - def create_from_dataframe(self, df: pd.DataFrame, stream: io.TextIOWrapper, **kwargs) -> None: # skipcq PYL-R0201 + def create_from_dataframe( + self, df: pd.DataFrame, stream: io.TextIOWrapper, **kwargs + ) -> None: # skipcq PYL-R0201 """Write csv file to one of the supported locations :param df: pandas dataframe diff --git a/python-sdk/src/astro/files/types/excel.py b/python-sdk/src/astro/files/types/excel.py index e4e6b434a..ae49b497f 100644 --- a/python-sdk/src/astro/files/types/excel.py +++ b/python-sdk/src/astro/files/types/excel.py @@ -37,7 +37,9 @@ def export_to_dataframe( return PandasDataframe.from_pandas_df(df) # We need skipcq because it's a method overloading so we don't want to make it a static method - def create_from_dataframe(self, df: pd.DataFrame, stream: io.TextIOWrapper, **kwargs) -> None: # skipcq PYL-R0201 + def create_from_dataframe( + self, df: pd.DataFrame, stream: io.TextIOWrapper, **kwargs + ) -> None: # skipcq PYL-R0201 """Write Excel file to one of the supported locations :param df: pandas dataframe diff --git a/python-sdk/src/astro/files/types/json.py b/python-sdk/src/astro/files/types/json.py index 18a153e70..8e5802bbb 100644 --- a/python-sdk/src/astro/files/types/json.py +++ b/python-sdk/src/astro/files/types/json.py @@ -42,7 +42,9 @@ def export_to_dataframe( return PandasDataframe.from_pandas_df(df) # We need skipcq because it's a method overloading so we don't want to make it a static method - def create_from_dataframe(self, df: pd.DataFrame, stream: io.TextIOWrapper, **kwargs) -> None: # skipcq PYL-R0201 + def create_from_dataframe( + self, df: pd.DataFrame, stream: io.TextIOWrapper, **kwargs + ) -> None: # skipcq PYL-R0201 """Write json file to one of the supported locations :param df: pandas dataframe diff --git a/python-sdk/src/astro/files/types/ndjson.py b/python-sdk/src/astro/files/types/ndjson.py index 94935167d..2a0bd63ed 100644 --- a/python-sdk/src/astro/files/types/ndjson.py +++ b/python-sdk/src/astro/files/types/ndjson.py @@ -39,7 +39,9 @@ def export_to_dataframe( return PandasDataframe.from_pandas_df(df) # We need skipcq because it's a method overloading so we don't want to make it a static method - def create_from_dataframe(self, df: pd.DataFrame, stream: io.TextIOWrapper, **kwargs) -> None: # skipcq PYL-R0201 + def create_from_dataframe( + self, df: pd.DataFrame, stream: io.TextIOWrapper, **kwargs + ) -> None: # skipcq PYL-R0201 """Write ndjson file to one of the supported locations :param df: pandas dataframe diff --git a/python-sdk/src/astro/files/types/parquet.py b/python-sdk/src/astro/files/types/parquet.py index 1a61e7446..c6bf0b010 100644 --- a/python-sdk/src/astro/files/types/parquet.py +++ b/python-sdk/src/astro/files/types/parquet.py @@ -57,7 +57,9 @@ def _convert_remote_file_to_byte_stream(stream) -> io.IOBase: return remote_obj_buffer # We need skipcq because it's a method overloading so we don't want to make it a static method - def create_from_dataframe(self, df: pd.DataFrame, stream: io.TextIOWrapper, **kwargs) -> None: # skipcq PYL-R0201 + def create_from_dataframe( + self, df: pd.DataFrame, stream: io.TextIOWrapper, **kwargs + ) -> None: # skipcq PYL-R0201 """Write parquet file to one of the supported locations :param df: pandas dataframe diff --git a/python-sdk/src/astro/sql/operators/export_to_file.py b/python-sdk/src/astro/sql/operators/export_to_file.py index 27a00a409..fff2d3a5b 100644 --- a/python-sdk/src/astro/sql/operators/export_to_file.py +++ b/python-sdk/src/astro/sql/operators/export_to_file.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import Any - import pandas as pd from airflow.decorators.base import get_unique_task_id from airflow.models.xcom_arg import XComArg @@ -60,7 +58,9 @@ def execute(self, context: Context) -> File: # skipcq PYL-W0613 raise ValueError(f"Expected input_table to be Table or dataframe. Got {type(self.input_data)}") # Write file if overwrite == True or if file doesn't exist. if self.if_exists == "replace" or not self.output_file.exists(): - self.output_file.create_from_dataframe(df, store_as_dataframe=False, export_options=self.export_options) + self.output_file.create_from_dataframe( + df, store_as_dataframe=False, export_options=self.export_options + ) return self.output_file else: raise FileExistsError(f"{self.output_file.path} file already exists.")