Skip to content

Commit

Permalink
Add types to parameters to KeyringBackend methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 27, 2021
1 parent c0d4b92 commit db6896a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions keyring/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ def __str__(self):
)

@abc.abstractmethod
def get_password(self, service, username) -> Optional[str]:
def get_password(self, service: str, username: str) -> Optional[str]:
"""Get password of the username for the service"""
return None

@abc.abstractmethod
def set_password(self, service, username, password):
def set_password(self, service: str, username: str, password: str) -> None:
"""Set password for the username of the service.
If the backend cannot store passwords, raise
Expand All @@ -110,7 +110,7 @@ def set_password(self, service, username, password):
# for backward-compatibility, don't require a backend to implement
# delete_password
# @abc.abstractmethod
def delete_password(self, service, username):
def delete_password(self, service: str, username: str) -> None:
"""Delete the password for the username of the service.
If the backend cannot delete passwords, raise
Expand All @@ -122,7 +122,9 @@ def delete_password(self, service, username):
# get_credential
# @abc.abstractmethod
def get_credential(
self, service, username
self,
service: str,
username: Optional[str],
) -> Optional[credentials.SimpleCredential]:
"""Gets the username and password for the service.
Returns a Credential instance.
Expand Down
2 changes: 1 addition & 1 deletion keyring/backends/fail.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def get_password(self, service, username, password=None):
)
raise NoKeyringError(msg)

set_password = delete_password = get_password
set_password = delete_password = get_password # type: ignore
2 changes: 1 addition & 1 deletion keyring/backends/null.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class Keyring(KeyringBackend):
def get_password(self, service, username, password=None):
pass

set_password = delete_password = get_password
set_password = delete_password = get_password # type: ignore

0 comments on commit db6896a

Please sign in to comment.