Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass mypy, update test requirements and more detailed comments #56

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion keyrings/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
4 changes: 3 additions & 1 deletion keyrings/alt/Gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 15 additions & 7 deletions keyrings/alt/_win_crypto.py
Original file line number Diff line number Diff line change
@@ -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
)

# python/mypy#8166
# python/typing#1732
# python/mypy#9025
assert sys.platform == "win32"

from ctypes import ( # noqa: E402
POINTER,
WINFUNCTYPE,
Structure,
Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion keyrings/alt/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
15 changes: 12 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 13 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "keyrings.alt"
authors = [
{ name = "Jason R. Coombs", email = "[email protected]" },
]
authors = [{ name = "Jason R. Coombs", email = "[email protected]" }]
description = "Alternate keyring implementations"
readme = "README.rst"
classifiers = [
Expand All @@ -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]
Expand All @@ -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"',
]

Expand All @@ -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",
]


Expand All @@ -88,7 +80,3 @@ multi = "keyrings.alt.multi"


[tool.setuptools_scm]


[tool.pytest-enabler.mypy]
# Disabled due to jaraco/skeleton#143
2 changes: 1 addition & 1 deletion tests/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
Loading