Skip to content

Commit

Permalink
Run updated ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
jl-wynen committed Apr 19, 2024
1 parent e7e5ccd commit d16d864
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ ignore = [
"B905", # `zip()` without an explicit `strict=` parameter
"S324", # insecure hsh function; we don't use hashing for security
"E741", "E742", "E743", # do not use names ‘l’, ‘O’, or ‘I’; they are not a problem with a proper font
"UP038", # does not seem to work and leads to slower code
"E111", "E114", "E117", "D206", "D300", # conflict with ruff format
"D105",
]
Expand Down
4 changes: 2 additions & 2 deletions src/scitacean/_internal/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import json
import os
import subprocess
from typing import Any, Union
from typing import Any

_PathLike = Union[str, os.PathLike[str]]
_PathLike = str | os.PathLike[str]


def docker_compose_up(config_file: _PathLike, *services: str) -> None:
Expand Down
8 changes: 4 additions & 4 deletions src/scitacean/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from collections.abc import Callable, Iterable, Iterator
from contextlib import contextmanager
from pathlib import Path
from typing import Any, Union
from typing import Any
from urllib.parse import quote_plus

import requests
Expand Down Expand Up @@ -1162,9 +1162,9 @@ def _get_token(
raise ScicatLoginError(response.content)


FileSelector = Union[
bool, str, list[str], tuple[str], re.Pattern[str], Callable[[File], bool]
]
FileSelector = (
bool | str | list[str] | tuple[str] | re.Pattern[str] | Callable[[File], bool]
)


def _file_selector(select: FileSelector) -> Callable[[File], bool]:
Expand Down
2 changes: 1 addition & 1 deletion src/scitacean/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class DownloadDataset(
dataQualityMetrics: int | None = None
description: str | None = None
endTime: datetime | None = None
history: None | None = None
history: None = None
instrumentGroup: str | None = None
instrumentId: str | None = None
isPublished: bool | None = None
Expand Down
4 changes: 2 additions & 2 deletions src/scitacean/testing/backend/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import time
from copy import deepcopy
from pathlib import Path
from typing import Any, Union
from typing import Any
from urllib.parse import urljoin

import requests
Expand All @@ -14,7 +14,7 @@
from ..._internal.docker import docker_compose_down, docker_compose_up
from . import config

_PathLike = Union[str, os.PathLike[str]]
_PathLike = str | os.PathLike[str]


def _read_yaml(filename: str) -> Any:
Expand Down
6 changes: 3 additions & 3 deletions src/scitacean/testing/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import string
from functools import partial
from typing import Any, Optional
from typing import Any

from email_validator import EmailNotValidError, ValidatedEmail, validate_email
from hypothesis import strategies as st
Expand Down Expand Up @@ -151,7 +151,7 @@ def _scientific_metadata_strategy(
def _job_parameters_strategy(
field: Dataset.Field,
) -> st.SearchStrategy[dict[str, str] | None]:
return st.from_type(Optional[dict[str, str]]) # type: ignore[arg-type]
return st.from_type(dict[str, str] | None) # type: ignore[arg-type]


def _lifecycle_strategy(
Expand Down Expand Up @@ -192,7 +192,7 @@ def _field_strategy(field: Dataset.Field) -> st.SearchStrategy[Any]:
if (strategy := _SPECIAL_FIELDS.get(field.name)) is not None:
return strategy(field)

typ = field.type if field.required else Optional[field.type]
typ = field.type if field.required else field.type | None
return st.from_type(typ) # type:ignore[arg-type]


Expand Down
9 changes: 6 additions & 3 deletions src/scitacean/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

"""Definitions for type checking."""

from contextlib import AbstractContextManager
from pathlib import Path
from typing import ContextManager, Protocol
from typing import Protocol

from .dataset import Dataset
from .file import File
Expand All @@ -29,7 +30,7 @@ def download_files(self, *, remote: list[RemotePath], local: list[Path]) -> None
class Downloader(Protocol):
"""Handler for file downloads."""

def connect_for_download(self) -> ContextManager[DownloadConnection]:
def connect_for_download(self) -> AbstractContextManager[DownloadConnection]:
"""Open a connection to the file server.
Returns
Expand Down Expand Up @@ -90,7 +91,9 @@ def source_folder_for(self, dataset: Dataset) -> RemotePath:
The source folder for ``dataset``.
"""

def connect_for_upload(self, dataset: Dataset) -> ContextManager[UploadConnection]:
def connect_for_upload(
self, dataset: Dataset
) -> AbstractContextManager[UploadConnection]:
"""Open a connection to the file server.
Parameters
Expand Down

0 comments on commit d16d864

Please sign in to comment.