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

Import serialization early to break cyclic import #5795

Closed
wants to merge 1 commit into from

Conversation

tiran
Copy link
Contributor

@tiran tiran commented Feb 9, 2021

Fixes: #5794
Signed-off-by: Christian Heimes cheimes@redhat.com

Fixes: pyca#5794
Signed-off-by: Christian Heimes <cheimes@redhat.com>
@tiran
Copy link
Contributor Author

tiran commented Feb 9, 2021

Meh, import cycles from hell!

 ImportError while loading conftest '/home/runner/work/cryptography/cryptography/tests/conftest.py'.
tests/conftest.py:8: in <module>
    from cryptography.hazmat.backends.openssl import backend as openssl_backend
.tox/py39/lib/python3.9/site-packages/cryptography/hazmat/backends/openssl/__init__.py:6: in <module>
    from cryptography.hazmat.backends.openssl.backend import backend
.tox/py39/lib/python3.9/site-packages/cryptography/hazmat/backends/openssl/backend.py:12: in <module>
    from cryptography import utils, x509
.tox/py39/lib/python3.9/site-packages/cryptography/x509/__init__.py:7: in <module>
    from cryptography.x509.base import (
.tox/py39/lib/python3.9/site-packages/cryptography/x509/base.py:12: in <module>
    from cryptography.hazmat._types import _PRIVATE_KEY_TYPES, _PUBLIC_KEY_TYPES
.tox/py39/lib/python3.9/site-packages/cryptography/hazmat/_types.py:7: in <module>
    from cryptography.hazmat.primitives.asymmetric import (
.tox/py39/lib/python3.9/site-packages/cryptography/hazmat/primitives/__init__.py:6: in <module>
    from . import serialization
.tox/py39/lib/python3.9/site-packages/cryptography/hazmat/primitives/serialization/__init__.py:15: in <module>
    from cryptography.hazmat.primitives.serialization.base import (
.tox/py39/lib/python3.9/site-packages/cryptography/hazmat/primitives/serialization/base.py:8: in <module>
    from cryptography.hazmat._types import (
E   ImportError: cannot import name '_PRIVATE_KEY_TYPES' from partially initialized module 'cryptography.hazmat._types' (most likely due to a circular import) (/home/runner/work/cryptography/cryptography/.tox/py39/lib/python3.9/site-packages/cryptography/hazmat/_types.py)
ERROR: InvocationError for command /home/runner/work/cryptography/cryptography/.tox/py39/bin/pytest -n auto --cov=cryptography --cov=tests --capture=no --strict --durations=10 --color=yes --wycheproof-root=wycheproof (exited with code 4)

alex added a commit to alex/cryptography that referenced this pull request Feb 9, 2021
@tiran tiran closed this Feb 9, 2021
reaperhulk pushed a commit that referenced this pull request Feb 9, 2021
alex added a commit to alex/cryptography that referenced this pull request Feb 9, 2021
reaperhulk added a commit that referenced this pull request Feb 9, 2021
* fixed a circular import error (due to type hints) (#5800)

fixes #5794
closes #5795

* Added a py.typed so mypy prefers us to typeshed (#5802)

closes #5796

* 3.4.4 changelog + version bump

* Update CHANGELOG.rst

Co-authored-by: Paul Kehrer <paul.l.kehrer@gmail.com>

Co-authored-by: Paul Kehrer <paul.l.kehrer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Circular import error (again) in 3.4.3
1 participant