From 18a464237f2c0c871fac8dd8f4b1a450381489d0 Mon Sep 17 00:00:00 2001 From: Hendrik Makait Date: Fri, 1 Jul 2022 18:34:49 +0200 Subject: [PATCH] Merge `extend-ignore` and `ignore` values for `flake8` (#6660) --- distributed/comm/ucx.py | 3 ++- distributed/dashboard/components/scheduler.py | 3 +-- distributed/dashboard/components/worker.py | 4 +--- distributed/protocol/numpy.py | 5 ++++- distributed/tests/test_scheduler.py | 4 +++- docs/source/conf.py | 20 +++++++++---------- setup.cfg | 20 ++++++++++--------- 7 files changed, 32 insertions(+), 27 deletions(-) diff --git a/distributed/comm/ucx.py b/distributed/comm/ucx.py index 0573d745803..16ce82d49d2 100644 --- a/distributed/comm/ucx.py +++ b/distributed/comm/ucx.py @@ -134,7 +134,8 @@ def init_once(): try: import rmm - device_array = lambda n: rmm.DeviceBuffer(size=n) + def device_array(n): + return rmm.DeviceBuffer(size=n) if pool_size_str is not None: pool_size = parse_bytes(pool_size_str) diff --git a/distributed/dashboard/components/scheduler.py b/distributed/dashboard/components/scheduler.py index 5617282f089..0d2f0883e13 100644 --- a/distributed/dashboard/components/scheduler.py +++ b/distributed/dashboard/components/scheduler.py @@ -48,6 +48,7 @@ from bokeh.plotting import figure from bokeh.themes import Theme from bokeh.transform import cumsum, factor_cmap, linear_cmap, stack +from jinja2 import Environment, FileSystemLoader from tlz import curry, pipe, valmap from tlz.curried import concat, groupby, map from tornado import escape @@ -89,8 +90,6 @@ logger = logging.getLogger(__name__) -from jinja2 import Environment, FileSystemLoader - env = Environment( loader=FileSystemLoader( os.path.join(os.path.dirname(__file__), "..", "..", "http", "templates") diff --git a/distributed/dashboard/components/worker.py b/distributed/dashboard/components/worker.py index 2fa2518daef..20d55b7c9d6 100644 --- a/distributed/dashboard/components/worker.py +++ b/distributed/dashboard/components/worker.py @@ -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 @@ -35,9 +36,6 @@ from distributed.utils import log_errors logger = logging.getLogger(__name__) - -from jinja2 import Environment, FileSystemLoader - env = Environment( loader=FileSystemLoader( os.path.join(os.path.dirname(__file__), "..", "..", "http", "templates") diff --git a/distributed/protocol/numpy.py b/distributed/protocol/numpy.py index a9d54c76be1..4eda9cc8eae 100644 --- a/distributed/protocol/numpy.py +++ b/distributed/protocol/numpy.py @@ -25,7 +25,10 @@ def serialize_numpy_ndarray(x, context=None): if x.dtype.hasobject or (x.dtype.flags & np.core.multiarray.LIST_PICKLE): header = {"pickle": True} frames = [None] - buffer_callback = lambda f: frames.append(memoryview(f)) + + def buffer_callback(f): + frames.append(memoryview(f)) + frames[0] = pickle.dumps( x, buffer_callback=buffer_callback, diff --git a/distributed/tests/test_scheduler.py b/distributed/tests/test_scheduler.py index 175375dc19f..34f3a610175 100644 --- a/distributed/tests/test_scheduler.py +++ b/distributed/tests/test_scheduler.py @@ -582,7 +582,9 @@ def test_dumps_task(): d = dumps_task((inc, 1)) assert set(d) == {"function", "args"} - f = lambda x, y=2: x + y + def f(x, y=2): + return x + y + d = dumps_task((apply, f, (1,), {"y": 10})) assert cloudpickle.loads(d["function"])(1, 2) == 3 assert cloudpickle.loads(d["args"]) == (1,) diff --git a/docs/source/conf.py b/docs/source/conf.py index 81f735771fe..e048e4f7747 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,5 +1,15 @@ from __future__ import annotations +from docutils.parsers.rst import directives + +# -- Configuration to keep autosummary in sync with autoclass::members ---------------------------------------------- +# Fixes issues/3693 +# See https://stackoverflow.com/questions/20569011/python-sphinx-autosummary-automated-listing-of-member-functions +from sphinx.ext.autosummary import Autosummary, get_documenter +from sphinx.util.inspect import safe_getattr + +import distributed + # # Dask.distributed documentation build configuration file, created by # sphinx-quickstart on Tue Oct 6 14:42:44 2015. @@ -65,7 +75,6 @@ # built documents. # # The short X.Y version. -import distributed version = distributed.__version__ # The full version, including alpha/beta/rc tags. @@ -428,15 +437,6 @@ def copy_legacy_redirects(app, docname): f.write(page) -from docutils.parsers.rst import directives - -# -- Configuration to keep autosummary in sync with autoclass::members ---------------------------------------------- -# Fixes issues/3693 -# See https://stackoverflow.com/questions/20569011/python-sphinx-autosummary-automated-listing-of-member-functions -from sphinx.ext.autosummary import Autosummary, get_documenter -from sphinx.util.inspect import safe_getattr - - class AutoAutoSummary(Autosummary): """Create a summary for methods and attributes (autosummary). diff --git a/setup.cfg b/setup.cfg index 87e5bc40e23..bc76731dde2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,21 +3,23 @@ # https://flake8.readthedocs.io/en/latest/user/configuration.html # https://flake8.readthedocs.io/en/latest/user/error-codes.html -# Aligned with black https://github.com/psf/black/blob/main/.flake8 -extend-ignore = E203, E266, E501 # Note: there cannot be spaces after commas here exclude = __init__.py,versioneer.py,distributed/_concurrent_futures_thread.py ignore = - E4, # Import formatting - E731, # Assigning lambda expression - W503, # line break before binary operator - + # Ignores below are aligned with black https://github.com/psf/black/blob/main/.flake8 + E203, # Whitespace before ':' + E266, # Too many leading '#' for block comment + E501, # Line too long + W503, # Line break occurred before a binary operator per-file-ignores = **/tests/*: - # local variable is assigned to but never used - F841, - # Ambiguous variable name + # Module level import not at top of file (to silence on pytest.importorskip) + # See https://github.com/PyCQA/pycodestyle/issues/472 + E402, + # Do not use variables named 'I', 'O', or 'l' E741, + # Local variable name is assigned to but never used + F841, max-line-length = 88