jaymd96-pants-baseline 0.2.4__py3-none-any.whl → 0.2.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {jaymd96_pants_baseline-0.2.4.dist-info → jaymd96_pants_baseline-0.2.5.dist-info}/METADATA +1 -1
- {jaymd96_pants_baseline-0.2.4.dist-info → jaymd96_pants_baseline-0.2.5.dist-info}/RECORD +8 -8
- pants_baseline/__about__.py +1 -1
- pants_baseline/register.py +5 -22
- pants_baseline/rules/fmt_rules.py +37 -52
- pants_baseline/rules/lint_rules.py +38 -44
- {jaymd96_pants_baseline-0.2.4.dist-info → jaymd96_pants_baseline-0.2.5.dist-info}/WHEEL +0 -0
- {jaymd96_pants_baseline-0.2.4.dist-info → jaymd96_pants_baseline-0.2.5.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jaymd96-pants-baseline
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Opinionated Python code quality baseline plugin for Pants build system
|
|
5
5
|
Project-URL: Homepage, https://github.com/jaymd96/pants-baseline
|
|
6
6
|
Project-URL: Repository, https://github.com/jaymd96/pants-baseline.git
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
pants_baseline/__about__.py,sha256=
|
|
1
|
+
pants_baseline/__about__.py,sha256=aRtmXIH9GkUkoHOTtIdKb9mgSqNQenoXYmbXPqXvv2Y,98
|
|
2
2
|
pants_baseline/__init__.py,sha256=uVRGi1D2gFjc7emmeewWdcvpO-NsUuKsMbX3rztOxWU,655
|
|
3
3
|
pants_baseline/bundled_claude_plugins.py,sha256=rHchQRQ_UabOOKyQOxVwoyE2xLjE8eiUFVN7oERDCe0,1608
|
|
4
|
-
pants_baseline/register.py,sha256=
|
|
4
|
+
pants_baseline/register.py,sha256=_ahV7CRNWxv4lUXb03ZBM9vJnP4ekLw8DgnpInVK35o,1078
|
|
5
5
|
pants_baseline/targets.py,sha256=Z9O09Aqd5inMqwIUFt4HSE9HtWjn8pGSU4FZHg22Tpo,3379
|
|
6
6
|
pants_baseline/goals/__init__.py,sha256=pf6KU2CIQuDkx8ER3IS0H-kuNbBtX-AH5B5SnSP9_yw,192
|
|
7
7
|
pants_baseline/goals/audit.py,sha256=i7zyyKssWw6EE2zN5putWP9sikkcjUKn7g3Jrapv994,2380
|
|
@@ -11,8 +11,8 @@ pants_baseline/goals/test.py,sha256=THW4kJAFbAzPCjLbq1dxg81T19QdywXYiwTNKSB4z8M,
|
|
|
11
11
|
pants_baseline/goals/typecheck.py,sha256=nqfwy1BZqhEzlDX-_hme9mKuDI2KqH-XpN4ygzWMQ6Y,2626
|
|
12
12
|
pants_baseline/rules/__init__.py,sha256=UpvDpGVImhRfp2_VeUNsRPGiWjBbMI6AV1-Yx3kS0Gg,252
|
|
13
13
|
pants_baseline/rules/audit_rules.py,sha256=5VzHExJdvB00KrVIAuxlb7pwNfTC0djr5QzF8wXMYws,2906
|
|
14
|
-
pants_baseline/rules/fmt_rules.py,sha256=
|
|
15
|
-
pants_baseline/rules/lint_rules.py,sha256=
|
|
14
|
+
pants_baseline/rules/fmt_rules.py,sha256=uVpm4GXTXEml_dMxZ4hzkWNVjBPEjfK83KhL6QBmDrw,3840
|
|
15
|
+
pants_baseline/rules/lint_rules.py,sha256=U44iqnniHXb-Ayl9_Jmz0apZOrer4vzMd98sLUXDh0k,4413
|
|
16
16
|
pants_baseline/rules/test_rules.py,sha256=Q_opWXkNS2IDSRQmDdYz-PETl9QEXgwaO_iPN4QWHjY,4268
|
|
17
17
|
pants_baseline/rules/typecheck_rules.py,sha256=5jr7S9IPzDQOdO5kwwpn3q6m45GKJVlEDO2FN8wN6Ac,4579
|
|
18
18
|
pants_baseline/subsystems/__init__.py,sha256=LteH_qmUIgRAnXYmmi7f6o894QfpY3hMNH5dlvJbSoM,387
|
|
@@ -20,7 +20,7 @@ pants_baseline/subsystems/baseline.py,sha256=CU8ZhNCJw8BSXSyuvZ1eH-Y2CSPggp2O-I2
|
|
|
20
20
|
pants_baseline/subsystems/ruff.py,sha256=47fQg4fM_qzLGfxb_WFLYT1URL_4VxkJWw7LBOEQyT0,4248
|
|
21
21
|
pants_baseline/subsystems/ty.py,sha256=F9F2YyYlbt1PlvsVP8qMAa_l0C-JezyjiDnBs4RMTIc,3722
|
|
22
22
|
pants_baseline/subsystems/uv.py,sha256=z8gflmuuF0mEN4Bhlp29w2BlrM0M-4cYv7Y0wKhjOnk,3369
|
|
23
|
-
jaymd96_pants_baseline-0.2.
|
|
24
|
-
jaymd96_pants_baseline-0.2.
|
|
25
|
-
jaymd96_pants_baseline-0.2.
|
|
26
|
-
jaymd96_pants_baseline-0.2.
|
|
23
|
+
jaymd96_pants_baseline-0.2.5.dist-info/METADATA,sha256=qUXXXkNLlWGZeRmN4fzqBgfHhnsofaeUvVnsJKnrDOo,8764
|
|
24
|
+
jaymd96_pants_baseline-0.2.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
25
|
+
jaymd96_pants_baseline-0.2.5.dist-info/licenses/LICENSE,sha256=oLGLZv7XKM_oKCbdMW1bZB37SXsdexmhNSuh3Xg4m4I,10754
|
|
26
|
+
jaymd96_pants_baseline-0.2.5.dist-info/RECORD,,
|
pants_baseline/__about__.py
CHANGED
pants_baseline/register.py
CHANGED
|
@@ -2,19 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
This module is the entry point for the Pants plugin system.
|
|
4
4
|
It registers all rules, targets, and subsystems provided by this plugin.
|
|
5
|
+
|
|
6
|
+
This plugin integrates with Pants' built-in lint, fmt, and check goals
|
|
7
|
+
rather than providing custom goals.
|
|
5
8
|
"""
|
|
6
9
|
|
|
7
10
|
from typing import Iterable
|
|
8
11
|
|
|
9
12
|
from pants.engine.rules import Rule
|
|
10
13
|
|
|
11
|
-
from pants_baseline.
|
|
12
|
-
from pants_baseline.goals import fmt as fmt_goal
|
|
13
|
-
from pants_baseline.goals import lint as lint_goal
|
|
14
|
-
from pants_baseline.goals import test as test_goal
|
|
15
|
-
from pants_baseline.goals import typecheck as typecheck_goal
|
|
16
|
-
from pants_baseline.rules import audit_rules, fmt_rules, lint_rules, test_rules, typecheck_rules
|
|
17
|
-
from pants_baseline.subsystems import baseline, ruff, ty, uv
|
|
14
|
+
from pants_baseline.rules import fmt_rules, lint_rules
|
|
18
15
|
from pants_baseline.targets import BaselinePythonProject
|
|
19
16
|
|
|
20
17
|
|
|
@@ -26,23 +23,9 @@ def rules() -> Iterable[Rule]:
|
|
|
26
23
|
rather than using collect_rules() which only collects @rule functions.
|
|
27
24
|
"""
|
|
28
25
|
return [
|
|
29
|
-
#
|
|
30
|
-
*baseline.rules(),
|
|
31
|
-
*ruff.rules(),
|
|
32
|
-
*ty.rules(),
|
|
33
|
-
*uv.rules(),
|
|
34
|
-
# Tool rules
|
|
26
|
+
# Tool rules (integrate with Pants built-in lint/fmt goals)
|
|
35
27
|
*lint_rules.rules(),
|
|
36
28
|
*fmt_rules.rules(),
|
|
37
|
-
*typecheck_rules.rules(),
|
|
38
|
-
*test_rules.rules(),
|
|
39
|
-
*audit_rules.rules(),
|
|
40
|
-
# Goal rules
|
|
41
|
-
*lint_goal.rules(),
|
|
42
|
-
*fmt_goal.rules(),
|
|
43
|
-
*typecheck_goal.rules(),
|
|
44
|
-
*test_goal.rules(),
|
|
45
|
-
*audit_goal.rules(),
|
|
46
29
|
]
|
|
47
30
|
|
|
48
31
|
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"""Rules for Ruff formatting."""
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
-
from typing import Iterable
|
|
4
|
+
from typing import Any, Iterable
|
|
5
5
|
|
|
6
6
|
from pants.core.goals.fmt import FmtResult, FmtTargetsRequest
|
|
7
|
-
from pants.core.util_rules.external_tool import download_external_tool
|
|
7
|
+
from pants.core.util_rules.external_tool import DownloadedExternalTool, download_external_tool
|
|
8
8
|
from pants.core.util_rules.partitions import PartitionerType
|
|
9
|
-
from pants.
|
|
10
|
-
from pants.engine.
|
|
11
|
-
from pants.engine.internals.selectors import concurrently
|
|
12
|
-
from pants.engine.intrinsics import merge_digests, execute_process, digest_to_snapshot
|
|
9
|
+
from pants.engine.fs import Digest, MergeDigests, Snapshot
|
|
10
|
+
from pants.engine.intrinsics import digest_to_snapshot, merge_digests
|
|
13
11
|
from pants.engine.platform import Platform
|
|
14
|
-
from pants.engine.process import Process
|
|
12
|
+
from pants.engine.process import FallibleProcessResult, Process, execute_process_or_raise
|
|
15
13
|
from pants.engine.rules import collect_rules, implicitly, rule
|
|
16
14
|
from pants.engine.target import FieldSet, Target
|
|
17
15
|
from pants.util.logging import LogLevel
|
|
16
|
+
from pants.util.meta import classproperty
|
|
18
17
|
|
|
19
18
|
from pants_baseline.subsystems.baseline import BaselineSubsystem
|
|
20
19
|
from pants_baseline.subsystems.ruff import RuffSubsystem
|
|
@@ -43,57 +42,41 @@ class RuffFmtRequest(FmtTargetsRequest):
|
|
|
43
42
|
tool_subsystem = RuffSubsystem
|
|
44
43
|
partitioner_type = PartitionerType.DEFAULT_SINGLE_PARTITION
|
|
45
44
|
|
|
45
|
+
@classproperty
|
|
46
|
+
def tool_name(cls) -> str:
|
|
47
|
+
return "baseline-ruff-fmt"
|
|
48
|
+
|
|
49
|
+
@classproperty
|
|
50
|
+
def tool_id(cls) -> str:
|
|
51
|
+
return "baseline-ruff-fmt"
|
|
52
|
+
|
|
46
53
|
|
|
47
54
|
@rule(desc="Format with Ruff", level=LogLevel.DEBUG)
|
|
48
55
|
async def run_ruff_fmt(
|
|
49
|
-
request: RuffFmtRequest.Batch,
|
|
56
|
+
request: RuffFmtRequest.Batch[RuffFmtFieldSet, Any],
|
|
50
57
|
ruff_subsystem: RuffSubsystem,
|
|
51
58
|
baseline_subsystem: BaselineSubsystem,
|
|
52
59
|
platform: Platform,
|
|
53
60
|
) -> FmtResult:
|
|
54
61
|
"""Run Ruff formatter on Python files."""
|
|
62
|
+
if ruff_subsystem.skip:
|
|
63
|
+
return FmtResult.skip(request, formatter_name="baseline-ruff-fmt")
|
|
64
|
+
|
|
55
65
|
if not baseline_subsystem.enabled:
|
|
56
|
-
return FmtResult(
|
|
57
|
-
input=request.snapshot,
|
|
58
|
-
output=request.snapshot,
|
|
59
|
-
stdout="",
|
|
60
|
-
stderr="",
|
|
61
|
-
formatter_name="ruff",
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
if not request.elements:
|
|
65
|
-
return FmtResult(
|
|
66
|
-
input=request.snapshot,
|
|
67
|
-
output=request.snapshot,
|
|
68
|
-
stdout="No targets to format",
|
|
69
|
-
stderr="",
|
|
70
|
-
formatter_name="ruff",
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
# Download ruff and get source files in parallel using new intrinsics
|
|
74
|
-
downloaded_ruff_get = download_external_tool(ruff_subsystem.get_request(platform))
|
|
75
|
-
sources_get = SourceFilesRequest(
|
|
76
|
-
sources_fields=[fs.sources for fs in request.elements],
|
|
77
|
-
for_sources_types=(BaselineSourcesField,),
|
|
78
|
-
)
|
|
66
|
+
return FmtResult.skip(request, formatter_name="baseline-ruff-fmt")
|
|
79
67
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
68
|
+
snapshot = request.snapshot
|
|
69
|
+
if not snapshot.files:
|
|
70
|
+
return FmtResult.skip(request, formatter_name="baseline-ruff-fmt")
|
|
84
71
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
stdout="No files to format",
|
|
90
|
-
stderr="",
|
|
91
|
-
formatter_name="ruff",
|
|
92
|
-
)
|
|
72
|
+
# Download ruff
|
|
73
|
+
downloaded_ruff: DownloadedExternalTool = await download_external_tool(
|
|
74
|
+
ruff_subsystem.get_request(platform)
|
|
75
|
+
)
|
|
93
76
|
|
|
94
77
|
# Merge the ruff binary with the source files
|
|
95
|
-
input_digest = await merge_digests(
|
|
96
|
-
MergeDigests([downloaded_ruff.digest,
|
|
78
|
+
input_digest: Digest = await merge_digests(
|
|
79
|
+
MergeDigests([downloaded_ruff.digest, snapshot.digest]),
|
|
97
80
|
)
|
|
98
81
|
|
|
99
82
|
# Build Ruff format command
|
|
@@ -104,26 +87,28 @@ async def run_ruff_fmt(
|
|
|
104
87
|
f"--line-length={baseline_subsystem.line_length}",
|
|
105
88
|
f"--quote-style={ruff_subsystem.quote_style}",
|
|
106
89
|
f"--indent-style={ruff_subsystem.indent_style}",
|
|
107
|
-
*
|
|
90
|
+
*snapshot.files,
|
|
108
91
|
]
|
|
109
92
|
|
|
110
93
|
process = Process(
|
|
111
94
|
argv=argv,
|
|
112
95
|
input_digest=input_digest,
|
|
113
|
-
output_files=
|
|
114
|
-
description=f"Run Ruff format on {len(
|
|
96
|
+
output_files=snapshot.files,
|
|
97
|
+
description=f"Run Ruff format on {len(snapshot.files)} files",
|
|
115
98
|
level=LogLevel.DEBUG,
|
|
116
99
|
)
|
|
117
100
|
|
|
118
|
-
result = await
|
|
119
|
-
|
|
101
|
+
result: FallibleProcessResult = await execute_process_or_raise(
|
|
102
|
+
**implicitly(process)
|
|
103
|
+
)
|
|
104
|
+
output_snapshot: Snapshot = await digest_to_snapshot(result.output_digest)
|
|
120
105
|
|
|
121
106
|
return FmtResult(
|
|
122
|
-
input=
|
|
107
|
+
input=snapshot,
|
|
123
108
|
output=output_snapshot,
|
|
124
109
|
stdout=result.stdout.decode(),
|
|
125
110
|
stderr=result.stderr.decode(),
|
|
126
|
-
formatter_name="ruff",
|
|
111
|
+
formatter_name="baseline-ruff-fmt",
|
|
127
112
|
)
|
|
128
113
|
|
|
129
114
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"""Rules for Ruff linting."""
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
-
from typing import Iterable
|
|
4
|
+
from typing import Any, Iterable
|
|
5
5
|
|
|
6
6
|
from pants.core.goals.lint import LintResult, LintTargetsRequest
|
|
7
|
-
from pants.core.util_rules.external_tool import download_external_tool
|
|
7
|
+
from pants.core.util_rules.external_tool import DownloadedExternalTool, download_external_tool
|
|
8
8
|
from pants.core.util_rules.partitions import PartitionerType
|
|
9
|
-
from pants.core.util_rules.source_files import SourceFiles, SourceFilesRequest
|
|
10
|
-
from pants.engine.fs import MergeDigests
|
|
11
|
-
from pants.engine.
|
|
12
|
-
from pants.engine.intrinsics import merge_digests, execute_process
|
|
9
|
+
from pants.core.util_rules.source_files import SourceFiles, SourceFilesRequest, determine_source_files
|
|
10
|
+
from pants.engine.fs import Digest, MergeDigests
|
|
11
|
+
from pants.engine.intrinsics import merge_digests
|
|
13
12
|
from pants.engine.platform import Platform
|
|
14
|
-
from pants.engine.process import Process
|
|
13
|
+
from pants.engine.process import FallibleProcessResult, Process, execute_process_or_raise
|
|
15
14
|
from pants.engine.rules import collect_rules, implicitly, rule
|
|
16
15
|
from pants.engine.target import FieldSet, Target
|
|
17
16
|
from pants.util.logging import LogLevel
|
|
17
|
+
from pants.util.meta import classproperty
|
|
18
18
|
|
|
19
19
|
from pants_baseline.subsystems.baseline import BaselineSubsystem
|
|
20
20
|
from pants_baseline.subsystems.ruff import RuffSubsystem
|
|
@@ -43,58 +43,50 @@ class RuffLintRequest(LintTargetsRequest):
|
|
|
43
43
|
tool_subsystem = RuffSubsystem
|
|
44
44
|
partitioner_type = PartitionerType.DEFAULT_SINGLE_PARTITION
|
|
45
45
|
|
|
46
|
+
@classproperty
|
|
47
|
+
def tool_name(cls) -> str:
|
|
48
|
+
return "baseline-ruff"
|
|
49
|
+
|
|
50
|
+
@classproperty
|
|
51
|
+
def tool_id(cls) -> str:
|
|
52
|
+
return "baseline-ruff"
|
|
53
|
+
|
|
46
54
|
|
|
47
55
|
@rule(desc="Lint with Ruff", level=LogLevel.DEBUG)
|
|
48
56
|
async def run_ruff_lint(
|
|
49
|
-
request: RuffLintRequest.Batch,
|
|
57
|
+
request: RuffLintRequest.Batch[RuffLintFieldSet, Any],
|
|
50
58
|
ruff_subsystem: RuffSubsystem,
|
|
51
59
|
baseline_subsystem: BaselineSubsystem,
|
|
52
60
|
platform: Platform,
|
|
53
61
|
) -> LintResult:
|
|
54
62
|
"""Run Ruff linter on Python files."""
|
|
63
|
+
if ruff_subsystem.skip:
|
|
64
|
+
return LintResult.create(request, exit_code=0, stdout="", stderr="", strip_chroot_path=True)
|
|
65
|
+
|
|
55
66
|
if not baseline_subsystem.enabled:
|
|
56
|
-
return LintResult(
|
|
57
|
-
exit_code=0,
|
|
58
|
-
stdout="",
|
|
59
|
-
stderr="",
|
|
60
|
-
linter_name="ruff",
|
|
61
|
-
partition_description=None,
|
|
62
|
-
)
|
|
67
|
+
return LintResult.create(request, exit_code=0, stdout="", stderr="", strip_chroot_path=True)
|
|
63
68
|
|
|
64
|
-
field_sets = request.elements
|
|
69
|
+
field_sets = list(request.elements)
|
|
65
70
|
|
|
66
71
|
if not field_sets:
|
|
67
|
-
return LintResult(
|
|
68
|
-
exit_code=0,
|
|
69
|
-
stdout="No targets to lint",
|
|
70
|
-
stderr="",
|
|
71
|
-
linter_name="ruff",
|
|
72
|
-
partition_description=None,
|
|
73
|
-
)
|
|
72
|
+
return LintResult.create(request, exit_code=0, stdout="No targets to lint", stderr="", strip_chroot_path=True)
|
|
74
73
|
|
|
75
|
-
# Download ruff and get source files
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
sources_fields=[fs.sources for fs in field_sets],
|
|
79
|
-
for_sources_types=(BaselineSourcesField,),
|
|
74
|
+
# Download ruff and get source files
|
|
75
|
+
downloaded_ruff: DownloadedExternalTool = await download_external_tool(
|
|
76
|
+
ruff_subsystem.get_request(platform)
|
|
80
77
|
)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
sources: SourceFiles = await determine_source_files(
|
|
79
|
+
SourceFilesRequest(
|
|
80
|
+
sources_fields=[fs.sources for fs in field_sets],
|
|
81
|
+
for_sources_types=(BaselineSourcesField,),
|
|
82
|
+
)
|
|
85
83
|
)
|
|
86
84
|
|
|
87
85
|
if not sources.files:
|
|
88
|
-
return LintResult(
|
|
89
|
-
exit_code=0,
|
|
90
|
-
stdout="No files to lint",
|
|
91
|
-
stderr="",
|
|
92
|
-
linter_name="ruff",
|
|
93
|
-
partition_description=None,
|
|
94
|
-
)
|
|
86
|
+
return LintResult.create(request, exit_code=0, stdout="No files to lint", stderr="", strip_chroot_path=True)
|
|
95
87
|
|
|
96
88
|
# Merge the ruff binary with the source files
|
|
97
|
-
input_digest = await merge_digests(
|
|
89
|
+
input_digest: Digest = await merge_digests(
|
|
98
90
|
MergeDigests([downloaded_ruff.digest, sources.snapshot.digest]),
|
|
99
91
|
)
|
|
100
92
|
|
|
@@ -120,14 +112,16 @@ async def run_ruff_lint(
|
|
|
120
112
|
level=LogLevel.DEBUG,
|
|
121
113
|
)
|
|
122
114
|
|
|
123
|
-
result = await
|
|
115
|
+
result: FallibleProcessResult = await execute_process_or_raise(
|
|
116
|
+
**implicitly(process)
|
|
117
|
+
)
|
|
124
118
|
|
|
125
|
-
return LintResult(
|
|
119
|
+
return LintResult.create(
|
|
120
|
+
request,
|
|
126
121
|
exit_code=result.exit_code,
|
|
127
122
|
stdout=result.stdout.decode(),
|
|
128
123
|
stderr=result.stderr.decode(),
|
|
129
|
-
|
|
130
|
-
partition_description=request.partition_metadata,
|
|
124
|
+
strip_chroot_path=True,
|
|
131
125
|
)
|
|
132
126
|
|
|
133
127
|
|
|
File without changes
|
{jaymd96_pants_baseline-0.2.4.dist-info → jaymd96_pants_baseline-0.2.5.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|