Skip to content

Commit 8784b5c

Browse files
author
Timon Viola
committed
chore: add typestubs and fix linting
1 parent 5dc950f commit 8784b5c

File tree

358 files changed

+36973
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

358 files changed

+36973
-7
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ repos:
1414
hooks:
1515
- id: typos
1616
stages: [commit]
17+
exclude: "^typings/.*"
1718
- repo: https://github.com/pre-commit/mirrors-mypy
1819
rev: v1.10.1 # Use the sha / tag you want to point at
1920
hooks:
2021
- id: mypy
22+
language: system
23+
pass_filenames: false
24+
args: ['.']
2125
- repo: https://github.com/compilerla/conventional-pre-commit
2226
rev: v3.3.0
2327
hooks:

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ venvPath = ".venv"
188188
venv = "dev"
189189

190190
[tool.ruff]
191+
exclude = [
192+
"typings/*"
193+
]
191194
[tool.ruff.format]
192195
quote-style = "double"
193196
indent-style = "space"
@@ -304,7 +307,8 @@ disable_error_code = [
304307
"annotation-unchecked",
305308
]
306309
exclude = [
307-
"examles/*",
310+
"^examples/*",
311+
"^typings/*"
308312
]
309313

310314
[tool.versioningit]

src/dagcellent/operators/mlflow/hooks.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import functools
77
import logging
8-
from collections.abc import Callable
98
from typing import TYPE_CHECKING, TypeVar
109
from warnings import warn
1110

@@ -15,6 +14,8 @@
1514

1615
if TYPE_CHECKING:
1716
# NOTE ruff fails for this check
17+
from collections.abc import Callable
18+
1819
import mlflow.entities.model_registry # noqa: TCH004
1920

2021
from dagcellent.operators.mlflow._utils import MlflowModelStage
@@ -31,8 +32,9 @@ def _mlflow_request_wrapper(query: Callable[P, T]) -> T:
3132
try:
3233
res = query()
3334
except mlflow.MlflowException as exc:
34-
_LOGGER.error("Error during mlflow query.", exc_info=exc)
35-
raise mlflow.MlflowException from exc
35+
_msg = "Error during mlflow query."
36+
_LOGGER.error(_msg, exc_info=exc)
37+
raise mlflow.MlflowException(_msg) from exc
3638
return res
3739

3840

tests/dags/test_msql_reflect_otherdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
execute = SQLExecuteQueryOperator(
2424
task_id="execute_query",
2525
conn_id=CONN_ID,
26-
sql=reflect_table.output,
26+
sql=reflect_table.output, # type: ignore
2727
database="model",
2828
)
2929

tests/dags/test_msql_reflect_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
execute = SQLExecuteQueryOperator(
2828
task_id="execute_query",
2929
conn_id=CONN_ID,
30-
sql=reflect_table.output,
30+
sql=reflect_table.output, # type: ignore
3131
database="model",
3232
)
3333

tests/dags/test_mssql_reflect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
create_pet_table = SQLExecuteQueryOperator(
3131
task_id="create_pet_table",
3232
conn_id=CONN_ID,
33-
sql=reflect_table.output,
33+
sql=reflect_table.output, # type: ignore
3434
)
3535

3636
reflect_table >> create_pet_table

typings/airflow/__init__.pyi

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
This type stub file was generated by pyright.
3+
"""
4+
5+
import os
6+
import sys
7+
from typing import TYPE_CHECKING
8+
9+
from airflow import settings
10+
from airflow.models.dag import DAG
11+
from airflow.models.dataset import Dataset
12+
from airflow.models.xcom_arg import XComArg
13+
14+
__version__ = ...
15+
if os.environ.get("_AIRFLOW_PATCH_GEVENT"): ...
16+
if sys.platform == "win32": ...
17+
__all__ = ["__version__", "DAG", "Dataset", "XComArg"]
18+
__path__ = ...
19+
if not os.environ.get("_AIRFLOW__AS_LIBRARY", None): ...
20+
__lazy_imports: dict[str, tuple[str, str, bool]] = ...
21+
if TYPE_CHECKING: ...
22+
23+
def __getattr__(name: str): # -> bool | Any | ModuleType:
24+
...
25+
26+
if not settings.LAZY_LOAD_PROVIDERS:
27+
manager = ...
28+
if not settings.LAZY_LOAD_PLUGINS: ...
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
This type stub file was generated by pyright.
3+
"""
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""
2+
This type stub file was generated by pyright.
3+
"""
4+
5+
from typing import Any
6+
7+
HEALTHY = ...
8+
UNHEALTHY = ...
9+
10+
def get_airflow_health() -> dict[str, Any]:
11+
"""Get the health for Airflow metadatabase, scheduler and triggerer."""
12+
...
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
This type stub file was generated by pyright.
3+
"""
4+
5+
from typing import TYPE_CHECKING
6+
7+
from airflow.utils.session import provide_session
8+
from sqlalchemy.orm import Session
9+
10+
"""Delete DAGs APIs."""
11+
if TYPE_CHECKING: ...
12+
log = ...
13+
14+
@provide_session
15+
def delete_dag(
16+
dag_id: str, keep_records_in_log: bool = ..., session: Session = ...
17+
) -> int:
18+
"""
19+
Delete a DAG by a dag_id.
20+
21+
:param dag_id: the dag_id of the DAG to delete
22+
:param keep_records_in_log: whether keep records of the given dag_id
23+
in the Log table in the backend database (for reasons like auditing).
24+
The default value is True.
25+
:param session: session used
26+
:return count of deleted dags
27+
"""
28+
...

0 commit comments

Comments
 (0)