File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
+ import inspect
3
4
import logging
4
5
import warnings
5
6
import yaml
@@ -276,18 +277,24 @@ def dynamic_alias(
276
277
splits = object_path .split ("." )
277
278
278
279
canonical_path = None
279
- parts = []
280
280
crnt_part = mod
281
281
for ii , attr_name in enumerate (splits ):
282
282
try :
283
283
crnt_part = getattr (crnt_part , attr_name )
284
284
if not isinstance (crnt_part , ModuleType ) and not canonical_path :
285
- canonical_path = crnt_part .__module__ + ":" + "." .join (splits [ii :])
285
+ if inspect .isclass (crnt_part ) or inspect .isfunction (crnt_part ):
286
+ _mod = getattr (crnt_part , "__module__" , None )
287
+
288
+ if _mod is None :
289
+ canonical_path = path
290
+ else :
291
+ canonical_path = _mod + ":" + "." .join (splits [ii :])
292
+ else :
293
+ canonical_path = path
286
294
elif isinstance (crnt_part , ModuleType ) and ii == (len (splits ) - 1 ):
287
295
# final object is module
288
296
canonical_path = crnt_part .__name__
289
297
290
- parts .append (crnt_part )
291
298
except AttributeError :
292
299
# Fetching the attribute can fail if it is purely a type hint,
293
300
# and has no value. This can be an issue if you have added a
You can’t perform that action at this time.
0 commit comments