commitizen-tools / commitizen

Create committing rules for projects :rocket: auto bump versions :arrow_up: and auto changelog generation :open_file_folder:
https://commitizen-tools.github.io/commitizen/
MIT License
2.56k stars 266 forks source link

clear way to manage settings #425

Closed Lee-W closed 1 year ago

Lee-W commented 3 years ago

Description

currently, we use dict to dynamically manage our settings/configurations which makes it a bit hard to maintain if any new settings are to introduce

Possible Solution

  1. list all the available settings and use typedict

    Additional context

Related Issue

Lee-W commented 3 years ago

This also relates to https://github.com/commitizen-tools/commitizen/issues/153 as most of the untyped parts are from configurations.

Also, https://github.com/commitizen-tools/commitizen/issues/300

woile commented 3 years ago

I'd avoid introducing more dependencies if possible and potentially use dataclasses instead. Or typeddict.

I'm wondering also, would it be possible to easily add new settings when creating a custom commitizen?

Lee-W commented 3 years ago

I'd avoid introducing more dependencies if possible and potentially use dataclasses instead. Or typeddict.

Let's try TypeDict first then. It would be easier than using dataclasses. we can migrate to dataclass if we find it more maintainable.

I'm wondering also, would it be possible to easily add new settings when creating a custom commitizen?

not sure, but that's part of the goal of this refactor as well

josix commented 3 years ago

I would take this issue in the sprint of PyConTW'21.

Lee-W commented 3 years ago

Hi @josix , I'm actually working on it. Which part do you want to start from? Maybe we could split our effort.

josix commented 3 years ago

I would like to use TypedDict to define the available fields for JSON, YAML, TOML config first.

Lee-W commented 3 years ago

Sure :) Then, I'll focus on other parts first. I'm thinking of creating another feature branch and merge it once we finish all the refactoring.

woile commented 1 year ago

Both of this are typedict now

CzSettings
Settings

closing as it looks like it was fixed.

Feel free to open again if I made a mistake

Lee-W commented 1 year ago

Yep, it looks better than it was. I think the next step is moving some conventional commit defaults out of the global default. But we could create another issue for that

woile commented 1 year ago

Sounds good