Skip to content

Commit 8e2f1cf

Browse files
authored
_plequal: marginally reduce cyclomatic complexity (#223)
1 parent 8282d6a commit 8e2f1cf

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

inflect/__init__.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -2594,20 +2594,16 @@ def singular_noun(
25942594
return f"{pre}{plural}{post}"
25952595
return False
25962596

2597-
def _plequal(self, word1: str, word2: str, pl) -> Union[str, bool]: # noqa: C901
2597+
def _plequal(self, word1: str, word2: str, pl) -> Union[str, bool]:
25982598
classval = self.classical_dict.copy()
2599-
self.classical_dict = all_classical.copy()
2600-
if word1 == word2:
2601-
return "eq"
2602-
if word1 == pl(word2):
2603-
return "p:s"
2604-
if pl(word1) == word2:
2605-
return "s:p"
2606-
self.classical_dict = no_classical.copy()
2607-
if word1 == pl(word2):
2608-
return "p:s"
2609-
if pl(word1) == word2:
2610-
return "s:p"
2599+
for dictionary in (all_classical, no_classical):
2600+
self.classical_dict = dictionary.copy()
2601+
if word1 == word2:
2602+
return "eq"
2603+
if word1 == pl(word2):
2604+
return "p:s"
2605+
if pl(word1) == word2:
2606+
return "s:p"
26112607
self.classical_dict = classval.copy()
26122608

26132609
if pl == self.plural or pl == self.plural_noun:

0 commit comments

Comments
 (0)