Skip to content

Commit

Permalink
Merge Pull Request #224 from jayaddison.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Dec 28, 2024
2 parents 3803796 + 13b86a9 commit 758a56a
Show file tree
Hide file tree
Showing 2 changed files with 3 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
1 change: 1 addition & 0 deletions newsfragments/225.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated `ast` classes for Python 3.14 compatibility.

0 comments on commit 758a56a

Please sign in to comment.