diff --git a/.github/scripts/check_plugin_api.py b/.github/scripts/check_plugin_api.py index 962fbd91..c66d524c 100644 --- a/.github/scripts/check_plugin_api.py +++ b/.github/scripts/check_plugin_api.py @@ -419,8 +419,10 @@ def caller_breaks(path: str, old: griffe.Object, new: griffe.Object, reshaped: s else: found += [f"{path}.{name}: no longer in __all__" for name in sorted(set(before or ()) - set(after or ())) if name in new.members] - for breakage in griffe.find_breaking_changes(old, new): - if _benign(breakage, old, new) or breakage.obj.path in reshaped: + scope = (old.parent, new.parent) if old.is_function else (old, new) + for breakage in griffe.find_breaking_changes(*scope): + if (old.is_function and breakage.obj.path != old.path) or _benign(breakage, old, new) \ + or breakage.obj.path in reshaped: continue found.append(_describe(breakage, public)) return found diff --git a/tst/unit/test_check_plugin_api.py b/tst/unit/test_check_plugin_api.py index 84fc4c5b..e0aad0e7 100644 --- a/tst/unit/test_check_plugin_api.py +++ b/tst/unit/test_check_plugin_api.py @@ -116,6 +116,14 @@ def settings(package, config=None): "internal.py": ''' def compute(x): return x +''', + "runner/store.py": ''' +def count_runs(task_id=None): + return 0 + + +def prune_runs(days=30): + return 0 ''', } @@ -188,11 +196,13 @@ def _check(tmp_path: Path, edits: list[tuple[str, str, str]], title: str | None "agent_env.plugins.ENVS: Attribute value was changed"), ([(ARTIFACT, "Field(default=0,", "Field(default=1,")], "agent_env.artifact.artifact.Artifact.version: Attribute value was changed"), + ([("runner/store.py", "def count_runs(task_id=None):", "def count_runs(task_id):")], + "agent_env.runner.store.count_runs(task_id): Parameter is now required"), ], ids=["method-removed", "parameter-renamed", "required-parameter-added", "default-changed", "class-attribute-changed", "base-removed", "abstract-method-added", "method-became-abstract", "method-became-required", "hook-parameter-added", "async-to-sync", "classmethod-to-staticmethod", "required-private-method-changed", "dataclass-field-removed", "dropped-from-all", "export-removed", "settings-signature-changed", - "group-name-changed", "field-default-changed"]) + "group-name-changed", "field-default-changed", "used-function-signature-changed"]) def test_reports_a_break(tmp_path, edits, reported): result = _check(tmp_path, edits) @@ -213,9 +223,10 @@ def test_reports_a_break(tmp_path, edits, reported): [(CONTEXT, " agent_model: str | None = None\n", " agent_harness: str | None = None\n agent_model: str | None = None\n")], [(ARTIFACT, 'Field(description="Unique id")', 'Field(description="The artifact\'s id")')], + [("runner/store.py", "def prune_runs(days=30):", "def prune_runs(days):")], ], ids=["docstring", "new-optional-method", "private-rename", "internal-module", "parameter-swallowed-by-kwargs", "annotation-gains-a-value", "instance-attribute-expression", "default-to-equal-literal", - "dataclass-field-inserted", "field-description"]) + "dataclass-field-inserted", "field-description", "unused-sibling-of-a-used-function"]) def test_passes_a_compatible_change(tmp_path, edits): result = _check(tmp_path, edits)