From a0d81b3fa18d57af2eda82203c78c79e09570c7a Mon Sep 17 00:00:00 2001 From: James Date: Thu, 4 Mar 2021 08:11:14 +0100 Subject: [PATCH] remove regex warnings (#8592) --- conans/client/build/msbuild.py | 2 +- conans/client/conf/detect.py | 10 +++++----- conans/client/tools/scm.py | 8 +++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/conans/client/build/msbuild.py b/conans/client/build/msbuild.py index 60ca59c0dc1..da88f07037b 100644 --- a/conans/client/build/msbuild.py +++ b/conans/client/build/msbuild.py @@ -252,7 +252,7 @@ def get_version(settings): try: out = version_runner(command, shell=True) version_line = decode_text(out).split("\n")[-1] - prog = re.compile("(\d+\.){2,3}\d+") + prog = re.compile(r"(\d+\.){2,3}\d+") result = prog.match(version_line).group() return Version(result) except Exception as e: diff --git a/conans/client/conf/detect.py b/conans/client/conf/detect.py index dd824389846..4b19639ac61 100644 --- a/conans/client/conf/detect.py +++ b/conans/client/conf/detect.py @@ -6,7 +6,7 @@ from conans.client.conf.compiler_id import UNKNOWN_COMPILER, LLVM_GCC, detect_compiler_id from conans.client.output import Color -from conans.client.tools import detected_os, detected_architecture, OSInfo +from conans.client.tools import detected_os, detected_architecture from conans.client.tools.win import latest_visual_studio_version_installed from conans.model.version import Version from conans.util.conan_v2_mode import CONAN_V2_MODE_ENVVAR @@ -41,7 +41,7 @@ def _gcc_compiler(output, compiler_exe="gcc"): if ret != 0: return None compiler = "gcc" - installed_version = re.search("([0-9]+(\.[0-9])?)", out).group() + installed_version = re.search(r"([0-9]+(\.[0-9])?)", out).group() # Since GCC 7.1, -dumpversion return the major version number # only ("7"). We must use -dumpfullversion to get the full version # number ("7.1.1"). @@ -61,7 +61,7 @@ def _clang_compiler(output, compiler_exe="clang"): compiler = "apple-clang" elif "clang version" in out: compiler = "clang" - installed_version = re.search("([0-9]+\.[0-9])", out).group() + installed_version = re.search(r"([0-9]+\.[0-9])", out).group() if installed_version: output.success("Found %s %s" % (compiler, installed_version)) return compiler, installed_version @@ -73,11 +73,11 @@ def _sun_cc_compiler(output, compiler_exe="cc"): try: _, out = detect_runner('%s -V' % compiler_exe) compiler = "sun-cc" - installed_version = re.search("Sun C.*([0-9]+\.[0-9]+)", out) + installed_version = re.search(r"Sun C.*([0-9]+\.[0-9]+)", out) if installed_version: installed_version = installed_version.group(1) else: - installed_version = re.search("([0-9]+\.[0-9]+)", out).group() + installed_version = re.search(r"([0-9]+\.[0-9]+)", out).group() if installed_version: output.success("Found %s %s" % (compiler, installed_version)) return compiler, installed_version diff --git a/conans/client/tools/scm.py b/conans/client/tools/scm.py index b8cb2cfec40..39d77954ecf 100644 --- a/conans/client/tools/scm.py +++ b/conans/client/tools/scm.py @@ -109,9 +109,11 @@ def get_url_with_credentials(self, url): return url scp_regex = re.compile("^(?P[a-zA-Z0-9_]+)@(?P[a-zA-Z0-9._-]+):(?P.*)$") - url_user_pass_regex = re.compile("^(?Pfile|http|https|git|ssh):\/\/(?P\w+):(?P\w+)@(?P.*)$") - url_user_regex = re.compile("^(?Pfile|http|https|git|ssh):\/\/(?P\w+)@(?P.*)$") - url_basic_regex = re.compile("^(?Pfile|http|https|git|ssh):\/\/(?P.*)$") + url_user_pass_regex = re.compile( + r"^(?Pfile|http|https|git|ssh)://(?P\w+):(?P\w+)@(?P.*)$") + url_user_regex = re.compile( + r"^(?Pfile|http|https|git|ssh)://(?P\w+)@(?P.*)$") + url_basic_regex = re.compile(r"^(?Pfile|http|https|git|ssh)://(?P.*)$") url_patterns = [ (scp_regex, self._handle_scp_pattern),