Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ytausch committed Jun 26, 2024
1 parent b183dab commit fc33822
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions conda_forge_tick/auto_tick.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
from conda.models.version import VersionOrder

from conda_forge_tick.cli_context import CliContext
from conda_forge_tick.deploy import deploy
from conda_forge_tick.contexts import (
ClonedFeedstockContext,
FeedstockContext,
MigratorSessionContext,
)
from conda_forge_tick.deploy import deploy
from conda_forge_tick.feedstock_parser import BOOTSTRAP_MAPPINGS
from conda_forge_tick.git_utils import (
DryRunBackend,
Expand Down Expand Up @@ -620,7 +620,7 @@ def run(
os.path.join("pr_json", f"{pr_data.id}.json"),
)
with pr_lazy_json as __edit_pr_lazy_json:
__edit_pr_lazy_json.update(**pr_data.model_dump())
__edit_pr_lazy_json.update(**pr_data.model_dump(mode="json"))
else:
pr_lazy_json = False

Expand Down
5 changes: 3 additions & 2 deletions conda_forge_tick/git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,12 +1037,13 @@ def create_pull_request(
Target Repository: {target_owner}/{target_repo}
Branches: {self.user}:{head_branch} -> {target_owner}:{base_branch}
Body:
{body}
==============================================================
"""
)
)

logger.debug(body)
logger.debug("==============================================================")

now = datetime.now()
return PullRequestData.model_validate(
{
Expand Down
24 changes: 9 additions & 15 deletions conda_forge_tick/models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
BeforeValidator,
ConfigDict,
Field,
PlainSerializer,
UrlConstraints,
)
from pydantic_core import Url
Expand Down Expand Up @@ -77,7 +78,7 @@ def none_to_empty_dict(value: T | None) -> T | dict[Never]:
return value


NoneIsEmptyDict = Annotated[dict[T], BeforeValidator(none_to_empty_dict)]
NoneIsEmptyDict = Annotated[dict[K, V], BeforeValidator(none_to_empty_dict)]
"""
A generic dict type that converts `None` to an empty dict.
This should not be needed if this proper data model is used in production.
Expand Down Expand Up @@ -151,22 +152,15 @@ def parse_rfc_2822_date(value: str) -> datetime:
return email.utils.parsedate_to_datetime(value)


RFC2822Date = Annotated[datetime, BeforeValidator(parse_rfc_2822_date)]


def none_to_empty_dict(value: T | None) -> T | dict[Never, Never]:
"""
Convert `None` to an empty dictionary f, otherwise keep the value as is.
"""
if value is None:
return {}
return value
def serialize_rfc_2822_date(value: datetime) -> str:
return email.utils.format_datetime(value)


NoneIsEmptyDict = Annotated[dict[K, V], BeforeValidator(none_to_empty_dict)]
"""
A generic dict type that converts `None` to an empty dict.
"""
RFC2822Date = Annotated[
datetime,
BeforeValidator(parse_rfc_2822_date),
PlainSerializer(serialize_rfc_2822_date),
]


GitUrl = Annotated[Url, UrlConstraints(allowed_schemes=["git"])]
Expand Down

0 comments on commit fc33822

Please sign in to comment.