Skip to content

Add type check to travis #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[mypy]
disallow_any_unimported = True
disallow_any_expr = True
disallow_any_decorated = True
disallow_any_explicit = True
disallow_any_generics = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
warn_unused_ignores = True
warn_return_any = True
13 changes: 13 additions & 0 deletions opentelemetry-api/opentelemetry/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2019, OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
12 changes: 6 additions & 6 deletions opentelemetry-api/opentelemetry/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"""

from contextlib import contextmanager
from typing import Iterator
import typing


class Tracer:
Expand All @@ -85,8 +85,8 @@ def get_current_span(self) -> 'Span':
"""


@contextmanager
def start_span(self, name: str, parent: 'Span') -> Iterator['Span']:
@contextmanager # type: ignore
def start_span(self, name: str, parent: 'Span') -> typing.Iterator['Span']:
"""Context manager for span creation.

Create a new child of the current span, or create a root span if no
Expand Down Expand Up @@ -154,8 +154,8 @@ def create_span(self, name: str, parent: 'Span') -> 'Span':
The newly-created span.
"""

@contextmanager
def use_span(self, span: 'Span') -> Iterator[None]:
@contextmanager # type: ignore
def use_span(self, span: 'Span') -> typing.Iterator[None]:
"""Context manager for controlling a span's lifetime.

Start the given span and set it as the current span in this tracer's
Expand Down Expand Up @@ -229,5 +229,5 @@ class TraceOptions(int):


# TODO
class TraceState(dict):
class TraceState(typing.Dict[str, str]):
pass
1 change: 1 addition & 0 deletions opentelemetry-api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
include_package_data=True,
long_description=open("README.rst").read(),
install_requires=[
"typing; python_version<'3.5'",
],
extras_require={},
license="Apache-2.0",
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[tox]
skipsdist = True
envlist = py37-lint
envlist = py37-lint, py37-mypy

[testenv]
deps =
py37-lint: pylint
py37-mypy: mypy

commands =
py37-lint: pylint opentelemetry-api/opentelemetry/trace/
py37-lint: pylint opentelemetry-api/opentelemetry/
py37-mypy: mypy opentelemetry-api/opentelemetry/