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

fix node import themes.py #27

Merged
merged 1 commit into from
Nov 20, 2024
Merged

Conversation

Tara-Lakshmipathy
Copy link
Contributor

Current implementation throws NameError: name 'Node' is not defined Node class is imported only when the code is being type-checked, but not when it's being executed which causes the error.

Current implementation throws NameError: name 'Node' is not defined
Node class is imported only when the code is being type-checked, but not when it's being executed which causes the error.
Copy link
Member

@liamhuber liamhuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but you can also get it with from __future__ import annotations at the top of the file. Although the future import is supposedly not necessary from 3.11 onward, in this case when combined with TYPE_CHECKING I find I do still need it -- not sure about 3.12.

Since Node is not actually used outside the type hint, the annotations import is my preferred solution because (a) it makes it marginally clearer how the import is used in this file to keep it wrapped in TYPE_CHECKING (subjective!), and (b) it can lead to speedups (objective). In this case, pyiron_workflow.node is getting imported by the other imports anyhow, so the speedup is non-existent and thus your solution here is objectively fine.

@Tara-Lakshmipathy Tara-Lakshmipathy merged commit 93e6b4d into main Nov 20, 2024
2 checks passed
@Tara-Lakshmipathy Tara-Lakshmipathy deleted the fix_themes_node_import branch November 20, 2024 09:27
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.

2 participants