bugfix: local import in spec.py#16809
Conversation
|
@skosukhin Local imports are usually done to optimize on startup time. Here though I don't understand what's going on, since the two forms seem to me semantically equivalent: import foo
s = foo.func()vs. import foo as bar
s = bar.func()Can you be more explicit what is the issue and why this is solving it? |
|
First, in the scenarios that I've checked, Second, |
|
@skosukhin Thanks. TIL this gotcha, that a nested import as the effect of assigning to the root module. Will search for references in Python docs to read more about that.
I would be for performing the local import at the beginning of the function. Can you add a test to check that we raise the correct exception (i.e. |
|
Thanks! |
Without this we have:
With this:
@alalazo do we need this local import at all?