Skip to content
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

Replace flake8 and isort with Ruff #14212

Merged
merged 6 commits into from
Apr 11, 2023
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
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 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
2 changes: 1 addition & 1 deletion cloudera/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from contextlib import nullcontext as does_not_raise

import pytest
from tests.common import METRICS

from datadog_checks.base.types import ServiceCheck
from datadog_checks.cloudera.metrics import TIMESERIES_METRICS
from tests.common import METRICS


@pytest.mark.usefixtures('dd_environment')
Expand Down
2 changes: 1 addition & 1 deletion cloudera/tests/test_unit_autodiscover.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import mock
import pytest
from packaging.version import Version
from tests.common import query_time_series

from datadog_checks.base.types import ServiceCheck
from datadog_checks.cloudera.metrics import NATIVE_METRICS, TIMESERIES_METRICS
from tests.common import query_time_series

pytestmark = [pytest.mark.unit]

Expand Down
2 changes: 1 addition & 1 deletion cloudera/tests/test_unit_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import mock
import pytest
from packaging.version import Version
from tests.common import query_time_series

from datadog_checks.base.types import ServiceCheck
from datadog_checks.cloudera.metrics import TIMESERIES_METRICS
from tests.common import query_time_series

pytestmark = [pytest.mark.unit]

Expand Down
2 changes: 1 addition & 1 deletion cloudera/tests/test_unit_disks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import mock
import pytest
from packaging.version import Version
from tests.common import query_time_series

from datadog_checks.base.types import ServiceCheck
from datadog_checks.cloudera.metrics import TIMESERIES_METRICS
from tests.common import query_time_series

pytestmark = [pytest.mark.unit]

Expand Down
2 changes: 1 addition & 1 deletion cloudera/tests/test_unit_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import mock
import pytest
from packaging.version import Version
from tests.common import query_time_series

from datadog_checks.base.types import ServiceCheck
from datadog_checks.cloudera.metrics import NATIVE_METRICS, TIMESERIES_METRICS
from tests.common import query_time_series

pytestmark = [pytest.mark.unit]

Expand Down
2 changes: 1 addition & 1 deletion cloudera/tests/test_unit_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import mock
import pytest
from packaging.version import Version
from tests.common import query_time_series

from datadog_checks.base.types import ServiceCheck
from datadog_checks.cloudera.metrics import TIMESERIES_METRICS
from tests.common import query_time_series

pytestmark = [pytest.mark.unit]

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(
iliakur marked this conversation as resolved.
Show resolved Hide resolved
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)
Loading