Skip to content

Commit

Permalink
Add type annotations for test helper functions
Browse files Browse the repository at this point in the history
Since we have `disallow_untyped_calls = True` in our mypy config for
tests, we must add type annotations to any function that is called
from a test.
  • Loading branch information
johananl committed Oct 21, 2019
1 parent 88f428c commit 8dd4160
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions opentelemetry-api/tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import sys
import unittest
from importlib import reload
from typing import Any, Callable

from opentelemetry import trace
from opentelemetry.util import loader
Expand Down Expand Up @@ -59,7 +60,7 @@ def test_preferred_impl(self):

# NOTE: We use do_* + *_<arg> methods because subtest wouldn't run setUp,
# which we require here.
def do_test_preferred_impl(self, setter):
def do_test_preferred_impl(self, setter: Callable[[Any], Any]) -> None:
setter(get_opentelemetry_implementation)
tracer = trace.tracer()
self.assertIs(tracer, DUMMY_TRACER)
Expand All @@ -81,7 +82,7 @@ def test_try_set_again(self):
)
self.assertIn("already loaded", str(einfo.exception))

def do_test_get_envvar(self, envvar_suffix):
def do_test_get_envvar(self, envvar_suffix: str) -> None:
global DUMMY_TRACER # pylint:disable=global-statement

# Test is not runnable with this!
Expand Down

0 comments on commit 8dd4160

Please sign in to comment.