Commit 35ab0821 by Mickaël Schoentgen

Fix several DeprecationWarning: invalid escape sequence

parent 07e71abb
......@@ -132,13 +132,13 @@ class Installer:
CURRENT_PYTHON = sys.executable
METADATA_URL = "https://pypi.org/pypi/poetry/json"
VERSION_REGEX = re.compile(
"v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?"
r"v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?"
"("
"[._-]?"
"(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*)?)?"
r"(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*)?)?"
"([.-]?dev)?"
")?"
"(?:\+[^\s]+)?"
r"(?:\+[^\s]+)?"
)
def __init__(self, version=None, preview=False):
......
......@@ -148,12 +148,12 @@ class Application(BaseApplication):
formatter = o.get_formatter()
lines = []
for line in re.split("\r?\n", str(e)):
for line in re.split(r"\r?\n", str(e)):
for splitline in [
line[x : x + (width - 4)] for x in range(0, len(line), width - 4)
]:
line_length = (
len(re.sub("\[[^m]*m", "", formatter.format(splitline))) + 4
len(re.sub(r"\[[^m]*m", "", formatter.format(splitline))) + 4
)
lines.append((splitline, line_length))
......
......@@ -102,7 +102,7 @@ To remove a repository (repo is a short alias for repositories):
# show the value if no value is provided
if not self.argument("value") and not self.option("unset"):
m = re.match("^repos?(?:itories)?(?:\.(.+))?", self.argument("key"))
m = re.match(r"^repos?(?:itories)?(?:\.(.+))?", self.argument("key"))
if m:
if not m.group(1):
value = {}
......@@ -144,7 +144,7 @@ To remove a repository (repo is a short alias for repositories):
)
# handle repositories
m = re.match("^repos?(?:itories)?(?:\.(.+))?", self.argument("key"))
m = re.match(r"^repos?(?:itories)?(?:\.(.+))?", self.argument("key"))
if m:
if not m.group(1):
raise ValueError("You cannot remove the [repositories] section")
......@@ -173,7 +173,7 @@ To remove a repository (repo is a short alias for repositories):
)
# handle auth
m = re.match("^(http-basic)\.(.+)", self.argument("key"))
m = re.match(r"^(http-basic)\.(.+)", self.argument("key"))
if m:
if self.option("unset"):
if not self._auth_config.setting(
......@@ -278,7 +278,7 @@ To remove a repository (repo is a short alias for repositories):
if k is None:
k = ""
k += re.sub("^config\.", "", key + ".")
k += re.sub(r"^config\.", "", key + ".")
if setting and len(setting) > 1:
setting = ".".join(setting.split(".")[1:])
......
......@@ -15,7 +15,7 @@ from ..utils.module import Module
from ..utils.package_include import PackageInclude
AUTHOR_REGEX = re.compile("(?u)^(?P<name>[- .,\w\d'’\"()]+) <(?P<email>.+?)>$")
AUTHOR_REGEX = re.compile(r"(?u)^(?P<name>[- .,\w\d'’\"()]+) <(?P<email>.+?)>$")
class Builder(object):
......
......@@ -280,7 +280,7 @@ class SdistBuilder(Builder):
):
main = []
extras = defaultdict(list)
req_regex = re.compile("^(.+) \((.+)\)$")
req_regex = re.compile(r"^(.+) \((.+)\)$")
for dependency in dependencies:
if dependency.is_optional():
......
......@@ -179,8 +179,8 @@ class WheelBuilder(Builder):
@property
def wheel_filename(self): # type: () -> str
return "{}-{}-{}.whl".format(
re.sub("[^\w\d.]+", "_", self._package.pretty_name, flags=re.UNICODE),
re.sub("[^\w\d.]+", "_", self._meta.version, flags=re.UNICODE),
re.sub(r"[^\w\d.]+", "_", self._package.pretty_name, flags=re.UNICODE),
re.sub(r"[^\w\d.]+", "_", self._meta.version, flags=re.UNICODE),
self.tag,
)
......@@ -190,8 +190,8 @@ class WheelBuilder(Builder):
)
def dist_info_name(self, distribution, version): # type: (...) -> str
escaped_name = re.sub("[^\w\d.]+", "_", distribution, flags=re.UNICODE)
escaped_version = re.sub("[^\w\d.]+", "_", version, flags=re.UNICODE)
escaped_name = re.sub(r"[^\w\d.]+", "_", distribution, flags=re.UNICODE)
escaped_version = re.sub(r"[^\w\d.]+", "_", version, flags=re.UNICODE)
return "{}-{}.dist-info".format(escaped_name, escaped_version)
......
......@@ -60,9 +60,9 @@ class Uploader:
dist.glob(
"{}-{}-*.whl".format(
re.sub(
"[^\w\d.]+", "_", self._package.pretty_name, flags=re.UNICODE
r"[^\w\d.]+", "_", self._package.pretty_name, flags=re.UNICODE
),
re.sub("[^\w\d.]+", "_", version, flags=re.UNICODE),
re.sub(r"[^\w\d.]+", "_", version, flags=re.UNICODE),
)
)
)
......
......@@ -62,7 +62,7 @@ def dependency_from_pep_508(name):
link = Link(path_to_url(os.path.normpath(os.path.abspath(link.path))))
# wheel file
if link.is_wheel:
m = re.match("^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))", link.filename)
m = re.match(r"^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))", link.filename)
if not m:
raise ValueError("Invalid wheel name: {}".format(link.filename))
......
......@@ -84,7 +84,7 @@ class GenericConstraint(BaseConstraint):
"""
pretty_constraint = constraints
or_constraints = re.split("\s*\|\|?\s*", constraints.strip())
or_constraints = re.split(r"\s*\|\|?\s*", constraints.strip())
or_groups = []
for constraints in or_constraints:
and_constraints = re.split(
......@@ -116,12 +116,12 @@ class GenericConstraint(BaseConstraint):
@classmethod
def _parse_constraint(cls, constraint):
m = re.match("(?i)^v?[xX*](\.[xX*])*$", constraint)
m = re.match(r"(?i)^v?[xX*](\.[xX*])*$", constraint)
if m:
return (EmptyConstraint(),)
# Basic Comparators
m = re.match("^(!=|==?)?\s*(.*)", constraint)
m = re.match(r"^(!=|==?)?\s*(.*)", constraint)
if m:
return (GenericConstraint(m.group(1) or "=", m.group(2)),)
......
......@@ -6,7 +6,7 @@ from .constraint import Constraint
class WilcardConstraint(Constraint):
def __init__(self, constraint): # type: (str) -> None
m = re.match(
"^(!= ?|==)?v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.[xX*])+$", constraint
r"^(!= ?|==)?v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.[xX*])+$", constraint
)
if not m:
raise ValueError("Invalid value for wildcard constraint")
......
......@@ -19,7 +19,7 @@ from .directory_dependency import DirectoryDependency
from .file_dependency import FileDependency
from .vcs_dependency import VCSDependency
AUTHOR_REGEX = re.compile("(?u)^(?P<name>[- .,\w\d'’\"()]+)(?: <(?P<email>.+?)>)?$")
AUTHOR_REGEX = re.compile(r"(?u)^(?P<name>[- .,\w\d'’\"()]+)(?: <(?P<email>.+?)>)?$")
class Package(object):
......
......@@ -508,8 +508,8 @@ class Provider:
if message.startswith("fact:"):
if "depends on" in message:
m = re.match("fact: (.+?) depends on (.+?) \((.+?)\)", message)
m2 = re.match("(.+?) \((.+?)\)", m.group(1))
m = re.match(r"fact: (.+?) depends on (.+?) \((.+?)\)", message)
m2 = re.match(r"(.+?) \((.+?)\)", m.group(1))
if m2:
name = m2.group(1)
version = " (<comment>{}</comment>)".format(m2.group(2))
......@@ -531,19 +531,19 @@ class Provider:
)
else:
message = re.sub(
"(?<=: )(.+?) \((.+?)\)",
r"(?<=: )(.+?) \((.+?)\)",
"<info>\\1</info> (<comment>\\2</comment>)",
message,
)
message = "<fg=blue>fact</>: {}".format(message.split("fact: ")[1])
elif message.startswith("selecting "):
message = re.sub(
"selecting (.+?) \((.+?)\)",
r"selecting (.+?) \((.+?)\)",
"<fg=blue>selecting</> <info>\\1</info> (<comment>\\2</comment>)",
message,
)
elif message.startswith("derived:"):
m = re.match("derived: (.+?) \((.+?)\)$", message)
m = re.match(r"derived: (.+?) \((.+?)\)$", message)
if m:
message = "<fg=blue>derived</>: <info>{}</info> (<comment>{}</comment>)".format(
m.group(1), m.group(2)
......@@ -553,9 +553,9 @@ class Provider:
message.split("derived: ")[1]
)
elif message.startswith("conflict:"):
m = re.match("conflict: (.+?) depends on (.+?) \((.+?)\)", message)
m = re.match(r"conflict: (.+?) depends on (.+?) \((.+?)\)", message)
if m:
m2 = re.match("(.+?) \((.+?)\)", m.group(1))
m2 = re.match(r"(.+?) \((.+?)\)", m.group(1))
if m2:
name = m2.group(1)
version = " (<comment>{}</comment>)".format(m2.group(2))
......
......@@ -46,7 +46,7 @@ from .pypi_repository import PyPiRepository
class Page:
VERSION_REGEX = re.compile("(?i)([a-z0-9_\-.]+?)-(?=\d)([a-z0-9_.!+-]+)")
VERSION_REGEX = re.compile(r"(?i)([a-z0-9_\-.]+?)-(?=\d)([a-z0-9_.!+-]+)")
def __init__(self, url, content, headers):
if not url.endswith("/"):
......
......@@ -290,7 +290,7 @@ class PyPiRepository(Repository):
# If bdist_wheel, check if it's universal
filename = url["filename"]
if not re.search("-py2\.py3-none-any.whl", filename):
if not re.search(r"-py2\.py3-none-any.whl", filename):
continue
urls[dist_type] = url["url"]
......
......@@ -16,7 +16,7 @@ def parse_constraint(constraints): # type: (str) -> VersionConstraint
if constraints == "*":
return VersionRange()
or_constraints = re.split("\s*\|\|?\s*", constraints.strip())
or_constraints = re.split(r"\s*\|\|?\s*", constraints.strip())
or_groups = []
for constraints in or_constraints:
and_constraints = re.split(
......@@ -46,7 +46,7 @@ def parse_constraint(constraints): # type: (str) -> VersionConstraint
def parse_single_constraint(constraint): # type: (str) -> VersionConstraint
m = re.match("(?i)^v?[xX*](\.[xX*])*$", constraint)
m = re.match(r"(?i)^v?[xX*](\.[xX*])*$", constraint)
if m:
return VersionRange()
......
......@@ -2,20 +2,20 @@ import re
MODIFIERS = (
"[._-]?"
"((?!post)(?:beta|b|c|pre|RC|alpha|a|patch|pl|p|dev)(?:(?:[.-]?\d+)*)?)?"
"([+-]?([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?"
r"((?!post)(?:beta|b|c|pre|RC|alpha|a|patch|pl|p|dev)(?:(?:[.-]?\d+)*)?)?"
r"([+-]?([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?"
)
_COMPLETE_VERSION = "v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?{}(?:\+[^\s]+)?".format(
_COMPLETE_VERSION = r"v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?{}(?:\+[^\s]+)?".format(
MODIFIERS
)
COMPLETE_VERSION = re.compile("(?i)" + _COMPLETE_VERSION)
CARET_CONSTRAINT = re.compile("(?i)^\^({})$".format(_COMPLETE_VERSION))
CARET_CONSTRAINT = re.compile(r"(?i)^\^({})$".format(_COMPLETE_VERSION))
TILDE_CONSTRAINT = re.compile("(?i)^~(?!=)({})$".format(_COMPLETE_VERSION))
TILDE_PEP440_CONSTRAINT = re.compile("(?i)^~=({})$".format(_COMPLETE_VERSION))
X_CONSTRAINT = re.compile("^(!=|==)?\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.[xX*])+$")
X_CONSTRAINT = re.compile(r"^(!=|==)?\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.[xX*])+$")
BASIC_CONSTRAINT = re.compile(
"(?i)^(<>|!=|>=?|<=?|==?)?\s*({}|dev)".format(_COMPLETE_VERSION)
r"(?i)^(<>|!=|>=?|<=?|==?)?\s*({}|dev)".format(_COMPLETE_VERSION)
)
......@@ -280,7 +280,7 @@ class Version(VersionRange):
if not pre:
return
m = re.match("(?i)^(a|alpha|b|beta|c|pre|rc|dev)[-.]?(\d+)?$", pre)
m = re.match(r"(?i)^(a|alpha|b|beta|c|pre|rc|dev)[-.]?(\d+)?$", pre)
if not m:
return
......
......@@ -64,7 +64,7 @@ def user_cache_dir(appname):
def user_data_dir(appname, roaming=False):
"""
r"""
Return full path to the user-specific data dir for this application.
"appname" is the name of application.
......@@ -84,8 +84,8 @@ def user_data_dir(appname, roaming=False):
...Application Data\<AppName>
Win XP (roaming): C:\Documents and Settings\<username>\Local ...
...Settings\Application Data\<AppName>
Win 7 (not roaming): C:\\Users\<username>\AppData\Local\<AppName>
Win 7 (roaming): C:\\Users\<username>\AppData\Roaming\<AppName>
Win 7 (not roaming): C:\Users\<username>\AppData\Local\<AppName>
Win 7 (roaming): C:\Users\<username>\AppData\Roaming\<AppName>
For Unix, we follow the XDG spec and support $XDG_DATA_HOME.
That means, by default "~/.local/share/<AppName>".
......@@ -137,7 +137,7 @@ def user_config_dir(appname, roaming=True):
# for the discussion regarding site_config_dirs locations
# see <https://github.com/pypa/pip/issues/1733>
def site_config_dirs(appname):
"""Return a list of potential user-shared config dirs for this application.
r"""Return a list of potential user-shared config dirs for this application.
"appname" is the name of application.
......
......@@ -12,7 +12,7 @@ _Version = namedtuple("_Version", ["epoch", "release", "dev", "pre", "post", "lo
VERSION_PATTERN = re.compile(
"""
r"""
^
v?
(?:
......
......@@ -73,7 +73,7 @@ def test_wheel_c_extension():
Wheel-Version: 1.0
Generator: poetry {}
Root-Is-Purelib: false
Tag: cp[23]\d-cp[23]\dmu?-.+
Tag: cp[23]\\d-cp[23]\\dmu?-.+
$""".format(
__version__
),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment