Skip to content

Commit

Permalink
fix: Remove position and keyword only params
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfarias committed Feb 8, 2022
1 parent 360a810 commit 41f5353
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 37 deletions.
20 changes: 6 additions & 14 deletions airflow_dbt_python/hooks/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ class DbtBackend(ABC, LoggingMixin):
instantiate a hook for this backend.
"""

def pull_dbt_profiles(
self, source_prefix: StrPath, destination: StrPath, / # noqa: W504
) -> Path:
def pull_dbt_profiles(self, source_prefix: StrPath, destination: StrPath) -> Path:
"""Pull a dbt profiles.yml file from a given source_prefix.
Args:
Expand Down Expand Up @@ -75,15 +73,13 @@ def push_dbt_project(
self,
source: StrPath,
destination: StrPath,
/,
*,
replace: bool = False,
delete_before: bool = False,
) -> None:
"""Push all dbt project files from a given source_prefix.
Args:
source_prefix: Path to a directory containing a dbt project.
source: Path to a directory containing a dbt project.
destination: Path or URL to a directory where the will be stored.
replace: Flag to indicate whether to replace existing files.
delete_before: Flag to indicate wheter to clear any existing files before
Expand All @@ -95,7 +91,7 @@ def push_dbt_project(
)

@abstractmethod
def pull_one(self, source: StrPath, destination: StrPath, /) -> Path:
def pull_one(self, source: StrPath, destination: StrPath) -> Path:
"""Pull a single dbt file from source and store it in destination.
Args:
Expand All @@ -110,7 +106,7 @@ def pull_one(self, source: StrPath, destination: StrPath, /) -> Path:
return NotImplemented

@abstractmethod
def pull_many(self, source: StrPath, destination: StrPath, /) -> Path:
def pull_many(self, source: StrPath, destination: StrPath) -> Path:
"""Pull all dbt files under source and store them under destination.
Args:
Expand All @@ -125,9 +121,7 @@ def pull_many(self, source: StrPath, destination: StrPath, /) -> Path:
return NotImplemented

@abstractmethod
def push_one(
self, source: StrPath, destination: StrPath, /, *, replace: bool = False
):
def push_one(self, source: StrPath, destination: StrPath, replace: bool = False):
"""Push a single dbt file from source and store it in destination."""
return NotImplemented

Expand All @@ -136,16 +130,14 @@ def push_many(
self,
source: StrPath,
destination: StrPath,
/,
*,
replace: bool = False,
delete_before: bool = False,
):
"""Push all dbt files under source and store them under destination."""
return NotImplemented


def zip_all_paths(paths: Iterable[Path], /, *, zip_path: Path) -> None:
def zip_all_paths(paths: Iterable[Path], zip_path: Path) -> None:
"""Add all paths to a zip file in zip_path."""
with ZipFile(zip_path, "w") as zf:
for _file in paths:
Expand Down
8 changes: 3 additions & 5 deletions airflow_dbt_python/hooks/backends/localfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DbtLocalFsBackend(DbtBackend):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def pull_one(self, source: StrPath, destination: StrPath, /) -> Path:
def pull_one(self, source: StrPath, destination: StrPath) -> Path:
"""Pull a file from local path.
Args:
Expand All @@ -36,7 +36,7 @@ def pull_one(self, source: StrPath, destination: StrPath, /) -> Path:

return shutil.copy(source, destination)

def pull_many(self, source: StrPath, destination: StrPath, /) -> Path:
def pull_many(self, source: StrPath, destination: StrPath) -> Path:
"""Pull many files from local path.
Args:
Expand All @@ -57,7 +57,7 @@ def pull_many(self, source: StrPath, destination: StrPath, /) -> Path:
return Path(destination)

def push_one(
self, source: StrPath, destination: StrPath, /, *, replace: bool = False
self, source: StrPath, destination: StrPath, replace: bool = False
) -> None:
"""Pull many files from local path.
Expand All @@ -77,8 +77,6 @@ def push_many(
self,
source: StrPath,
destination: StrPath,
/,
*,
replace: bool = False,
delete_before: bool = False,
) -> None:
Expand Down
11 changes: 4 additions & 7 deletions airflow_dbt_python/hooks/backends/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def hook(self) -> S3Hook:
self._hook = S3Hook()
return self._hook

