Skip to content

Commit

Permalink
fix: use python 3.8 compatible type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
MArpogaus committed Sep 15, 2024
1 parent 5fd537c commit 407633d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/dvc_stage/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# author : Marcel Arpogaus <znepry.necbtnhf@tznvy.pbz>
#
# created : 2024-09-15 13:51:13 (Marcel Arpogaus)
# changed : 2024-09-15 13:53:53 (Marcel Arpogaus)
# changed : 2024-09-15 14:23:53 (Marcel Arpogaus)

# %% Description ###############################################################
"""loading module."""
Expand All @@ -13,6 +13,7 @@
import fnmatch
import logging
import os
from typing import Union

import pandas as pd
from tqdm import tqdm
Expand Down Expand Up @@ -81,13 +82,13 @@ def _get_data_key(path: str, key_map: dict) -> str:
# %% public functions ##########################################################
def load_data(
format: str,
paths: str | list,
paths: Union[str, list],
key_map: dict = None,
import_from: str = None,
quiet: bool = False,
return_keys: list = False,
**kwds: object,
) -> object | dict:
) -> Union[object, dict]:
"""Load data from one or more files. Executes substage "loading".
Parameters
Expand Down
6 changes: 3 additions & 3 deletions src/dvc_stage/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# author : Marcel Arpogaus <znepry.necbtnhf@tznvy.pbz>
#
# created : 2024-09-15 13:18:39 (Marcel Arpogaus)
# changed : 2024-09-15 13:25:58 (Marcel Arpogaus)
# changed : 2024-09-15 14:24:02 (Marcel Arpogaus)

# %% Description ###############################################################
"""utils module."""
Expand All @@ -14,7 +14,7 @@
import importlib
import logging
import re
from typing import Any, Callable, Dict, List, Set, Tuple
from typing import Any, Callable, Dict, List, Set, Tuple, Union

# %% globals ###################################################################
__LOGGER__ = logging.getLogger(__name__)
Expand Down Expand Up @@ -75,7 +75,7 @@ def flatten_dict(


def get_deps(
path: str | List[str], params: Dict[str, Any]
path: Union[str, List[str]], params: Dict[str, Any]
) -> Tuple[List[str], Set[str]]:
"""Get dependencies given a path pattern and parameter values.
Expand Down
16 changes: 8 additions & 8 deletions src/dvc_stage/validating.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# author : Marcel Arpogaus <znepry.necbtnhf@tznvy.pbz>
#
# created : 2024-09-15 14:05:05 (Marcel Arpogaus)
# changed : 2024-09-15 14:12:22 (Marcel Arpogaus)
# changed : 2024-09-15 14:30:56 (Marcel Arpogaus)


# %% Description ###############################################################
"""validating module."""

# %% imports ###################################################################
import logging
from typing import Any, Dict, Union
from typing import Any, Dict, List, Union

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -66,8 +66,8 @@ def _apply_validation(
import_from: str = None,
reduction: str = "any",
expected: bool = True,
include: list[str] = [],
exclude: list[str] = [],
include: List[str] = [],
exclude: List[str] = [],
pass_key_to_fn: bool = False,
**kwds: Dict[str, Any],
) -> None:
Expand All @@ -93,9 +93,9 @@ def _apply_validation(
returned in full.
expected : bool
The expected output of the validation.
include : list[str]
include : List[str]
List of keys to include in the validation. If empty, all keys will be included.
exclude : list[str]
exclude : List[str]
List of keys to exclude from the validation.
pass_key_to_fn : bool
Flag to indicate if the key should be passed to the validation function.
Expand Down Expand Up @@ -222,14 +222,14 @@ def validate_pandera_schema(
return True


def apply_validations(data: any, validations: list[dict]) -> None:
def apply_validations(data: any, validations: List[dict]) -> None:
"""Apply validations to input data. Entrypoint for validation substage.
Parameters
----------
data : pandas.DataFrame or dict of pandas.DataFrame
Input data.
validations : list[dict]
validations : List[dict]
List of dictionaries containing validation parameters.
"""
Expand Down

0 comments on commit 407633d

Please sign in to comment.