diff --git a/keyrings/__init__.py b/keyrings/__init__.py index 0d1f7ed..69e3be5 100644 --- a/keyrings/__init__.py +++ b/keyrings/__init__.py @@ -1 +1 @@ -__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/keyrings/alt/Gnome.py b/keyrings/alt/Gnome.py index 1ab5900..6f5dd76 100644 --- a/keyrings/alt/Gnome.py +++ b/keyrings/alt/Gnome.py @@ -2,7 +2,9 @@ import gi gi.require_version('GnomeKeyring', '1.0') - from gi.repository import GnomeKeyring + from gi.repository import ( # type: ignore[attr-defined] # Missing from PyGObject-stubs + GnomeKeyring, + ) except (ImportError, ValueError, AttributeError): pass diff --git a/keyrings/alt/_win_crypto.py b/keyrings/alt/_win_crypto.py index 6d02c7e..53a2db0 100644 --- a/keyrings/alt/_win_crypto.py +++ b/keyrings/alt/_win_crypto.py @@ -1,4 +1,17 @@ -from ctypes import ( +import os +import sys + +if os.name != "nt": + raise ImportError( + "Module " + __name__ + " can only be imported on nt platforms. Not " + os.name + ) + +# if TYPE_CHECKING: +# python/mypy#8166 +# python/typing#1732 +assert sys.platform == "win32" + +from ctypes import ( # noqa: E402 POINTER, WINFUNCTYPE, Structure, @@ -10,14 +23,9 @@ create_string_buffer, memmove, windll, + wintypes, ) -try: - from ctypes import wintypes -except ValueError: - # see http://bugs.python.org/issue16396 - raise ImportError("wintypes") - # Crypto API ctypes bindings diff --git a/keyrings/alt/file.py b/keyrings/alt/file.py index 8d0bfed..bcce681 100644 --- a/keyrings/alt/file.py +++ b/keyrings/alt/file.py @@ -14,7 +14,7 @@ class PlaintextKeyring(Keyring): """Simple File Keyring with no encryption""" - priority = 0.5 # type: ignore + priority = 0.5 # type: ignore[assignment] # jaraco.classes.properties.classproperty isn't seen as a property "Applicable for all platforms, but not recommended" filename = 'keyring_pass.cfg' diff --git a/mypy.ini b/mypy.ini index 2241eb9..5e1fe12 100644 --- a/mypy.ini +++ b/mypy.ini @@ -13,6 +13,15 @@ explicit_package_bases = True # Disable overload-overlap due to many false-positives disable_error_code = overload-overlap -# workaround for realpython/pytest-mypy#160 -[mypy-keyrings.alt._win_crypto] -ignore_errors = True +# gdata is archived since 2022, last update in 2016 +# it installs but doesn't import on Python 3 +# https://github.com/google/gdata-python-client/issues/29 +# https://github.com/google/gdata-python-client/issues/65 +[mypy-gdata.*] +ignore_missing_imports = True + +# Keyczar is deprecated in favor of Tink as of 2019. Archived since 2022. +# python-keyczar also doesn't install on Python 3 +# https://github.com/google/keyczar/issues/125 +[mypy-keyczar.*] +ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index 3deb4b4..c1beb68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,9 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "keyrings.alt" -authors = [ - { name = "Jason R. Coombs", email = "jaraco@jaraco.com" }, -] +authors = [{ name = "Jason R. Coombs", email = "jaraco@jaraco.com" }] description = "Alternate keyring implementations" readme = "README.rst" classifiers = [ @@ -17,10 +15,7 @@ classifiers = [ "Programming Language :: Python :: 3 :: Only", ] requires-python = ">=3.8" -dependencies = [ - "jaraco.classes", - "jaraco.context", -] +dependencies = ["jaraco.classes", "jaraco.context"] dynamic = ["version"] [project.urls] @@ -35,11 +30,14 @@ test = [ "keyring >= 20", "pycryptodomex", "pycryptodome", - # gdata doesn't currently install on Python 3 - # http://code.google.com/p/gdata-python-client/issues/detail?id=229 + # gdata is archived since 2022, last update in 2016 + # it installs but doesn't import on Python 3 + # https://github.com/google/gdata-python-client/issues/29 + # https://github.com/google/gdata-python-client/issues/65 'gdata; python_version=="2.7"', - # keyczar doesn't currently install on Python 3. - # http://code.google.com/p/keyczar/issues/detail?id=125 + # Keyczar is deprecated in favor of Tink as of 2019. Archived since 2022. + # python-keyczar also doesn't install on Python 3 + # https://github.com/google/keyczar/issues/125 'python-keyczar; python_version=="2.7"', ] @@ -57,24 +55,18 @@ doc = [ # local ] -check = [ - "pytest-checkdocs >= 2.4", - "pytest-ruff >= 0.2.1; sys_platform != 'cygwin'", -] +check = ["pytest-checkdocs >= 2.4", "pytest-ruff >= 0.2.1; sys_platform != 'cygwin'"] -cover = [ - "pytest-cov", -] +cover = ["pytest-cov"] -enabler = [ - "pytest-enabler >= 2.2", -] +enabler = ["pytest-enabler >= 2.2"] type = [ # upstream "pytest-mypy", # local + "PyGObject-stubs", ] @@ -88,7 +80,3 @@ multi = "keyrings.alt.multi" [tool.setuptools_scm] - - -[tool.pytest-enabler.mypy] -# Disabled due to jaraco/skeleton#143 diff --git a/tests/test_multi.py b/tests/test_multi.py index 3cf978b..f21d490 100644 --- a/tests/test_multi.py +++ b/tests/test_multi.py @@ -10,7 +10,7 @@ class MultipartKeyringWrapperTestCase(unittest.TestCase): """Test the wrapper that breaks passwords into smaller chunks""" class MockKeyring(KeyringBackend): - priority = 1 # type: ignore + priority = 1 # type: ignore[assignment] # jaraco.classes.properties.classproperty isn't seen as a property def __init__(self): self.passwords = {}