Skip to content

Commit e63c9d9

Browse files
docs: inject AnyValue into attributes namespace via conf.py instead of re-exporting
Signed-off-by: Raajhesh Kannaa Chidambaram <495042+raajheshkannaa@users.noreply.github.com>
1 parent 9ede05f commit e63c9d9

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

docs/conf.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626

2727
settings.configure()
2828

29+
# Provide AnyValue in opentelemetry.attributes module's namespace so the
30+
# "AnyValue" forward reference in opentelemetry.util.types._ExtendedAttributes
31+
# resolves when sphinx_autodoc_typehints calls typing.get_type_hints() on
32+
# BoundedAttributes (whose __globals__ is the attributes module). Docs-only.
33+
import opentelemetry.attributes # noqa: E402
34+
from opentelemetry.util.types import AnyValue as _AnyValue # noqa: E402
35+
36+
opentelemetry.attributes.AnyValue = _AnyValue
37+
2938

3039
source_dirs = [
3140
os.path.abspath("../opentelemetry-instrumentation/src/"),

opentelemetry-api/src/opentelemetry/attributes/__init__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@
99

1010
from opentelemetry.util import types
1111

12-
# Re-exported so the "AnyValue" forward reference in
13-
# util.types._ExtendedAttributes resolves against this module's globals when
14-
# sphinx_autodoc_typehints introspects BoundedAttributes.
15-
from opentelemetry.util.types import AnyValue
16-
17-
__all__ = ["AnyValue", "BoundedAttributes"]
18-
1912
# bytes are accepted as a user supplied value for attributes but
2013
# decoded to strings internally.
2114
_VALID_ATTR_VALUE_TYPES = (bool, str, bytes, int, float)

0 commit comments

Comments
 (0)