@@ -71,8 +71,8 @@ def create_thing(value: object, /) -> strcs.ConvertResponse[Thing]:
7171"""
7272
7373import inspect
74- import typing as tp
75- from collections . abc import Mapping
74+ from collections . abc import Callable , Generator , Mapping
75+ from typing import TYPE_CHECKING , Generic , TypeVar , cast
7676
7777import attrs
7878import cattrs
@@ -84,14 +84,14 @@ def create_thing(value: object, /) -> strcs.ConvertResponse[Thing]:
8484from .not_specified import NotSpecified , NotSpecifiedMeta
8585from .standard import builtin_types
8686
87- if tp . TYPE_CHECKING :
87+ if TYPE_CHECKING :
8888 from .register import CreateRegister
8989
90- T = tp . TypeVar ("T" )
90+ T = TypeVar ("T" )
9191
9292
9393@attrs .define
94- class CreateArgs (tp . Generic [T ]):
94+ class CreateArgs (Generic [T ]):
9595 """
9696 The object given to ``ConvertFunction`` objects to produce an instance of the
9797 desired type.
@@ -108,7 +108,7 @@ class CreateArgs(tp.Generic[T]):
108108# Either a value instructing strcs to do something, an object that strcs should
109109# use as is, or a generator that can operate on the object strcs creates.
110110type ConvertResponseValues [T ] = bool | dict [str , object ] | T | NotSpecifiedMeta
111- type ConvertResponseGenerator [T ] = tp . Generator [ConvertResponseValues [T ] | tp . Generator | None , T ]
111+ type ConvertResponseGenerator [T ] = Generator [ConvertResponseValues [T ] | Generator | None , T ]
112112type ConvertResponse [T ] = ConvertResponseValues [T ] | ConvertResponseGenerator [T ] | None
113113
114114# ConvertDefinition is the developer provided functions that do transformation
@@ -124,11 +124,11 @@ class CreateArgs(tp.Generic[T]):
124124# - want: Type[T] = The strcs.Type object for the desired type
125125# - meta values are from the meta object, or the special objects known by
126126# strcs.ArgExtractor
127- type ConvertDefinition [T ] = tp . Callable [..., ConvertResponse [T ]]
127+ type ConvertDefinition [T ] = Callable [..., ConvertResponse [T ]]
128128
129129# ConvertFunction is the object the strcs.CreateRegister interacts with to invoke
130130# the ConvertDefinition objects.
131- type ConvertFunction [T ] = tp . Callable [[CreateArgs [T ]], T ]
131+ type ConvertFunction [T ] = Callable [[CreateArgs [T ]], T ]
132132
133133
134134def take_or_make (value : object , want : Type [T ], / ) -> ConvertResponse [T ]:
@@ -148,7 +148,7 @@ def take_or_make(value: object, want: Type[T], /) -> ConvertResponse[T]:
148148 return None
149149
150150
151- class WrappedCreator (tp . Generic [T ]):
151+ class WrappedCreator (Generic [T ]):
152152 """
153153 An implementation of ``strcs.ConvertFunction`` that operates on the provided
154154 ConvertDefinition.
@@ -197,7 +197,7 @@ def __call__(self, create_args: "CreateArgs") -> T:
197197
198198 if self .assume_unchanged_converted and want .is_type_for (value ):
199199 if want .origin_type not in builtin_types :
200- return tp . cast (T , value )
200+ return cast (T , value )
201201
202202 try :
203203 args = ArgsExtractor (
@@ -260,7 +260,7 @@ def deal(res: ConvertResponse[T], value: object) -> T:
260260 reason = "Told to use NotSpecified as the final value" ,
261261 creator = self .func ,
262262 )
263- return tp . cast (T , value )
263+ return cast (T , value )
264264 else :
265265 if not isinstance (res , Mapping ) and issubclass (
266266 want .checkable , self .type_cache .disassemble (type (res )).checkable
@@ -288,7 +288,7 @@ def _process_generator(
288288 self ,
289289 res : ConvertResponseGenerator [T ],
290290 value : object ,
291- deal : tp . Callable [[ConvertResponse [T ], object ], T ],
291+ deal : Callable [[ConvertResponse [T ], object ], T ],
292292 ) -> T :
293293 try :
294294 made : ConvertResponse [T ]
0 commit comments