This week at I went on a bit of a side quest investigating why pytest collection was so slow.
Just running from our project root was taking a painfully ...
This is a function definition, not where it’s called; any number of things can happen between these statements running.
Second, multiple return statements is not unusual when there is control logic, i.e. if statements.
The sample code for lazy imports looks wrong
STRIPE = None def _stripe(): global STRIPE if STRIPE is None: import stripe return stripe return STRIPE
STRIPE
is never changed. And two return statements in the same function?!Anyways can imagine how to do lazy imports without relying on the given code sample.
This is a function definition, not where it’s called; any number of things can happen between these statements running. Second, multiple return statements is not unusual when there is control logic, i.e. if statements.
You are in for a real treat!
Here is how to step in and get the locals
This technique depends on there being only one return statement
https://logging-strict.readthedocs.io/en/stable/code/tech_niques/context_locals.html
Multiple return statements is unusual. In very rare situations i understand. But the rule is never do that.
When there is only one return statement, can step into the function to see the local variables