Skip to content

Commit b8f138a

Browse files
committed
fix: changelog and update test list
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 0123251 commit b8f138a

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

docs/changelog/3446.feature.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add a ``schema`` command to produce a JSON Schema for tox and the current plugins.
2+
3+
- by :user:`henryiii`

src/tox/session/cmd/schema.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import sys
77
import typing
88
from pathlib import Path
9-
from types import NoneType
109
from typing import TYPE_CHECKING
1110

1211
import packaging.requirements
@@ -39,7 +38,7 @@ def _process_type(of_type: typing.Any) -> dict[str, typing.Any]: # noqa: C901,
3938
}:
4039
return {"type": "string"}
4140
if typing.get_origin(of_type) is typing.Union:
42-
types = [x for x in typing.get_args(of_type) if x is not NoneType]
41+
types = [x for x in typing.get_args(of_type) if x is not type(None)]
4342
if len(types) == 1:
4443
return _process_type(types[0])
4544
msg = f"Union types are not supported: {of_type}"
@@ -95,7 +94,7 @@ def gen_schema(state: State) -> int:
9594
strict = state.conf.options.strict
9695

9796
# Accessing this adds extra stuff to core, so we need to do it first
98-
env_properties = _get_schema(state.envs["3.13"].conf, path="#/properties/env_run_base/properties")
97+
env_properties = _get_schema(state.envs["py"].conf, path="#/properties/env_run_base/properties")
9998

10099
properties = _get_schema(core, path="#/properties")
101100

tests/config/cli/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from tox.session.cmd.quickstart import quickstart
1313
from tox.session.cmd.run.parallel import run_parallel
1414
from tox.session.cmd.run.sequential import run_sequential
15+
from tox.session.cmd.schema import gen_schema
1516
from tox.session.cmd.show_config import show_config
1617

1718
if TYPE_CHECKING:
@@ -23,6 +24,7 @@ def core_handlers() -> dict[str, Callable[[State], int]]:
2324
return {
2425
"config": show_config,
2526
"c": show_config,
27+
"schema": gen_schema,
2628
"list": list_env,
2729
"l": list_env,
2830
"run": run_sequential,

tests/session/cmd/test_schema.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from __future__ import annotations
2+
3+
import json
4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from pathlib import Path
8+
9+
from tox.pytest import MonkeyPatch, ToxProjectCreator
10+
11+
12+
def test_show_schema_empty_dir(tox_project: ToxProjectCreator, monkeypatch: MonkeyPatch, tmp_path: Path) -> None:
13+
monkeypatch.chdir(tmp_path)
14+
15+
project = tox_project({})
16+
result = project.run("-qq", "schema")
17+
schema = json.loads(result.out)
18+
assert "properties" in schema
19+
assert "tox_root" in schema["properties"]
20+

0 commit comments

Comments
 (0)