Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar committed Dec 16, 2024
1 parent 379d43d commit 9c15288
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/pyorderly/outpack/location_push.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from dataclasses import dataclass
from typing import List, Union

from pyorderly.outpack.util import as_list
from pyorderly.outpack.location import _location_driver, location_resolve_valid
from pyorderly.outpack.location_driver import LocationDriver
from pyorderly.outpack.location_pull import _find_all_dependencies
from pyorderly.outpack.root import OutpackRoot, find_file_by_hash, root_open
from pyorderly.outpack.static import LOCATION_LOCAL
from pyorderly.outpack.util import as_list


@dataclass
Expand Down
30 changes: 14 additions & 16 deletions src/pyorderly/outpack/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from contextlib import contextmanager
from itertools import filterfalse, tee
from pathlib import Path, PurePath
from typing import Dict, List, Optional, Union, overload
from typing import Dict, List, Optional, TypeVar, Union


def find_file_descend(filename, path):
Expand Down Expand Up @@ -60,7 +60,9 @@ def transient_working_directory(path):
os.chdir(origin)


def assert_file_exists(path: Union[str, List[str]], *, workdir=None, name="File"):
def assert_file_exists(
path: Union[str, List[str]], *, workdir=None, name="File"
):
with transient_working_directory(workdir):
if isinstance(path, list):
missing = [str(p) for p in path if not os.path.exists(p)]
Expand Down Expand Up @@ -193,19 +195,10 @@ def openable_temporary_file(*, mode: str = "w+b", dir: Optional[str] = None):
pass


@overload
def as_posix_path(paths: str) -> str: ...
Paths = TypeVar("Paths", str, List[str], Dict[str, str])


@overload
def as_posix_path(paths: List[str]) -> List[str]: ...


@overload
def as_posix_path(paths: Dict[str, str]) -> Dict[str, str]: ...


def as_posix_path(paths):
def as_posix_path(paths: Paths) -> Paths:
"""
Convert a native path into a posix path.
Expand All @@ -219,7 +212,12 @@ def as_posix_path(paths):
else:
return PurePath(paths).as_posix()

T = TypeVar('T')

T = TypeVar("T")


def as_list(x: Union[T, List[T]]) -> List[T]:
if isinstance(x, list): return x
else: return [x]
if isinstance(x, list):
return x
else:
return [x]
6 changes: 4 additions & 2 deletions tests/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pyorderly.outpack.location import outpack_location_add_path
from pyorderly.outpack.metadata import MetadataCore, PacketDepends
from pyorderly.outpack.packet import Packet, insert_packet
from pyorderly.outpack.root import root_open, OutpackRoot
from pyorderly.outpack.root import OutpackRoot, root_open
from pyorderly.outpack.schema import outpack_schema_version
from pyorderly.outpack.util import openable_temporary_file
from pyorderly.run import orderly_run
Expand Down Expand Up @@ -44,7 +44,9 @@ def create_packet(root, name, *, packet_id=None, parameters=None):
insert_packet(root, Path(src), metadata)


def create_random_packet(root, name="data", *, parameters=None, packet_id=None) -> str:
def create_random_packet(
root, name="data", *, parameters=None, packet_id=None
) -> str:
d = [f"{random.random()}\n" for _ in range(10)]

with create_packet(
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/outpack_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import pytest
import requests

from pyorderly.outpack.root import OutpackRoot
from pyorderly.outpack.init import outpack_init
from pyorderly.outpack.root import OutpackRoot


def _wait_ready(p, url, args, timeout=2):
Expand Down

0 comments on commit 9c15288

Please sign in to comment.