Skip to content

Commit

Permalink
Get far enough that conftest.py type checks (#1398)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex authored Jan 7, 2025
1 parent d3621f5 commit 1fdced6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSSL/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__}"
)

Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 1fdced6

Please sign in to comment.