-
Notifications
You must be signed in to change notification settings - Fork 76
/
version_pr_info.py
47 lines (36 loc) · 1.55 KB
/
version_pr_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from typing import Literal
from pydantic import TypeAdapter, model_validator
from conda_forge_tick.models.common import NoneIsEmptyDict, StrictBaseModel
class VersionPrInfo(StrictBaseModel):
bad: str | Literal[False] = False
"""
If this value is non-False, the string indicates the error.
"""
new_version: str | Literal[False] = False
"""
The latest version found by update_upstream_versions, which is copied from `versions` in the beginning of the
auto_tick run.
"""
new_version_attempts: NoneIsEmptyDict[str, int | float] = {}
"""
Mapping (version -> number of attempts) to describe the number of attempts that were made to update the versions in
the PR. The value can be a float since failing with a solving error is counted as a partial attempt, which only
increases the count by a fraction that is specified in auto_tick.run (03/2024: 0.2).
"""
new_version_errors: NoneIsEmptyDict[str, str] = {}
"""
Mapping (version -> error message) to describe the errors that occurred when trying to update the versions in the
PR.
"""
@model_validator(mode="after")
def check_new_version_error_keys(self):
wrong_versions = [
version
for version in self.new_version_errors
if version not in self.new_version_attempts
]
if wrong_versions:
raise ValueError(
f"new_version_errors contains at least one version not in new_version_attempts: {wrong_versions}"
)
VersionPrInfo = TypeAdapter(VersionPrInfo)