File tree Expand file tree Collapse file tree 3 files changed +15
-16
lines changed
Expand file tree Collapse file tree 3 files changed +15
-16
lines changed Original file line number Diff line number Diff line change 11import enum
22import inspect
3- import platform
4- import packaging .version
53from 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
2219else :
2320 UnionType = Union # type: ignore
Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change 1- import platform
2- import packaging .version
31import typing
42
53import pytest
4+
65from function_schema .core import guess_type
6+ from function_schema .utils import is_py310_atleast
77
88
99def 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)
7773def test_union_type ():
7874 """Test union types in Python 3.10+"""
You can’t perform that action at this time.
0 commit comments