Skip to content

Commit

Permalink
Merge pull request #666 from dimbleby/priority-typing
Browse files Browse the repository at this point in the history
simplify and fix typing of priority()
  • Loading branch information
jaraco authored Feb 27, 2024
2 parents c7d3d59 + 5c2c45d commit f34f4e4
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions keyring/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@


try:
from jaraco.classes import properties # type: ignore # pragma: no-cover
from jaraco.classes import properties # pragma: no-cover
except ImportError:
from . import _properties_compat as properties # type: ignore # pragma: no-cover
from . import _properties_compat as properties # type: ignore[no-redef] # pragma: no-cover
3 changes: 1 addition & 2 deletions keyring/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

by_priority = operator.attrgetter('priority')
_limit: typing.Optional[typing.Callable[[KeyringBackend], bool]] = None
Number = typing.Union[int, float]


class KeyringBackendMeta(abc.ABCMeta):
Expand All @@ -48,7 +47,7 @@ def __init__(self):
self.set_properties_from_env()

@properties.classproperty
def priority(self) -> Number:
def priority(self) -> float:
"""
Each backend class must supply a priority, a number (float or integer)
indicating the priority of the backend relative to all other backends.
Expand Down
2 changes: 1 addition & 1 deletion keyring/backends/SecretService.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Keyring(backend.SchemeSelectable, KeyringBackend):
appid = 'Python keyring library'

@properties.classproperty
def priority(cls):
def priority(cls) -> float:
with ExceptionRaisedContext() as exc:
secretstorage.__name__
if exc:
Expand Down
2 changes: 1 addition & 1 deletion keyring/backends/Windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class WinVaultKeyring(KeyringBackend):
persist = Persistence()

@properties.classproperty
def priority(cls):
def priority(cls) -> float:
"""
If available, the preferred backend on Windows.
"""
Expand Down
2 changes: 1 addition & 1 deletion keyring/backends/chainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ChainerBackend(backend.KeyringBackend):
viable = True

@properties.classproperty
def priority(cls):
def priority(cls) -> float:
"""
If there are backends to chain, high priority
Otherwise very low priority since our operation when empty
Expand Down
2 changes: 1 addition & 1 deletion keyring/backends/fail.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Keyring(KeyringBackend):
"""

@properties.classproperty
def priority(cls):
def priority(cls) -> float:
return 0

def get_password(self, service, username, password=None):
Expand Down
2 changes: 1 addition & 1 deletion keyring/backends/null.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Keyring(KeyringBackend):
"""

@properties.classproperty
def priority(cls):
def priority(cls) -> float:
return -1

def get_password(self, service, username, password=None):
Expand Down

0 comments on commit f34f4e4

Please sign in to comment.