@@ -180,14 +180,8 @@ class RiverIntersectionType(BaseModel):
180180 allOf : List ["RiverType" ]
181181
182182
183- class RiverNotType (BaseModel ):
184- """This is used to represent void / never."""
185-
186- not_ : Any = Field (..., alias = "not" )
187-
188-
189183RiverType = Union [
190- RiverConcreteType , RiverUnionType , RiverNotType , RiverIntersectionType
184+ RiverConcreteType , RiverUnionType , RiverIntersectionType
191185]
192186
193187
@@ -239,8 +233,6 @@ def encode_type(
239233) -> Tuple [TypeExpression , list [ModuleName ], list [FileContents ], set [TypeName ]]:
240234 encoder_name : Optional [str ] = None # defining this up here to placate mypy
241235 chunks : List [FileContents ] = []
242- if isinstance (type , RiverNotType ):
243- return (TypeName ("None" ), [], [], set ())
244236 if isinstance (type , RiverUnionType ):
245237 typeddict_encoder = list [str ]()
246238 encoder_names : set [TypeName ] = set ()
@@ -457,7 +449,7 @@ def flatten_union(tpe: RiverType) -> list[RiverType]:
457449 )
458450 )
459451 return (prefix , in_module , chunks , encoder_names )
460- if isinstance (type , RiverIntersectionType ):
452+ elif isinstance (type , RiverIntersectionType ):
461453
462454 def extract_props (tpe : RiverType ) -> list [dict [str , RiverType ]]:
463455 if isinstance (tpe , RiverUnionType ):
@@ -478,12 +470,14 @@ def extract_props(tpe: RiverType) -> list[dict[str, RiverType]]:
478470 base_model ,
479471 in_module ,
480472 )
481- if isinstance (type , RiverConcreteType ):
473+ elif isinstance (type , RiverConcreteType ):
482474 typeddict_encoder = list [str ]()
483475 if type .type is None :
484476 # Handle the case where type is not specified
485477 typeddict_encoder .append ("x" )
486478 return (TypeName ("Any" ), [], [], set ())
479+ elif type .type == "not" :
480+ return (TypeName ("None" ), [], [], set ())
487481 elif type .type == "string" :
488482 if type .const :
489483 typeddict_encoder .append (repr (type .const ))
@@ -572,9 +566,7 @@ def extract_props(tpe: RiverType) -> list[dict[str, RiverType]]:
572566 encoder_name = None
573567 chunks .extend (contents )
574568 if base_model == "TypedDict" :
575- if isinstance (prop , RiverNotType ):
576- typeddict_encoder .append ("'not implemented'" )
577- elif isinstance (prop , RiverUnionType ):
569+ if isinstance (prop , RiverUnionType ):
578570 encoder_name = TypeName (
579571 f"encode_{ ensure_literal_type (type_name )} "
580572 )
@@ -593,7 +585,9 @@ def extract_props(tpe: RiverType) -> list[dict[str, RiverType]]:
593585 safe_name = "kind"
594586 else :
595587 safe_name = name
596- if prop .type == "object" and not prop .patternProperties :
588+ if prop .type == "not" :
589+ typeddict_encoder .append ("'not implemented'" )
590+ elif prop .type == "object" and not prop .patternProperties :
597591 encoder_name = TypeName (
598592 f"encode_{ ensure_literal_type (type_name )} "
599593 )
0 commit comments