diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index c4ace5aa776..68249429df2 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -141,7 +141,7 @@ class _ZipLoaderModule(Protocol): __loader__: zipimport.zipimporter -_PEP440_FALLBACK = re.compile(r"^v?(?P(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.I) +_PEP440_FALLBACK = re.compile(r"^v?(?P(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.IGNORECASE) class PEP440Warning(RuntimeWarning): diff --git a/setuptools/_normalization.py b/setuptools/_normalization.py index e858052ccd3..e2e75e6200f 100644 --- a/setuptools/_normalization.py +++ b/setuptools/_normalization.py @@ -8,10 +8,10 @@ from .extern import packaging # https://packaging.python.org/en/latest/specifications/core-metadata/#name -_VALID_NAME = re.compile(r"^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$", re.I) -_UNSAFE_NAME_CHARS = re.compile(r"[^A-Z0-9._-]+", re.I) -_NON_ALPHANUMERIC = re.compile(r"[^A-Z0-9]+", re.I) -_PEP440_FALLBACK = re.compile(r"^v?(?P(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.I) +_VALID_NAME = re.compile(r"^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$", re.IGNORECASE) +_UNSAFE_NAME_CHARS = re.compile(r"[^A-Z0-9._-]+", re.IGNORECASE) +_NON_ALPHANUMERIC = re.compile(r"[^A-Z0-9]+", re.IGNORECASE) +_PEP440_FALLBACK = re.compile(r"^v?(?P(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.IGNORECASE) def safe_identifier(name: str) -> str: diff --git a/setuptools/package_index.py b/setuptools/package_index.py index c91e419923c..d14b0892a8a 100644 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -45,12 +45,12 @@ EGG_FRAGMENT = re.compile(r'^egg=([-A-Za-z0-9_.+!]+)$') -HREF = re.compile(r"""href\s*=\s*['"]?([^'"> ]+)""", re.I) +HREF = re.compile(r"""href\s*=\s*['"]?([^'"> ]+)""", re.IGNORECASE) PYPI_MD5 = re.compile( r'([^<]+)\n\s+\(md5\)' ) -URL_SCHEME = re.compile('([-+.a-z0-9]{2,}):', re.I).match +URL_SCHEME = re.compile('([-+.a-z0-9]{2,}):', re.IGNORECASE).match EXTENSIONS = ".tar.gz .tar.bz2 .tar .zip .tgz".split() __all__ = [ @@ -213,7 +213,7 @@ def wrapper(*args, **kwargs): return wrapper -REL = re.compile(r"""<([^>]*\srel\s{0,10}=\s{0,10}['"]?([^'" >]+)[^>]*)>""", re.I) +REL = re.compile(r"""<([^>]*\srel\s{0,10}=\s{0,10}['"]?([^'" >]+)[^>]*)>""", re.IGNORECASE) """ Regex for an HTML tag with 'rel="val"' attributes. """ diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py index 6b3ee9cf1ec..ab8460f9e0b 100644 --- a/setuptools/tests/config/test_apply_pyprojecttoml.py +++ b/setuptools/tests/config/test_apply_pyprojecttoml.py @@ -350,7 +350,7 @@ def test_not_listed_in_dynamic(self, tmp_path, attr, field, value): """Setuptools cannot set a field if not listed in ``dynamic``""" pyproject = self.pyproject(tmp_path, []) dist = makedist(tmp_path, **{attr: value}) - msg = re.compile(f"defined outside of `pyproject.toml`:.*{field}", re.S) + msg = re.compile(f"defined outside of `pyproject.toml`:.*{field}", re.DOTALL) with pytest.warns(_MissingDynamic, match=msg): dist = pyprojecttoml.apply_configuration(dist, pyproject) diff --git a/setuptools/tests/config/test_pyprojecttoml.py b/setuptools/tests/config/test_pyprojecttoml.py index bf8cae5a242..0be018604bc 100644 --- a/setuptools/tests/config/test_pyprojecttoml.py +++ b/setuptools/tests/config/test_pyprojecttoml.py @@ -208,7 +208,7 @@ def test_scripts_not_listed_in_dynamic(self, tmp_path, missing_dynamic): dynamic = {"scripts", "gui-scripts", "entry-points"} - {missing_dynamic} msg = f"defined outside of `pyproject.toml`:.*{missing_dynamic}" - with pytest.raises(OptionError, match=re.compile(msg, re.S)): + with pytest.raises(OptionError, match=re.compile(msg, re.DOTALL)): expand_configuration(self.pyproject(dynamic), tmp_path) @@ -326,7 +326,7 @@ def test_invalid_example(tmp_path, example, error_msg): pyproject = tmp_path / "pyproject.toml" pyproject.write_text(cleandoc(example), encoding="utf-8") - pattern = re.compile(f"invalid pyproject.toml.*{error_msg}.*", re.M | re.S) + pattern = re.compile(f"invalid pyproject.toml.*{error_msg}.*", re.MULTILINE | re.DOTALL) with pytest.raises(ValueError, match=pattern): read_configuration(pyproject) diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index 44be6c3284f..5a5c85ec1a0 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -86,7 +86,7 @@ def test_invalid_version(self, tmp_path): """ config = "[metadata]\nname=proj\nversion=42\n[egg_info]\ntag_build=invalid!!!\n" (tmp_path / "setup.cfg").write_text(config, encoding="utf-8") - msg = re.compile("invalid version", re.M | re.I) + msg = re.compile("invalid version", re.MULTILINE | re.IGNORECASE) proc = run_command_inner("dist_info", cwd=tmp_path, check=False) assert proc.returncode assert msg.search(proc.stdout) diff --git a/tools/finalize.py b/tools/finalize.py index 3ba5d16ac7d..f1746c26502 100644 --- a/tools/finalize.py +++ b/tools/finalize.py @@ -38,7 +38,7 @@ def _repair_changelog(): """ changelog_fn = pathlib.Path('NEWS.rst') changelog = changelog_fn.read_text(encoding='utf-8') - fixed = re.sub(r'^(v[0-9.]+)v[0-9.]+$', r'\1', changelog, flags=re.M) + fixed = re.sub(r'^(v[0-9.]+)v[0-9.]+$', r'\1', changelog, flags=re.MULTILINE) changelog_fn.write_text(fixed, encoding='utf-8') subprocess.check_output(['git', 'add', changelog_fn]) diff --git a/tools/vendored.py b/tools/vendored.py index edc9195f3cf..29106312afe 100644 --- a/tools/vendored.py +++ b/tools/vendored.py @@ -40,7 +40,7 @@ def rewrite_jaraco_text(pkg_files, new_root): text = re.sub(r' (jaraco\.)', rf' {new_root}.\1', text) text = re.sub(r' (importlib_resources)', rf' {new_root}.\1', text) # suppress loading of lorem_ipsum; ref #3072 - text = re.sub(r'^lorem_ipsum.*\n$', '', text, flags=re.M) + text = re.sub(r'^lorem_ipsum.*\n$', '', text, flags=re.MULTILINE) file.write_text(text)