55import warnings
66from dataclasses import _MISSING_TYPE , Field , dataclass
77from pathlib import Path
8- from typing import (TYPE_CHECKING , ForwardRef , Iterable , NamedTuple , TypedDict ,
9- get_args , get_type_hints )
8+ from typing import (
9+ TYPE_CHECKING ,
10+ ForwardRef ,
11+ Iterable ,
12+ NamedTuple ,
13+ TypedDict ,
14+ get_args ,
15+ get_type_hints ,
16+ )
1017
1118from _view import Context
1219
@@ -25,11 +32,15 @@ def _eval_type(*args) -> Any: ...
2532
2633from ._logging import Internal
2734from ._util import docs_hint , is_annotated , is_union , set_load
28- from .exceptions import (DuplicateRouteError , InvalidBodyError ,
29- InvalidRouteError , LoaderWarning ,
30- UnknownBuildStepError , ViewInternalError )
31- from .routing import (BodyParam , Method , Route , RouteData , RouteInput ,
32- _NoDefault )
35+ from .exceptions import (
36+ DuplicateRouteError ,
37+ InvalidBodyError ,
38+ InvalidRouteError ,
39+ LoaderWarning ,
40+ UnknownBuildStepError ,
41+ ViewInternalError ,
42+ )
43+ from .routing import BodyParam , Method , Route , RouteData , RouteInput , _NoDefault
3344from .typing import Any , RouteInputDict , TypeInfo , ValueType
3445
3546ExtNotRequired : Any = None
@@ -348,9 +359,7 @@ def __view_construct__(**kwargs):
348359 vbody_types = vbody
349360
350361 doc = {}
351- codes .append (
352- (TYPECODE_CLASS , tp , _format_body (vbody_types , doc , tp ))
353- )
362+ codes .append ((TYPECODE_CLASS , tp , _format_body (vbody_types , doc , tp )))
354363 setattr (tp , "_view_doc" , doc )
355364 continue
356365
@@ -364,9 +373,7 @@ def __view_construct__(**kwargs):
364373 key , value = get_args (tp )
365374
366375 if key is not str :
367- raise InvalidBodyError (
368- f"dictionary keys must be strings, not { key } "
369- )
376+ raise InvalidBodyError (f"dictionary keys must be strings, not { key } " )
370377
371378 tp_codes = _build_type_codes ((value ,))
372379 codes .append ((TYPECODE_DICT , None , tp_codes ))
@@ -437,9 +444,7 @@ def finalize(routes: Iterable[Route], app: ViewApp):
437444
438445 for step in route .steps or []:
439446 if step not in app .config .build .steps :
440- raise UnknownBuildStepError (
441- f"build step { step !r} is not defined"
442- )
447+ raise UnknownBuildStepError (f"build step { step !r} is not defined" )
443448
444449 if route .method :
445450 target = targets [route .method ]
@@ -487,9 +492,7 @@ def finalize(routes: Iterable[Route], app: ViewApp):
487492 route .inputs .insert (index , 1 )
488493 continue
489494
490- default = (
491- v .default if v .default is not inspect ._empty else _NoDefault
492- )
495+ default = v .default if v .default is not inspect ._empty else _NoDefault
493496
494497 route .inputs .insert (
495498 index ,
@@ -584,9 +587,7 @@ def load_fs(app: ViewApp, target_dir: Path) -> None:
584587 )
585588 else :
586589 path_obj = Path (path )
587- stripped = list (
588- path_obj .parts [len (target_dir .parts ) :]
589- ) # noqa
590+ stripped = list (path_obj .parts [len (target_dir .parts ) :]) # noqa
590591 if stripped [- 1 ] == "index.py" :
591592 stripped .pop (len (stripped ) - 1 )
592593
0 commit comments