MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / tox_parameters

Function tox_parameters

tools/toxnox.py:27–177  ·  view source on GitHub ↗

r"""Decorator to create a parameter/tagging structure for a nox session function that acts to a large degree like tox's generative environments. The output is a ``nox.parametrize()`` decorator that's built up from individual ``nox.param()`` instances. :param names: names of the par

(
    names: Sequence[str],
    token_lists: Sequence[Sequence[str]],
    *,
    base_tag: str | None = None,
    filter_: Callable[..., bool] | None = None,
    always_include_in_tag: Sequence[str] | None = None,
)

Source from the content-addressed store, hash-verified

25
26
27def tox_parameters(
28 names: Sequence[str],
29 token_lists: Sequence[Sequence[str]],
30 *,
31 base_tag: str | None = None,
32 filter_: Callable[..., bool] | None = None,
33 always_include_in_tag: Sequence[str] | None = None,
34) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
35 r"""Decorator to create a parameter/tagging structure for a nox session
36 function that acts to a large degree like tox's generative environments.
37
38 The output is a ``nox.parametrize()`` decorator that's built up from
39 individual ``nox.param()`` instances.
40
41 :param names: names of the parameters sent to the session function.
42 These names go straight to the first argument of ``nox.parametrize()``
43 and should all match argument names accepted by the decorated function
44 (except for ``python``, which is optional).
45 :param token_lists: a sequence of lists of values for each parameter. a
46 ``nox.param()`` will be created for the full product of these values,
47 minus those filtered out using the ``filter_`` callable. These tokens
48 are used to create the args, tags, and ids of each ``nox.param()``. The
49 list of tags will be generated out including all values for a parameter
50 joined by ``-``, as well as combinations that include a subset of those
51 values, where the omitted elements of the tag are implicitly considered to
52 match the "default" value, indicated by them being first in their
53 collection (with the exception of "python", where the current python in
54 use is the default). Additionally, values that start with an underscore
55 are omitted from all ids and tags. Values that refer to Python versions
56 wlil be expanded to the full Python executable name when passed as
57 arguments to the session function, which is currently a workaround to
58 allow free-threaded python interpreters to be located.
59 :param base_tag: optional tag that will be appended to all tags generated,
60 e.g. if the decorator yields tags like ``python314-x86-windows``, a
61 ``basetag`` value of ``all`` would yield the
62 tag as ``python314-x86-windows-all``.
63 :param filter\_: optional filtering function, must accept keyword arguments
64 matching the names in ``names``. Returns True or False indicating if
65 a certain tag combination should be included.
66 :param always_include_in_tag: list of names from ``names`` that indicate
67 parameters that should always be part of all tags, and not be omitted
68 as a "default"
69
70
71 """
72
73 PY_RE = re.compile(r"(?:python)?([234]\.\d+(t?))")
74
75 def _is_py_version(token: str) -> bool:
76 return bool(PY_RE.match(token))
77
78 def _python_to_tag(token: str) -> str:
79 m = PY_RE.match(token)
80 if m:
81 return f"py{m.group(1).replace('.', '')}"
82 else:
83 return token
84

Callers

nothing calls this directly

Calls 2

_recur_paramFunction · 0.85
compileMethod · 0.45

Tested by

no test coverage detected