diff --git a/pyproject.toml b/pyproject.toml index 1a45df95..bdf4e6f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,14 +13,11 @@ source = [ ] [tool.coverage.report] -exclude_also = [ - "assert False", -] +exclude_also = ["assert False"] show_missing = true [tool.mypy] warn_unused_configs = true -follow_imports = "skip" strict = true [[tool.mypy.overrides]] diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py index 3119c4f0..e7ae772c 100644 --- a/src/OpenSSL/crypto.py +++ b/src/OpenSSL/crypto.py @@ -264,10 +264,10 @@ def to_cryptography_key(self) -> _Key: if self._only_public: der = dump_publickey(FILETYPE_ASN1, self) - return load_der_public_key(der) + return typing.cast(_Key, load_der_public_key(der)) else: der = dump_privatekey(FILETYPE_ASN1, self) - return load_der_private_key(der, None) + return typing.cast(_Key, load_der_private_key(der, password=None)) @classmethod def from_cryptography_key(cls, crypto_key: _Key) -> PKey: diff --git a/tests/conftest.py b/tests/conftest.py index 73ab7a68..26711da7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,13 +7,14 @@ import pytest -def pytest_report_header(config): +def pytest_report_header(config: pytest.Config) -> str: import cryptography import OpenSSL.SSL return ( - f"OpenSSL: {OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION)}\n" + f"OpenSSL: " + f"{OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION)!r}\n" f"cryptography: {cryptography.__version__}" ) diff --git a/tox.ini b/tox.ini index 87842ff8..62b7ddfa 100644 --- a/tox.ini +++ b/tox.ini @@ -42,11 +42,12 @@ commands = ruff format --check . [testenv:py311-mypy] +extras = + test deps = mypy -skip_install = true commands = - mypy src + mypy src/ tests/conftest.py [testenv:check-manifest] deps =