-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fix] Renaming or removing a contracted model raises a BreakingChange warning/error #10221
Changes from 3 commits
c59aced
7414955
326a887
0ebff00
e10efff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Renaming or removing a contracted model should raise a BreakingChange warning/error | ||
time: 2024-05-23T20:42:51.033946-04:00 | ||
custom: | ||
Author: michelleark | ||
Issue: "10116" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -719,7 +719,9 @@ def check_modified_contract( | |
) -> Callable[[Optional[SelectorTarget], SelectorTarget], bool]: | ||
# get a function that compares two selector target based on compare method provided | ||
def check_modified_contract(old: Optional[SelectorTarget], new: SelectorTarget) -> bool: | ||
if hasattr(new, compare_method): | ||
if new is None and hasattr(old, compare_method + "_deleted"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't say I'm in love with this but it was the best way forward I could think of that:
open to other suggestions! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's good to keep the diff method localized to the node type. It's kind of a bit hacky, but I can't think of a better way. |
||
return getattr(old, compare_method + "_deleted")() | ||
elif hasattr(new, compare_method): | ||
# when old body does not exist or old and new are not the same | ||
return not old or not getattr(new, compare_method)(old, adapter_type) # type: ignore | ||
else: | ||
|
@@ -785,6 +787,16 @@ def search(self, included_nodes: Set[UniqueId], selector: str) -> Iterator[Uniqu | |
if checker(previous_node, node, **keyword_args): # type: ignore | ||
yield unique_id | ||
|
||
# checkers that can handle deleted nodes | ||
if checker.__name__ in ["check_modified_contract"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could look to implement a new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ m8 |
||
# ignore included_nodes, since those cannot contain deleted nodes | ||
for previous_unique_id, previous_node in manifest.nodes.items(): | ||
# detect deleted or renamed node | ||
if previous_unique_id not in self.manifest.nodes.keys(): | ||
# do not yield -- deleted nodes should never be selected for downstream execution | ||
# as they are not part of the current project's manifest | ||
checker(previous_node, None, **keyword_args) # type: ignore | ||
|
||
|
||
class ResultSelectorMethod(SelectorMethod): | ||
def search(self, included_nodes: Set[UniqueId], selector: str) -> Iterator[UniqueId]: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "past", not "passed"