Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ruff, test latest OS and bump setuptools #2588

Merged
merged 3 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
py:
- "3.12.0-alpha.7"
- "3.12.0-beta.2"
- "3.11"
- "3.10"
- "3.9"
Expand All @@ -29,12 +29,12 @@ jobs:
- pypy-3.8
- pypy-3.7
os:
- ubuntu-22.04
- macos-12
- windows-2022
- ubuntu-latest
- macos-latest
- windows-latest
include:
- { os: macos-12, py: "brew@3.9" }
- { os: macos-12, py: "brew@3.8" }
- { os: macos-latest, py: "brew@3.9" }
- { os: macos-latest, py: "brew@3.8" }
steps:
- uses: taiki-e/install-action@cargo-binstall
- name: Install OS dependencies
Expand Down Expand Up @@ -100,17 +100,17 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- windows-2022
- ubuntu-latest
- windows-latest
tox_env:
- dev
- docs
- readme
- upgrade
- zipapp
exclude:
- { os: windows-2022, tox_env: readme }
- { os: windows-2022, tox_env: docs }
- { os: windows-latest, tox_env: readme }
- { os: windows-latest, tox_env: docs }
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
release:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/virtualenv
Expand Down
63 changes: 9 additions & 54 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,33 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: check-merge-conflict
- id: check-yaml
- id: check-toml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.4.0
hooks:
- id: add-trailing-comma
args: [--py36-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: [--safe]
- repo: https://github.com/asottile/blacken-docs
rev: 1.13.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.3]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "1.3.0"
hooks:
- id: tox-ini-fmt
args: ["-p", "fix"]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "0.11.2"
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==23.3.23
- flake8-comprehensions==3.12
- flake8-pytest-style==1.7.2
- flake8-spellcheck==0.28
- flake8-unused-arguments==0.0.13
- flake8-noqa==1.3.1
- pep8-naming==0.13.3
- flake8-pyproject==1.2.3
- id: pyproject-fmt
additional_dependencies: ["tox>=4.6"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1"
rev: "v3.0.0-alpha.9-for-vscode"
hooks:
- id: prettier
additional_dependencies:
- prettier@2.7.1
- "@prettier/plugin-xml@2.2"
args: ["--print-width=120", "--prose-wrap=always"]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.272"
hooks:
- id: markdownlint
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "0.9.2"
hooks:
- id: pyproject-fmt
3 changes: 3 additions & 0 deletions docs/changelog/2588.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Upgrade embedded wheels:

* setuptools to ``67.8.0`` from ``67.7.2``
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import subprocess
import sys
from datetime import date, datetime
from datetime import datetime, timezone
from pathlib import Path

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

extensions = [
"sphinx.ext.autodoc",
Expand All @@ -31,7 +31,7 @@
today_fmt = "%B %d, %Y"

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

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

# the CLI arguments are dynamically generated
Expand Down
41 changes: 19 additions & 22 deletions docs/render_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,14 @@ def a(*args, **kwargs):
prev(*args, **kwargs)
if key == "activators":
return True
elif key == "creator":
if key == "creator":
if name == "venv":
from virtualenv.create.via_global_ref.venv import (
ViaGlobalRefMeta,
)
from virtualenv.create.via_global_ref.venv import ViaGlobalRefMeta

meta = ViaGlobalRefMeta()
meta.symlink_error = None
return meta
from virtualenv.create.via_global_ref.builtin.via_global_self_do import (
BuiltinViaGlobalRefMeta,
)
from virtualenv.create.via_global_ref.builtin.via_global_self_do import BuiltinViaGlobalRefMeta

meta = BuiltinViaGlobalRefMeta()
meta.symlink_error = None
Expand Down Expand Up @@ -126,11 +122,16 @@ def build_rows(options):
for option in options:
names = option["name"]
default = option["default"]
if default is not None:
if isinstance(default, str) and default and default[0] == default[-1] and default[0] == '"':
default = default[1:-1]
if default == SUPPRESS:
default = None
if (
default is not None
and isinstance(default, str)
and default
and default[0] == default[-1]
and default[0] == '"'
):
default = default[1:-1]
if default == SUPPRESS:
default = None
choices = option.get("choices")
key = names[0].strip("-")
if key in CliTable.plugins:
Expand Down Expand Up @@ -176,10 +177,7 @@ def _get_targeted_names(self, row):
@staticmethod
def _get_help_text(row):
name = row.names[0]
if name in ("--creator",):
content = row.help[: row.help.index("(") - 1]
else:
content = row.help
content = row.help[: row.help.index("(") - 1] if name in ("--creator",) else row.help
help_body = n.paragraph("", "", n.Text(content))
if row.choices is not None:
help_body += n.Text("; choice of: ")
Expand Down Expand Up @@ -207,11 +205,10 @@ def _get_default(row):
default_body += n.literal(text="builtin")
default_body += n.Text(" if exist, else ")
default_body += n.literal(text="venv")
elif default is None:
default_body = n.paragraph("", text="")
else:
if default is None:
default_body = n.paragraph("", text="")
else:
default_body = n.literal(text=default if isinstance(default, str) else str(default))
default_body = n.literal(text=default if isinstance(default, str) else str(default))
return default_body

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


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

Expand Down
72 changes: 41 additions & 31 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
build-backend = "hatchling.build"
requires = [
"hatch-vcs>=0.3",
"hatchling>=1.14",
"hatchling>=1.17.1",
]

[project]
Expand All @@ -24,8 +24,13 @@ classifiers = [
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries",
Expand All @@ -37,31 +42,31 @@ dynamic = [
]
dependencies = [
"distlib<1,>=0.3.6",
"filelock<4,>=3.11",
'importlib-metadata>=6.4.1; python_version < "3.8"',
"platformdirs<4,>=3.2",
"filelock<4,>=3.12",
'importlib-metadata>=6.6; python_version < "3.8"',
"platformdirs<4,>=3.5.1",
]
optional-dependencies.docs = [
"furo>=2023.3.27",
"furo>=2023.5.20",
"proselint>=0.13",
"sphinx>=6.1.3",
"sphinx>=7.0.1",
"sphinx-argparse>=0.4",
"sphinxcontrib-towncrier>=0.2.1a0",
"towncrier>=22.12",
"towncrier>=23.6",
]
optional-dependencies.test = [
"covdefaults>=2.3",
"coverage>=7.2.3",
"coverage>=7.2.7",
"coverage-enable-subprocess>=1",
"flaky>=3.7",
"packaging>=23.1",
"pytest>=7.3.1",
"pytest-env>=0.8.1",
'pytest-freezer>=0.4.2; platform_python_implementation == "PyPy"',
'pytest-freezer>=0.4.6; platform_python_implementation == "PyPy"',
"pytest-mock>=3.10",
"pytest-randomly>=3.12",
"pytest-timeout>=2.1",
"setuptools>=67.7.1",
"setuptools>=67.8",
'time-machine>=2.9; platform_python_implementation == "CPython"',
]
urls.Documentation = "https://virtualenv.pypa.io"
Expand Down Expand Up @@ -98,23 +103,6 @@ version.source = "vcs"
[tool.black]
line-length = 120

[tool.isort]
profile = "black"
known_first_party = ["virtualenv"]
add_imports = ["from __future__ import annotations"]

[tool.flake8]
max-complexity = 22
max-line-length = 120
unused-arguments-ignore-abstract-functions = true
noqa-require-code = true
dictionaries = ["en_US", "python", "technical", "django"]
ignore = [
"E203", # whitespace before ':'
"C901", # is too complex
"W503", # line break before binary operator
]

[tool.pytest.ini_options]
markers = ["slow"]
timeout = 600
Expand All @@ -139,13 +127,35 @@ run.parallel = true
run.plugins = ["covdefaults"]
run.relative_files = true

[tool.pep8]
max-line-length = "120"

[tool.towncrier]
name = "tox"
filename = "docs/changelog.rst"
directory = "docs/changelog"
title_format = false
issue_format = ":issue:`{issue}`"
template = "docs/changelog/template.jinja2"

[tool.ruff]
select = ["ALL"]
line-length = 120
target-version = "py37"
isort = {known-first-party = ["virtualenv"], required-imports = ["from __future__ import annotations"]}
ignore = [
"ANN", # no type checking added yet
"D10", # no docstrings
"D40", # no imperative mode for docstrings
"PTH", # no pathlib, <=39 has problems on Windows with absolute/resolve, can revisit once we no longer need 39
"INP001", # ignore implicit namespace packages
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
"S104", # Possible binding to all interface
]
[tool.ruff.per-file-ignores]
"tests/**/*.py" = [
"S101", # asserts allowed in tests...
"FBT", # don"t care about booleans as positional arguments in tests
"INP001", # no implicit namespace
"D", # don"t care about documentation in tests
"S603", # `subprocess` call: check for execution of untrusted input
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
]
Loading