Skip to content

Commit 0c1fa96

Browse files
committed
Add type linting for HtPP and RzGraph.
1 parent b2a1f44 commit 0c1fa96

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/lint.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def cursor_get_comment(cursor: Cursor, *, packed: bool = False) -> Optional[str]
177177
return comment
178178

179179
# Check pointer (or lack of) and space between pointer
180-
if typeref_spelling in {"RzList", "RzListIter", "RzPVector", "RzGraph"}:
180+
if typeref_spelling in {"RzList", "RzListIter", "RzPVector"}:
181181
if comment[-2] != "*":
182182
warn(f"Type comment at {stringify_location(cursor.location)} lacks pointer")
183183
elif comment[-3] != " ":
@@ -189,8 +189,19 @@ def cursor_get_comment(cursor: Cursor, *, packed: bool = False) -> Optional[str]
189189
warn(
190190
f"Type comment at {stringify_location(cursor.location)} should not have pointer"
191191
)
192+
elif typeref_spelling in {"RzGraph", "HtPP"}:
193+
if not re.match(r"/\*<[A-Za-z0-9]+ \*, [A-Za-z0-9]+ \*>\*/", comment):
194+
if typeref_spelling == "RzGraph":
195+
warn(
196+
f"Type comment at {stringify_location(cursor.location)} must "
197+
"follow exactly the pattern '/*<NodeType *, EdgeType *>*/'."
198+
)
199+
elif typeref_spelling == "HtPP":
200+
warn(
201+
f"Type comment at {stringify_location(cursor.location)} must "
202+
"follow exactly the pattern '/*<KeyType *, ValueType *>*/'."
203+
)
192204
elif typeref_spelling in {
193-
"HtPP",
194205
"HtUP",
195206
"HtUU",
196207
"HtPU",

0 commit comments

Comments
 (0)