Skip to content

Commit

Permalink
Ignore F401 for unused imports used in typings (#14213)
Browse files Browse the repository at this point in the history
* add comment

* Fix all C linting errors (#14214)

* ignore existing F401

* fix all C linting errors

* resolve merge conflicts

* Fix misc linting issues (#14215)

* fix misc issues

* Ignore minor linting issues (#14216)

* ignore minor issues

* change flake8 to ruff (#14223)

* licence sync
  • Loading branch information
steveny91 committed Mar 28, 2023
1 parent c70e023 commit f2c5990
Show file tree
Hide file tree
Showing 265 changed files with 672 additions and 684 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog-label-check.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import os
import re
import re # noqa: F401


with open(os.environ['GITHUB_EVENT_PATH']) as event_file:
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/reminder/remind.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) Datadog, Inc. 2019-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import json
import json # noqa: F401
import os
import sys
import time
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/validate-logs-intgs/validate_log_intgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This script is expected to run from a CLI, do not import it."""
import sys
import json
from typing import List, Optional, Set
from typing import List, Optional, Set # noqa: F401
import re
import yaml
import os
Expand Down
6 changes: 3 additions & 3 deletions .stubs/pyVmomi/vim/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ from datetime import datetime
from enum import Enum
from typing import Any, List

from . import event
from . import fault
from . import view
from . import event # noqa: F401
from . import fault # noqa: F401
from . import view # noqa: F401
from ..vmodl.query import PropertyCollector
from .event import EventManager
from .option import OptionManager
Expand Down
4 changes: 2 additions & 2 deletions .stubs/pyVmomi/vim/option.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, List, Type
from typing import Any, List, Type # noqa: F401

from pyVmomi.vim import ManagedEntity
from pyVmomi.vim import ManagedEntity # noqa: F401

class OptionManager:
def QueryOptions(self, name: str) -> List[OptionValue]: ...
Expand Down
4 changes: 2 additions & 2 deletions .stubs/pyVmomi/vmodl/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any

from . import fault
from . import query
from . import fault # noqa: F401
from . import query # noqa: F401

class DynamicProperty:
name: str
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Component,Origin,License,Copyright
JPype1,PyPI,Apache-2.0,Copyright (c) 2004-2008 Steve Menard
JayDeBeApi,PyPI,LGPL-3.0-only,Copyright (C) 2014 Bastian Bowe
PyJWT,PyPI,MIT,Copyright (c) 2015-2022 José Padilla
PyMySQL,PyPI,MIT,"Copyright (c) 2010, 2013 PyMySQL contributors"
PySocks,PyPI,BSD-3-Clause,Copyright 2006 Dan-Haim. All rights reserved.
PyYAML,PyPI,MIT,Copyright (c) 2017-2021 Ingy döt Net
Pyro4,PyPI,MIT,Copyright (c) 2016 Irmen de Jong
Expand Down Expand Up @@ -64,6 +63,7 @@ pycryptodomex,PyPI,Unlicense,Helder Eijs. pycryptodomex is dedicated to the publ
pydantic,PyPI,MIT,Copyright (c) 2017 - 2022 Samuel Colvin and other contributors
pymongo,PyPI,Apache-2.0,Copyright 2009 The MongoDB Python Team
pymqi,PyPI,PSF,Copyright (c) Zato Source s.r.o.
pymysql,PyPI,MIT,"Copyright (c) 2010, 2013 PyMySQL contributors"
pyodbc,PyPI,MIT,Copyright (c) 2008 Michael Kleehammer
pysmi,PyPI,BSD-3-Clause,Copyright (c) 2015-2020 Ilya Etingof <etingof@gmail.com>
pysnmp,PyPI,BSD-3-Clause,"Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>"
Expand Down
2 changes: 1 addition & 1 deletion active_directory/tests/test_active_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from datadog_checks.active_directory import ActiveDirectoryCheck
from datadog_checks.active_directory.metrics import DEFAULT_COUNTERS
from datadog_checks.base.stubs.aggregator import AggregatorStub
from datadog_checks.base.stubs.aggregator import AggregatorStub # noqa: F401
from datadog_checks.dev.testing import requires_py2
from datadog_checks.dev.utils import get_metadata_metrics

Expand Down
2 changes: 1 addition & 1 deletion aerospike/datadog_checks/aerospike/aerospike.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import re
from collections import defaultdict
from typing import List
from typing import List # noqa: F401

from six import PY2, iteritems

Expand Down
6 changes: 3 additions & 3 deletions azure_iot_edge/datadog_checks/azure_iot_edge/config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from typing import List
from typing import List # noqa: F401

from datadog_checks.base import ConfigurationError
from datadog_checks.base.types import InstanceType
from datadog_checks.base.types import InstanceType # noqa: F401

from .metrics import EDGE_AGENT_METRICS, EDGE_AGENT_TYPE_OVERRIDES, EDGE_HUB_METRICS
from .types import Instance
from .types import Instance # noqa: F401


class Config(object):
Expand Down
1 change: 0 additions & 1 deletion azure_iot_edge/datadog_checks/azure_iot_edge/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
'edgehub_reported_properties_update_duration_seconds': 'reported_properties_update_duration_seconds',
'edgehub_direct_method_duration_seconds': 'direct_method_duration_seconds',
'edgehub_direct_methods_total': 'direct_methods_total',
'edgehub_queue_length': 'queue_length',
'edgehub_messages_dropped_total': 'messages_dropped_total',
'edgehub_messages_unack_total': 'messages_unack_total',
'edgehub_offline_count_total': 'offline_count_total',
Expand Down
2 changes: 1 addition & 1 deletion azure_iot_edge/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import os
from typing import List, Tuple
from typing import List, Tuple # noqa: F401

from datadog_checks.base import is_affirmative
from datadog_checks.base.stubs.aggregator import AggregatorStub
Expand Down
2 changes: 1 addition & 1 deletion azure_iot_edge/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from datadog_checks.azure_iot_edge.types import Instance
from datadog_checks.azure_iot_edge.types import Instance # noqa: F401
from datadog_checks.dev import docker_run
from datadog_checks.dev.conditions import CheckDockerLogs, WaitFor

Expand Down
2 changes: 1 addition & 1 deletion azure_iot_edge/tests/e2e_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from typing import Any
from typing import Any # noqa: F401

import requests

Expand Down
8 changes: 4 additions & 4 deletions azure_iot_edge/tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import copy
from typing import Callable
from typing import Callable # noqa: F401

import pytest
import requests

from datadog_checks.azure_iot_edge import AzureIoTEdgeCheck
from datadog_checks.azure_iot_edge.types import Instance
from datadog_checks.base.stubs.aggregator import AggregatorStub
from datadog_checks.base.stubs.datadog_agent import DatadogAgentStub
from datadog_checks.azure_iot_edge.types import Instance # noqa: F401
from datadog_checks.base.stubs.aggregator import AggregatorStub # noqa: F401
from datadog_checks.base.stubs.datadog_agent import DatadogAgentStub # noqa: F401
from datadog_checks.dev.utils import get_metadata_metrics

from . import common
Expand Down
2 changes: 1 addition & 1 deletion azure_iot_edge/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from datadog_checks.azure_iot_edge.config import Config
from datadog_checks.azure_iot_edge.metrics import EDGE_AGENT_METRICS, EDGE_AGENT_TYPE_OVERRIDES, EDGE_HUB_METRICS
from datadog_checks.azure_iot_edge.types import Instance
from datadog_checks.azure_iot_edge.types import Instance # noqa: F401
from datadog_checks.base import ConfigurationError


Expand Down
4 changes: 2 additions & 2 deletions azure_iot_edge/tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import copy
from typing import Callable
from typing import Callable # noqa: F401

import pytest
import requests

from datadog_checks.azure_iot_edge import AzureIoTEdgeCheck
from datadog_checks.base.stubs.aggregator import AggregatorStub
from datadog_checks.base.stubs.aggregator import AggregatorStub # noqa: F401

from . import common

Expand Down
4 changes: 2 additions & 2 deletions cacti/datadog_checks/cacti/cacti.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _read_rrd(self, rrd_path, hostname, device_name, tags):
return metric_count

# Find the consolidation functions for the RRD metrics
c_funcs = set([v for k, v in info.items() if k.endswith('.cf')])
c_funcs = {v for k, v in info.items() if k.endswith('.cf')}
if not c_funcs:
self.log.debug("No funcs found for %s", rrd_path)

Expand Down Expand Up @@ -223,7 +223,7 @@ def _in_whitelist(rrd):
res.append((hostname, device_name, rrd_path))

# Collect stats
num_hosts = len(set([r[0] for r in res]))
num_hosts = len({r[0] for r in res})
self.gauge('cacti.rrd.count', len(res), tags=tags)
self.gauge('cacti.hosts.count', num_hosts, tags=tags)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) Datadog, Inc. 2021-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from typing import Any, Dict, List
from typing import Any, Dict, List # noqa: F401

import yaml
from six.moves import xmlrpc_client as xmlrpclib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import re
from typing import Any, List, Optional, Tuple
from typing import Any, List, Optional, Tuple # noqa: F401

SIMPLE_METRICS = {
'memory': '.memory',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import copy
import json
import time
from typing import Any, Dict, Generator, Tuple
from typing import Any, Dict, Generator, Tuple # noqa: F401

from requests.exceptions import HTTPError, RequestException
from semver import VersionInfo
from six.moves.urllib_parse import urlparse

from datadog_checks.base import AgentCheck
from datadog_checks.base.errors import CheckException, ConfigurationError
from datadog_checks.base.types import Event
from datadog_checks.base.types import Event # noqa: F401

from .constants import (
API_SERVICE_CHECK_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from datetime import datetime
from typing import Any, Dict
from typing import Any, Dict # noqa: F401

from dateutil import parser, tz
from six.moves.urllib_parse import urljoin
Expand Down
4 changes: 2 additions & 2 deletions confluent_platform/tests/test_e2e.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from typing import Any
from typing import Any # noqa: F401

import pytest

from datadog_checks.base.stubs.aggregator import AggregatorStub
from datadog_checks.base.stubs.aggregator import AggregatorStub # noqa: F401

from .common import CHECK_CONFIG
from .conftest import CONFLUENT_VERSION
Expand Down
18 changes: 9 additions & 9 deletions consul/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,14 +518,14 @@ def test_config(test_case, extra_config, expected_http_kwargs, mocker):

check.check(None)

http_wargs = dict(
auth=mock.ANY,
cert=mock.ANY,
headers=mock.ANY,
proxies=mock.ANY,
timeout=mock.ANY,
verify=mock.ANY,
allow_redirects=mock.ANY,
)
http_wargs = {
'auth': mock.ANY,
'cert': mock.ANY,
'headers': mock.ANY,
'proxies': mock.ANY,
'timeout': mock.ANY,
'verify': mock.ANY,
'allow_redirects': mock.ANY,
}
http_wargs.update(expected_http_kwargs)
r.get.assert_called_with('/v1/status/leader', **http_wargs)
2 changes: 1 addition & 1 deletion couch/tests/test_couchv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def run(self):
self.compact_views()
theid = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
docs.append(self.post_doc(theid))
docs = list(map(lambda x: self.update_doc(x), docs))
docs = [self.update_doc(x) for x in docs]
self.generate_views()

def generate_views(self):
Expand Down
18 changes: 9 additions & 9 deletions couch/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ def test_config(test_case, extra_config, expected_http_kwargs):

check.check(instance)

http_wargs = dict(
auth=mock.ANY,
cert=mock.ANY,
headers=mock.ANY,
proxies=mock.ANY,
timeout=mock.ANY,
verify=mock.ANY,
allow_redirects=mock.ANY,
)
http_wargs = {
'auth': mock.ANY,
'cert': mock.ANY,
'headers': mock.ANY,
'proxies': mock.ANY,
'timeout': mock.ANY,
'verify': mock.ANY,
'allow_redirects': mock.ANY,
}
http_wargs.update(expected_http_kwargs)

r.get.assert_called_with('http://{}:5984/_all_dbs/'.format(common.HOST), **http_wargs)
18 changes: 9 additions & 9 deletions couchbase/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ def test_config(test_case, dd_run_check, extra_config, expected_http_kwargs, ins

dd_run_check(check)

http_wargs = dict(
auth=mock.ANY,
cert=mock.ANY,
headers=mock.ANY,
proxies=mock.ANY,
timeout=mock.ANY,
verify=mock.ANY,
allow_redirects=mock.ANY,
)
http_wargs = {
'auth': mock.ANY,
'cert': mock.ANY,
'headers': mock.ANY,
'proxies': mock.ANY,
'timeout': mock.ANY,
'verify': mock.ANY,
'allow_redirects': mock.ANY,
}
http_wargs.update(expected_http_kwargs)
r.get.assert_called_with('http://localhost:8091/pools/default/tasks', **http_wargs)

Expand Down
20 changes: 10 additions & 10 deletions datadog_checks_base/datadog_checks/base/checks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import unicodedata
from collections import deque
from os.path import basename
from typing import TYPE_CHECKING, Any, AnyStr, Callable, Deque, Dict, List, Optional, Sequence, Set, Tuple, Union
from typing import TYPE_CHECKING, Any, AnyStr, Callable, Deque, Dict, List, Optional, Sequence, Set, Tuple, Union # noqa: F401

import yaml
from six import PY2, binary_type, iteritems, raise_from, text_type
Expand All @@ -21,13 +21,13 @@
from ..constants import ServiceCheck
from ..errors import ConfigurationError
from ..types import (
AgentConfigType,
Event,
ExternalTagType,
InitConfigType,
InstanceType,
ProxySettings,
ServiceCheckStatus,
AgentConfigType, # noqa: F401
Event, # noqa: F401
ExternalTagType, # noqa: F401
InitConfigType, # noqa: F401
InstanceType, # noqa: F401
ProxySettings, # noqa: F401
ServiceCheckStatus, # noqa: F401
)
from ..utils.agent.utils import should_profile_memory
from ..utils.common import ensure_bytes, to_native_string
Expand Down Expand Up @@ -70,7 +70,7 @@
from pydantic import BaseModel, ValidationError

if TYPE_CHECKING:
import ssl
import ssl # noqa: F401

# Metric types for which it's only useful to submit once per set of tags
ONE_PER_CONTEXT_METRIC_TYPES = [aggregator.GAUGE, aggregator.RATE, aggregator.MONOTONIC_COUNT]
Expand Down Expand Up @@ -439,7 +439,7 @@ def log_typos_in_options(self, user_config, models_config, level):
models_config = models_config or {}
typos = set() # type: Set[str]

known_options = set([k for k, _ in models_config]) # type: Set[str]
known_options = {k for k, _ in models_config} # type: Set[str]

if not PY2:

Expand Down
Loading

0 comments on commit f2c5990

Please sign in to comment.