MCPcopy Index your code
hub / github.com/nonebot/nonebot2 / resolve_dot_notation

Function resolve_dot_notation

nonebot/utils.py:359–372  ·  view source on GitHub ↗

解析并导入点分表示法的对象

(
    obj_str: str, default_attr: str, default_prefix: str | None = None
)

Source from the content-addressed store, hash-verified

357
358
359def resolve_dot_notation(
360 obj_str: str, default_attr: str, default_prefix: str | None = None
361) -> Any:
362 """解析并导入点分表示法的对象"""
363 modulename, _, cls = obj_str.partition(":")
364 if default_prefix is not None and modulename.startswith("~"):
365 modulename = default_prefix + modulename[1:]
366 module = importlib.import_module(modulename)
367 if not cls:
368 return getattr(module, default_attr)
369 instance = module
370 for attr_str in cls.split("."):
371 instance = getattr(instance, attr_str)
372 return instance
373
374
375class classproperty(Generic[T]):

Callers 2

_resolve_combine_exprFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected