Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fastship/maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from fastcore.basics import *
from fastcore.imports import *
from fastcore.nbio import *
from fastcore.pyparse import parse_py
from fastcore.pyparse import parse_py, patch_targets

import ast

Expand Down Expand Up @@ -46,7 +46,7 @@ def make_all(self:ModuleMaker, cells):
# NB: "_all_" can include strings (names), or symbols, so we look for "id" or "value"
all_vals = [v for o in trees if isinstance(o, (ast.Assign, ast.AnnAssign, ast.AugAssign))
and getattr(o.targets[0] if isinstance(o, ast.Assign) else o.target, 'id', None)=='_all_' for v in _val_or_id(o)]
syms = [d.name for d in m.defs if d.is_public and not any(dec.startswith('patch') for dec in d.decos)]
syms = [d.name for d in m.defs if d.is_public and not patch_targets(d)]
assigns = [nm for nm in m.assigns if not nm.startswith('_')]
return L(assigns + syms + all_vals).unique()

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies = [
"aihist>=0.1.2",
"execnb>=0.4.1",
"fast5ever>=0.1.7",
"fastcore>=2.3.18",
"fastcore>=2.3.19",
"fastgit>=0.1.0",
"ghapi>=2.1.4",
"mdhtml[fill,hl]>=0.1.59",
Expand Down
9 changes: 5 additions & 4 deletions ship/api/01_maker.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"from fastcore.basics import *\n",
"from fastcore.imports import *\n",
"from fastcore.nbio import *\n",
"from fastcore.pyparse import parse_py\n",
"from fastcore.pyparse import parse_py, patch_targets\n",
"\n",
"import ast\n",
"\n",
Expand Down Expand Up @@ -147,7 +147,7 @@
" # NB: \"_all_\" can include strings (names), or symbols, so we look for \"id\" or \"value\"\n",
" all_vals = [v for o in trees if isinstance(o, (ast.Assign, ast.AnnAssign, ast.AugAssign))\n",
" and getattr(o.targets[0] if isinstance(o, ast.Assign) else o.target, 'id', None)=='_all_' for v in _val_or_id(o)]\n",
" syms = [d.name for d in m.defs if d.is_public and not any(dec.startswith('patch') for dec in d.decos)]\n",
" syms = [d.name for d in m.defs if d.is_public and not patch_targets(d)]\n",
" assigns = [nm for nm in m.assigns if not nm.startswith('_')]\n",
" return L(assigns + syms + all_vals).unique()"
]
Expand Down Expand Up @@ -182,8 +182,9 @@
"outputs": [],
"source": [
"nb = make_code_cells(\"from __future__ import print_function\", \"def a():...\", \"def b():...\",\n",
" \"c=d=1\", \"_f=1\", \"_g=1\", \"_h=1\", \"_all_=['_g', _h]\", \"@patch\\ndef h(self:ca):...\")\n",
"test_eq(set(mm.make_all(nb)), set(['a','b','c','d', '_g', '_h']))"
" \"c=d=1\", \"_f=1\", \"_g=1\", \"_h=1\", \"_all_=['_g', _h]\", \"@patch\\ndef h(self:ca):...\",\n",
" \"@patch_to(ca)\\ndef r(self):...\", \"@app.patch('/x')\\ndef p(req:Req):...\", \"@app.patch\\ndef q(req:Req):...\")\n",
"test_eq(set(mm.make_all(nb)), set(['a','b','c','d', '_g', '_h', 'p', 'q']))"
]
},
{
Expand Down