Skip to content

Commit a983bd0

Browse files
committed
refactor: define internal vars for each tag class
1 parent b679a79 commit a983bd0

File tree

1 file changed

+37
-33
lines changed

1 file changed

+37
-33
lines changed

python/private/python.bzl

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -297,18 +297,14 @@ def _get_bazel_version_specific_kwargs():
297297

298298
return kwargs
299299

300-
python = module_extension(
301-
doc = """Bzlmod extension that is used to register Python toolchains.
302-
""",
303-
implementation = _python_impl,
304-
tag_classes = {
305-
"rules_python_private_testing": tag_class(
306-
attrs = {
307-
"register_all_versions": attr.bool(default = False),
308-
},
309-
),
310-
"toolchain": tag_class(
311-
doc = """Tag class used to register Python toolchains.
300+
_rules_python_private_testing = tag_class(
301+
attrs = {
302+
"register_all_versions": attr.bool(default = False),
303+
},
304+
)
305+
306+
_toolchain = tag_class(
307+
doc = """Tag class used to register Python toolchains.
312308
Use this tag class to register one or more Python toolchains. This class
313309
is also potentially called by sub modules. The following covers different
314310
business rules and use cases.
@@ -338,14 +334,14 @@ A toolchain's repository name uses the format `python_{major}_{minor}`, e.g.
338334
`python_3_10`. The `major` and `minor` components are
339335
`major` and `minor` are the Python version from the `python_version` attribute.
340336
""",
341-
attrs = {
342-
"configure_coverage_tool": attr.bool(
343-
mandatory = False,
344-
doc = "Whether or not to configure the default coverage tool for the toolchains.",
345-
),
346-
"ignore_root_user_error": attr.bool(
347-
default = False,
348-
doc = """\
337+
attrs = {
338+
"configure_coverage_tool": attr.bool(
339+
mandatory = False,
340+
doc = "Whether or not to configure the default coverage tool for the toolchains.",
341+
),
342+
"ignore_root_user_error": attr.bool(
343+
default = False,
344+
doc = """\
349345
If False, the Python runtime installation will be made read only. This improves
350346
the ability for Bazel to cache it, but prevents the interpreter from creating
351347
pyc files for the standard library dynamically at runtime as they are loaded.
@@ -355,21 +351,29 @@ interpreter to create pyc files for the standard library, but, because they are
355351
created as needed, it adversely affects Bazel's ability to cache the runtime and
356352
can result in spurious build failures.
357353
""",
358-
mandatory = False,
359-
),
360-
"is_default": attr.bool(
361-
mandatory = False,
362-
doc = "Whether the toolchain is the default version",
363-
),
364-
"python_version": attr.string(
365-
mandatory = True,
366-
doc = "The Python version, in `major.minor` format, e.g " +
367-
"'3.12', to create a toolchain for. Patch level " +
368-
"granularity (e.g. '3.12.1') is not supported.",
369-
),
370-
},
354+
mandatory = False,
355+
),
356+
"is_default": attr.bool(
357+
mandatory = False,
358+
doc = "Whether the toolchain is the default version",
359+
),
360+
"python_version": attr.string(
361+
mandatory = True,
362+
doc = "The Python version, in `major.minor` format, e.g " +
363+
"'3.12', to create a toolchain for. Patch level " +
364+
"granularity (e.g. '3.12.1') is not supported.",
371365
),
372366
},
367+
)
368+
369+
python = module_extension(
370+
doc = """Bzlmod extension that is used to register Python toolchains.
371+
""",
372+
implementation = _python_impl,
373+
tag_classes = {
374+
"rules_python_private_testing": _rules_python_private_testing,
375+
"toolchain": _toolchain,
376+
},
373377
**_get_bazel_version_specific_kwargs()
374378
)
375379

0 commit comments

Comments
 (0)