py_research.reflect.ref module
Utils for creating presistent references to Python objects.
-
class PyObjectRef(object_type, package, module, object, package_version=None, object_version=None, repo=None, repo_revision=None, docs_url=None)[source]
Bases: Generic
[T
]
Reference to a static Python object.
- Parameters:
object_type (type[T]) –
package (str) –
module (str) –
object (str) –
package_version (str | None) –
object_version (str | None) –
repo (str | None) –
repo_revision (str | None) –
docs_url (str | None) –
-
object_type: type[T]
Type of the object.
-
package: str
Name of the package the object belongs to.
-
module: str
Name of the module the object belongs to.
-
object: str
Name of the object.
-
package_version: str | None = None
Semver version range of the package or object.
-
object_version: str | None = None
Semver version range of the object (independent of package-version).
-
repo: str | None = None
URL of the package’s repository.
-
repo_revision: str | None = None
Revision of the repo.
-
docs_url: str | None = None
Deep-link to this object’s section within the package’s API reference.
-
static reference(obj, version=None, pkg_version_strategy='major', obj_version_strategy='major')[source]
Create a reference to given object.
- Parameters:
obj (T2) –
version (str | None) –
pkg_version_strategy (Literal['exact', 'minor', 'major']) –
obj_version_strategy (Literal['exact', 'minor', 'major']) –
- Return type:
PyObjectRef[T2]
-
static from_url(url, obj_type)[source]
Create a reference from given URL.
- Parameters:
-
- Return type:
PyObjectRef[T]
-
to_url()[source]
Convert object reference to URL.
- Return type:
str
-
resolve()[source]
Resolve object reference.
- Return type:
T
-
stref(obj)[source]
Get string representation of given object reference.
- Parameters:
obj (Any) –
- Return type:
str