Skip to content

Commit

Permalink
Python 3.9 typehints fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kgodlewski committed Dec 18, 2024
1 parent 0e12c81 commit dd55939
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/neptune_scale/api/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
__all__ = ("Attribute", "AttributeStore")


def _extract_named_kwargs(fn: Callable) -> Set[str]:
def _extract_named_kwargs(fn: Callable) -> set[str]:
"""Return a set of named arguments of a function, that are not positional-only."""
import inspect

Expand Down
9 changes: 2 additions & 7 deletions src/neptune_scale/net/ingest_code.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from typing import (
Dict,
Type,
)

from neptune_api.proto.neptune_pb.ingest.v1.ingest_pb2 import IngestCode

from neptune_scale.exceptions import (
Expand All @@ -29,7 +24,7 @@
NeptuneUnexpectedError,
)

CODE_TO_ERROR: Dict[IngestCode.ValueType, Type[Exception]] = {
CODE_TO_ERROR: dict[IngestCode.ValueType, type[Exception]] = {
IngestCode.PROJECT_NOT_FOUND: NeptuneProjectNotFound,
IngestCode.PROJECT_INVALID_NAME: NeptuneProjectInvalidName,
IngestCode.RUN_NOT_FOUND: NeptuneRunNotFound,
Expand All @@ -53,7 +48,7 @@
}


def code_to_exception(code: IngestCode.ValueType) -> Type[Exception]:
def code_to_exception(code: IngestCode.ValueType) -> type[Exception]:
if exc_class := CODE_TO_ERROR.get(code):
return exc_class

Expand Down
1 change: 1 addition & 0 deletions src/neptune_scale/sync/errors_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import multiprocessing
import queue
import time
import traceback
from collections.abc import Callable
from typing import Optional

Expand Down
12 changes: 6 additions & 6 deletions src/neptune_scale/sync/files/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
import mimetypes
import time
import uuid
from collections.abc import (
Callable,
Sequence,
)
from concurrent import futures
from datetime import datetime
from pathlib import Path
from queue import Empty
from typing import (
BinaryIO,
Callable,
List,
Literal,
Optional,
Sequence,
Tuple,
)

import backoff
Expand Down Expand Up @@ -167,7 +167,7 @@ def _submit_attribute(self, attribute_path: str, file_path: str, timestamp: date

@backoff.on_exception(backoff.expo, NeptuneRetryableError, max_time=MAX_REQUEST_RETRY_SECONDS)
@with_api_errors_handling
def _wait_for_completion(self, request_ids: List[str]) -> None:
def _wait_for_completion(self, request_ids: list[str]) -> None:
assert self._backend is not None # mypy

while self.is_running():
Expand Down Expand Up @@ -212,7 +212,7 @@ def determine_path_and_mime_type(
local_path: Optional[Path],
target_path: Optional[str],
target_basename: Optional[str],
) -> Tuple[str, str]:
) -> tuple[str, str]:
mime_type = guess_mime_type(attribute_path, local_path)

# Target path always takes precedence as-is
Expand Down

0 comments on commit dd55939

Please sign in to comment.