diff --git a/nbdev/config.py b/nbdev/config.py index bd01638b5..0c3c61ac1 100644 --- a/nbdev/config.py +++ b/nbdev/config.py @@ -222,7 +222,7 @@ def create_output(txt, mime): def show_src(src, lang='python'): return Markdown(f'```{lang}\n{src}\n```') # %% ../nbs/api/01_config.ipynb 48 -_re_version = re.compile('^__version__\s*=.*$', re.MULTILINE) +_re_version = re.compile(r'^__version__\s*=.*$', re.MULTILINE) _init = '__init__.py' def update_version(path=None): diff --git a/nbdev/doclinks.py b/nbdev/doclinks.py index 9b3ed3d0c..97cd373f9 100644 --- a/nbdev/doclinks.py +++ b/nbdev/doclinks.py @@ -98,7 +98,7 @@ def _build_modidx(dest=None, nbs_path=None, skip_exists=False): res['settings'] = {k:v for k,v in get_config().d.items() if k in ('doc_host','doc_baseurl','lib_path','git_url','branch')} code_root = dest.parent.resolve() - for file in globtastic(dest, file_glob="*.py", skip_file_re='^_', skip_folder_re="\.ipynb_checkpoints"): + for file in globtastic(dest, file_glob="*.py", skip_file_re='^_', skip_folder_re=r"\.ipynb_checkpoints"): res['syms'].update(_get_modidx((dest.parent/file).resolve(), code_root, nbs_path=nbs_path)) idxfile.write_text("# Autogenerated by nbdev\n\nd = "+pformat(res, width=140, indent=2, compact=True)+'\n') diff --git a/nbdev/quarto.py b/nbdev/quarto.py index ea71ded34..db0f44a45 100644 --- a/nbdev/quarto.py +++ b/nbdev/quarto.py @@ -68,7 +68,7 @@ def _sort(a): if y.startswith('index.'): return x,'00' return a #|export -_def_file_re = '\.(?:ipynb|qmd|html)$' +_def_file_re = r'\.(?:ipynb|qmd|html)$' @delegates(nbglob_cli) def _nbglob_docs( @@ -87,12 +87,12 @@ def _recursive_parser( set_index: bool = True): # If `True`, `index` file will be set to href. for name, val in dir_dict.items(): if type(val) is str: - if re.search('index\..*', re.sub('^\d+_', '', val)) and set_index and section: + if re.search('index\..*', re.sub(r'^\d+_', '', val)) and set_index and section: section.update({'href': str(dirpath/val)}) else: contents.append(str(dirpath/val)) elif type(val) is dict: - name = re.sub('^\d+_', '', name) + name = re.sub(r'^\d+_', '', name) section = {'section': name, 'contents': []} contents.append(section) _recursive_parser(val, section['contents'], dirpath/name, section=section) diff --git a/nbdev/showdoc.py b/nbdev/showdoc.py index c37925b3b..7442d9a62 100644 --- a/nbdev/showdoc.py +++ b/nbdev/showdoc.py @@ -25,7 +25,7 @@ def _bold(s): return f'**{s}**' if s.strip() else s # %% ../nbs/api/08_showdoc.ipynb 7 def _escape_markdown(s): - for c in '|^': s = re.sub(rf'\\?\{c}', f'\{c}', s) + for c in '|^': s = re.sub(rf'\\?\{c}', rf'\{c}', s) return s.replace('\n', '
') # %% ../nbs/api/08_showdoc.ipynb 9 diff --git a/nbdev/sync.py b/nbdev/sync.py index 14a87226a..95cb7a346 100644 --- a/nbdev/sync.py +++ b/nbdev/sync.py @@ -34,7 +34,7 @@ def _mod_files(): return L(files for mod in midx.d['syms'].values() for _,files in mod.values()).unique() # %% ../nbs/api/06_sync.ipynb 8 -_re_import = re.compile("from\s+\S+\s+import\s+\S") +_re_import = re.compile(r"from\s+\S+\s+import\s+\S") # %% ../nbs/api/06_sync.ipynb 10 def _to_absolute(code, py_path, lib_dir): diff --git a/nbs/api/01_config.ipynb b/nbs/api/01_config.ipynb index 2157ed385..6da2b94b5 100644 --- a/nbs/api/01_config.ipynb +++ b/nbs/api/01_config.ipynb @@ -682,7 +682,7 @@ "outputs": [], "source": [ "#|export\n", - "_re_version = re.compile('^__version__\\s*=.*$', re.MULTILINE)\n", + "_re_version = re.compile(r'^__version__\\s*=.*$', re.MULTILINE)\n", "_init = '__init__.py'\n", "\n", "def update_version(path=None):\n", diff --git a/nbs/api/05_doclinks.ipynb b/nbs/api/05_doclinks.ipynb index c9d7ea037..5f9946292 100644 --- a/nbs/api/05_doclinks.ipynb +++ b/nbs/api/05_doclinks.ipynb @@ -239,7 +239,7 @@ " res['settings'] = {k:v for k,v in get_config().d.items()\n", " if k in ('doc_host','doc_baseurl','lib_path','git_url','branch')}\n", " code_root = dest.parent.resolve()\n", - " for file in globtastic(dest, file_glob=\"*.py\", skip_file_re='^_', skip_folder_re=\"\\.ipynb_checkpoints\"):\n", + " for file in globtastic(dest, file_glob=\"*.py\", skip_file_re='^_', skip_folder_re=r\"\\.ipynb_checkpoints\"):\n", " res['syms'].update(_get_modidx((dest.parent/file).resolve(), code_root, nbs_path=nbs_path))\n", " idxfile.write_text(\"# Autogenerated by nbdev\\n\\nd = \"+pformat(res, width=140, indent=2, compact=True)+'\\n')" ] diff --git a/nbs/api/06_sync.ipynb b/nbs/api/06_sync.ipynb index e77b2712e..627b78425 100644 --- a/nbs/api/06_sync.ipynb +++ b/nbs/api/06_sync.ipynb @@ -109,7 +109,7 @@ "outputs": [], "source": [ "#|export\n", - "_re_import = re.compile(\"from\\s+\\S+\\s+import\\s+\\S\")" + "_re_import = re.compile(r\"from\\s+\\S+\\s+import\\s+\\S\")" ] }, { diff --git a/nbs/api/08_showdoc.ipynb b/nbs/api/08_showdoc.ipynb index c1a62ec9b..76452eea0 100644 --- a/nbs/api/08_showdoc.ipynb +++ b/nbs/api/08_showdoc.ipynb @@ -92,7 +92,7 @@ "source": [ "#|export\n", "def _escape_markdown(s):\n", - " for c in '|^': s = re.sub(rf'\\\\?\\{c}', f'\\{c}', s)\n", + " for c in '|^': s = re.sub(rf'\\\\?\\{c}', rf'\\{c}', s)\n", " return s.replace('\\n', '
')" ] }, diff --git a/nbs/api/14_quarto.ipynb b/nbs/api/14_quarto.ipynb index b8a4e9fab..f327bfed7 100644 --- a/nbs/api/14_quarto.ipynb +++ b/nbs/api/14_quarto.ipynb @@ -159,7 +159,7 @@ " if y.startswith('index.'): return x,'00'\n", " return a\n", "#|export\n", - "_def_file_re = '\\.(?:ipynb|qmd|html)$'\n", + "_def_file_re = r'\\.(?:ipynb|qmd|html)$'\n", "\n", "@delegates(nbglob_cli)\n", "def _nbglob_docs(\n", @@ -186,12 +186,12 @@ " set_index: bool = True): # If `True`, `index` file will be set to href.\n", " for name, val in dir_dict.items():\n", " if type(val) is str:\n", - " if re.search('index\\..*', re.sub('^\\d+_', '', val)) and set_index and section:\n", + " if re.search('index\\..*', re.sub(r'^\\d+_', '', val)) and set_index and section:\n", " section.update({'href': str(dirpath/val)})\n", " else:\n", " contents.append(str(dirpath/val))\n", " elif type(val) is dict:\n", - " name = re.sub('^\\d+_', '', name)\n", + " name = re.sub(r'^\\d+_', '', name)\n", " section = {'section': name, 'contents': []}\n", " contents.append(section)\n", " _recursive_parser(val, section['contents'], dirpath/name, section=section)\n",