jaymd96-pants-baseline 0.1.2__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.
@@ -0,0 +1,138 @@
1
+ """Target types for the Python Baseline plugin."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pants.engine.target import (
6
+ COMMON_TARGET_FIELDS,
7
+ BoolField,
8
+ IntField,
9
+ StringField,
10
+ StringSequenceField,
11
+ Target,
12
+ )
13
+
14
+
15
+ class BaselineSourcesField(StringSequenceField):
16
+ """Source files for the baseline Python project."""
17
+
18
+ alias = "sources"
19
+ default = ("**/*.py",)
20
+ help = "Python source files to include in baseline checks."
21
+
22
+
23
+ class BaselineTestSourcesField(StringSequenceField):
24
+ """Test source files for the baseline Python project."""
25
+
26
+ alias = "test_sources"
27
+ default = ("tests/**/*.py",)
28
+ help = "Test files to include in baseline checks."
29
+
30
+
31
+ class PythonVersionField(StringField):
32
+ """Target Python version for the project."""
33
+
34
+ alias = "python_version"
35
+ default = "3.11"
36
+ help = "Target Python version (e.g., '3.11', '3.12')."
37
+
38
+
39
+ class LineLengthField(IntField):
40
+ """Maximum line length for formatting."""
41
+
42
+ alias = "line_length"
43
+ default = 120
44
+ help = "Maximum line length for code formatting."
45
+
46
+
47
+ class StrictModeField(BoolField):
48
+ """Enable strict mode for all checks."""
49
+
50
+ alias = "strict"
51
+ default = True
52
+ help = "Enable strict mode for type checking and linting."
53
+
54
+
55
+ class CoverageThresholdField(IntField):
56
+ """Minimum coverage percentage required."""
57
+
58
+ alias = "coverage_threshold"
59
+ default = 80
60
+ help = "Minimum code coverage percentage required."
61
+
62
+
63
+ class SkipLintField(BoolField):
64
+ """Skip linting for this target."""
65
+
66
+ alias = "skip_lint"
67
+ default = False
68
+ help = "Skip Ruff linting for this target."
69
+
70
+
71
+ class SkipFormatField(BoolField):
72
+ """Skip formatting for this target."""
73
+
74
+ alias = "skip_fmt"
75
+ default = False
76
+ help = "Skip Ruff formatting for this target."
77
+
78
+
79
+ class SkipTypecheckField(BoolField):
80
+ """Skip type checking for this target."""
81
+
82
+ alias = "skip_typecheck"
83
+ default = False
84
+ help = "Skip ty type checking for this target."
85
+
86
+
87
+ class SkipTestField(BoolField):
88
+ """Skip testing for this target."""
89
+
90
+ alias = "skip_test"
91
+ default = False
92
+ help = "Skip pytest for this target."
93
+
94
+
95
+ class SkipAuditField(BoolField):
96
+ """Skip security audit for this target."""
97
+
98
+ alias = "skip_audit"
99
+ default = False
100
+ help = "Skip uv security audit for this target."
101
+
102
+
103
+ class BaselinePythonProject(Target):
104
+ """A Python project with baseline quality checks.
105
+
106
+ This target type enables opinionated code quality checks using the
107
+ Astral ecosystem (Ruff, ty, uv) plus pytest for testing.
108
+
109
+ Example:
110
+
111
+ baseline_python_project(
112
+ name="my_project",
113
+ sources=["src/**/*.py"],
114
+ test_sources=["tests/**/*.py"],
115
+ python_version="3.11",
116
+ line_length=120,
117
+ strict=True,
118
+ coverage_threshold=80,
119
+ )
120
+ """
121
+
122
+ alias = "baseline_python_project"
123
+ help = "A Python project with baseline quality checks."
124
+
125
+ core_fields = (
126
+ *COMMON_TARGET_FIELDS,
127
+ BaselineSourcesField,
128
+ BaselineTestSourcesField,
129
+ PythonVersionField,
130
+ LineLengthField,
131
+ StrictModeField,
132
+ CoverageThresholdField,
133
+ SkipLintField,
134
+ SkipFormatField,
135
+ SkipTypecheckField,
136
+ SkipTestField,
137
+ SkipAuditField,
138
+ )