Skip to content

Commit

Permalink
add type hint for minio/credentials/credentials.py (#1298)
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 authored Sep 24, 2023
1 parent 661bb7c commit 0957e71
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions minio/credentials/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

"""Credential definitions to access S3 service."""
from __future__ import annotations

from datetime import datetime, timedelta, timezone

Expand All @@ -24,8 +25,17 @@ class Credentials:
Represents credentials access key, secret key and session token.
"""

_access_key: str
_secret_key: str
_session_token: str | None
_expiration: datetime | None

def __init__(
self, access_key, secret_key, session_token=None, expiration=None,
self,
access_key: str,
secret_key: str,
session_token: str | None = None,
expiration: datetime | None = None,
):
if not access_key:
raise ValueError("Access key must not be empty")
Expand All @@ -43,21 +53,21 @@ def __init__(
self._expiration = expiration

@property
def access_key(self):
def access_key(self) -> str:
"""Get access key."""
return self._access_key

@property
def secret_key(self):
def secret_key(self) -> str:
"""Get secret key."""
return self._secret_key

@property
def session_token(self):
def session_token(self) -> str | None:
"""Get session token."""
return self._session_token

def is_expired(self):
def is_expired(self) -> bool:
"""Check whether this credentials expired or not."""
return (
self._expiration < (datetime.utcnow() + timedelta(seconds=10))
Expand Down

0 comments on commit 0957e71

Please sign in to comment.