commitizen icon indicating copy to clipboard operation
commitizen copied to clipboard

clear way to manage settings

Open Lee-W opened this issue 4 years ago • 7 comments

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 avatar Sep 25 '21 04:09 Lee-W

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

Lee-W avatar Sep 25 '21 04:09 Lee-W

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?

woile avatar Sep 25 '21 13:09 woile

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

Lee-W avatar Sep 25 '21 16:09 Lee-W

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

josix avatar Sep 26 '21 07:09 josix

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

Lee-W avatar Sep 26 '21 07:09 Lee-W

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

josix avatar Sep 28 '21 02:09 josix

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.

Lee-W avatar Sep 28 '21 02:09 Lee-W

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

woile avatar Apr 28 '23 13:04 woile

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

Lee-W avatar May 06 '23 10:05 Lee-W

Sounds good

woile avatar May 06 '23 12:05 woile