Skip to content

Commit c7ead2e

Browse files
committed
clean
1 parent 255c8be commit c7ead2e

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

nbdev/export.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def __call__(self, cell):
3737
def black_format(cell, # Cell to format
3838
force=False): # Turn black formatting on regardless of pyproject.toml
3939
"Processor to format code with `black`"
40-
try: cfg = get_config()
41-
except FileNotFoundError: return
40+
cfg = get_config()
4241
if (not cfg.black_formatting and not force) or cell.cell_type != 'code': return
4342
try: import black
4443
except: raise ImportError("You must install black: `pip install black` if you wish to use black formatting with nbdev")
@@ -53,8 +52,7 @@ def black_format(cell, # Cell to format
5352

5453
def scrub_magics(cell): # Cell to format
5554
"Processor to remove cell magics from exported code"
56-
try: cfg = get_config()
57-
except FileNotFoundError: return
55+
cfg = get_config()
5856
if cell.cell_type != 'code': return
5957
try: cell.source = _magics_pattern.sub('', cell.source)
6058
except: pass

nbs/api/01_config.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@
537537
"id": "0e537860",
538538
"metadata": {},
539539
"source": [
540-
"Note: `get_config()` requires a `pyproject.toml` with `[tool.nbdev]` to exist. If not found, it raises `FileNotFoundError`."
540+
"Note: If no `pyproject.toml` with `[tool.nbdev]` is found, `get_config()` returns a minimal config with defaults based on the current directory. Use `is_nbdev()` to check if you're in an nbdev project."
541541
]
542542
},
543543
{

nbs/api/04_export.ipynb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@
126126
"def black_format(cell, # Cell to format\n",
127127
" force=False): # Turn black formatting on regardless of pyproject.toml\n",
128128
" \"Processor to format code with `black`\"\n",
129-
" try: cfg = get_config()\n",
130-
" except FileNotFoundError: return\n",
129+
" cfg = get_config()\n",
131130
" if (not cfg.black_formatting and not force) or cell.cell_type != 'code': return\n",
132131
" try: import black\n",
133132
" except: raise ImportError(\"You must install black: `pip install black` if you wish to use black formatting with nbdev\")\n",
@@ -162,8 +161,7 @@
162161
"\n",
163162
"def scrub_magics(cell): # Cell to format\n",
164163
" \"Processor to remove cell magics from exported code\"\n",
165-
" try: cfg = get_config()\n",
166-
" except FileNotFoundError: return\n",
164+
" cfg = get_config()\n",
167165
" if cell.cell_type != 'code': return\n",
168166
" try: cell.source = _magics_pattern.sub('', cell.source)\n",
169167
" except: pass"

0 commit comments

Comments
 (0)