Skip to content

Commit

Permalink
Add typing to sse.py
Browse files Browse the repository at this point in the history
Signed-off-by: Bala.FA <bala@minio.io>
  • Loading branch information
balamurugana committed Nov 22, 2023
1 parent c3317be commit 95a2f25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
20 changes: 10 additions & 10 deletions minio/sse.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ 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 {}


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",
Expand All @@ -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"
Expand All @@ -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

0 comments on commit 95a2f25

Please sign in to comment.