From 95a2f25995a8945c5a7fde538847c4144b7bc819 Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Wed, 22 Nov 2023 08:26:52 +0530 Subject: [PATCH] Add typing to sse.py Signed-off-by: Bala.FA --- .github/workflows/ci.yml | 6 +++--- minio/sse.py | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 328209484..854c109c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,11 +30,11 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] os: [ubuntu-latest, windows-latest, macos-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run spell check on Ubuntu if: matrix.os == 'ubuntu-latest' uses: codespell-project/actions-codespell@master @@ -59,7 +59,7 @@ jobs: echo "/Users/runner/.local/bin" >> $GITHUB_PATH - name: Run unit tests run: | - python setup.py install + pip install pytest - name: Run functional tests on Ubuntu if: matrix.os == 'ubuntu-latest' diff --git a/minio/sse.py b/minio/sse.py index eef5019a7..5e2996c1e 100644 --- a/minio/sse.py +++ b/minio/sse.py @@ -34,14 +34,14 @@ class Sse: __metaclass__ = ABCMeta @abstractmethod - def headers(self): + def headers(self) -> dict[str, str]: """Return headers.""" - def tls_required(self): # pylint: disable=no-self-use + def tls_required(self) -> bool: # pylint: disable=no-self-use """Return TLS required to use this server-side encryption.""" return True - def copy_headers(self): # pylint: disable=no-self-use + def copy_headers(self) -> dict[str, str]: # pylint: disable=no-self-use """Return copy headers.""" return {} @@ -49,7 +49,7 @@ def copy_headers(self): # pylint: disable=no-self-use class SseCustomerKey(Sse): """ Server-side encryption - customer key type.""" - def __init__(self, key): + def __init__(self, key: bytes): if len(key) != 32: raise ValueError( "SSE-C keys need to be 256 bit base64 encoded", @@ -71,17 +71,17 @@ def __init__(self, key): md5key, } - def headers(self): + def headers(self) -> dict[str, str]: return self._headers.copy() - def copy_headers(self): + def copy_headers(self) -> dict[str, str]: return self._copy_headers.copy() class SseKMS(Sse): """Server-side encryption - KMS type.""" - def __init__(self, key, context): + def __init__(self, key: str, context: dict): self._headers = { "X-Amz-Server-Side-Encryption-Aws-Kms-Key-Id": key, "X-Amz-Server-Side-Encryption": "aws:kms" @@ -92,17 +92,17 @@ def __init__(self, key, context): base64.b64encode(data).decode() ) - def headers(self): + def headers(self) -> dict[str, str]: return self._headers.copy() class SseS3(Sse): """Server-side encryption - S3 type.""" - def headers(self): + def headers(self) -> dict[str, str]: return { "X-Amz-Server-Side-Encryption": "AES256" } - def tls_required(self): + def tls_required(self) -> bool: return False