Skip to content

Commit dbb6873

Browse files
committed
refactor: use Schema.from_dict in from_deps transforms
1 parent ff6fd62 commit dbb6873

1 file changed

Lines changed: 40 additions & 40 deletions

File tree

src/taskgraph/transforms/from_deps.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,46 @@
2222
from taskgraph.util.schema import Schema, validate_schema
2323
from taskgraph.util.set_name import SET_NAME_MAP
2424

25-
26-
class FromDepsConfig(Schema):
27-
# Limit dependencies to specified kinds (defaults to all kinds in
28-
# `kind-dependencies`).
29-
#
30-
# The first kind in the list is the "primary" kind. The
31-
# dependency of this kind will be used to derive the label
32-
# and copy attributes (if `copy-attributes` is True).
33-
kinds: Optional[list[str]] = None
34-
# Set-name function (dynamic: validated at runtime against SET_NAME_MAP).
35-
set_name: Optional[Union[bool, str, dict[str, object]]] = None
36-
# Limit dependencies to tasks whose attributes match
37-
# using :func:`~taskgraph.util.attributes.attrmatch`.
38-
with_attributes: Optional[dict[str, Union[list, str]]] = None
39-
# Group cross-kind dependencies using the given group-by
40-
# function. One task will be created for each group. If not
41-
# specified, the 'single' function will be used which creates
42-
# a new task for each individual dependency.
43-
group_by: Optional[Union[str, dict[str, object]]] = None
44-
# If True, copy attributes from the dependency matching the
45-
# first kind in the `kinds` list (whether specified explicitly
46-
# or taken from `kind-dependencies`).
47-
copy_attributes: Optional[bool] = None
48-
# If true (the default), there must be only a single unique task
49-
# for each kind in a dependency group. Setting this to false
50-
# disables that requirement.
51-
unique_kinds: Optional[bool] = None
52-
# If present, a `fetches` entry will be added for each task
53-
# dependency. Attributes of the upstream task may be used as
54-
# substitution values in the `artifact` or `dest` values of the
55-
# `fetches` entry.
56-
fetches: Optional[dict[str, list[FetchesEntrySchema]]] = None
57-
58-
59-
#: Schema for from_deps transforms
60-
class FromDepsSchema(Schema, forbid_unknown_fields=False, kw_only=True):
61-
from_deps: FromDepsConfig
62-
63-
64-
FROM_DEPS_SCHEMA = FromDepsSchema
25+
FROM_DEPS_SCHEMA = Schema.from_dict(
26+
{
27+
"from-deps": Schema.from_dict(
28+
{
29+
# Limit dependencies to specified kinds (defaults to all kinds in
30+
# `kind-dependencies`).
31+
#
32+
# The first kind in the list is the "primary" kind. The
33+
# dependency of this kind will be used to derive the label
34+
# and copy attributes (if `copy-attributes` is True).
35+
"kinds": Optional[list[str]],
36+
# Set-name function (dynamic: validated at runtime against SET_NAME_MAP).
37+
"set-name": Optional[Union[bool, str, dict[str, object]]],
38+
# Limit dependencies to tasks whose attributes match
39+
# using :func:`~taskgraph.util.attributes.attrmatch`.
40+
"with-attributes": Optional[dict[str, Union[list, str]]],
41+
# Group cross-kind dependencies using the given group-by
42+
# function. One task will be created for each group. If not
43+
# specified, the 'single' function will be used which creates
44+
# a new task for each individual dependency.
45+
"group-by": Optional[Union[str, dict[str, object]]],
46+
# If True, copy attributes from the dependency matching the
47+
# first kind in the `kinds` list (whether specified explicitly
48+
# or taken from `kind-dependencies`).
49+
"copy-attributes": Optional[bool],
50+
# If true (the default), there must be only a single unique task
51+
# for each kind in a dependency group. Setting this to false
52+
# disables that requirement.
53+
"unique-kinds": Optional[bool],
54+
# If present, a `fetches` entry will be added for each task
55+
# dependency. Attributes of the upstream task may be used as
56+
# substitution values in the `artifact` or `dest` values of the
57+
# `fetches` entry.
58+
"fetches": Optional[dict[str, list[FetchesEntrySchema]]],
59+
},
60+
),
61+
},
62+
name="FromDepsSchema",
63+
forbid_unknown_fields=False,
64+
)
6565

6666
transforms = TransformSequence()
6767
transforms.add_validate(FROM_DEPS_SCHEMA)

0 commit comments

Comments
 (0)