Skip to content

Commit

Permalink
Merge pull request #2273 from ytausch/small-fixes
Browse files Browse the repository at this point in the history
Small Fixes
  • Loading branch information
beckermr authored Mar 18, 2024
2 parents bdc3ec2 + 7f1ad3c commit e3c3745
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
6 changes: 3 additions & 3 deletions conda_forge_tick/auto_tick.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ def add_rebuild_migration_yaml(
excluded_feedstocks: MutableSet[str],
exclude_pinned_pkgs: bool,
migration_yaml: str,
config: dict = {},
migration_name: str = "",
config: dict,
migration_name: str,
pr_limit: int = PR_LIMIT,
max_solver_attempts: int = 3,
) -> None:
Expand Down Expand Up @@ -689,9 +689,9 @@ def add_rebuild_migration_yaml(
cycles = list(nx.simple_cycles(total_graph))
migrator = MigrationYaml(
migration_yaml,
name=migration_name,
graph=total_graph,
pr_limit=pr_limit,
name=migration_name,
top_level=top_level,
cycles=cycles,
piggy_back_migrations=piggy_back_migrations,
Expand Down
17 changes: 7 additions & 10 deletions conda_forge_tick/git_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for managing github repos"""

import copy
import datetime
import os
Expand Down Expand Up @@ -365,7 +366,7 @@ def delete_branch(ctx: GithubContext, pr_json: LazyJson, dry_run: bool = False)
pr_json["head"]["ref"] = "this_is_not_a_branch"


def trim_pr_josn_keys(
def trim_pr_json_keys(
pr_json: Union[Dict, LazyJson],
src_pr_json: Optional[Union[Dict, LazyJson]] = None,
) -> Union[Dict, LazyJson]:
Expand All @@ -386,6 +387,7 @@ def trim_pr_josn_keys(
A dict-like object with the current PR information trimmed to the subset of
keys.
"""

# keep a subset of keys
def _munge_dict(dest, src, keys):
for k, v in keys.items():
Expand All @@ -405,10 +407,7 @@ def _munge_dict(dest, src, keys):


def lazy_update_pr_json(
pr_json: Union[Dict, LazyJson],
ctx: GithubContext,
force: bool = False,
trim: bool = True,
pr_json: Union[Dict, LazyJson], ctx: GithubContext, force: bool = False
) -> Union[Dict, LazyJson]:
"""Lazily update a GitHub PR.
Expand Down Expand Up @@ -464,13 +463,11 @@ def lazy_update_pr_json(
)

if r.status_code == 200:
if trim:
pr_json = trim_pr_josn_keys(pr_json, src_pr_json=r.json())
pr_json = trim_pr_json_keys(pr_json, src_pr_json=r.json())
pr_json["ETag"] = r.headers["ETag"]
pr_json["Last-Modified"] = r.headers["Last-Modified"]
else:
if trim:
pr_json = trim_pr_josn_keys(pr_json)
pr_json = trim_pr_json_keys(pr_json)

return pr_json

Expand Down Expand Up @@ -662,7 +659,7 @@ def push_repo(
# Return a json object so we can remake the PR if needed
pr_dict: dict = pr.as_dict()

return trim_pr_josn_keys(pr_dict)
return trim_pr_json_keys(pr_dict)


def comment_on_pr(pr_json, comment, repo):
Expand Down
4 changes: 2 additions & 2 deletions conda_forge_tick/migrators/migration_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class MigrationYaml(GraphMigrator):
def __init__(
self,
yaml_contents: str,
name: str,
graph: nx.DiGraph = None,
name: Optional[str] = None,
pr_limit: int = 50,
top_level: Set["PackageName"] = None,
cycles: Optional[Sequence["PackageName"]] = None,
Expand All @@ -147,7 +147,7 @@ def __init__(
)
self.yaml_contents = yaml_contents
assert isinstance(name, str)
self.name: str = name
self.name = name
self.top_level = top_level or set()
self.cycles = set(chain.from_iterable(cycles or []))
self.automerge = automerge
Expand Down
6 changes: 3 additions & 3 deletions tests/test_git_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from conda_forge_tick.git_utils import trim_pr_josn_keys
from conda_forge_tick.git_utils import trim_pr_json_keys


def test_trim_pr_json_keys():
Expand All @@ -12,7 +12,7 @@ def test_trim_pr_json_keys():
"base": {"repo": {"namee": "None", "name": "foo"}},
}

pr_json = trim_pr_josn_keys(pr_json)
pr_json = trim_pr_json_keys(pr_json)
assert "random" not in pr_json
assert pr_json["head"] == {}
assert pr_json["base"]["repo"] == {"name": "foo"}
Expand All @@ -30,7 +30,7 @@ def test_trim_pr_json_keys_src():
"base": {"repo": {"namee": "None", "name": "foo"}},
}

pr_json = trim_pr_josn_keys({"r": None}, src_pr_json=src_pr_json)
pr_json = trim_pr_json_keys({"r": None}, src_pr_json=src_pr_json)
assert "random" not in pr_json
assert pr_json["head"] == {}
assert pr_json["base"]["repo"] == {"name": "foo"}
Expand Down

0 comments on commit e3c3745

Please sign in to comment.