Skip to content
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

Merged
merged 1 commit into from
Jun 24, 2024
Merged

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Jun 24, 2024

Now that we have state during the recursion we can detect circular imports. This commit adds it and a matching test.

@mvo5 mvo5 requested a review from achilleas-k June 24, 2024 12:09
@@ -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):

Copy link
Contributor Author

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!)

Copy link
Member

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.

src/otk/error.py Outdated Show resolved Hide resolved
Now that we have state during the recursion we can detect circular
imports. This commit adds it and a matching test.
Copy link
Member

@supakeen supakeen left a 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.

@supakeen supakeen added this pull request to the merge queue Jun 24, 2024
Merged via the queue into osbuild:main with commit 2c6764f Jun 24, 2024
3 checks passed
Comment on lines +22 to +23
if includes is None:
includes = self.includes.copy()
Copy link
Member

@achilleas-k achilleas-k Jun 24, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants