Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tox-dev/tox
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4.8.0
Choose a base ref
...
head repository: tox-dev/tox
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4.9.0
Choose a head ref
  • 3 commits
  • 36 files changed
  • 4 contributors

Commits on Aug 14, 2023

  1. Disallow command line environments which are not explicitly specified…

    … in the config file (#3089)
    
    Co-authored-by: Bernát Gábor <bgabor8@bloomberg.net>
    tjsmart and gaborbernat authored Aug 14, 2023
    Copy the full SHA
    2124458 View commit details

Commits on Aug 15, 2023

  1. [pre-commit.ci] pre-commit autoupdate (#3091)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    pre-commit-ci[bot] authored Aug 15, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    6ca8d9b View commit details

Commits on Aug 16, 2023

  1. release 4.9.0

    jugmac00 committed Aug 16, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    3627f11 View commit details
Showing with 207 additions and 169 deletions.
  1. +1 −2 .github/workflows/check.yml
  2. +3 −3 .pre-commit-config.yaml
  3. +8 −0 docs/changelog.rst
  4. +16 −0 docs/user_guide.rst
  5. +13 −14 pyproject.toml
  6. +1 −6 src/tox/config/cli/parser.py
  7. +7 −3 src/tox/config/loader/api.py
  8. +1 −8 src/tox/config/loader/convert.py
  9. +1 −1 src/tox/config/loader/ini/replace.py
  10. +10 −4 src/tox/config/loader/section.py
  11. +9 −8 src/tox/config/of_type.py
  12. +10 −7 src/tox/config/types.py
  13. +8 −1 src/tox/execute/local_sub_process/read_via_thread.py
  14. +7 −1 src/tox/execute/stream.py
  15. +1 −5 src/tox/provision.py
  16. +21 −29 src/tox/pytest.py
  17. +3 −3 src/tox/session/cmd/run/single.py
  18. +13 −4 src/tox/session/env_select.py
  19. +1 −5 src/tox/tox_env/python/virtual_env/package/cmd_builder.py
  20. +1 −4 src/tox/tox_env/python/virtual_env/package/pyproject.py
  21. +1 −5 tests/config/loader/ini/replace/conftest.py
  22. +1 −4 tests/config/loader/test_str_convert.py
  23. +1 −5 tests/config/test_set_env.py
  24. +5 −13 tests/conftest.py
  25. +7 −10 tests/demo_pkg_inline/build.py
  26. +5 −5 tests/execute/local_subprocess/test_local_subprocess.py
  27. +10 −1 tests/plugin/test_plugin.py
  28. +1 −1 tests/session/cmd/test_devenv.py
  29. +1 −1 tests/session/cmd/test_parallel.py
  30. +2 −2 tests/session/cmd/test_sequential.py
  31. +32 −0 tests/session/test_env_select.py
  32. +1 −4 tests/test_provision.py
  33. +1 −3 tests/tox_env/python/virtual_env/package/conftest.py
  34. +1 −1 tests/tox_env/python/virtual_env/package/test_package_pyproject.py
  35. +1 −4 tests/tox_env/python/virtual_env/package/test_python_package_util.py
  36. +2 −2 tox.ini
3 changes: 1 addition & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -18,12 +18,11 @@ jobs:
fail-fast: false
matrix:
py:
- "3.12.0-beta.2"
- "3.12.0-rc.1"
- "3.11"
- "3.10"
- "3.9"
- "3.8"
- "3.7"
os:
- ubuntu-latest
- windows-latest
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -14,10 +14,10 @@ repos:
- id: tox-ini-fmt
args: ["-p", "fix"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "0.13.0"
rev: "0.13.1"
hooks:
- id: pyproject-fmt
additional_dependencies: ["tox>=4.6.4"]
additional_dependencies: ["tox>=4.8"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.1"
hooks:
@@ -29,7 +29,7 @@ repos:
- id: blacken-docs
additional_dependencies: [black==23.7]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.282"
rev: "v0.0.284"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
8 changes: 8 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -4,6 +4,14 @@ Release History

.. towncrier release notes start
v4.9.0 (2023-08-16)
-------------------

Features - 4.9.0
~~~~~~~~~~~~~~~~
- Disallow command line environments which are not explicitly specified in the config file - by :user:`tjsmart`. (:issue:`2858`)


v4.8.0 (2023-08-12)
-------------------

16 changes: 16 additions & 0 deletions docs/user_guide.rst
Original file line number Diff line number Diff line change
@@ -541,3 +541,19 @@ create your virtual env for the developers.
py310-lint -> [no description]
py311-black -> [no description]
py311-lint -> [no description]
Disallow command line environments which are not explicitly specified in the config file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previously, any environment would be implicitly created even if no such environment was specified in the configuration
file.For example, given this config:

.. code-block:: ini
[testenv:unit]
deps = pytest
commands = pytest
Running ``tox -e unit`` would run our tests but running ``tox -e unt`` or ``tox -e unti`` would ultimately succeed
without running any tests. A special exception is made for environments starting in ``py*``. In the above example
running ``tox -e py310`` would still function as intended.
27 changes: 13 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
build-backend = "hatchling.build"
requires = [
"hatch-vcs>=0.3",
"hatchling>=1.17.1",
"hatchling>=1.18",
]

[project]
@@ -24,7 +24,7 @@ maintainers = [
{ name = "Oliver Bestwalter", email = "oliver@bestwalter.de" },
]
authors = [{ name = "Bernát Gábor", email = "gaborjbernat@gmail.com" }]
requires-python = ">=3.7"
requires-python = ">=3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Framework :: tox",
@@ -34,7 +34,6 @@ classifiers = [
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"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",
@@ -49,23 +48,23 @@ dynamic = [
]
dependencies = [
"cachetools>=5.3.1",
"chardet>=5.1",
"chardet>=5.2",
"colorama>=0.4.6",
"filelock>=3.12.2",
'importlib-metadata>=6.7; python_version < "3.8"',
'importlib-metadata>=6.8; python_version < "3.8"',
"packaging>=23.1",
"platformdirs>=3.9.1",
"platformdirs>=3.10",
"pluggy>=1.2",
"pyproject-api>=1.5.3",
'tomli>=2.0.1; python_version < "3.11"',
'typing-extensions>=4.7.1; python_version < "3.8"',
"virtualenv>=20.24.1",
"virtualenv>=20.24.3",
]
optional-dependencies.docs = [
"furo>=2023.5.20",
"sphinx>=7.0.1",
"furo>=2023.7.26",
"sphinx>=7.1.2",
"sphinx-argparse-cli>=1.11.1",
"sphinx-autodoc-typehints!=1.23.4,>=1.23.3",
"sphinx-autodoc-typehints!=1.23.4,>=1.24",
"sphinx-copybutton>=0.5.2",
"sphinx-inline-tabs>=2023.4.21",
"sphinxcontrib-towncrier>=0.2.1a0",
@@ -80,15 +79,15 @@ optional-dependencies.testing = [
"distlib>=0.3.7",
"flaky>=3.7",
"hatch-vcs>=0.3",
"hatchling>=1.17.1",
"hatchling>=1.18",
"psutil>=5.9.5",
"pytest>=7.4",
"pytest-cov>=4.1",
"pytest-mock>=3.11.1",
"pytest-xdist>=3.3.1",
"re-assert>=1.1",
'time-machine>=2.10; implementation_name != "pypy"',
"wheel>=0.40",
'time-machine>=2.12; implementation_name != "pypy"',
"wheel>=0.41.1",
]
urls.Documentation = "https://tox.wiki"
urls.Homepage = "http://tox.readthedocs.org"
@@ -109,7 +108,7 @@ line-length = 120
[tool.ruff]
select = ["ALL"]
line-length = 120
target-version = "py37"
target-version = "py38"
isort = {known-first-party = ["tox", "tests"], required-imports = ["from __future__ import annotations"]}
ignore = [
"INP001", # no implicit namespaces here
7 changes: 1 addition & 6 deletions src/tox/config/cli/parser.py
Original file line number Diff line number Diff line change
@@ -7,19 +7,14 @@
import sys
from argparse import SUPPRESS, Action, ArgumentDefaultsHelpFormatter, ArgumentParser, Namespace
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Sequence, Tuple, Type, TypeVar, cast
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Literal, Optional, Sequence, Tuple, Type, TypeVar, cast

from tox.config.loader.str_convert import StrConvert
from tox.plugin import NAME

from .env_var import get_env_var
from .ini import IniConfig

if sys.version_info >= (3, 8): # pragma: no cover (py38+)
from typing import Literal
else: # pragma: no cover (py38+)
from typing_extensions import Literal

if TYPE_CHECKING:
from tox.session.state import State

10 changes: 7 additions & 3 deletions src/tox/config/loader/api.py
Original file line number Diff line number Diff line change
@@ -38,12 +38,16 @@ def __repr__(self) -> str:
def __str__(self) -> str:
return f"{self.namespace}{'.' if self.namespace else ''}{self.key}={self.value}"

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
if type(self) != type(other):
return False
return (self.namespace, self.key, self.value) == (other.namespace, other.key, other.value)
return (self.namespace, self.key, self.value) == (
other.namespace, # type: ignore[attr-defined]
other.key, # type: ignore[attr-defined]
other.value, # type: ignore[attr-defined]
)

def __ne__(self, other: Any) -> bool:
def __ne__(self, other: object) -> bool:
return not (self == other)


9 changes: 1 addition & 8 deletions src/tox/config/loader/convert.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
from __future__ import annotations

import sys
from abc import ABC, abstractmethod
from collections import OrderedDict
from pathlib import Path
from typing import Any, Callable, Dict, Generic, Iterator, List, Optional, Set, TypeVar, Union, cast
from typing import Any, Callable, Dict, Generic, Iterator, List, Literal, Optional, Set, TypeVar, Union, cast

from tox.config.types import Command, EnvList

if sys.version_info >= (3, 8): # pragma: no cover (py38+)
from typing import Literal
else: # pragma: no cover (py38+)
from typing_extensions import Literal


_NO_MAPPING = object()
T = TypeVar("T")
V = TypeVar("V")
2 changes: 1 addition & 1 deletion src/tox/config/loader/ini/replace.py
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ def __init__(self, expr: Sequence[MatchArg], term_pos: int | None = None) -> Non
def __repr__(self) -> str:
return f"MatchExpression(expr={self.expr!r}, term_pos={self.term_pos!r})"

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
if isinstance(other, type(self)):
return self.expr == other.expr
return NotImplemented
14 changes: 10 additions & 4 deletions src/tox/config/loader/section.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
from __future__ import annotations

from typing import Any, TypeVar
from typing import TYPE_CHECKING

_Section = TypeVar("_Section", bound="Section")
if TYPE_CHECKING:
import sys

if sys.version_info >= (3, 11): # pragma: no cover (py311+)
from typing import Self
else: # pragma: no cover (<py311)
from typing_extensions import Self


class Section:
@@ -15,7 +21,7 @@ def __init__(self, prefix: str | None, name: str) -> None:
self._name = name

@classmethod
def from_key(cls: type[_Section], key: str) -> _Section:
def from_key(cls: type[Self], key: str) -> Self:
"""
Create a section from a section key.
@@ -50,7 +56,7 @@ def __str__(self) -> str:
def __repr__(self) -> str:
return f"{self.__class__.__name__}(prefix={self._prefix!r}, name={self._name!r})"

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
return isinstance(other, self.__class__) and (self._prefix, self._name) == (
other._prefix,
other.name,
17 changes: 9 additions & 8 deletions src/tox/config/of_type.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

from abc import ABC, abstractmethod
from itertools import product
from typing import TYPE_CHECKING, Any, Callable, Generic, Iterable, TypeVar, cast
from typing import TYPE_CHECKING, Callable, Generic, Iterable, TypeVar, cast

from tox.config.loader.api import ConfigLoadArgs, Loader

@@ -27,10 +27,10 @@ def __init__(self, keys: Iterable[str], desc: str) -> None:
def __call__(self, conf: Config, loaders: list[Loader[T]], args: ConfigLoadArgs) -> T:
raise NotImplementedError

def __eq__(self, o: Any) -> bool:
return type(self) == type(o) and (self.keys, self.desc) == (o.keys, o.desc)
def __eq__(self, o: object) -> bool:
return type(self) == type(o) and (self.keys, self.desc) == (o.keys, o.desc) # type: ignore[attr-defined]

def __ne__(self, o: Any) -> bool:
def __ne__(self, o: object) -> bool:
return not (self == o)


@@ -54,8 +54,8 @@ def __call__(
) -> T:
return self.value() if callable(self.value) else self.value

def __eq__(self, o: Any) -> bool:
return type(self) == type(o) and super().__eq__(o) and self.value == o.value
def __eq__(self, o: object) -> bool:
return type(self) == type(o) and super().__eq__(o) and self.value == o.value # type: ignore[attr-defined]


_PLACE_HOLDER = object()
@@ -112,11 +112,12 @@ def __repr__(self) -> str:
values = ((k, v) for k, v in vars(self).items() if k != "post_process" and v is not None)
return f"{type(self).__name__}({', '.join(f'{k}={v}' for k, v in values)})"

def __eq__(self, o: Any) -> bool:
def __eq__(self, o: object) -> bool:
return (
type(self) == type(o)
and super().__eq__(o)
and (self.of_type, self.default, self.post_process) == (o.of_type, o.default, o.post_process)
and (self.of_type, self.default, self.post_process)
== (o.of_type, o.default, o.post_process) # type: ignore[attr-defined]
)


17 changes: 10 additions & 7 deletions src/tox/config/types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections import OrderedDict
from typing import Any, Iterator, Sequence
from typing import Iterator, Sequence

from tox.execute.request import shell_cmd

@@ -21,10 +21,13 @@ def __init__(self, args: list[str]) -> None:
def __repr__(self) -> str:
return f"{type(self).__name__}(args={(['-'] if self.ignore_exit_code else [])+ self.args!r})"

def __eq__(self, other: Any) -> bool:
return type(self) == type(other) and (self.args, self.ignore_exit_code) == (other.args, other.ignore_exit_code)
def __eq__(self, other: object) -> bool:
return type(self) == type(other) and (self.args, self.ignore_exit_code) == (
other.args, # type: ignore[attr-defined]
other.ignore_exit_code, # type: ignore[attr-defined]
)

def __ne__(self, other: Any) -> bool:
def __ne__(self, other: object) -> bool:
return not (self == other)

@property
@@ -47,10 +50,10 @@ def __init__(self, envs: Sequence[str]) -> None:
def __repr__(self) -> str:
return f"{type(self).__name__}({self.envs!r})"

def __eq__(self, other: Any) -> bool:
return type(self) == type(other) and self.envs == other.envs
def __eq__(self, other: object) -> bool:
return type(self) == type(other) and self.envs == other.envs # type: ignore[attr-defined]

def __ne__(self, other: Any) -> bool:
def __ne__(self, other: object) -> bool:
return not (self == other)

def __iter__(self) -> Iterator[str]:
9 changes: 8 additions & 1 deletion src/tox/execute/local_sub_process/read_via_thread.py
Original file line number Diff line number Diff line change
@@ -6,8 +6,15 @@
from typing import TYPE_CHECKING, Callable

if TYPE_CHECKING:
import sys
from types import TracebackType

if sys.version_info >= (3, 11): # pragma: no cover (py311+)
from typing import Self
else: # pragma: no cover (<py311)
from typing_extensions import Self


WAIT_GENERAL = 0.05 # stop thread join every so often (give chance to a signal interrupt)


@@ -19,7 +26,7 @@ def __init__(self, file_no: int, handler: Callable[[bytes], None], name: str, dr
self.handler = handler
self._on_exit_drain = drain

def __enter__(self) -> ReadViaThread:
def __enter__(self) -> Self:
self.thread.start()
return self

8 changes: 7 additions & 1 deletion src/tox/execute/stream.py
Original file line number Diff line number Diff line change
@@ -7,8 +7,14 @@
from colorama import Fore

if TYPE_CHECKING:
import sys
from types import TracebackType

if sys.version_info >= (3, 11): # pragma: no cover (py311+)
from typing import Self
else: # pragma: no cover (<py311)
from typing_extensions import Self


class SyncWrite:
"""
@@ -33,7 +39,7 @@ def __init__(self, name: str, target: IO[bytes] | None, color: str | None = None
def __repr__(self) -> str:
return f"{self.__class__.__name__}(name={self.name!r}, target={self._target!r}, color={self._color!r})"

def __enter__(self) -> SyncWrite:
def __enter__(self) -> Self:
if self._target_enabled:
self._start()
return self
Loading