Skip to content

Commit 0b5058f

Browse files
authored
Merge pull request #1419 from imagejan/escape-sequences
Fix raw strings containing escape sequences
2 parents 4fea0e2 + 1d263e4 commit 0b5058f

File tree

10 files changed

+14
-14
lines changed

10 files changed

+14
-14
lines changed

nbdev/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def create_output(txt, mime):
222222
def show_src(src, lang='python'): return Markdown(f'```{lang}\n{src}\n```')
223223

224224
# %% ../nbs/api/01_config.ipynb 48
225-
_re_version = re.compile('^__version__\s*=.*$', re.MULTILINE)
225+
_re_version = re.compile(r'^__version__\s*=.*$', re.MULTILINE)
226226
_init = '__init__.py'
227227

228228
def update_version(path=None):

nbdev/doclinks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def _build_modidx(dest=None, nbs_path=None, skip_exists=False):
9898
res['settings'] = {k:v for k,v in get_config().d.items()
9999
if k in ('doc_host','doc_baseurl','lib_path','git_url','branch')}
100100
code_root = dest.parent.resolve()
101-
for file in globtastic(dest, file_glob="*.py", skip_file_re='^_', skip_folder_re="\.ipynb_checkpoints"):
101+
for file in globtastic(dest, file_glob="*.py", skip_file_re='^_', skip_folder_re=r"\.ipynb_checkpoints"):
102102
res['syms'].update(_get_modidx((dest.parent/file).resolve(), code_root, nbs_path=nbs_path))
103103
idxfile.write_text("# Autogenerated by nbdev\n\nd = "+pformat(res, width=140, indent=2, compact=True)+'\n')
104104

nbdev/quarto.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _sort(a):
6868
if y.startswith('index.'): return x,'00'
6969
return a
7070
#|export
71-
_def_file_re = '\.(?:ipynb|qmd|html)$'
71+
_def_file_re = r'\.(?:ipynb|qmd|html)$'
7272

7373
@delegates(nbglob_cli)
7474
def _nbglob_docs(
@@ -87,12 +87,12 @@ def _recursive_parser(
8787
set_index: bool = True): # If `True`, `index` file will be set to href.
8888
for name, val in dir_dict.items():
8989
if type(val) is str:
90-
if re.search('index\..*', re.sub('^\d+_', '', val)) and set_index and section:
90+
if re.search('index\..*', re.sub(r'^\d+_', '', val)) and set_index and section:
9191
section.update({'href': str(dirpath/val)})
9292
else:
9393
contents.append(str(dirpath/val))
9494
elif type(val) is dict:
95-
name = re.sub('^\d+_', '', name)
95+
name = re.sub(r'^\d+_', '', name)
9696
section = {'section': name, 'contents': []}
9797
contents.append(section)
9898
_recursive_parser(val, section['contents'], dirpath/name, section=section)

nbdev/showdoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _bold(s): return f'**{s}**' if s.strip() else s
2525

2626
# %% ../nbs/api/08_showdoc.ipynb 7
2727
def _escape_markdown(s):
28-
for c in '|^': s = re.sub(rf'\\?\{c}', f'\{c}', s)
28+
for c in '|^': s = re.sub(rf'\\?\{c}', rf'\{c}', s)
2929
return s.replace('\n', '<br>')
3030

3131
# %% ../nbs/api/08_showdoc.ipynb 9

nbdev/sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _mod_files():
3434
return L(files for mod in midx.d['syms'].values() for _,files in mod.values()).unique()
3535

3636
# %% ../nbs/api/06_sync.ipynb 8
37-
_re_import = re.compile("from\s+\S+\s+import\s+\S")
37+
_re_import = re.compile(r"from\s+\S+\s+import\s+\S")
3838

3939
# %% ../nbs/api/06_sync.ipynb 10
4040
def _to_absolute(code, py_path, lib_dir):

nbs/api/01_config.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@
682682
"outputs": [],
683683
"source": [
684684
"#|export\n",
685-
"_re_version = re.compile('^__version__\\s*=.*$', re.MULTILINE)\n",
685+
"_re_version = re.compile(r'^__version__\\s*=.*$', re.MULTILINE)\n",
686686
"_init = '__init__.py'\n",
687687
"\n",
688688
"def update_version(path=None):\n",

nbs/api/05_doclinks.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@
239239
" res['settings'] = {k:v for k,v in get_config().d.items()\n",
240240
" if k in ('doc_host','doc_baseurl','lib_path','git_url','branch')}\n",
241241
" code_root = dest.parent.resolve()\n",
242-
" for file in globtastic(dest, file_glob=\"*.py\", skip_file_re='^_', skip_folder_re=\"\\.ipynb_checkpoints\"):\n",
242+
" for file in globtastic(dest, file_glob=\"*.py\", skip_file_re='^_', skip_folder_re=r\"\\.ipynb_checkpoints\"):\n",
243243
" res['syms'].update(_get_modidx((dest.parent/file).resolve(), code_root, nbs_path=nbs_path))\n",
244244
" idxfile.write_text(\"# Autogenerated by nbdev\\n\\nd = \"+pformat(res, width=140, indent=2, compact=True)+'\\n')"
245245
]

nbs/api/06_sync.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"outputs": [],
110110
"source": [
111111
"#|export\n",
112-
"_re_import = re.compile(\"from\\s+\\S+\\s+import\\s+\\S\")"
112+
"_re_import = re.compile(r\"from\\s+\\S+\\s+import\\s+\\S\")"
113113
]
114114
},
115115
{

nbs/api/08_showdoc.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"source": [
9393
"#|export\n",
9494
"def _escape_markdown(s):\n",
95-
" for c in '|^': s = re.sub(rf'\\\\?\\{c}', f'\\{c}', s)\n",
95+
" for c in '|^': s = re.sub(rf'\\\\?\\{c}', rf'\\{c}', s)\n",
9696
" return s.replace('\\n', '<br>')"
9797
]
9898
},

nbs/api/14_quarto.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
" if y.startswith('index.'): return x,'00'\n",
160160
" return a\n",
161161
"#|export\n",
162-
"_def_file_re = '\\.(?:ipynb|qmd|html)$'\n",
162+
"_def_file_re = r'\\.(?:ipynb|qmd|html)$'\n",
163163
"\n",
164164
"@delegates(nbglob_cli)\n",
165165
"def _nbglob_docs(\n",
@@ -186,12 +186,12 @@
186186
" set_index: bool = True): # If `True`, `index` file will be set to href.\n",
187187
" for name, val in dir_dict.items():\n",
188188
" if type(val) is str:\n",
189-
" if re.search('index\\..*', re.sub('^\\d+_', '', val)) and set_index and section:\n",
189+
" if re.search('index\\..*', re.sub(r'^\\d+_', '', val)) and set_index and section:\n",
190190
" section.update({'href': str(dirpath/val)})\n",
191191
" else:\n",
192192
" contents.append(str(dirpath/val))\n",
193193
" elif type(val) is dict:\n",
194-
" name = re.sub('^\\d+_', '', name)\n",
194+
" name = re.sub(r'^\\d+_', '', name)\n",
195195
" section = {'section': name, 'contents': []}\n",
196196
" contents.append(section)\n",
197197
" _recursive_parser(val, section['contents'], dirpath/name, section=section)\n",

0 commit comments

Comments
 (0)