Skip to content

Commit ffd9609

Browse files
committed
more badness cases
1 parent 34ebffa commit ffd9609

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

src/hyperbase/cli/repl.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ class CommandCompleter(Completer):
270270
# command name.
271271
PATH_ARG_COMMANDS = frozenset({"load", "save", "count-csv", "classify"})
272272

273+
# Commands that take multiple path arguments. Unlike the single-arg
274+
# case above (which feeds PathCompleter everything after the first
275+
# space), these complete only the current word — the slice between
276+
# the cursor and the previous space — so that successive paths can
277+
# each be completed independently.
278+
MULTI_PATH_ARG_COMMANDS = frozenset({"genparse"})
279+
273280
def __init__(
274281
self,
275282
commands: dict,
@@ -295,6 +302,12 @@ def get_completions(
295302
sub_doc = Document(text=arg, cursor_position=len(arg))
296303
yield from self.path_completer.get_completions(sub_doc, complete_event)
297304
return
305+
if cmd_name in self.MULTI_PATH_ARG_COMMANDS:
306+
last_space = text.rfind(" ")
307+
word = text[last_space + 1 :]
308+
sub_doc = Document(text=word, cursor_position=len(word))
309+
yield from self.path_completer.get_completions(sub_doc, complete_event)
310+
return
298311
if cmd_name == "set" and " " in arg:
299312
setting_name, _, value = arg.partition(" ")
300313
if setting_name in self.path_settings:

src/hyperbase/parsers/badness.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def _visit(current_edge: Hyperedge) -> None:
2929
ars = current_edge.argroles()
3030
ar_counts: Counter[str] = Counter()
3131
for ar in ars:
32-
if ar not in "masox?":
32+
if ar not in "masox":
3333
current_errors.append(
3434
(
3535
"bad-argrole",
36-
f"Bad argument role '{ar}'. Should be one of 'masox?'.",
36+
f"Bad argument role '{ar}'. Should be one of 'masox'.",
3737
2,
3838
)
3939
)
@@ -46,7 +46,7 @@ def _visit(current_edge: Hyperedge) -> None:
4646
connector_type = current_edge[0].type()
4747
if len(current_edge) >= 2:
4848
target_mt = current_edge[1].mt
49-
if connector_type in {"Md", "Mq", "Mp"} and target_mt != "C":
49+
if connector_type in {"Ma", "Md", "Mq", "Mp"} and target_mt != "C":
5050
current_errors.append(
5151
(
5252
f"bad-{connector_type.lower()}-target",
@@ -64,6 +64,15 @@ def _visit(current_edge: Hyperedge) -> None:
6464
3,
6565
)
6666
)
67+
elif connector_type == "Mn" and target_mt not in {"C", "P"}:
68+
current_errors.append(
69+
(
70+
"bad-mn-target",
71+
"Modifiers of type 'Mn' should only be applied to "
72+
"concepts (type 'C') or predicates (type 'P').",
73+
3,
74+
)
75+
)
6776
except Exception:
6877
pass
6978

0 commit comments

Comments
 (0)