Skip to content

Commit

Permalink
_plequal: marginally reduce cyclomatic complexity (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayaddison authored Dec 28, 2024
1 parent 8282d6a commit 8e2f1cf
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions inflect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2594,20 +2594,16 @@ def singular_noun(
return f"{pre}{plural}{post}"
return False

def _plequal(self, word1: str, word2: str, pl) -> Union[str, bool]: # noqa: C901
def _plequal(self, word1: str, word2: str, pl) -> Union[str, bool]:
classval = self.classical_dict.copy()
self.classical_dict = all_classical.copy()
if word1 == word2:
return "eq"
if word1 == pl(word2):
return "p:s"
if pl(word1) == word2:
return "s:p"
self.classical_dict = no_classical.copy()
if word1 == pl(word2):
return "p:s"
if pl(word1) == word2:
return "s:p"
for dictionary in (all_classical, no_classical):
self.classical_dict = dictionary.copy()
if word1 == word2:
return "eq"
if word1 == pl(word2):
return "p:s"
if pl(word1) == word2:
return "s:p"
self.classical_dict = classval.copy()

if pl == self.plural or pl == self.plural_noun:
Expand Down

0 comments on commit 8e2f1cf

Please sign in to comment.