@@ -22,28 +22,30 @@ def _wrapper(
2222 name : str ,
2323 kwargs : AttributeDict ,
2424) -> t .Type :
25- if not reflect .get_metadata (watermark_key , target ):
26- if not isinstance (target , type ):
27- raise ImproperConfiguration (f"{ name } is a class decorator - { target } " )
25+ if reflect .get_metadata (watermark_key , target ):
26+ raise ImproperConfiguration (f"{ target } is already identified as a Module" )
2827
29- if not kwargs . base_directory :
30- kwargs . update ( base_directory = Path ( inspect . getfile ( target )). resolve (). parent )
28+ if not isinstance ( target , type ) :
29+ raise ImproperConfiguration ( f" { name } is a class decorator - { target } " )
3130
32- if type (target ) != ModuleBaseMeta :
33- attr : t .Dict = {
34- item : getattr (target , item ) for item in dir (target ) if "__" not in item
35- }
36- target = type (
37- target .__name__ ,
38- (target , ModuleBase ),
39- attr ,
40- )
31+ if not kwargs .base_directory :
32+ kwargs .update (base_directory = Path (inspect .getfile (target )).resolve ().parent )
4133
42- reflect .define_metadata (watermark_key , True , target )
43- for key in metadata_keys :
44- reflect .define_metadata (key , kwargs [key ], target )
45- injectable (SingletonScope )(target )
46- return target
34+ if type (target ) != ModuleBaseMeta :
35+ attr : t .Dict = {
36+ item : getattr (target , item ) for item in dir (target ) if "__" not in item
37+ }
38+ target = type (
39+ target .__name__ ,
40+ (target , ModuleBase ),
41+ attr ,
42+ )
43+
44+ reflect .define_metadata (watermark_key , True , target )
45+ for key in metadata_keys :
46+ reflect .define_metadata (key , kwargs [key ], target )
47+ injectable (SingletonScope )(target )
48+ return t .cast (t .Type , target )
4749
4850
4951def Module (
0 commit comments