1
1
from dataclasses import dataclass
2
- from typing import Type , Optional , Set , Dict
2
+ from typing import Type , Optional , Dict
3
3
4
- from marshy .factory .impl_marshaller_factory import ImplMarshallerFactory
5
4
from marshy .types import ExternalItemType
6
5
7
6
from schemey .factory .schema_factory_abc import SchemaFactoryABC
@@ -27,7 +26,10 @@ def from_type(
27
26
path : str ,
28
27
ref_schemas : Dict [Type , Schema ],
29
28
) -> Optional [Schema ]:
30
- impls = self .get_impls (type_ , context )
29
+ # noinspection PyTypeChecker
30
+ impls = context .marshy_context .injecty_context .get_impls (
31
+ type_ , permit_no_impl = True
32
+ )
31
33
if impls :
32
34
impls = sorted (list (impls ), key = lambda i : i .__name__ )
33
35
any_of = []
@@ -55,17 +57,7 @@ def from_json(
55
57
name = item .get ("name" )
56
58
if not name or not item .get ("anyOf" ):
57
59
return
58
- factories = context .marshaller_context .get_factories ()
59
- for factory in factories :
60
- if isinstance (factory , ImplMarshallerFactory ):
61
- if factory .base .__name__ == name :
62
- schema = self .from_type (factory .base , context , path , ref_schemas )
63
- return schema
64
-
65
- @staticmethod
66
- def get_impls (type_ : Type , context : SchemaContext ) -> Optional [Set [Type ]]:
67
- factories = context .marshaller_context .get_factories ()
68
- for factory in factories :
69
- if isinstance (factory , ImplMarshallerFactory ):
70
- if factory .base == type_ :
71
- return factory .impls
60
+ for base , _ in context .marshy_context .injecty_context .impls .items ():
61
+ if base .__name__ == name :
62
+ schema = self .from_type (base , context , path , ref_schemas )
63
+ return schema
0 commit comments