Skip to content

Commit c36dd3d

Browse files
ocelotlalrex
authored and
Michael Stella
committed
Store ints as ints in the configuration object (open-telemetry#1119)
Fixes open-telemetry#1118 Co-authored-by: alrex <[email protected]>
1 parent 4c1ad74 commit c36dd3d

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

Diff for: opentelemetry-api/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
- Store `int`s as `int`s in the global Configuration object
6+
([#1118](https://github.com/open-telemetry/opentelemetry-python/pull/1118))
7+
58
## Version 0.13b0
69

710
Released 2020-09-17

Diff for: opentelemetry-api/src/opentelemetry/configuration/__init__.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,10 @@ def __new__(cls) -> "Configuration":
128128
try:
129129
value = int(value_str)
130130
except ValueError:
131-
pass
132-
try:
133-
value = float(value_str)
134-
except ValueError:
135-
pass
131+
try:
132+
value = float(value_str)
133+
except ValueError:
134+
pass
136135

137136
instance._config_map[key] = value
138137

Diff for: opentelemetry-api/tests/configuration/test_configuration.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,12 @@ def test_boolean(self) -> None:
119119
},
120120
)
121121
def test_integer(self) -> None:
122-
self.assertEqual(
123-
Configuration().POSITIVE_INTEGER, 123
124-
) # pylint: disable=no-member
125-
self.assertEqual(
126-
Configuration().NEGATIVE_INTEGER, -123
127-
) # pylint: disable=no-member
128-
self.assertEqual(
129-
Configuration().NON_INTEGER, "-12z3"
130-
) # pylint: disable=no-member
122+
# pylint: disable=no-member
123+
self.assertIsInstance(Configuration().POSITIVE_INTEGER, int)
124+
self.assertEqual(Configuration().POSITIVE_INTEGER, 123)
125+
self.assertIsInstance(Configuration().NEGATIVE_INTEGER, int)
126+
self.assertEqual(Configuration().NEGATIVE_INTEGER, -123)
127+
self.assertEqual(Configuration().NON_INTEGER, "-12z3")
131128

132129
@patch.dict(
133130
"os.environ", # type: ignore

0 commit comments

Comments
 (0)