Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 22, 2024
1 parent 64cb781 commit b3341c8
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
4 changes: 3 additions & 1 deletion python-sdk/src/astro/files/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion python-sdk/src/astro/files/types/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion python-sdk/src/astro/files/types/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion python-sdk/src/astro/files/types/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion python-sdk/src/astro/files/types/ndjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion python-sdk/src/astro/files/types/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions python-sdk/src/astro/sql/operators/export_to_file.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.")
Expand Down

0 comments on commit b3341c8

Please sign in to comment.