Skip to content

Commit 148babc

Browse files
committed
build: use pydantic >=1.10
1 parent c9b2ba7 commit 148babc

File tree

8 files changed

+10
-18
lines changed

8 files changed

+10
-18
lines changed

commitizen/commands/commit.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ def prompt_commit_questions(self) -> str:
5656
for question in (q for q in questions if isinstance(q, ListQuestion)):
5757
question.use_shortcuts = self.config.settings["use_shortcuts"]
5858
try:
59-
answers = questionary.prompt(
60-
(q.model_dump() for q in questions), style=cz.style
61-
)
59+
answers = questionary.prompt((q.dict() for q in questions), style=cz.style)
6260
except ValueError as err:
6361
root_err = err.__context__
6462
if isinstance(root_err, CzException):

commitizen/cz/conventional_commits/conventional_commits.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ def questions(self) -> list[CzQuestion]:
146146
),
147147
},
148148
]
149-
return [
150-
CzQuestionModel.model_validate({"question": q}).question for q in questions
151-
]
149+
return [CzQuestionModel.parse_obj({"question": q}).question for q in questions]
152150

153151
def message(self, answers: dict) -> str:
154152
prefix = answers["prefix"]

commitizen/cz/customize/customize.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ def __init__(self, config: BaseConfig):
4848

4949
def questions(self) -> list[CzQuestion]:
5050
questions = self.custom_settings.get("questions", [{}])
51-
return [
52-
CzQuestionModel.model_validate({"question": q}).question for q in questions
53-
]
51+
return [CzQuestionModel.parse_obj({"question": q}).question for q in questions]
5452

5553
def message(self, answers: dict) -> str:
5654
message_template = Template(self.custom_settings.get("message_template", ""))

commitizen/cz/jira/jira.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ def questions(self) -> list[CzQuestion]:
4242
"filter": lambda x: "#comment " + x if x else "",
4343
},
4444
]
45-
return [
46-
CzQuestionModel.model_validate({"question": q}).question for q in questions
47-
]
45+
return [CzQuestionModel.parse_obj({"question": q}).question for q in questions]
4846

4947
def message(self, answers: dict) -> str:
5048
return " ".join(

commitizen/question.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55

66
class CzModel(BaseModel):
7-
def model_dump(self, **kwargs):
8-
return super().model_dump(exclude_unset=True, **kwargs)
7+
def dict(self, **kwargs):
8+
return super().dict(**{"exclude_unset": True, **kwargs})
99

1010

1111
class Choice(CzModel):

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies = [
2525
# Use the Python 3.11 and 3.12 compatible API: https://github.com/python/importlib_metadata#compatibility
2626
"importlib-metadata >=8.0.0,!=8.7.0,<9.0.0 ; python_version == '3.9'", # [email protected] + python3.9 breaks our unit test
2727
"importlib-metadata >=8.0.0,<9.0.0 ; python_version != '3.9'",
28-
"pydantic (>=2.11.5,<3.0.0)",
28+
"pydantic (>=1.10,<3.0.0)",
2929
]
3030
keywords = ["commitizen", "conventional", "commits", "git"]
3131
# See also: https://pypi.org/classifiers/

tests/test_cz_customize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def test_questions(config):
443443
"message": "Do you want to add body message in commit?",
444444
},
445445
]
446-
assert [q.model_dump() for q in questions] == expected_questions
446+
assert [q.dict() for q in questions] == expected_questions
447447

448448

449449
def test_questions_unicode(config_with_unicode):
@@ -466,7 +466,7 @@ def test_questions_unicode(config_with_unicode):
466466
"message": "Do you want to add body message in commit?",
467467
},
468468
]
469-
assert [q.model_dump() for q in questions] == expected_questions
469+
assert [q.dict() for q in questions] == expected_questions
470470

471471

472472
def test_answer(config):

0 commit comments

Comments
 (0)