-
-
Notifications
You must be signed in to change notification settings - Fork 279
ImportError: cannot import name 'BaseCommitizen' and others in files starting with cz_
#287
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
Comments
I guess the main idea here is that a library shouldn't discover and load files from the python path by regex. That can be very tricky to find and could be even more problematic at other levels e.g. security. At the moment I'm kind of saturated and don't have any meaningful quickfix, apart from the obvious Don't ever name any Python file starting by |
Sorry if it's a big frustrating 😞 , the plugin system can be improved, but it's based on a simple version of flask extension system. There should be a way to avoid this kind of errors, I'm open to enhancements |
Thanks for your answer, I would have to analyze more the plugin system to propose something more specific. https://amir.rachum.com/blog/2017/07/28/python-entry-points/ |
I browse through the article you shared but not yet try it, but it looks like a good approach to me. Also, I just found how poetry can support similiar functionality. https://python-poetry.org/docs/pyproject/#plugins |
Interesting, I like it, seems quite intuitive. We'd have to update the template as well. Keep in mind, this would introduce a breaking change, but it's fine by me. |
If you guys are comfortable with that I could give a hand in the next few weeks (we could do a hackathon or something) and try to refactor the CLI/plugin section. Only changes that you approve of course. I'd love to play around with poetry, seems neat |
It sounds good to me. I just add a |
I'm in, great idea! Let's coordinate a date |
21 November 2020 I'll be joining to pycon argentina with a sprint for commitizen, hope you can join! |
Sounds good, I can't promise it but will mark the date 📝. In any case this sounds amazing for the project! Looking forward to what comes out of it |
Hi @andres-fr , https://github.com/commitizen-tools/commitizen/pull/480/files seems to solve this issue. Could you please check again? As this issue also proposed something worth enhancing, @woile do you think we should keep this one open or create a new one for tracking that stuff? |
I think we should create a new ticket, I still want to refactor the plugin system |
Hey, sorry for dropping the ball here. I'm happy to close this one if you think that is appropriate! |
Hi all, I've created a new issue for tracking this #495. Let's close this one |
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 bycommitizen
. Unfortunately this also includes files that aren't in the scope of commitizen but happen to be inPYTHONPATH
: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
cz_...
and call e.g.from commitizen.commands.bump import Bump
sys.path
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())"
The text was updated successfully, but these errors were encountered: