@@ -87,6 +87,8 @@ def _filt_dec(x): return decor_id(x).startswith('patch')
8787def _wants (o ): return isinstance (o ,_def_types ) and not any (L (o .decorator_list ).filter (_filt_dec ))
8888
8989# %% ../nbs/09_API/02_maker.ipynb 20
90+ def _targets (o ): return [o .target ] if isinstance (o , ast .AnnAssign ) else o .targets
91+
9092@patch
9193def make_all (self :ModuleMaker , cells ):
9294 "Create `__all__` with all exports in `cells`"
@@ -95,11 +97,11 @@ def make_all(self:ModuleMaker, cells):
9597 # include anything mentioned in "_all_", even if otherwise private
9698 # NB: "_all_" can include strings (names), or symbols, so we look for "id" or "value"
9799 assigns = trees .filter (risinstance (_assign_types ))
98- all_assigns = assigns .filter (lambda o : getattr (o . targets [0 ],'id' ,None )== '_all_' )
100+ all_assigns = assigns .filter (lambda o : getattr (_targets ( o ) [0 ],'id' ,None )== '_all_' )
99101 all_vals = all_assigns .map (_val_or_id ).concat ()
100102 syms = trees .filter (_wants ).attrgot ('name' )
101103 # assignment targets (NB: can be multiple, e.g. "a=b=c", and/or destructuring e.g "a,b=(1,2)")
102- assign_targs = L (L (assn . targets ).map (_all_targets ).concat () for assn in assigns ).concat ()
104+ assign_targs = L (L (_targets ( assn ) ).map (_all_targets ).concat () for assn in assigns ).concat ()
103105 exports = (assign_targs .attrgot ('id' )+ syms ).filter (lambda o : o and o [0 ]!= '_' )
104106 return (exports + all_vals ).unique ()
105107
0 commit comments