Skip to content

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

Closed
@KyleKing

Description

@KyleKing

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions