Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions mypyc/namegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ def make_module_translation_map(names: list[str]) -> dict[str, str]:
for name in names:
for suffix in candidate_suffixes(name):
if num_instances[suffix] == 1:
result[name] = suffix
break
else:
assert False, names
# Takes the last suffix if none are unique
result[name] = suffix
return result


Expand Down
6 changes: 6 additions & 0 deletions mypyc/test/test_namegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ def test_make_module_translation_map(self) -> None:
"fu.bar": "fu.bar.",
"foo.baz": "baz.",
}
assert make_module_translation_map(["foo", "foo.foo", "bar.foo", "bar.foo.bar.foo"]) == {
"foo": "foo.",
"foo.foo": "foo.foo.",
"bar.foo": "bar.foo.",
"bar.foo.bar.foo": "foo.bar.foo.",
}

def test_name_generator(self) -> None:
g = NameGenerator([["foo", "foo.zar"]])
Expand Down
Loading