Skip to content

Commit 025e96f

Browse files
Add ruff, test latest OS and bump setuptools (#2588)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent c8da7ff commit 025e96f

File tree

118 files changed

+1027
-1004
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1027
-1004
lines changed

.github/workflows/check.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
py:
22-
- "3.12.0-alpha.7"
22+
- "3.12.0-beta.2"
2323
- "3.11"
2424
- "3.10"
2525
- "3.9"
@@ -29,12 +29,12 @@ jobs:
2929
- pypy-3.8
3030
- pypy-3.7
3131
os:
32-
- ubuntu-22.04
33-
- macos-12
34-
- windows-2022
32+
- ubuntu-latest
33+
- macos-latest
34+
- windows-latest
3535
include:
36-
- { os: macos-12, py: "[email protected]" }
37-
- { os: macos-12, py: "[email protected]" }
36+
- { os: macos-latest, py: "[email protected]" }
37+
- { os: macos-latest, py: "[email protected]" }
3838
steps:
3939
- uses: taiki-e/install-action@cargo-binstall
4040
- name: Install OS dependencies
@@ -100,17 +100,17 @@ jobs:
100100
fail-fast: false
101101
matrix:
102102
os:
103-
- ubuntu-22.04
104-
- windows-2022
103+
- ubuntu-latest
104+
- windows-latest
105105
tox_env:
106106
- dev
107107
- docs
108108
- readme
109109
- upgrade
110110
- zipapp
111111
exclude:
112-
- { os: windows-2022, tox_env: readme }
113-
- { os: windows-2022, tox_env: docs }
112+
- { os: windows-latest, tox_env: readme }
113+
- { os: windows-latest, tox_env: docs }
114114
steps:
115115
- uses: actions/checkout@v3
116116
with:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
release:
8-
runs-on: ubuntu-22.04
8+
runs-on: ubuntu-latest
99
environment:
1010
name: release
1111
url: https://pypi.org/p/virtualenv

.pre-commit-config.yaml

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,33 @@ repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
33
rev: v4.4.0
44
hooks:
5-
- id: check-ast
6-
- id: check-builtin-literals
7-
- id: check-docstring-first
8-
- id: check-merge-conflict
9-
- id: check-yaml
10-
- id: check-toml
11-
- id: debug-statements
125
- id: end-of-file-fixer
136
- id: trailing-whitespace
14-
- repo: https://github.com/asottile/add-trailing-comma
15-
rev: v2.4.0
16-
hooks:
17-
- id: add-trailing-comma
18-
args: [--py36-plus]
19-
- repo: https://github.com/asottile/pyupgrade
20-
rev: v3.3.1
21-
hooks:
22-
- id: pyupgrade
23-
args: ["--py37-plus"]
24-
- repo: https://github.com/PyCQA/isort
25-
rev: 5.12.0
26-
hooks:
27-
- id: isort
287
- repo: https://github.com/psf/black
298
rev: 23.3.0
309
hooks:
3110
- id: black
32-
args: [--safe]
33-
- repo: https://github.com/asottile/blacken-docs
34-
rev: 1.13.0
35-
hooks:
36-
- id: blacken-docs
37-
additional_dependencies: [black==23.3]
38-
- repo: https://github.com/pre-commit/pygrep-hooks
39-
rev: v1.10.0
40-
hooks:
41-
- id: rst-backticks
4211
- repo: https://github.com/tox-dev/tox-ini-fmt
4312
rev: "1.3.0"
4413
hooks:
4514
- id: tox-ini-fmt
4615
args: ["-p", "fix"]
47-
- repo: https://github.com/PyCQA/flake8
48-
rev: 6.0.0
16+
- repo: https://github.com/tox-dev/pyproject-fmt
17+
rev: "0.11.2"
4918
hooks:
50-
- id: flake8
51-
additional_dependencies:
52-
- flake8-bugbear==23.3.23
53-
- flake8-comprehensions==3.12
54-
- flake8-pytest-style==1.7.2
55-
- flake8-spellcheck==0.28
56-
- flake8-unused-arguments==0.0.13
57-
- flake8-noqa==1.3.1
58-
- pep8-naming==0.13.3
59-
- flake8-pyproject==1.2.3
19+
- id: pyproject-fmt
20+
additional_dependencies: ["tox>=4.6"]
6021
- repo: https://github.com/pre-commit/mirrors-prettier
61-
rev: "v2.7.1"
22+
rev: "v3.0.0-alpha.9-for-vscode"
6223
hooks:
6324
- id: prettier
64-
additional_dependencies:
65-
66-
- "@prettier/[email protected]"
6725
args: ["--print-width=120", "--prose-wrap=always"]
68-
- repo: https://github.com/igorshubovych/markdownlint-cli
69-
rev: v0.33.0
26+
- repo: https://github.com/astral-sh/ruff-pre-commit
27+
rev: "v0.0.272"
7028
hooks:
71-
- id: markdownlint
29+
- id: ruff
30+
args: [--fix, --exit-non-zero-on-fix]
7231
- repo: meta
7332
hooks:
7433
- id: check-hooks-apply
7534
- id: check-useless-excludes
76-
- repo: https://github.com/tox-dev/pyproject-fmt
77-
rev: "0.9.2"
78-
hooks:
79-
- id: pyproject-fmt

docs/changelog/2588.bugfix.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Upgrade embedded wheels:
2+
3+
* setuptools to ``67.8.0`` from ``67.7.2``

docs/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import subprocess
44
import sys
5-
from datetime import date, datetime
5+
from datetime import datetime, timezone
66
from pathlib import Path
77

88
from virtualenv.version import __version__
@@ -11,7 +11,7 @@
1111
name = "virtualenv"
1212
version = ".".join(__version__.split(".")[:2])
1313
release = __version__
14-
copyright = f"2007-{date.today().year}, {company}, PyPA"
14+
copyright = f"2007-{datetime.now(tz=timezone.utc).year}, {company}, PyPA" # noqa: A001
1515

1616
extensions = [
1717
"sphinx.ext.autodoc",
@@ -31,7 +31,7 @@
3131
today_fmt = "%B %d, %Y"
3232

3333
html_theme = "furo"
34-
html_title, html_last_updated_fmt = project, datetime.now().isoformat()
34+
html_title, html_last_updated_fmt = project, datetime.now(tz=timezone.utc).isoformat()
3535
pygments_style, pygments_dark_style = "sphinx", "monokai"
3636
html_static_path, html_css_files = ["_static"], ["custom.css"]
3737

@@ -52,7 +52,7 @@ def setup(app):
5252
root, exe = here.parent, Path(sys.executable)
5353
towncrier = exe.with_name(f"towncrier{exe.suffix}")
5454
cmd = [str(towncrier), "build", "--draft", "--version", "NEXT"]
55-
new = subprocess.check_output(cmd, cwd=root, text=True, stderr=subprocess.DEVNULL, encoding="UTF-8")
55+
new = subprocess.check_output(cmd, cwd=root, text=True, stderr=subprocess.DEVNULL, encoding="UTF-8") # noqa: S603
5656
(root / "docs" / "_draft.rst").write_text("" if "No significant changes" in new else new, encoding="UTF-8")
5757

5858
# the CLI arguments are dynamically generated

docs/render_cli.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,14 @@ def a(*args, **kwargs):
7676
prev(*args, **kwargs)
7777
if key == "activators":
7878
return True
79-
elif key == "creator":
79+
if key == "creator":
8080
if name == "venv":
81-
from virtualenv.create.via_global_ref.venv import (
82-
ViaGlobalRefMeta,
83-
)
81+
from virtualenv.create.via_global_ref.venv import ViaGlobalRefMeta
8482

8583
meta = ViaGlobalRefMeta()
8684
meta.symlink_error = None
8785
return meta
88-
from virtualenv.create.via_global_ref.builtin.via_global_self_do import (
89-
BuiltinViaGlobalRefMeta,
90-
)
86+
from virtualenv.create.via_global_ref.builtin.via_global_self_do import BuiltinViaGlobalRefMeta
9187

9288
meta = BuiltinViaGlobalRefMeta()
9389
meta.symlink_error = None
@@ -126,11 +122,16 @@ def build_rows(options):
126122
for option in options:
127123
names = option["name"]
128124
default = option["default"]
129-
if default is not None:
130-
if isinstance(default, str) and default and default[0] == default[-1] and default[0] == '"':
131-
default = default[1:-1]
132-
if default == SUPPRESS:
133-
default = None
125+
if (
126+
default is not None
127+
and isinstance(default, str)
128+
and default
129+
and default[0] == default[-1]
130+
and default[0] == '"'
131+
):
132+
default = default[1:-1]
133+
if default == SUPPRESS:
134+
default = None
134135
choices = option.get("choices")
135136
key = names[0].strip("-")
136137
if key in CliTable.plugins:
@@ -176,10 +177,7 @@ def _get_targeted_names(self, row):
176177
@staticmethod
177178
def _get_help_text(row):
178179
name = row.names[0]
179-
if name in ("--creator",):
180-
content = row.help[: row.help.index("(") - 1]
181-
else:
182-
content = row.help
180+
content = row.help[: row.help.index("(") - 1] if name in ("--creator",) else row.help
183181
help_body = n.paragraph("", "", n.Text(content))
184182
if row.choices is not None:
185183
help_body += n.Text("; choice of: ")
@@ -207,11 +205,10 @@ def _get_default(row):
207205
default_body += n.literal(text="builtin")
208206
default_body += n.Text(" if exist, else ")
209207
default_body += n.literal(text="venv")
208+
elif default is None:
209+
default_body = n.paragraph("", text="")
210210
else:
211-
if default is None:
212-
default_body = n.paragraph("", text="")
213-
else:
214-
default_body = n.literal(text=default if isinstance(default, str) else str(default))
211+
default_body = n.literal(text=default if isinstance(default, str) else str(default))
215212
return default_body
216213

217214
def register_target_option(self, target) -> None:
@@ -221,9 +218,9 @@ def register_target_option(self, target) -> None:
221218
domain.add_program_option(None, key, self.env.docname, key)
222219

223220

224-
def literal_data(rawtext, app, type, slug, options): # noqa: U100
221+
def literal_data(rawtext, app, of_type, slug, options): # noqa: ARG001
225222
"""Create a link to a BitBucket resource."""
226-
of_class = type.split(".")
223+
of_class = of_type.split(".")
227224
data = getattr(__import__(".".join(of_class[:-1]), fromlist=[of_class[-1]]), of_class[-1])
228225
return [n.literal("", text=",".join(data))], []
229226

pyproject.toml

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
build-backend = "hatchling.build"
33
requires = [
44
"hatch-vcs>=0.3",
5-
"hatchling>=1.14",
5+
"hatchling>=1.17.1",
66
]
77

88
[project]
@@ -24,8 +24,13 @@ classifiers = [
2424
"Operating System :: MacOS :: MacOS X",
2525
"Operating System :: Microsoft :: Windows",
2626
"Operating System :: POSIX",
27-
"Programming Language :: Python :: 3",
2827
"Programming Language :: Python :: 3 :: Only",
28+
"Programming Language :: Python :: 3.7",
29+
"Programming Language :: Python :: 3.8",
30+
"Programming Language :: Python :: 3.9",
31+
"Programming Language :: Python :: 3.10",
32+
"Programming Language :: Python :: 3.11",
33+
"Programming Language :: Python :: 3.12",
2934
"Programming Language :: Python :: Implementation :: CPython",
3035
"Programming Language :: Python :: Implementation :: PyPy",
3136
"Topic :: Software Development :: Libraries",
@@ -37,31 +42,31 @@ dynamic = [
3742
]
3843
dependencies = [
3944
"distlib<1,>=0.3.6",
40-
"filelock<4,>=3.11",
41-
'importlib-metadata>=6.4.1; python_version < "3.8"',
42-
"platformdirs<4,>=3.2",
45+
"filelock<4,>=3.12",
46+
'importlib-metadata>=6.6; python_version < "3.8"',
47+
"platformdirs<4,>=3.5.1",
4348
]
4449
optional-dependencies.docs = [
45-
"furo>=2023.3.27",
50+
"furo>=2023.5.20",
4651
"proselint>=0.13",
47-
"sphinx>=6.1.3",
52+
"sphinx>=7.0.1",
4853
"sphinx-argparse>=0.4",
4954
"sphinxcontrib-towncrier>=0.2.1a0",
50-
"towncrier>=22.12",
55+
"towncrier>=23.6",
5156
]
5257
optional-dependencies.test = [
5358
"covdefaults>=2.3",
54-
"coverage>=7.2.3",
59+
"coverage>=7.2.7",
5560
"coverage-enable-subprocess>=1",
5661
"flaky>=3.7",
5762
"packaging>=23.1",
5863
"pytest>=7.3.1",
5964
"pytest-env>=0.8.1",
60-
'pytest-freezer>=0.4.2; platform_python_implementation == "PyPy"',
65+
'pytest-freezer>=0.4.6; platform_python_implementation == "PyPy"',
6166
"pytest-mock>=3.10",
6267
"pytest-randomly>=3.12",
6368
"pytest-timeout>=2.1",
64-
"setuptools>=67.7.1",
69+
"setuptools>=67.8",
6570
'time-machine>=2.9; platform_python_implementation == "CPython"',
6671
]
6772
urls.Documentation = "https://virtualenv.pypa.io"
@@ -98,23 +103,6 @@ version.source = "vcs"
98103
[tool.black]
99104
line-length = 120
100105

101-
[tool.isort]
102-
profile = "black"
103-
known_first_party = ["virtualenv"]
104-
add_imports = ["from __future__ import annotations"]
105-
106-
[tool.flake8]
107-
max-complexity = 22
108-
max-line-length = 120
109-
unused-arguments-ignore-abstract-functions = true
110-
noqa-require-code = true
111-
dictionaries = ["en_US", "python", "technical", "django"]
112-
ignore = [
113-
"E203", # whitespace before ':'
114-
"C901", # is too complex
115-
"W503", # line break before binary operator
116-
]
117-
118106
[tool.pytest.ini_options]
119107
markers = ["slow"]
120108
timeout = 600
@@ -139,13 +127,35 @@ run.parallel = true
139127
run.plugins = ["covdefaults"]
140128
run.relative_files = true
141129

142-
[tool.pep8]
143-
max-line-length = "120"
144-
145130
[tool.towncrier]
146131
name = "tox"
147132
filename = "docs/changelog.rst"
148133
directory = "docs/changelog"
149134
title_format = false
150135
issue_format = ":issue:`{issue}`"
151136
template = "docs/changelog/template.jinja2"
137+
138+
[tool.ruff]
139+
select = ["ALL"]
140+
line-length = 120
141+
target-version = "py37"
142+
isort = {known-first-party = ["virtualenv"], required-imports = ["from __future__ import annotations"]}
143+
ignore = [
144+
"ANN", # no type checking added yet
145+
"D10", # no docstrings
146+
"D40", # no imperative mode for docstrings
147+
"PTH", # no pathlib, <=39 has problems on Windows with absolute/resolve, can revisit once we no longer need 39
148+
"INP001", # ignore implicit namespace packages
149+
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
150+
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
151+
"S104", # Possible binding to all interface
152+
]
153+
[tool.ruff.per-file-ignores]
154+
"tests/**/*.py" = [
155+
"S101", # asserts allowed in tests...
156+
"FBT", # don"t care about booleans as positional arguments in tests
157+
"INP001", # no implicit namespace
158+
"D", # don"t care about documentation in tests
159+
"S603", # `subprocess` call: check for execution of untrusted input
160+
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
161+
]

0 commit comments

Comments
 (0)