Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 4, 2024
1 parent fa23b53 commit e9cb567
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 24 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check_release_tag.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Check that the GitHub release tag matches the package version."""

import argparse
import pathlib
import re
Expand Down
33 changes: 16 additions & 17 deletions disk_objectstore/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,12 @@ def _get_config_file(self) -> Path:
@overload
def _get_session(
self, create: bool = False, raise_if_missing: Literal[True] = True
) -> Session:
...
) -> Session: ...

@overload
def _get_session(
self, create: bool = False, raise_if_missing: Literal[False] = False
) -> Session | None:
...
) -> Session | None: ...

def _get_session(
self, create: bool = False, raise_if_missing: bool = False
Expand Down Expand Up @@ -528,17 +526,15 @@ def _get_objects_stream_meta_generator(
hashkeys: Sequence[str],
skip_if_missing: bool,
with_streams: Literal[False],
) -> Iterator[tuple[str, ObjectMeta]]:
...
) -> Iterator[tuple[str, ObjectMeta]]: ...

@overload
def _get_objects_stream_meta_generator(
self,
hashkeys: Sequence[str],
skip_if_missing: bool,
with_streams: Literal[True],
) -> Iterator[tuple[str, StreamSeekBytesType | None, ObjectMeta]]:
...
) -> Iterator[tuple[str, StreamSeekBytesType | None, ObjectMeta]]: ...

def _get_objects_stream_meta_generator( # pylint: disable=too-many-branches,too-many-statements,too-many-locals
self,
Expand Down Expand Up @@ -1323,8 +1319,9 @@ def pack_all_loose( # pylint: disable=too-many-locals,too-many-branches,too-man
compress: bool | CompressMode = CompressMode.NO,
validate_objects: bool = True,
do_fsync: bool = True,
callback: None
| (Callable[[Arg(str, "action"), Arg(Any, "value")], None]) = None,
callback: None | (
Callable[[Arg(str, "action"), Arg(Any, "value")], None]
) = None,
) -> None:
"""Pack all loose objects.
Expand Down Expand Up @@ -2616,8 +2613,9 @@ def delete_objects(self, hashkeys: list[str]) -> list[str | Any]:
def repack(
self,
compress_mode: CompressMode = CompressMode.KEEP,
callback: None
| (Callable[[Arg(str, "action"), Arg(Any, "value")], None]) = None,
callback: None | (
Callable[[Arg(str, "action"), Arg(Any, "value")], None]
) = None,
) -> None:
"""Perform a repack of all packed objects.
Expand Down Expand Up @@ -2645,8 +2643,9 @@ def repack_pack( # pylint: disable=too-many-branches,too-many-statements,too-ma
self,
pack_id: str,
compress_mode: CompressMode = CompressMode.KEEP,
callback: None
| (Callable[[Arg(str, "action"), Arg(Any, "value")], None]) = None,
callback: None | (
Callable[[Arg(str, "action"), Arg(Any, "value")], None]
) = None,
) -> None:
"""Perform a repack of a given pack object.
Expand Down Expand Up @@ -2723,9 +2722,9 @@ def repack_pack( # pylint: disable=too-many-branches,too-many-statements,too-ma
source_compressed,
) in session.execute(stmt):
# This is the read handle of the bytes in the pack - it might be
read_handle: (
PackedObjectReader | ZlibStreamDecompresser
) = PackedObjectReader(read_pack, offset, length)
read_handle: PackedObjectReader | ZlibStreamDecompresser = (
PackedObjectReader(read_pack, offset, length)
)

# Determine if I should compress or not the destination - this function will
# try to do it in a cheap way (e.g. if the source is already compressed, will just
Expand Down
1 change: 1 addition & 0 deletions disk_objectstore/database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Models for the container index file (SQLite DB)."""

from pathlib import Path
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions disk_objectstore/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Definition of the dataclasses used as return values of
a number of methods.
"""

from dataclasses import asdict, dataclass
from typing import TYPE_CHECKING, List, Optional, Union

Expand Down
13 changes: 6 additions & 7 deletions disk_objectstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Some might be useful also for end users, like the wrappers to get streams,
like the ``LazyOpener``.
"""

# pylint: disable= too-many-lines
from __future__ import annotations

Expand Down Expand Up @@ -809,9 +810,9 @@ def __init__(
self._decompressor = self.decompressobj_class()
self._internal_buffer = b""
self._pos = 0
self._lazy_uncompressed_stream: None | (
LazyLooseStream
) = lazy_uncompressed_stream
self._lazy_uncompressed_stream: None | (LazyLooseStream) = (
lazy_uncompressed_stream
)
# If True, this class just proxies request to the underlying
# uncompressed stream
self._use_uncompressed_stream: bool = False
Expand Down Expand Up @@ -1326,11 +1327,9 @@ def safe_flush_to_disk(
fhandle.flush()

# Default fsync function, replaced on Mac OS X
_fsync_function: Callable[
[Any], Any
] = lambda fileno: os.fsync( # pylint: disable=unnecessary-lambda
_fsync_function: Callable[[Any], Any] = lambda fileno: os.fsync(
fileno
)
) # pylint: disable=unnecessary-lambda

# Flush to disk
if hasattr(fcntl, "F_FULLFSYNC") is not None and (
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Configuration file for pytest tests."""

import hashlib
import os
import random
Expand Down
1 change: 1 addition & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This is also a way to verify the behavior of the underlying OS/filesystem.
"""

import os
import subprocess
import sys
Expand Down
1 change: 1 addition & 0 deletions tests/test_benchmark.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test the performance of the container implementation."""

import hashlib
import random

Expand Down
1 change: 1 addition & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test the CLI commands"""

import platform
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions tests/test_concurrency.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test of the object-store container module."""

import os
import subprocess
import sys
Expand Down
1 change: 1 addition & 0 deletions tests/test_container.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test of the object-store container module."""

# pylint: disable=too-many-lines,protected-access
import dataclasses
import functools
Expand Down
1 change: 1 addition & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test of the object-store container module."""

import subprocess
import sys
import tempfile
Expand Down
1 change: 1 addition & 0 deletions tests/test_optional.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Additional optional tests to check additional functionality, such as
if the library works also with other external optional modules."""

from pathlib import Path

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test of the utils wrappers."""

# pylint: disable=too-many-lines,protected-access
import functools
import hashlib
Expand Down

0 comments on commit e9cb567

Please sign in to comment.