diff --git a/docs/changelog/3446.feature.rst b/docs/changelog/3446.feature.rst new file mode 100644 index 000000000..6edb4c852 --- /dev/null +++ b/docs/changelog/3446.feature.rst @@ -0,0 +1,3 @@ +Add a ``schema`` command to produce a JSON Schema for tox and the current plugins. + +- by :user:`henryiii` diff --git a/src/tox/session/cmd/schema.py b/src/tox/session/cmd/schema.py index 3a4af420e..7bf4b627e 100644 --- a/src/tox/session/cmd/schema.py +++ b/src/tox/session/cmd/schema.py @@ -6,7 +6,6 @@ import sys import typing from pathlib import Path -from types import NoneType from typing import TYPE_CHECKING import packaging.requirements @@ -39,7 +38,7 @@ def _process_type(of_type: typing.Any) -> dict[str, typing.Any]: # noqa: C901, }: return {"type": "string"} if typing.get_origin(of_type) is typing.Union: - types = [x for x in typing.get_args(of_type) if x is not NoneType] + types = [x for x in typing.get_args(of_type) if x is not type(None)] if len(types) == 1: return _process_type(types[0]) msg = f"Union types are not supported: {of_type}" diff --git a/tests/config/cli/conftest.py b/tests/config/cli/conftest.py index d5852bff8..138cdcef5 100644 --- a/tests/config/cli/conftest.py +++ b/tests/config/cli/conftest.py @@ -13,6 +13,7 @@ from tox.session.cmd.run.parallel import run_parallel from tox.session.cmd.run.sequential import run_sequential from tox.session.cmd.show_config import show_config +from tox.session.cmd.schema import gen_schema if TYPE_CHECKING: from tox.session.state import State @@ -23,6 +24,7 @@ def core_handlers() -> dict[str, Callable[[State], int]]: return { "config": show_config, "c": show_config, + "schema": gen_schema, "list": list_env, "l": list_env, "run": run_sequential,