Skip to content

Commit

Permalink
Store ints as ints in the configuration object
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Sep 16, 2020
1 parent 751e813 commit 25313c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 4 additions & 5 deletions opentelemetry-api/src/opentelemetry/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,10 @@ def __new__(cls) -> "Configuration":
try:
value = int(value_str)
except ValueError:
pass
try:
value = float(value_str)
except ValueError:
pass
try:
value = float(value_str)
except ValueError:
pass

instance._config_map[key] = value

Expand Down
9 changes: 6 additions & 3 deletions opentelemetry-api/tests/configuration/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,18 @@ def test_boolean(self) -> None:
},
)
def test_integer(self) -> None:
# pylint: disable=no-member
self.assertTrue(isinstance(Configuration().POSITIVE_INTEGER, int))
self.assertEqual(
Configuration().POSITIVE_INTEGER, 123
) # pylint: disable=no-member
)
self.assertTrue(isinstance(Configuration().NEGATIVE_INTEGER, int))
self.assertEqual(
Configuration().NEGATIVE_INTEGER, -123
) # pylint: disable=no-member
)
self.assertEqual(
Configuration().NON_INTEGER, "-12z3"
) # pylint: disable=no-member
)

@patch.dict(
"os.environ", # type: ignore
Expand Down

0 comments on commit 25313c5

Please sign in to comment.