Skip to content

Commit 8296748

Browse files
committed
Removed dependency on typing_compat and bumped the minimum python
version to 3.8
1 parent e05d3d0 commit 8296748

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
python-version: [3.7, 3.8, 3.9, 3.10]
17+
python-version: [3.8, 3.9, 3.10, 3.11, 3.12]
1818
runs-on: ubuntu-latest
1919

2020
steps:

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
psutil >=5.9, <=6.1.1
22
pystache>=0.6.0
33
typeguard>=3.0.1
4-
typing-compat
54
packaging >= 24.0, <= 24.2

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@
4242
},
4343

4444
install_requires=install_requires,
45-
python_requires='>=3.7'
45+
python_requires='>=3.8'
4646
)

src/psij/serialize.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from io import StringIO, TextIOBase
77
from pathlib import Path
88
from typing import Optional, Dict, Union, List, IO, AnyStr, TextIO
9-
import typing_compat
109

1110
from psij import ResourceSpec
1211
from psij.job_attributes import JobAttributes
@@ -135,12 +134,12 @@ def _from_psij_object(self, o: Union[JobSpec, JobAttributes, ResourceSpec]) \
135134

136135
def _canonicalize_type(self, t: object) -> object:
137136
# generics don't appear to be subclasses of Type, so we can't really use Type for t
138-
origin = typing_compat.get_origin(t)
137+
origin = typing.get_origin(t)
139138
if origin == Optional:
140139
# Python converts Optional[T] to Union[T, None], so this shouldn't happen
141-
return typing_compat.get_args(t)[0]
140+
return typing.get_args(t)[0]
142141
elif origin == Union:
143-
args = typing_compat.get_args(t)
142+
args = typing.get_args(t)
144143
if args[0] == NoneType:
145144
return args[1]
146145
elif args[1] == NoneType:
@@ -171,10 +170,10 @@ def _from_object(self, o: object, t: object) -> object:
171170
else:
172171
if t == Union[str, Path] or t == Optional[Union[str, Path]]:
173172
return str(o)
174-
if typing_compat.get_origin(t) == dict:
173+
if typing.get_origin(t) == dict:
175174
assert isinstance(o, dict)
176175
return self._from_dict(o)
177-
if typing_compat.get_origin(t) == list:
176+
if typing.get_origin(t) == list:
178177
assert isinstance(o, list)
179178
return self._from_list(o)
180179
raise ValueError('Cannot convert type "%s".' % t)
@@ -249,10 +248,10 @@ def _to_object(self, s: object, t: object) -> object:
249248
if t == Union[str, Path] or t == Optional[Union[str, Path]]:
250249
assert isinstance(s, str)
251250
return Path(s)
252-
if typing_compat.get_origin(t) == dict:
251+
if typing.get_origin(t) == dict:
253252
assert isinstance(s, dict)
254253
return self._to_dict(s)
255-
if typing_compat.get_origin(t) == list:
254+
if typing.get_origin(t) == list:
256255
assert isinstance(s, list)
257256
return self._to_list(s)
258257
raise ValueError('Cannot convert type "%s".' % t)

0 commit comments

Comments
 (0)