Skip to content

Error in 'cz changelog' ('commitizen.defaults' has no attribute 'commit_parser') #1046

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

Closed
KyleKing opened this issue Apr 1, 2024 · 1 comment

Comments

@KyleKing
Copy link
Contributor

KyleKing commented Apr 1, 2024

Description

In the most recent release, removing defaults.commit_parser appears to be causing issues with cz changelog (v3.21.2...v3.21.3):

Error with v3.21.3

~/ > poetry lock --no-update && poetry install --sync
Writing lock file
Installing dependencies from lock file

Package operations: 0 installs, 1 update, 0 removals

  - Updating commitizen (3.21.2 -> 3.21.3)

~/ > poetry run cz changelog                                       
Traceback (most recent call last):
  File "/.venv/bin/cz", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/.venv/lib/python3.12/site-packages/commitizen/cli.py", line 594, in main
    args.func(conf, arguments)()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.12/site-packages/commitizen/commands/changelog.py", line 36, in __init__
    self.cz = factory.commiter_factory(self.config)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.12/site-packages/commitizen/factory.py", line 11, in commiter_factory
    _cz = registry[name](config)
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.12/site-packages/cz_legacy/cz_legacy.py", line 42, in __init__
    self.commit_parser = defaults.commit_parser.replace('<change_type>', f'<change_type>{joined_types}|')
                         ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'commitizen.defaults' has no attribute 'commit_parser'

Works with v3.20.0 and v3.21.2

~/ > poetry lock --no-update && poetry install --sync
Writing lock file
Installing dependencies from lock file

Package operations: 0 installs, 1 update, 0 removals

  - Downgrading commitizen (3.21.3 -> 3.20.0)

~/ > poetry run cz changelog
~/ > poetry lock --no-update && poetry install --sync
Writing lock file
Installing dependencies from lock file

Package operations: 0 installs, 1 update, 0 removals

    - Updating commitizen (3.20.0 -> 3.21.2)

~/ > poetry run cz changelog                            
# No Issues with 3.21.2

Config

For reference, I was running cz against a minimal pyproject.toml config:

https://github.com/KyleKing/recipes/blob/942400f22ef63295fa209daaa9d7d2aeabf49851/pyproject.toml#L5C1-L23

Which turned out to be the problem! I'll make a fix to cz-legacy to use ConventionalCommitsCz from commitizen.cz.conventional_commits.conventional_commits

@KyleKing
Copy link
Contributor Author

KyleKing commented Apr 1, 2024

Closing, this is actually a problem with (my) cz-legacy: KyleKing/cz_legacy#15

@KyleKing KyleKing closed this as completed Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant