-
Notifications
You must be signed in to change notification settings - Fork 35
schemaview.py: allow detect_cycles to receive a list of nodes as args
#476
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
Conversation
| :raises ValueError: if a cycle is discovered through repeated calls to f(node) | ||
| """ | ||
| # ensure we have some nodes to start the analysis | ||
| if not node_list or not isinstance(node_list, Iterable) or isinstance(node_list, str): |
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.
make sure that the input is a non-empty iterable and that it isn't a string (which is an iterable, but probably not one that we need to detect cycles in!).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #476 +/- ##
==========================================
+ Coverage 78.08% 78.10% +0.01%
==========================================
Files 52 52
Lines 4508 4512 +4
Branches 982 983 +1
==========================================
+ Hits 3520 3524 +4
Misses 769 769
Partials 219 219 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| """ | ||
| if kwargs and kwargs.get("detect_cycles"): | ||
| detect_cycles(f, x) | ||
| detect_cycles(f, [x]) |
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.
currently this is the only place in the code where detect_cycles is called directly
| """Test detection of cycles in the types segment of the cycles schema.""" | ||
| if fn == "detect_cycles": | ||
| with pytest.raises(ValueError, match=f"Cycle detected at node '{cycle_start_node}'"): | ||
| detect_cycles(lambda x: sv_cycles_schema.type_parents(x), target) |
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.
don't need these lambdas - can just supply the function
amc-corey-cox
left a comment
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.
This looks good to me.
This is a minor edit to allow
detect_cyclesto take a list of nodes as input instead of restricting it to a single node.