-
Notifications
You must be signed in to change notification settings - Fork 25
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 code inspection notebook #832
Conversation
c8d543d
to
f0326c0
Compare
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.
Thanks @PhilippeMoussalli
Would be nice to include this in our test suite (eg. using https://stackoverflow.com/questions/40172281/unit-tests-for-functions-in-a-jupyter-notebook). Can you either include it in this PR or open a ticket to add it later instead?
from IPython import get_ipython | ||
|
||
shell = get_ipython().__class__.__name__ | ||
return shell == "ZMQInteractiveShell" |
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.
What about running in an IPython terminal instead of a notebook? (if shell == "TerminalInteractiveShell"
)
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.
Does this fix work for the other shells as well?
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.
I tested on my IDE python consol shell (PyDevTerminalInteractiveShell
), jupter notebook (ZMQInteractiveShell
) and colab (Shell
). I presume those are the main 3 options that will be used for compilation (even IDE console seems a bit unlikely)
component_source = extract_symbols(component_source, component_cls.__name__)[0][ | ||
0 | ||
] |
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.
Y u do this Black 😢
component_source = extract_symbols(component_source, component_cls.__name__)[0][ | |
0 | |
] | |
component_source = extract_symbols( | |
component_source, | |
component_cls.__name__, | |
)[0][0] |
Can you try changing it to this and see if Black keeps it this way? 😛
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.
haha it does this
component_source = extract_symbols(
component_source,
component_cls.__name__,
)[
0
][0]
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.
i'll break it into two lines
a3571e3
to
0ca0d5a
Compare
Best to tackle it in a separate PR since it seems a bit tricky, opened an issue |
When running the lightweight components in a notebook, the component class code inspection fails with error
source code is not available
.Full error log here log.txt
The error is related to the fact that
inspect
relies on the class located in a source file which is not the case in a notebook where everything runs interactively. This is described in details hereImplemented the workaround suggested here