Skip to content

Commit

Permalink
Enable MyPy checks in the CI, since pre-commit reached quota limit
Browse files Browse the repository at this point in the history
As observed in:
#482

The following exception was raised:
build of https://github.com/pre-commit/mirrors-mypy:types-PyYAML,types-attrs,attrs,types-requests,types-python-dateutil,[email protected] for python@python3 exceeds tier max size 250MiB: 262.2MiB

So we disabled MyPy checks as part of #485
  • Loading branch information
tatiana committed Sep 5, 2023
1 parent 0088c9d commit aeba36d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ jobs:
with:
path: |
~/.cache/pip
.nox
key: ${{ runner.os }}-${{ hashFiles('python-sdk/pyproject.toml') }}
- run: pip3 install nox
- run: nox -s type_check
key: ${{ runner.os }}-${{ hashFiles('pyproject.toml') }}
- run: pip3 install hatch mypy
- run: hatch run tests.py3.9-2.7:type-check

Run-Unit-Tests:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ repos:
rev: 'v1.5.0'
hooks:
- id: mypy
name: mypy-python-sdk
name: mypy-python
additional_dependencies: [types-PyYAML, types-attrs, attrs, types-requests, types-python-dateutil, apache-airflow]
files: ^cosmos

Expand Down
10 changes: 5 additions & 5 deletions cosmos/operators/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
)


class DbtDockerBaseOperator(DockerOperator, DbtBaseOperator): # type: ignore[misc] # ignores subclass MyPy error
class DbtDockerBaseOperator(DockerOperator, DbtBaseOperator): # type: ignore
"""
Executes a dbt core cli command in a Docker container.
"""

template_fields: Sequence[str] = DbtBaseOperator.template_fields + DockerOperator.template_fields
template_fields: Sequence[str] = tuple(list(DbtBaseOperator.template_fields) + list(DockerOperator.template_fields))

intercept_flag = False

Expand All @@ -39,7 +39,7 @@ def __init__(

def build_and_run_cmd(self, context: Context, cmd_flags: list[str] | None = None) -> Any:
self.build_command(context, cmd_flags)
self.log.info(f"Running command: {self.command}") # type: ignore[has-type]
self.log.info(f"Running command: {self.command}")
return super().execute(context)

def build_command(self, context: Context, cmd_flags: list[str] | None = None) -> None:
Expand All @@ -49,8 +49,8 @@ def build_command(self, context: Context, cmd_flags: list[str] | None = None) ->
self.dbt_executable_path = "dbt"
dbt_cmd, env_vars = self.build_cmd(context=context, cmd_flags=cmd_flags)
# set env vars
self.environment = {**env_vars, **self.environment} # type: ignore[has-type]
self.command = dbt_cmd
self.environment: dict[str, Any] = {**env_vars, **self.environment}
self.command: list[str] = dbt_cmd


class DbtLSDockerOperator(DbtDockerBaseOperator):
Expand Down
12 changes: 7 additions & 5 deletions cosmos/operators/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,28 @@
)


class DbtKubernetesBaseOperator(KubernetesPodOperator, DbtBaseOperator): # type: ignore[misc]
class DbtKubernetesBaseOperator(KubernetesPodOperator, DbtBaseOperator): # type: ignore
"""
Executes a dbt core cli command in a Kubernetes Pod.
"""

template_fields: Sequence[str] = DbtBaseOperator.template_fields + KubernetesPodOperator.template_fields
template_fields: Sequence[str] = tuple(
list(DbtBaseOperator.template_fields) + list(KubernetesPodOperator.template_fields)
)

intercept_flag = False

def __init__(self, **kwargs: Any) -> None:
super().__init__(**kwargs)

def build_env_args(self, env: dict[str, str | bytes | PathLike[Any]]) -> None:
env_vars_dict = dict()
env_vars_dict: dict[str, str] = dict()

for env_var in self.env_vars: # type: ignore[has-type]
for env_var in self.env_vars:
env_vars_dict[env_var.name] = env_var.value

self.env_vars = convert_env_vars({**env, **env_vars_dict})
self.env_vars: list[Any] = convert_env_vars({**env, **env_vars_dict})

def build_and_run_cmd(self, context: Context, cmd_flags: list[str] | None = None) -> Any:
self.build_kube_args(context, cmd_flags)
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ known_third_party = ["airflow", "jinja2"]

[tool.mypy]
strict = true
ignore_missing_imports = true
no_warn_unused_ignores = true

[tool.ruff]
line-length = 120
Expand Down

0 comments on commit aeba36d

Please sign in to comment.