Commit 35ab0821 by Mickaël Schoentgen

Fix several DeprecationWarning: invalid escape sequence

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