Skip to content

Set float_to_top isort flag #5170

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

Closed
wants to merge 3 commits into from
Closed
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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.8.0
rev: 5.9.3
hooks:
- id: isort
language_version: python3
Expand Down
6 changes: 3 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# https://pytest.org/latest/example/simple.html#control-skipping-of-tests-according-to-command-line-option
import pytest

# Make all fixtures available
from distributed.utils_test import * # noqa

# Uncomment to enable more logging and checks
# (https://docs.python.org/3/library/asyncio-dev.html)
# Note this makes things slower and might consume much memory.
Expand All @@ -16,9 +19,6 @@
except Exception:
pass

# Make all fixtures available
from distributed.utils_test import * # noqa


def pytest_addoption(parser):
parser.addoption("--runslow", action="store_true", help="run slow tests")
Expand Down
8 changes: 1 addition & 7 deletions distributed/_ipython_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@

import atexit
import os

try:
import queue
except ImportError:
# Python 2
import Queue as queue

import queue
Comment on lines 7 to +9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

import sys
from subprocess import Popen
from threading import Event, Thread
Expand Down
10 changes: 4 additions & 6 deletions distributed/cli/tests/test_dask_scheduler.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import psutil
import pytest

pytest.importorskip("requests")

import os
import shutil
import sys
import tempfile
from time import sleep

import requests
import psutil
import pytest
from click.testing import CliRunner

import distributed
Expand All @@ -24,6 +20,8 @@
popen,
)

requests = pytest.importorskip("requests")


def test_defaults(loop):
with popen(["dask-scheduler"]):
Expand Down
11 changes: 4 additions & 7 deletions distributed/cli/tests/test_dask_worker.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import asyncio

import pytest
from click.testing import CliRunner

pytest.importorskip("requests")

import os
from multiprocessing import cpu_count
from time import sleep

import requests
import pytest
from click.testing import CliRunner

import distributed.cli.dask_worker
from distributed import Client, Scheduler
Expand All @@ -19,6 +14,8 @@
from distributed.utils import parse_ports, sync, tmpfile
from distributed.utils_test import gen_cluster, popen, terminate_process, wait_for_port

requests = pytest.importorskip("requests")


def test_nanny_worker_ports(loop):
with popen(["dask-scheduler", "--port", "9359", "--no-dashboard"]):
Expand Down
10 changes: 3 additions & 7 deletions distributed/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
from queue import Queue as pyQueue

from tlz import first, groupby, keymap, merge, partition_all, valmap
from tornado import gen
from tornado.ioloop import IOLoop, PeriodicCallback

import dask
from dask.base import collections_to_dsk, normalize_token, tokenize
from dask.core import flatten
from dask.delayed import single_key
from dask.highlevelgraph import HighLevelGraph
from dask.optimization import SubgraphCallable
from dask.utils import (
Expand All @@ -41,13 +44,6 @@
stringify,
)

try:
from dask.delayed import single_key
except ImportError:
single_key = first
from tornado import gen
from tornado.ioloop import IOLoop, PeriodicCallback

from . import versions as version_module
from .batched import BatchedSend
from .cfexecutor import ClientExecutor
Expand Down
15 changes: 7 additions & 8 deletions distributed/comm/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@
import weakref
from ssl import SSLCertVerificationError, SSLError

from tornado import gen

try:
import ssl
except ImportError:
ssl = None

from tlz import sliding_window
from tornado import netutil
from tornado import gen, netutil
from tornado.iostream import StreamClosedError
from tornado.tcpclient import TCPClient
from tornado.tcpserver import TCPServer
Expand All @@ -33,6 +26,12 @@
from .registry import Backend, backends
from .utils import ensure_concrete_host, from_frames, get_tcp_server_address, to_frames

try:
import ssl
except ImportError:
ssl = None


logger = logging.getLogger(__name__)


Expand Down
9 changes: 5 additions & 4 deletions distributed/comm/tests/test_ucx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

import pytest

pytestmark = pytest.mark.gpu

ucp = pytest.importorskip("ucp")

from distributed import Client, Scheduler, wait
from distributed.comm import connect, listen, parse_address, ucx
from distributed.comm.registry import backends, get_backend
from distributed.deploy.local import LocalCluster
from distributed.protocol import to_serialize
from distributed.utils_test import gen_cluster, gen_test, inc

pytestmark = pytest.mark.gpu

ucp = pytest.importorskip("ucp")


try:
HOST = ucp.get_address()
except Exception:
Expand Down
5 changes: 3 additions & 2 deletions distributed/comm/tests/test_ucx_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

import pytest

pytestmark = pytest.mark.gpu

import dask

from distributed import Client
from distributed.comm.ucx import _scrub_ucx_config
from distributed.utils import get_ip
from distributed.utils_test import popen

pytestmark = pytest.mark.gpu


