Type checking error due to casting a subclass as backend.KeyringBackend
base class
#645
Labels
backend.KeyringBackend
base class
#645
Describe the bug
I am attempting to contribute an implementation using this library to a type checked project and mypy is failing the PR.
I think the cause of the failure is that the backend returned from
keyring.get_keyring()
is typed as the wrong class. It's being cast tokeyring.backend.Backend
but it is in fact a subclass.keyring/keyring/core.py
Lines 30 to 34 in af72339
Type checkers reject this incorrect casting whenever a method is used that's unique to a subclass, such as
get_preferred_collection()
which exists onkeyring.backends.SecretService.Keyring
but notkeyring.backend.KeyringBackend
.due to this code at line 666 👿 :
and further on at 676:
It looks tricky but maybe I can help make some progress on these type annotations, maybe the cast helps identify a place to start?
I can't figure out if there is already a mypy workflow in use in this project (is
pytest-mypy
called somewhere?)The text was updated successfully, but these errors were encountered: