|
6 | 6 | from io import StringIO, TextIOBase |
7 | 7 | from pathlib import Path |
8 | 8 | from typing import Optional, Dict, Union, List, IO, AnyStr, TextIO |
9 | | -import typing_compat |
10 | 9 |
|
11 | 10 | from psij import ResourceSpec |
12 | 11 | from psij.job_attributes import JobAttributes |
@@ -135,12 +134,12 @@ def _from_psij_object(self, o: Union[JobSpec, JobAttributes, ResourceSpec]) \ |
135 | 134 |
|
136 | 135 | def _canonicalize_type(self, t: object) -> object: |
137 | 136 | # 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) |
139 | 138 | if origin == Optional: |
140 | 139 | # 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] |
142 | 141 | elif origin == Union: |
143 | | - args = typing_compat.get_args(t) |
| 142 | + args = typing.get_args(t) |
144 | 143 | if args[0] == NoneType: |
145 | 144 | return args[1] |
146 | 145 | elif args[1] == NoneType: |
@@ -171,10 +170,10 @@ def _from_object(self, o: object, t: object) -> object: |
171 | 170 | else: |
172 | 171 | if t == Union[str, Path] or t == Optional[Union[str, Path]]: |
173 | 172 | return str(o) |
174 | | - if typing_compat.get_origin(t) == dict: |
| 173 | + if typing.get_origin(t) == dict: |
175 | 174 | assert isinstance(o, dict) |
176 | 175 | return self._from_dict(o) |
177 | | - if typing_compat.get_origin(t) == list: |
| 176 | + if typing.get_origin(t) == list: |
178 | 177 | assert isinstance(o, list) |
179 | 178 | return self._from_list(o) |
180 | 179 | raise ValueError('Cannot convert type "%s".' % t) |
@@ -249,10 +248,10 @@ def _to_object(self, s: object, t: object) -> object: |
249 | 248 | if t == Union[str, Path] or t == Optional[Union[str, Path]]: |
250 | 249 | assert isinstance(s, str) |
251 | 250 | return Path(s) |
252 | | - if typing_compat.get_origin(t) == dict: |
| 251 | + if typing.get_origin(t) == dict: |
253 | 252 | assert isinstance(s, dict) |
254 | 253 | return self._to_dict(s) |
255 | | - if typing_compat.get_origin(t) == list: |
| 254 | + if typing.get_origin(t) == list: |
256 | 255 | assert isinstance(s, list) |
257 | 256 | return self._to_list(s) |
258 | 257 | raise ValueError('Cannot convert type "%s".' % t) |
|
0 commit comments