Skip to content

Commit a1173ae

Browse files
authored
Merge pull request #13 from Harsh-br0/ditch-packaging
ditch packaging
2 parents 202d504 + 643bf6a commit a1173ae

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

function_schema/core.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
import enum
22
import inspect
3-
import platform
4-
import packaging.version
53
from typing import (
64
Annotated,
7-
Optional,
8-
Union,
5+
Any,
96
Callable,
107
Literal,
11-
Any,
8+
Optional,
9+
Union,
1210
get_args,
1311
get_origin,
1412
)
15-
from .types import FunctionSchema
1613

17-
current_version = packaging.version.parse(platform.python_version())
18-
py_310 = packaging.version.parse("3.10")
14+
from .types import FunctionSchema
15+
from .utils import is_py310_atleast
1916

20-
if current_version >= py_310:
17+
if is_py310_atleast():
2118
from types import UnionType
2219
else:
2320
UnionType = Union # type: ignore

function_schema/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import platform
2+
3+
4+
def is_py310_atleast():
5+
version_tuple = tuple(map(int, platform.python_version_tuple()))
6+
return version_tuple >= (3, 10)

test/test_guess_type.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import platform
2-
import packaging.version
31
import typing
42

53
import pytest
4+
65
from function_schema.core import guess_type
6+
from function_schema.utils import is_py310_atleast
77

88

99
def test_primitive():
@@ -67,12 +67,8 @@ def test_union():
6767
}
6868

6969

70-
current_version = packaging.version.parse(platform.python_version())
71-
py_310 = packaging.version.parse("3.10")
72-
73-
7470
@pytest.mark.skipif(
75-
current_version < py_310, reason="Union type is only available in Python 3.10+"
71+
not is_py310_atleast(), reason="Union type is only available in Python 3.10+"
7672
)
7773
def test_union_type():
7874
"""Test union types in Python 3.10+"""

0 commit comments

Comments
 (0)