def pull_one(self, source: StrPath, destination: StrPath, /) -> Path:
def pull_one(self, source: StrPath, destination: StrPath) -> Path:
"""Pull a file from S3.
Args:
Expand All @@ -58,7 +58,7 @@ def pull_one(self, source: StrPath, destination: StrPath, /) -> Path:
self.download_one_s3_object(s3_object, destination)
return Path(destination)

def pull_many(self, source: StrPath, destination: StrPath, /) -> Path:
def pull_many(self, source: StrPath, destination: StrPath) -> Path:
"""Pull many files from S3.
Lists all S3 keys that have source as a prefix to find what to pull.
Expand All @@ -82,7 +82,7 @@ def pull_many(self, source: StrPath, destination: StrPath, /) -> Path:
return Path(destination)

def push_one(
self, source: StrPath, destination: StrPath, /, *, replace: bool = False
self, source: StrPath, destination: StrPath, replace: bool = False
) -> None:
"""Push a file to S3.
Expand All @@ -105,8 +105,6 @@ def push_many(
self,
source: StrPath,
destination: StrPath,
/,
*,
replace: bool = False,
delete_before: bool = False,
) -> None:
Expand Down Expand Up @@ -155,7 +153,7 @@ def push_many(
)

def download_zip_s3_object(
self, s3_object: "S3Object", destination: StrPath, / # noqa: W504
self, s3_object: "S3Object", destination: StrPath
) -> None:
"""Download an S3Object and extract its contents."""
destination_path = Path(destination)
Expand Down Expand Up @@ -201,7 +199,6 @@ def download_one_s3_object(
self,
s3_object: "S3Object",
destination: StrPath,
/,
) -> None:
"""Download an S3 object into a local destination."""
self.log.info("Downloading S3Object %s to: %s", s3_object, destination)
Expand Down
6 changes: 0 additions & 6 deletions airflow_dbt_python/hooks/dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,6 @@ def pull_dbt_profiles(
self,
profiles_dir: StrPath,
destination: StrPath,
/,
*,
conn_id: Optional[str] = None,
) -> Path:
"""Pull a dbt profiles.yml file from a given profiles_dir.
Expand All @@ -511,8 +509,6 @@ def pull_dbt_project(
self,
project_dir: StrPath,
destination: StrPath,
/,
*,
conn_id: Optional[str] = None,
) -> Path:
"""Pull a dbt project from a given project_dir.
Expand All @@ -529,8 +525,6 @@ def push_dbt_project(
self,
project_dir: StrPath,
destination: StrPath,
/,
*,
conn_id: Optional[str] = None,
replace: bool = False,
delete_before: bool = False,
Expand Down
8 changes: 3 additions & 5 deletions tests/hooks/dbt/backends/test_dbt_backend_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,22 @@ def __init__(self, connection_id="default"):


class MyBackend(DbtBackend):
def pull_one(self, source, destination, /) -> Path:
def pull_one(self, source, destination) -> Path:
"""Pull a single dbt file from source and store it in destination."""
return super().pull_one(source, destination)

def pull_many(self, source, destination, /) -> Path:
def pull_many(self, source, destination) -> Path:
"""Pull all dbt files under source and store them under destination."""
return super().pull_many(source, destination)

def push_one(self, source, destination, /, *, replace: bool = False) -> None:
def push_one(self, source, destination, replace: bool = False) -> None:
"""Push a single dbt file from source and store it in destination."""
return super().push_one(source, destination)

def push_many(
self,
source,
destination,
/,
*,
replace: bool = False,
delete_before: bool = False,
) -> None:
Expand Down

0 comments on commit 41f5353

Please sign in to comment.