markback 0.1.2__py3-none-any.whl → 0.1.3__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.
- markback/linter.py +32 -7
- markback/parser.py +6 -2
- markback/types.py +34 -9
- markback/writer.py +10 -3
- {markback-0.1.2.dist-info → markback-0.1.3.dist-info}/METADATA +1 -1
- markback-0.1.3.dist-info/RECORD +14 -0
- markback-0.1.2.dist-info/RECORD +0 -14
- {markback-0.1.2.dist-info → markback-0.1.3.dist-info}/WHEEL +0 -0
- {markback-0.1.2.dist-info → markback-0.1.3.dist-info}/entry_points.txt +0 -0
- {markback-0.1.2.dist-info → markback-0.1.3.dist-info}/licenses/LICENSE +0 -0
markback/linter.py
CHANGED
|
@@ -137,36 +137,61 @@ def lint_prior_exists(
|
|
|
137
137
|
return diagnostics
|
|
138
138
|
|
|
139
139
|
|
|
140
|
+
def _is_position_invalid(source_ref) -> tuple[bool, str]:
|
|
141
|
+
"""Check if a SourceRef has an invalid position range.
|
|
142
|
+
|
|
143
|
+
Returns (is_invalid, error_message).
|
|
144
|
+
Position is invalid if:
|
|
145
|
+
- end_line < start_line
|
|
146
|
+
- end_line == start_line and end_column < start_column
|
|
147
|
+
"""
|
|
148
|
+
if source_ref.start_line is None or source_ref.end_line is None:
|
|
149
|
+
return False, ""
|
|
150
|
+
|
|
151
|
+
if source_ref.end_line < source_ref.start_line:
|
|
152
|
+
return True, f"end line {source_ref.end_line} is less than start line {source_ref.start_line}"
|
|
153
|
+
|
|
154
|
+
if source_ref.end_line == source_ref.start_line:
|
|
155
|
+
if (source_ref.start_column is not None and
|
|
156
|
+
source_ref.end_column is not None and
|
|
157
|
+
source_ref.end_column < source_ref.start_column):
|
|
158
|
+
return True, f"end column {source_ref.end_column} is less than start column {source_ref.start_column} on line {source_ref.start_line}"
|
|
159
|
+
|
|
160
|
+
return False, ""
|
|
161
|
+
|
|
162
|
+
|
|
140
163
|
def lint_line_range(
|
|
141
164
|
record: Record,
|
|
142
165
|
record_idx: int,
|
|
143
166
|
) -> list[Diagnostic]:
|
|
144
|
-
"""Check if line ranges are valid (end >= start)."""
|
|
167
|
+
"""Check if line/character ranges are valid (end position >= start position)."""
|
|
145
168
|
diagnostics: list[Diagnostic] = []
|
|
146
169
|
|
|
147
|
-
# Check @source
|
|
170
|
+
# Check @source range
|
|
148
171
|
if record.source and record.source.start_line is not None:
|
|
149
|
-
|
|
172
|
+
is_invalid, error_msg = _is_position_invalid(record.source)
|
|
173
|
+
if is_invalid:
|
|
150
174
|
diagnostics.append(Diagnostic(
|
|
151
175
|
file=record._source_file,
|
|
152
176
|
line=record._start_line,
|
|
153
177
|
column=None,
|
|
154
178
|
severity=Severity.ERROR,
|
|
155
179
|
code=ErrorCode.E011,
|
|
156
|
-
message=f"Invalid
|
|
180
|
+
message=f"Invalid range in @source: {error_msg}",
|
|
157
181
|
record_index=record_idx,
|
|
158
182
|
))
|
|
159
183
|
|
|
160
|
-
# Check @prior
|
|
184
|
+
# Check @prior range
|
|
161
185
|
if record.prior and record.prior.start_line is not None:
|
|
162
|
-
|
|
186
|
+
is_invalid, error_msg = _is_position_invalid(record.prior)
|
|
187
|
+
if is_invalid:
|
|
163
188
|
diagnostics.append(Diagnostic(
|
|
164
189
|
file=record._source_file,
|
|
165
190
|
line=record._start_line,
|
|
166
191
|
column=None,
|
|
167
192
|
severity=Severity.ERROR,
|
|
168
193
|
code=ErrorCode.E011,
|
|
169
|
-
message=f"Invalid
|
|
194
|
+
message=f"Invalid range in @prior: {error_msg}",
|
|
170
195
|
record_index=record_idx,
|
|
171
196
|
))
|
|
172
197
|
|
markback/parser.py
CHANGED
|
@@ -17,7 +17,7 @@ from .types import (
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
# Known header keywords
|
|
20
|
-
KNOWN_HEADERS = {"uri", "source", "prior"}
|
|
20
|
+
KNOWN_HEADERS = {"uri", "by", "source", "prior"}
|
|
21
21
|
|
|
22
22
|
# Patterns
|
|
23
23
|
HEADER_PATTERN = re.compile(r"^@([a-z]+)\s+(.+)$")
|
|
@@ -145,6 +145,7 @@ def parse_string(
|
|
|
145
145
|
nonlocal pending_uri, in_content, had_blank_line
|
|
146
146
|
|
|
147
147
|
uri = current_headers.get("uri") or pending_uri
|
|
148
|
+
by = current_headers.get("by")
|
|
148
149
|
source_str = current_headers.get("source")
|
|
149
150
|
source = SourceRef(source_str) if source_str else None
|
|
150
151
|
prior_str = current_headers.get("prior")
|
|
@@ -164,6 +165,7 @@ def parse_string(
|
|
|
164
165
|
record = Record(
|
|
165
166
|
feedback=feedback,
|
|
166
167
|
uri=uri,
|
|
168
|
+
by=by,
|
|
167
169
|
source=source,
|
|
168
170
|
prior=prior,
|
|
169
171
|
content=content,
|
|
@@ -242,14 +244,16 @@ def parse_string(
|
|
|
242
244
|
line_num,
|
|
243
245
|
)
|
|
244
246
|
|
|
245
|
-
# Use any pending @uri from previous line and @prior if present
|
|
247
|
+
# Use any pending @uri from previous line and @by, @prior if present
|
|
246
248
|
uri = pending_uri or current_headers.get("uri")
|
|
249
|
+
by = current_headers.get("by")
|
|
247
250
|
prior_str = current_headers.get("prior")
|
|
248
251
|
prior = SourceRef(prior_str) if prior_str else None
|
|
249
252
|
|
|
250
253
|
record = Record(
|
|
251
254
|
feedback=feedback or "",
|
|
252
255
|
uri=uri,
|
|
256
|
+
by=by,
|
|
253
257
|
source=source,
|
|
254
258
|
prior=prior,
|
|
255
259
|
content=None,
|
markback/types.py
CHANGED
|
@@ -78,8 +78,9 @@ class Diagnostic:
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
# Regex to parse line range from a path
|
|
82
|
-
|
|
81
|
+
# Regex to parse line/character range from a path
|
|
82
|
+
# Supports: path:line, path:line:col, path:line-line, path:line:col-line:col
|
|
83
|
+
_LINE_RANGE_PATTERN = re.compile(r'^(.+?):(\d+)(?::(\d+))?(?:-(\d+)(?::(\d+))?)?$')
|
|
83
84
|
|
|
84
85
|
|
|
85
86
|
@dataclass
|
|
@@ -89,6 +90,8 @@ class SourceRef:
|
|
|
89
90
|
is_uri: bool = False
|
|
90
91
|
start_line: Optional[int] = None
|
|
91
92
|
end_line: Optional[int] = None
|
|
93
|
+
start_column: Optional[int] = None
|
|
94
|
+
end_column: Optional[int] = None
|
|
92
95
|
_path_only: str = ""
|
|
93
96
|
|
|
94
97
|
def __post_init__(self):
|
|
@@ -102,16 +105,21 @@ class SourceRef:
|
|
|
102
105
|
self.is_uri = bool(parsed.scheme) and len(parsed.scheme) > 1
|
|
103
106
|
|
|
104
107
|
def _parse_line_range(self):
|
|
105
|
-
"""Parse optional line range from value."""
|
|
108
|
+
"""Parse optional line/character range from value."""
|
|
106
109
|
match = _LINE_RANGE_PATTERN.match(self.value)
|
|
107
110
|
if match:
|
|
108
111
|
self._path_only = match.group(1)
|
|
109
112
|
self.start_line = int(match.group(2))
|
|
110
113
|
if match.group(3):
|
|
111
|
-
self.
|
|
114
|
+
self.start_column = int(match.group(3))
|
|
115
|
+
if match.group(4):
|
|
116
|
+
self.end_line = int(match.group(4))
|
|
117
|
+
if match.group(5):
|
|
118
|
+
self.end_column = int(match.group(5))
|
|
112
119
|
else:
|
|
113
|
-
# Single line reference: start and end are the same
|
|
120
|
+
# Single line/position reference: start and end are the same
|
|
114
121
|
self.end_line = self.start_line
|
|
122
|
+
self.end_column = self.start_column
|
|
115
123
|
else:
|
|
116
124
|
self._path_only = self.value
|
|
117
125
|
|
|
@@ -122,12 +130,27 @@ class SourceRef:
|
|
|
122
130
|
|
|
123
131
|
@property
|
|
124
132
|
def line_range_str(self) -> Optional[str]:
|
|
125
|
-
"""Return formatted line range string, or None if no range."""
|
|
133
|
+
"""Return formatted line/character range string, or None if no range."""
|
|
126
134
|
if self.start_line is None:
|
|
127
135
|
return None
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
|
|
137
|
+
# Build start position
|
|
138
|
+
if self.start_column is not None:
|
|
139
|
+
start = f":{self.start_line}:{self.start_column}"
|
|
140
|
+
else:
|
|
141
|
+
start = f":{self.start_line}"
|
|
142
|
+
|
|
143
|
+
# Check if end is the same as start (single position)
|
|
144
|
+
if self.start_line == self.end_line and self.start_column == self.end_column:
|
|
145
|
+
return start
|
|
146
|
+
|
|
147
|
+
# Build end position
|
|
148
|
+
if self.end_column is not None:
|
|
149
|
+
end = f"-{self.end_line}:{self.end_column}"
|
|
150
|
+
else:
|
|
151
|
+
end = f"-{self.end_line}"
|
|
152
|
+
|
|
153
|
+
return f"{start}{end}"
|
|
131
154
|
|
|
132
155
|
def resolve(self, base_path: Optional[Path] = None) -> Path:
|
|
133
156
|
"""Resolve to a file path (relative paths resolved against base_path)."""
|
|
@@ -162,6 +185,7 @@ class Record:
|
|
|
162
185
|
"""A MarkBack record containing content and feedback."""
|
|
163
186
|
feedback: str
|
|
164
187
|
uri: Optional[str] = None
|
|
188
|
+
by: Optional[str] = None
|
|
165
189
|
source: Optional[SourceRef] = None
|
|
166
190
|
prior: Optional[SourceRef] = None
|
|
167
191
|
content: Optional[str] = None
|
|
@@ -195,6 +219,7 @@ class Record:
|
|
|
195
219
|
"""Convert to JSON-serializable dict."""
|
|
196
220
|
return {
|
|
197
221
|
"uri": self.uri,
|
|
222
|
+
"by": self.by,
|
|
198
223
|
"source": str(self.source) if self.source else None,
|
|
199
224
|
"prior": str(self.prior) if self.prior else None,
|
|
200
225
|
"content": self.content,
|
markback/writer.py
CHANGED
|
@@ -38,17 +38,21 @@ def write_record_canonical(
|
|
|
38
38
|
)
|
|
39
39
|
|
|
40
40
|
if use_compact:
|
|
41
|
-
# Compact format: @uri on
|
|
41
|
+
# Compact format: @uri, @by, @prior on own lines (if present), then @source ... <<<
|
|
42
42
|
if record.uri:
|
|
43
43
|
lines.append(f"@uri {record.uri}")
|
|
44
|
+
if record.by:
|
|
45
|
+
lines.append(f"@by {record.by}")
|
|
44
46
|
if record.prior:
|
|
45
47
|
lines.append(f"@prior {record.prior}")
|
|
46
48
|
lines.append(f"@source {record.source} <<< {record.feedback}")
|
|
47
49
|
else:
|
|
48
50
|
# Full format
|
|
49
|
-
# Headers: @uri first, then @prior, then @source
|
|
51
|
+
# Headers: @uri first, then @by, then @prior, then @source
|
|
50
52
|
if record.uri:
|
|
51
53
|
lines.append(f"@uri {record.uri}")
|
|
54
|
+
if record.by:
|
|
55
|
+
lines.append(f"@by {record.by}")
|
|
52
56
|
if record.prior:
|
|
53
57
|
lines.append(f"@prior {record.prior}")
|
|
54
58
|
if record.source:
|
|
@@ -151,7 +155,10 @@ def write_label_file(record: Record) -> str:
|
|
|
151
155
|
|
|
152
156
|
if record.uri:
|
|
153
157
|
lines.append(f"@uri {record.uri}")
|
|
154
|
-
|
|
158
|
+
|
|
159
|
+
if record.by:
|
|
160
|
+
lines.append(f"@by {record.by}")
|
|
161
|
+
|
|
155
162
|
if record.prior:
|
|
156
163
|
lines.append(f"@prior {record.prior}")
|
|
157
164
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: markback
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: A compact, human-writable format for storing content paired with feedback/labels
|
|
5
5
|
Project-URL: Homepage, https://github.com/dandriscoll/markback
|
|
6
6
|
Project-URL: Repository, https://github.com/dandriscoll/markback
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
markback/__init__.py,sha256=B0-2dpUu5nkbnUI0hPz-x7PHiOl7M-tiRi6s3UCYJFk,1540
|
|
2
|
+
markback/cli.py,sha256=5wMk1OUG7W_voS9DxeFxRJrBTMabEdOK_s_o3Irxuu0,13639
|
|
3
|
+
markback/config.py,sha256=eTVhb7UwDER9FRYo8QUAvneLHSqXD2ZtLUgtBtnljUs,5455
|
|
4
|
+
markback/linter.py,sha256=vKy5JHTEGspF4-lWRL9o4zDWieghqQWkah-bP_n8-kM,11977
|
|
5
|
+
markback/llm.py,sha256=ON5_2C6v4KIk7_aIceulfWjEEI6hmallaPlLv-1-s_o,4692
|
|
6
|
+
markback/parser.py,sha256=KHC1QKmN1wSnYgcobC36zXUqL6cdNsZajC6fHlhETZc,19016
|
|
7
|
+
markback/types.py,sha256=t6HdFIWgBTlCfC2KRKKhSO4VBzfxZcP3Uq_zoh-bXZ4,11006
|
|
8
|
+
markback/workflow.py,sha256=zC1RUm1i1wgiciFDqUilJKJ0-bgInvctxhQ0h5WSdoQ,10485
|
|
9
|
+
markback/writer.py,sha256=HY_RYnEk27cIsodo9gGf_MvUb_Bvdmkz05S9kyq6Tdo,8093
|
|
10
|
+
markback-0.1.3.dist-info/METADATA,sha256=ZvzRC2PHMoowUUjoJFzpPzw2425HD7OM-_lr09BOJho,5133
|
|
11
|
+
markback-0.1.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
12
|
+
markback-0.1.3.dist-info/entry_points.txt,sha256=Bc9aXvtlPxVPuOJ9BWGngAVrkx5dMvRgujjVzXC-V5U,46
|
|
13
|
+
markback-0.1.3.dist-info/licenses/LICENSE,sha256=lLK1n13C_CXb0M10O-6itEIDY6dsXKutZYQH-09n6s0,1068
|
|
14
|
+
markback-0.1.3.dist-info/RECORD,,
|
markback-0.1.2.dist-info/RECORD
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
markback/__init__.py,sha256=B0-2dpUu5nkbnUI0hPz-x7PHiOl7M-tiRi6s3UCYJFk,1540
|
|
2
|
-
markback/cli.py,sha256=5wMk1OUG7W_voS9DxeFxRJrBTMabEdOK_s_o3Irxuu0,13639
|
|
3
|
-
markback/config.py,sha256=eTVhb7UwDER9FRYo8QUAvneLHSqXD2ZtLUgtBtnljUs,5455
|
|
4
|
-
markback/linter.py,sha256=IctgPEFNfGDo5DcELdo0Ni3d7Dp0bIWtlDw61ccWDOQ,11210
|
|
5
|
-
markback/llm.py,sha256=ON5_2C6v4KIk7_aIceulfWjEEI6hmallaPlLv-1-s_o,4692
|
|
6
|
-
markback/parser.py,sha256=P7GRjlwhy8j6Tnub7XAqILtZ4pFdkfdHhB-aIjLVRYU,18881
|
|
7
|
-
markback/types.py,sha256=tFunBAoqUEVf9mi_4N1QwWmOsKt0nocZK7M7K_rybWg,10097
|
|
8
|
-
markback/workflow.py,sha256=zC1RUm1i1wgiciFDqUilJKJ0-bgInvctxhQ0h5WSdoQ,10485
|
|
9
|
-
markback/writer.py,sha256=3-LeupyuruGv4WZH9pV65hU4YDKuC5HgIIZ8YZ2SZnM,7896
|
|
10
|
-
markback-0.1.2.dist-info/METADATA,sha256=d_xMmpicyEYeakJ4hA8SsrlGgj5Qxpd6fMv7tKf-eaI,5133
|
|
11
|
-
markback-0.1.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
12
|
-
markback-0.1.2.dist-info/entry_points.txt,sha256=Bc9aXvtlPxVPuOJ9BWGngAVrkx5dMvRgujjVzXC-V5U,46
|
|
13
|
-
markback-0.1.2.dist-info/licenses/LICENSE,sha256=lLK1n13C_CXb0M10O-6itEIDY6dsXKutZYQH-09n6s0,1068
|
|
14
|
-
markback-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|