-
Notifications
You must be signed in to change notification settings - Fork 9
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
otk: detect circular imports #127
Conversation
@@ -65,7 +65,6 @@ def resolve_dict(ctx: Context, state: State, tree: dict[str, Any]) -> Any: | |||
if isinstance(val, str): | |||
val = substitute_vars(ctx, val) | |||
if is_directive(key): | |||
|
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 was added by precommit :( (which I still do not like very much!)
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.
Will be fixed after #125.
Now that we have state during the recursion we can detect circular imports. This commit adds it and a matching test.
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.
Tiny typo in a docstring if you want to address it, otherwise great.
if includes is None: | ||
includes = self.includes.copy() |
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.
Late to the party but:
Should we make copy()
"smarter" and add something like:
if path != includes[-1]:
includes.append(path)
so that whenever the path changes it's automatically added to the include stack?
Too smart?
Now that we have state during the recursion we can detect circular imports. This commit adds it and a matching test.