try:
HOST = get_ip()
except Exception:
Expand Down
13 changes: 7 additions & 6 deletions distributed/dashboard/components/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from bokeh.plotting import figure
from bokeh.themes import Theme
from bokeh.transform import cumsum, factor_cmap, linear_cmap
from jinja2 import Environment, FileSystemLoader
from tlz import curry, pipe
from tlz.curried import concat, groupby, map
from tornado import escape
Expand All @@ -48,11 +49,6 @@
from dask import config
from dask.utils import format_bytes, format_time, key_split, parse_timedelta

try:
import numpy as np
except ImportError:
np = False

from distributed.dashboard.components import add_periodic_callback
from distributed.dashboard.components.shared import (
DashboardComponent,
Expand All @@ -69,14 +65,19 @@
from distributed.metrics import time
from distributed.utils import Log, log_errors

try:
import numpy as np
except ImportError:
np = False


if dask.config.get("distributed.dashboard.export-tool"):
from distributed.dashboard.export_tool import ExportTool
else:
ExportTool = None

logger = logging.getLogger(__name__)

from jinja2 import Environment, FileSystemLoader

env = Environment(
loader=FileSystemLoader(
Expand Down
2 changes: 1 addition & 1 deletion distributed/dashboard/components/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from bokeh.palettes import RdBu
from bokeh.plotting import figure
from bokeh.themes import Theme
from jinja2 import Environment, FileSystemLoader
from tlz import merge, partition_all

from dask.utils import format_bytes, format_time
Expand All @@ -37,7 +38,6 @@

logger = logging.getLogger(__name__)

from jinja2 import Environment, FileSystemLoader

env = Environment(
loader=FileSystemLoader(
Expand Down
3 changes: 2 additions & 1 deletion distributed/dashboard/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
from bokeh.application.handlers.function import FunctionHandler
from bokeh.server.server import BokehTornado

import dask

try:
from bokeh.server.util import create_hosts_allowlist
except ImportError:
from bokeh.server.util import create_hosts_whitelist as create_hosts_allowlist

import dask

if LooseVersion(bokeh.__version__) < LooseVersion("1.0.0"):
warnings.warn(
Expand Down
4 changes: 3 additions & 1 deletion distributed/dashboard/tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import pytest

pytest.importorskip("bokeh")
# isort: off
bokeh = pytest.importorskip("bokeh")
# isort: on

from bokeh.models import ColumnDataSource, Model

Expand Down
3 changes: 3 additions & 0 deletions distributed/dashboard/tests/test_scheduler_bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

import pytest

# isort: off
pytest.importorskip("bokeh")
# isort: on

from bokeh.server.server import BokehTornado
from tlz import first
from tornado.httpclient import AsyncHTTPClient, HTTPRequest
Expand Down
2 changes: 2 additions & 0 deletions distributed/dashboard/tests/test_worker_bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import pytest

# isort: off
pytest.importorskip("bokeh")
# isort: on
from tlz import first
from tornado.httpclient import AsyncHTTPClient

Expand Down
8 changes: 4 additions & 4 deletions distributed/deploy/old_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import sys
import time
import traceback
from threading import Thread

from tlz import merge
from tornado import gen

try:
from queue import Queue
except ImportError: # Python 2.7 fix
from Queue import Queue

from threading import Thread

from tlz import merge
from tornado import gen

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions distributed/deploy/tests/test_old_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import pytest

pytest.importorskip("paramiko")

from distributed import Client
from distributed.deploy.old_ssh import SSHCluster
from distributed.metrics import time

pytest.importorskip("paramiko")


@pytest.mark.avoid_ci
def test_cluster(loop):
Expand Down
9 changes: 5 additions & 4 deletions distributed/deploy/tests/test_ssh.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import pytest

pytest.importorskip("asyncssh")

import sys

import pytest

import dask

from distributed import Client
from distributed.compatibility import MACOS, WINDOWS
from distributed.deploy.ssh import SSHCluster

pytest.importorskip("asyncssh")


pytestmark = [
pytest.mark.xfail(MACOS, reason="very high flakiness; see distributed/issues/4543"),
pytest.mark.skipif(WINDOWS, reason="no CI support; see distributed/issues/4509"),
Expand Down
8 changes: 4 additions & 4 deletions distributed/diagnostics/tests/test_nvml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import pytest

pytestmark = pytest.mark.gpu

pynvml = pytest.importorskip("pynvml")

import dask

from distributed.diagnostics import nvml
from distributed.utils_test import gen_cluster

pytestmark = pytest.mark.gpu

pynvml = pytest.importorskip("pynvml")


def test_one_time():
if nvml.device_get_count() < 1:
Expand Down
4 changes: 2 additions & 2 deletions distributed/diagnostics/tests/test_progress_stream.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import pytest

pytest.importorskip("bokeh")

from dask import delayed

from distributed.client import wait
from distributed.diagnostics.progress_stream import progress_quads, progress_stream
from distributed.utils_test import div, gen_cluster, inc

pytest.importorskip("bokeh")


def test_progress_quads():
msg = {
Expand Down
Loading