Skip to content

Commit

Permalink
Add type annotations to api methods for improved type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
przadka committed Feb 11, 2024
1 parent 4d79451 commit 31cf445
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions b2sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def create_bucket(
default_server_side_encryption: EncryptionSetting | None = None,
is_file_lock_enabled: bool | None = None,
replication: ReplicationConfiguration | None = None,
):
) -> Bucket:
"""
Create a bucket.
Expand Down Expand Up @@ -350,7 +350,7 @@ def get_bucket_by_id(self, bucket_id: str) -> Bucket:
# There is no such bucket.
raise BucketIdNotFound(bucket_id)

def get_bucket_by_name(self, bucket_name: str):
def get_bucket_by_name(self, bucket_name: str) -> Bucket:
"""
Return the Bucket matching the given bucket_name.
Expand Down Expand Up @@ -386,7 +386,8 @@ def delete_bucket(self, bucket):
account_id = self.account_info.get_account_id()
self.session.delete_bucket(account_id, bucket.id_)

def list_buckets(self, bucket_name=None, bucket_id=None, *, use_cache: bool = False):
def list_buckets(self, bucket_name=None, bucket_id=None, *,
use_cache: bool = False) -> list[Bucket]:
"""
Call ``b2_list_buckets`` and return a list of buckets.
Expand Down Expand Up @@ -502,7 +503,7 @@ def create_key(
valid_duration_seconds: int | None = None,
bucket_id: str | None = None,
name_prefix: str | None = None,
):
) -> FullApplicationKey:
"""
Create a new :term:`application key`.
Expand Down Expand Up @@ -537,7 +538,7 @@ def delete_key(self, application_key: BaseApplicationKey):

return self.delete_key_by_id(application_key.id_)

def delete_key_by_id(self, application_key_id: str):
def delete_key_by_id(self, application_key_id: str) -> ApplicationKey:
"""
Delete :term:`application key`.
Expand Down
2 changes: 1 addition & 1 deletion b2sdk/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ def copy(
content_disposition: str | None = None,
content_encoding: str | None = None,
content_language: str | None = None,
):
) -> FileVersion:
"""
Creates a new file in this bucket by (server-side) copying from an existing file.
Expand Down

0 comments on commit 31cf445

Please sign in to comment.