Skip to content

Commit

Permalink
Add types to compat module (#6029)
Browse files Browse the repository at this point in the history
* Add types to compat module

* Refine types
  • Loading branch information
florimondmanca authored Mar 11, 2020
1 parent 0c14210 commit 15334a6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 12 additions & 4 deletions snmp/datadog_checks/snmp/compat.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under Simplified BSD License (see LICENSE)
from typing import Any, Optional

try:
from datadog_checks.base.utils.common import total_time_to_temporal_percent
except ImportError:

# Provide fallback for agent < 6.16
def total_time_to_temporal_percent(total_time, scale=1000):
def total_time_to_temporal_percent(total_time, scale=1000): # type: ignore
return total_time / scale * 100


try:
from datadog_agent import get_config, read_persistent_cache, write_persistent_cache
except ImportError:

def get_config(value):
def get_config(key):
# type: (str) -> Optional[str]
return ''

def write_persistent_cache(value, key):
def write_persistent_cache(key, value):
# type: (str, str) -> None
pass

def read_persistent_cache(value):
def read_persistent_cache(key):
# type: (str) -> Optional[str]
return ''
6 changes: 6 additions & 0 deletions snmp/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ envlist =
description =
py{27,38}: e2e ready
dd_check_style = true
dd_check_types = true
dd_mypy_args =
--py2
--disallow-untyped-defs
--follow-imports silent
datadog_checks/snmp/compat.py
usedevelop = true
platform = linux|darwin|win32
deps =
Expand Down

0 comments on commit 15334a6

Please sign in to comment.