Skip to content

Commit 716bbc2

Browse files
authored
Add Python 3.13 and 3.14 checking in build workflow (#623)
* Add Python 3.13 and 3.14 checking in build workflow
1 parent 27f41ac commit 716bbc2

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
os: ["macos-latest", "ubuntu-latest"]
19-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-rc.2"]
19+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14.0-rc.2"]
2020
include:
2121
- {os: "ubuntu-22.04", python-version: "3.7"}
2222

fire/core.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,14 @@ def _CallAndUpdateTrace(component, args, component_trace, treatment='class',
678678

679679
# Call the function.
680680
if inspectutils.IsCoroutineFunction(fn):
681-
loop = asyncio.get_event_loop()
682-
component = loop.run_until_complete(fn(*varargs, **kwargs))
681+
try:
682+
loop = asyncio.get_running_loop()
683+
except RuntimeError:
684+
# No event loop running, create a new one
685+
component = asyncio.run(fn(*varargs, **kwargs))
686+
else:
687+
# Event loop is already running
688+
component = loop.run_until_complete(fn(*varargs, **kwargs))
683689
else:
684690
component = fn(*varargs, **kwargs)
685691

fire/inspectutils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
"""Inspection utility functions for Python Fire."""
1616

17-
import asyncio
1817
import inspect
1918
import sys
2019
import types
@@ -345,6 +344,6 @@ def GetClassAttrsDict(component):
345344

346345
def IsCoroutineFunction(fn):
347346
try:
348-
return asyncio.iscoroutinefunction(fn)
347+
return inspect.iscoroutinefunction(fn)
349348
except: # pylint: disable=bare-except
350349
return False

fire/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import sys
2020

2121
if sys.version_info[0:2] < (3, 8):
22-
_StrNode = ast.Str # type: ignore # deprecated but needed for Python < 3.8
22+
_StrNode = ast.Str # type: ignore # pylint: disable=no-member # deprecated but needed for Python < 3.8
2323
else:
2424
_StrNode = ast.Constant
2525

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ classifiers = [
2424
"Programming Language :: Python :: 3.11",
2525
"Programming Language :: Python :: 3.12",
2626
"Programming Language :: Python :: 3.13",
27+
"Programming Language :: Python :: 3.14",
2728
"Operating System :: OS Independent",
2829
"Operating System :: POSIX",
2930
"Operating System :: MacOS",

0 commit comments

Comments
 (0)