Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
klebster2 committed Nov 3, 2024
1 parent 95e0f37 commit c79091b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plugin/wordnet-cmp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function! s:wordnetcmp()
end
local query_word = line:sub(start + 1, vim.fn.col('.') - 1)
if #query_word < 3 then return end --- Short input requires a lot of processing, so let's skip it.
local items = vim.fn.py3eval('plugin.wordnet_complete(0, "' .. query_word .. '")')
local items = vim.fn.py3eval('plugin.wordnet_complete("' .. query_word .. '")')

-- Convert items to nvim-cmp format
local cached_items = {}
Expand Down
18 changes: 12 additions & 6 deletions python/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def get_synonyms(self, word: str) -> t.List[t.Dict[str, t.Any]]:
if isinstance(synset, wn.Synset):
for lemma in synset.lemmas():
if lemma.lower() != word.lower():
synset_definition: str | None = synset.definition()
synset_definition: str | None = (
synset.definition()
) # pylint: disable=unsupported-assignment-operation
if synset_definition is None:
synset_definition = ""
_item = self.format_completion_item(
Expand All @@ -105,7 +107,9 @@ def get_hyponyms(self, word: str) -> t.List[t.Dict[str, t.Any]]:
for synset in self.get_synsets(word): # pylint: disable=no-value-for-parameter
for hyponym in synset.hyponyms():
for lemma in hyponym.lemmas():
hyponym_definition: str | None = hyponym.definition()
hyponym_definition: str | None = (
hyponym.definition()
) # pylint: disable=unsupported-assignment-operation
if hyponym_definition is None:
hyponym_definition = ""

Expand All @@ -124,7 +128,9 @@ def get_meronyms(self, word: str) -> t.List[t.Dict[str, t.Any]]:
# Get both part and substance meronyms
for meronym in synset.meronyms():
for lemma in meronym.lemmas():
meronym_definition: str | None = meronym.definition()
meronym_definition: str | None = (
meronym.definition()
) # pylint: disable=unsupported-assignment-operation
if meronym_definition is None:
meronym_definition = ""
_item = self.format_completion_item(
Expand Down Expand Up @@ -220,16 +226,16 @@ def test_lookup_word__win():
]


def wordnet_complete(findstart: int, base: str) -> t.List[t.Dict[str, t.Any]]:
def wordnet_complete(base: str) -> t.List[t.Dict[str, t.Any]]:
"""Main completion function to be called from Vim."""
# Return completion items
return completer.get_all_completions(base) + [
completer.format_completion_item(*s) for s in get_formatted_synset(base)
]


def test_wordnet_complete():
assert wordnet_complete(0, "win") == [
def test_wordnet_complete__win():
assert wordnet_complete("win") == [
{
"word": "acquire",
"kind": "Synonym",
Expand Down

0 comments on commit c79091b

Please sign in to comment.