Skip to content

Commit 0bf0fad

Browse files
authored
Add type check to travis (open-telemetry#31)
1 parent 38d08e5 commit 0bf0fad

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
lines changed

mypy.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[mypy]
2+
disallow_any_unimported = True
3+
disallow_any_expr = True
4+
disallow_any_decorated = True
5+
disallow_any_explicit = True
6+
disallow_any_generics = True
7+
disallow_subclassing_any = True
8+
disallow_untyped_calls = True
9+
disallow_untyped_defs = True
10+
disallow_incomplete_defs = True
11+
check_untyped_defs = True
12+
disallow_untyped_decorators = True
13+
warn_unused_ignores = True
14+
warn_return_any = True
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2019, OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.

opentelemetry-api/opentelemetry/trace/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"""
6464

6565
from contextlib import contextmanager
66-
from typing import Iterator
66+
import typing
6767

6868

6969
class Tracer:
@@ -85,8 +85,8 @@ def get_current_span(self) -> 'Span':
8585
"""
8686

8787

88-
@contextmanager
89-
def start_span(self, name: str, parent: 'Span') -> Iterator['Span']:
88+
@contextmanager # type: ignore
89+
def start_span(self, name: str, parent: 'Span') -> typing.Iterator['Span']:
9090
"""Context manager for span creation.
9191
9292
Create a new child of the current span, or create a root span if no
@@ -154,8 +154,8 @@ def create_span(self, name: str, parent: 'Span') -> 'Span':
154154
The newly-created span.
155155
"""
156156

157-
@contextmanager
158-
def use_span(self, span: 'Span') -> Iterator[None]:
157+
@contextmanager # type: ignore
158+
def use_span(self, span: 'Span') -> typing.Iterator[None]:
159159
"""Context manager for controlling a span's lifetime.
160160
161161
Start the given span and set it as the current span in this tracer's
@@ -229,5 +229,5 @@ class TraceOptions(int):
229229

230230

231231
# TODO
232-
class TraceState(dict):
232+
class TraceState(typing.Dict[str, str]):
233233
pass

opentelemetry-api/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
include_package_data=True,
4242
long_description=open("README.rst").read(),
4343
install_requires=[
44+
"typing; python_version<'3.5'",
4445
],
4546
extras_require={},
4647
license="Apache-2.0",

tox.ini

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
[tox]
22
skipsdist = True
3-
envlist = py37-lint
3+
envlist = py37-lint, py37-mypy
44

55
[testenv]
66
deps =
77
py37-lint: pylint
8+
py37-mypy: mypy
89

910
commands =
10-
py37-lint: pylint opentelemetry-api/opentelemetry/trace/
11+
py37-lint: pylint opentelemetry-api/opentelemetry/
12+
py37-mypy: mypy opentelemetry-api/opentelemetry/

0 commit comments

Comments
 (0)