Skip to content

Commit

Permalink
Fix type hints for older versions of python (<3.9)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeberesford-palmetto committed Dec 2, 2021
1 parent cb184dd commit f6bfecf
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 26 deletions.
4 changes: 2 additions & 2 deletions palm/plugins/dbt/commands/cmd_compile.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import click
from typing import Optional
from typing import Optional, Tuple
from palm.plugins.dbt.dbt_palm_utils import dbt_env_vars


@click.command("compile")
@click.option("--models", multiple=True, help="see dbt docs on models flag")
@click.option("--fast", is_flag=True, help="will skip clean/deps/seed")
@click.pass_context
def cli(ctx, fast: bool, models: Optional[tuple] = tuple()):
def cli(ctx, fast: bool, models: Optional[Tuple] = tuple()):
"""Cleans up target directory and dependencies, then compiles dbt"""

if fast:
Expand Down
6 changes: 3 additions & 3 deletions palm/plugins/dbt/commands/cmd_cycle.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import click
from typing import Optional
from typing import Optional, Tuple
from palm.plugins.dbt.dbt_palm_utils import dbt_env_vars

# TODO: Refactor this command to reduce branching logic and simply join a list of
Expand All @@ -22,8 +22,8 @@ def cli(
fast: bool,
persist: bool,
no_seed: bool,
models: Optional[tuple] = tuple(),
select: Optional[tuple] = tuple(),
models: Optional[Tuple] = tuple(),
select: Optional[Tuple] = tuple(),
):
"""Consecutive run-test of the DBT repo. `count` is the number of run/test cycles to execute, defaults to 2"""

Expand Down
8 changes: 4 additions & 4 deletions palm/plugins/dbt/commands/cmd_run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import click
from typing import Optional
from typing import Optional, Tuple
from palm.plugins.dbt.dbt_palm_utils import shell_options, dbt_env_vars


Expand Down Expand Up @@ -32,9 +32,9 @@ def cli(
persist: bool,
full_refresh: bool,
no_seed: bool,
models: Optional[tuple] = tuple(),
select: Optional[tuple] = tuple(),
macros: Optional[tuple] = tuple(),
models: Optional[Tuple] = tuple(),
select: Optional[Tuple] = tuple(),
macros: Optional[Tuple] = tuple(),
):
"""Runs the DBT repo."""

Expand Down
4 changes: 2 additions & 2 deletions palm/plugins/dbt/commands/cmd_snapshot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import click
from typing import Optional
from typing import Optional, Tuple
from palm.plugins.dbt.dbt_palm_utils import dbt_env_vars


Expand All @@ -10,7 +10,7 @@
@click.option("--select", multiple=True)
@click.option("--fast", is_flag=True, help="will skip clean/deps/seed")
@click.pass_context
def cli(ctx, persist: bool, fast: bool, select: Optional[tuple] = tuple()):
def cli(ctx, persist: bool, fast: bool, select: Optional[Tuple] = tuple()):
"""Executes the DBT snapshots."""

if fast:
Expand Down
6 changes: 3 additions & 3 deletions palm/plugins/dbt/commands/cmd_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import click
from typing import Optional
from typing import Optional, Tuple
from palm.plugins.dbt.dbt_palm_utils import shell_options, dbt_env_vars


Expand All @@ -19,8 +19,8 @@ def cli(
persist: bool,
no_seed: bool,
no_fail_fast: bool,
models: Optional[tuple] = tuple(),
select: Optional[tuple] = tuple(),
models: Optional[Tuple] = tuple(),
select: Optional[Tuple] = tuple(),
):
"""Tests the DBT repo"""

Expand Down
8 changes: 4 additions & 4 deletions palm/plugins/dbt/dbt_containerizer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os, sys
from pathlib import Path
from typing import Optional, Tuple
from typing import Optional, Tuple, Dict
from palm.containerizer import PythonContainerizer
from palm.palm_exceptions import AbortPalm
import click
Expand Down Expand Up @@ -40,7 +40,7 @@ def run(self) -> None:
self.write_profile_envs()
super().generate(self.target_dir, self.replacements)

def validate_dbt_version(self) -> tuple[bool, str]:
def validate_dbt_version(self) -> Tuple[bool, str]:
"""Prompts the user for a DBT version.
Returns:
Expand All @@ -67,7 +67,7 @@ def validate_dbt_version(self) -> tuple[bool, str]:
return (True, f'{self.dbt_version} is valid')

@property
def replacements(self) -> dict:
def replacements(self) -> Dict:
"""
Return a dictionary of replacements for the dbt template.
"""
Expand Down Expand Up @@ -137,7 +137,7 @@ def determine_profile_strategy(cls, project_path: "Path") -> Tuple[str, str]:
return str(default_profile_path), container_default

@classmethod
def _relative_paths(cls, profiles_dir: str, project_path: str) -> tuple:
def _relative_paths(cls, profiles_dir: str, project_path: str) -> Tuple[str, str]:
"""the relative child path of the given profiles dir
Args:
profiles_dir: where is the profile?
Expand Down
14 changes: 7 additions & 7 deletions palm/plugins/dbt/dbt_palm_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from typing import Optional
from typing import Optional, Dict, Tuple
from palm.plugins.dbt.local_user_lookup import local_user_lookup

""" Shared DBT utilities to build out common CLI options """
Expand All @@ -24,8 +24,8 @@ def _short_cycle(
no_fail_fast: Optional[bool] = False,
full_refresh: Optional[bool] = False,
no_seed: Optional[bool] = False,
models: Optional[tuple] = (),
macros: Optional[tuple] = (),
models: Optional[Tuple] = (),
macros: Optional[Tuple] = (),
) -> str:

command = "" if no_seed else f" dbt seed --full-refresh && "
Expand Down Expand Up @@ -53,9 +53,9 @@ def _long_cycle(
no_fail_fast: Optional[bool] = False,
full_refresh: Optional[bool] = False,
no_seed: Optional[bool] = False,
select: Optional[tuple] = (),
models: Optional[tuple] = (),
macros: Optional[tuple] = (),
select: Optional[Tuple] = (),
models: Optional[Tuple] = (),
macros: Optional[Tuple] = (),
) -> str:
seed_cmd = "" if no_seed else "&& dbt seed --full-refresh"
command = f"dbt clean && dbt deps {seed_cmd}"
Expand All @@ -80,7 +80,7 @@ def _long_cycle(
return command


def dbt_env_vars(branch: str) -> dict:
def dbt_env_vars(branch: str) -> Dict:
return {
'PDP_DEV_SCHEMA': _generate_schema_from_branch(branch),
'PDP_ENV': 'DEVELOPMENT', # Deprecated - this will be removed!
Expand Down
3 changes: 2 additions & 1 deletion palm/plugins/dbt/sql_to_dbt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import click
from typing import Tuple
from shutil import copy
from pathlib import Path
from functools import lru_cache
Expand Down Expand Up @@ -151,7 +152,7 @@ def get_replacements() -> list:
return replacements


def get_replacements_for_file(file: Path) -> tuple:
def get_replacements_for_file(file: Path) -> Tuple:
"""Extracts the dbt naming conventions from a given file
Args:
Expand Down

0 comments on commit f6bfecf

Please sign in to comment.