From 76df995ba69ef5d790462856b3edbd42b28b906a Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 4 Mar 2021 17:02:02 -0500 Subject: raw string literals are next to godliness Invalid escape sequences are deprecated and will be removed from a future version of python. Use r"" to define them so they remain readable. --- mesonbuild/compilers/cuda.py | 4 ++-- mesonbuild/mcompile.py | 2 +- mesonbuild/scripts/depscan.py | 4 ++-- run_unittests.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index bbe6e95..733e362 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -186,7 +186,7 @@ class CudaCompiler(Compiler): @classmethod def _shield_nvcc_list_arg(cls, arg: str, listmode: bool=True) -> str: - """ + r""" Shield an argument against both splitting by NVCC's list-argument parse logic, and interpretation by any shell. @@ -256,7 +256,7 @@ class CudaCompiler(Compiler): # Shield individual strings, without listmode, then return them with # escaped commas between them. l = [cls._shield_nvcc_list_arg(s, listmode=False) for s in l] - return '\,'.join(l) + return r'\,'.join(l) @classmethod def _to_host_flags(cls, flags: T.List[str], phase: _Phase = _Phase.COMPILER) -> T.List[str]: diff --git a/mesonbuild/mcompile.py b/mesonbuild/mcompile.py index ba1d3cf..b7653d2 100644 --- a/mesonbuild/mcompile.py +++ b/mesonbuild/mcompile.py @@ -175,7 +175,7 @@ def generate_target_name_vs(target: ParsedTargetName, builddir: Path, introspect # Normalize project name # Source: https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-build-specific-targets-in-solutions-by-using-msbuild-exe - target_name = re.sub('[\%\$\@\;\.\(\)\']', '_', intro_target['id']) # type: str + target_name = re.sub(r"[\%\$\@\;\.\(\)']", '_', intro_target['id']) # type: str rel_path = Path(intro_target['filename'][0]).relative_to(builddir.resolve()).parent if rel_path != Path('.'): target_name = str(rel_path / target_name) diff --git a/mesonbuild/scripts/depscan.py b/mesonbuild/scripts/depscan.py index c85f8e7..2879d8b 100644 --- a/mesonbuild/scripts/depscan.py +++ b/mesonbuild/scripts/depscan.py @@ -22,8 +22,8 @@ import typing as T from ..backend.ninjabackend import TargetDependencyScannerInfo, ninja_quote from ..compilers.compilers import lang_suffixes -CPP_IMPORT_RE = re.compile('\w*import ([a-zA-Z0-9]+);') -CPP_EXPORT_RE = re.compile('\w*export module ([a-zA-Z0-9]+);') +CPP_IMPORT_RE = re.compile(r'\w*import ([a-zA-Z0-9]+);') +CPP_EXPORT_RE = re.compile(r'\w*export module ([a-zA-Z0-9]+);') FORTRAN_INCLUDE_PAT = r"^\s*include\s*['\"](\w+\.\w+)['\"]" FORTRAN_MODULE_PAT = r"^\s*\bmodule\b\s+(\w+)\s*(?:!+.*)*$" diff --git a/run_unittests.py b/run_unittests.py index 6cdcc8c..0d42ced 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -5893,7 +5893,7 @@ class FailureTests(BasePlatformTests): def test_error_func(self): self.assertMesonRaises("error('a', 'b', ['c', ['d', {'e': 'f'}]], 'g')", - "Problem encountered: a b \['c', \['d', {'e' : 'f'}\]\] g") + r"Problem encountered: a b \['c', \['d', {'e' : 'f'}\]\] g") @unittest.skipUnless(is_windows() or is_cygwin(), "requires Windows (or Windows via Cygwin)") -- cgit v1.1