ipython/ipynb

ipynb.fs.defs raise error if there is subscript line

ebraminio opened this issue · 2 comments

I've something like

import os
os.environ["KERAS_BACKEND"] = "tensorflow"

on top of my code (I know I can do that in some other way…) and ipynb.fs.defs fails to import this into another module. I like to fix this myself but honestly don't have good clue what should be done, excepting it from defs or accepting it? As this case, my favor is to accepting it but I am not sure if that would be what all want.

(Not the maintainer but I have been working on this recently.)

The way ipynb currently handles assignment definitions is prone to error. I have submitted a separate PR regarding tuple-based assignment. (See: #34)

It is the intention of the authors that top-level assignments are only importable if they are assumed to be constants (having UPPER_CASE_NAMES).

Anything else, including your example, should be ignored under the original intention - but certainly should not result in error.

If you want your environment configs to be effective given this, I’d recommend moving them into a function or class initialisation.

Fixed, AFAIC, thanks