Skip to content

Circular import issue: ImportError: cannot import name 'product' from partially initialized module 'mindee' #279

@JakobGM

Description

@JakobGM

Prerequisites

Put an X between the brackets on this line if you have done all of the following:

  • Reproduced the problem or exposed a new need
  • Checked the GitHub existing issues

Description

Version 4.14.1 of mindee introduces a circular import issue.

Steps to Reproduce

mkdir /tmp/test
cd /tmp/test
python -m venv .venv
source .venv/bin/activate
python -m pip install 'mindee==4.14.1'
python -c 'import mindee'

Expected behavior:

A successful import of the mindee package.

Actual behavior:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/test/.venv/lib/python3.12/site-packages/mindee/__init__.py", line 1, in <module>
    from mindee import product
ImportError: cannot import name 'product' from partially initialized module 'mindee' (most likely due to a circular import) (/tmp/test/.venv/lib/python3.12/site-packages/mindee/__init__.py)

Reproduces how often:

100%.

Versions

Python 3.12 on Linux.

mindee==4.14.1

Additional Information

We have introduced a caching layer on-top of Mindee in order to reduce duplicate parsings based on checksuming. Up until this point, this was done by mocking out the requests package in mindee.mindee_http.endpoint like this...

def inject_mindee_caching_layer() -> None:
    from mindee.mindee_http import endpoint

    endpoint.requests = MockedRequests

The new structure of the root __init__.py in the mindee package disallows access to this module. I will look into a work-around for this, but I just wanted to mention it here as well until I wait for the circular import issue to be resolved.

Thanks in advance, and have a nice weekend!

  • Jakob

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions