Description
Description
As it can be seen in the following line, all files present in the Python environment whose filename begins with cz_
will be discovered and iteratively loaded by commitizen
. Unfortunately this also includes files that aren't in the scope of commitizen but happen to be in PYTHONPATH
:
commitizen/commitizen/cz/__init__.py
Line 18 in 14b6c38
The reaction is very cryptic and can lead to long and frustrating debugging sessions. Fortunately it is known that the "cannot import" message is linked to circular dependencies, e.g. see https://stackoverflow.com/a/746655
Just importing commitizen
doesn't break, but further recursive imports down the package trigger the issue.
Steps to reproduce
- Create a file starting with
cz_...
and call e.g.from commitizen.commands.bump import Bump
- Run that file with the python interpreter, making sure that the file's directory is in
sys.path
- The import will trigger an
ImportError
that is internal to commitizen like the one in the title.
Current behavior
Code that runs from interactive CLI doesn't run from script
Desired behavior
Code that runs on CLI should also run on script.
Environment
python --version Python 3.6.12 :: Anaconda, Inc.
python3 -c "import platform; print(platform.system())"
- commitizen version: 2.4.2
- python version: 3.6
- operating system: Ubuntu