Skip to content

Commit

Permalink
engine: migrate from py3.14-removed ast classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jayaddison authored and jaraco committed Dec 28, 2024
1 parent 3803796 commit 0bf9533
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions inflect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2264,19 +2264,13 @@ def _get_value_from_ast(self, obj):
"""
Return the value of the ast object.
"""
if isinstance(obj, ast.Num):
return obj.n
elif isinstance(obj, ast.Str):
return obj.s
if isinstance(obj, ast.Constant):
return obj.value
elif isinstance(obj, ast.List):
return [self._get_value_from_ast(e) for e in obj.elts]
elif isinstance(obj, ast.Tuple):
return tuple([self._get_value_from_ast(e) for e in obj.elts])

# None, True and False are NameConstants in Py3.4 and above.
elif isinstance(obj, ast.NameConstant):
return obj.value

# Probably passed a variable name.
# Or passed a single word without wrapping it in quotes as an argument
# ex: p.inflect("I plural(see)") instead of p.inflect("I plural('see')")
Expand Down

0 comments on commit 0bf9533

Please sign in to comment.