diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f32290e..83b61bb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ exclude: ".venv|__pycache__|tests/dev/|tests/fixtures/" fail_fast: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-added-large-files args: ["--maxkb=1024"] @@ -22,25 +22,25 @@ repos: args: [--markdown-linebreak-ext=md] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.0.291" + rev: "v0.1.9" hooks: - id: ruff args: ["--fix-only", "--target-version=py38"] - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.12.1 hooks: - id: black args: ["--target-version=py38"] - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort args: ["--profile", "black", "--filter-files"] - repo: https://github.com/asottile/pyupgrade - rev: v3.13.0 + rev: v3.15.0 hooks: - id: pyupgrade args: diff --git a/src/rok4/storage.py b/src/rok4/storage.py index 1cf0f6f..075baa0 100644 --- a/src/rok4/storage.py +++ b/src/rok4/storage.py @@ -366,7 +366,7 @@ def __get_cached_data_binary(path: str, ttl_hash: int, range: Tuple[int, int] = ) except botocore.exceptions.ClientError as e: - if e.response["Error"]["Code"] == "404": + if e.response["Error"]["Code"] == "NoSuchKey": raise FileNotFoundError(f"{storage_type.value}{path}") else: raise StorageError("S3", e) @@ -443,6 +443,9 @@ def get_data_binary(path: str, range: Tuple[int, int] = None) -> str: Returns: str: Data binary content """ + print("########################################") + print(f"get_data_binary {path}") + print("########################################") return __get_cached_data_binary(path, __get_ttl_hash(), range) @@ -573,7 +576,7 @@ def exists(path: str) -> bool: s3_client["client"].head_object(Bucket=bucket_name, Key=base_name) return True except botocore.exceptions.ClientError as e: - if e.response["Error"]["Code"] == "404": + if e.response["Error"]["Code"] == "NoSuchKey": return False else: raise StorageError("S3", e) diff --git a/tests/test_storage.py b/tests/test_storage.py index dd7dddd..4e5e543 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -809,7 +809,7 @@ def test_exists_s3_ok(mocked_s3_client): assert False, f"S3 exists raises an exception: {exc}" s3_instance.head_object.side_effect = botocore.exceptions.ClientError( - operation_name="InvalidKeyPair.Duplicate", error_response={"Error": {"Code": "404"}} + operation_name="InvalidKeyPair.Duplicate", error_response={"Error": {"Code": "NoSuchKey"}} ) try: assert not exists("s3://bucket/object.ext")