From 15334a6652eb08345fae01723e15dc3a15b72f8a Mon Sep 17 00:00:00 2001 From: Florimond Manca Date: Wed, 11 Mar 2020 18:12:19 +0100 Subject: [PATCH] Add types to compat module (#6029) * Add types to compat module * Refine types --- snmp/datadog_checks/snmp/compat.py | 16 ++++++++++++---- snmp/tox.ini | 6 ++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/snmp/datadog_checks/snmp/compat.py b/snmp/datadog_checks/snmp/compat.py index 9da2c32d6888d..c737709875e59 100644 --- a/snmp/datadog_checks/snmp/compat.py +++ b/snmp/datadog_checks/snmp/compat.py @@ -1,9 +1,14 @@ +# (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 @@ -11,11 +16,14 @@ def total_time_to_temporal_percent(total_time, scale=1000): 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 '' diff --git a/snmp/tox.ini b/snmp/tox.ini index 71ed72f5fae08..15ad49dffef9e 100644 --- a/snmp/tox.ini +++ b/snmp/tox.ini @@ -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 =