Title: ImportError: cannot import name 'BaseCommitizen' and others in files starting with `cz_` · Issue #287 · commitizen-tools/commitizen · GitHub
Open Graph Title: ImportError: cannot import name 'BaseCommitizen' and others in files starting with `cz_` · Issue #287 · commitizen-tools/commitizen
X Title: ImportError: cannot import name 'BaseCommitizen' and others in files starting with `cz_` · Issue #287 · commitizen-tools/commitizen
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 i...
Open Graph 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. Unfortunatel...
X 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. Unfortunatel...
Opengraph URL: https://github.com/commitizen-tools/commitizen/issues/287
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ImportError: cannot import name 'BaseCommitizen' and others in files starting with `cz_`","articleBody":"## Description\r\n\r\nAs 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`:\r\n\r\nhttps://github.com/commitizen-tools/commitizen/blob/14b6c382ff96e37ba118ba1b75073b0d2313ee91/commitizen/cz/__init__.py#L18\r\n\r\nThe 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\r\n\r\nJust importing `commitizen` doesn't break, but further recursive imports down the package trigger the issue.\r\n\r\n## Steps to reproduce\r\n1. Create a file starting with `cz_...` and call e.g. ` from commitizen.commands.bump import Bump`\r\n2. Run that file with the python interpreter, making sure that the file's directory is in `sys.path`\r\n3. The import will trigger an `ImportError` that is **internal to commitizen** like the one in the title. \r\n\r\n## Current behavior\r\nCode that runs from interactive CLI doesn't run from script\r\n\r\n## Desired behavior\r\nCode that runs on CLI should also run on script.\r\n\r\n## Environment\r\n\r\npython --version Python 3.6.12 :: Anaconda, Inc.\r\npython3 -c \"import platform; print(platform.system())\"\r\n\r\n\r\n- commitizen version: 2.4.2\r\n- python version: 3.6\r\n- operating system: Ubuntu\r\n","author":{"url":"https://github.com/andres-fr","@type":"Person","name":"andres-fr"},"datePublished":"2020-10-27T02:19:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":14},"url":"https://github.com/287/commitizen/issues/287"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e9271597-53f8-110f-d879-16e7f3e31d67 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8BF8:35A2B4:1029BA6:16E4AC9:6978D2CC |
| html-safe-nonce | 5ee950e1562dddebeaf1f31523bd7fba41f1685d9a0c6677d7ef98971a6318b5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkY4OjM1QTJCNDoxMDI5QkE2OjE2RTRBQzk6Njk3OEQyQ0MiLCJ2aXNpdG9yX2lkIjoiNzUwNDk5NDY2OTA0MjM4OTcwOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 33e8e15e66f9f6ba792b6bca40f856152edd83a2aa002b3629f2315d61cfca82 |
| hovercard-subject-tag | issue:730043222 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/commitizen-tools/commitizen/287/issue_layout |
| twitter:image | https://opengraph.githubassets.com/59fc6935496e6665f8f5cdb81952e2b0a5e2a3774c8a25cad0776c15b37fb39e/commitizen-tools/commitizen/issues/287 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/59fc6935496e6665f8f5cdb81952e2b0a5e2a3774c8a25cad0776c15b37fb39e/commitizen-tools/commitizen/issues/287 |
| og:image:alt | 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. Unfortunatel... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | andres-fr |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8a71ca1f7ab5436216e1df86f398ef7a51ed3152c90e3f7332fc70cf97fcb9d6 |
| turbo-cache-control | no-preview |
| go-import | github.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git |
| octolytics-dimension-user_id | 62252524 |
| octolytics-dimension-user_login | commitizen-tools |
| octolytics-dimension-repository_id | 106127589 |
| octolytics-dimension-repository_nwo | commitizen-tools/commitizen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 106127589 |
| octolytics-dimension-repository_network_root_nwo | commitizen-tools/commitizen |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | eaed570eead52a9920afef75dc3eb6d826fdc5ef |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width