Skip to content

Commit

Permalink
chore: fix mypy errors in task-plugins and task_engine
Browse files Browse the repository at this point in the history
  • Loading branch information
keithmanville committed Dec 23, 2024
1 parent 6e74940 commit d017c4f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/dioptra/task_engine/type_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def build_type(

else: # else, a simple type
if super_type and not isinstance(super_type, types.SimpleType):
raise NonSimpleSuperTypeError(super_type_name)
raise NonSimpleSuperTypeError(cast(str, super_type_name))

# Here, super_type must either be null or an instance of SimpleType
# (the negation of the above if condition). I.e. it satisfies
Expand Down
4 changes: 2 additions & 2 deletions task-plugins/dioptra_builtins/artifacts/mlflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import tarfile
from pathlib import Path
from typing import Any, Callable, Dict, Optional, Union
from typing import Any, Callable, Dict, Literal, Optional, Union

import mlflow
import pandas as pd
Expand Down Expand Up @@ -183,7 +183,7 @@ def to_format(
def upload_directory_as_tarball_artifact(
source_dir: Union[str, Path],
tarball_filename: str,
tarball_write_mode: str = "w:gz",
tarball_write_mode: Literal["w", "w:", "w:gz", "x:bz2", "w:xz"] = "w:gz",
working_dir: Optional[Union[str, Path]] = None,
) -> None:
"""Archives a directory and uploads it as an artifact of the active MLFlow run.
Expand Down
6 changes: 3 additions & 3 deletions task-plugins/dioptra_builtins/artifacts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import uuid
from pathlib import Path
from tarfile import TarFile
from typing import Any, List, Union
from typing import Any, List, Literal, Union

import structlog
from structlog.stdlib import BoundLogger
Expand Down Expand Up @@ -54,7 +54,7 @@ def safe_extract(tar: TarFile, path: Union[str, Path] = ".") -> None:
@pyplugs.register
def extract_tarfile(
filepath: Union[str, Path],
tarball_read_mode: str = "r:gz",
tarball_read_mode: Literal["r", "r:*", "r:", "r:gz", "r:bz2", "r:xz"] = "r:gz",
output_dir: Any = None,
) -> None:
"""Extracts a tarball archive into the current working directory.
Expand Down Expand Up @@ -93,7 +93,7 @@ def make_directories(dirs: List[Union[str, Path]]) -> None:
@pyplugs.register
def extract_tarfile_in_unique_subdir(
filepath: Union[str, Path],
tarball_read_mode: str = "r:gz",
tarball_read_mode: Literal["r", "r:*", "r:", "r:gz", "r:bz2", "r:xz"] = "r:gz",
) -> Path:
"""Extracts a tarball archive into a unique subdirectory of the
current working directory.
Expand Down

0 comments on commit d017c4f

Please sign in to comment.