diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb15d7c9fe93a0f0307edb33c62f76e1f8deec5a..eeb510f2f23a786135c719af081185e3045bade2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -100,3 +100,12 @@ Documentation: - python3.5 only: - master + +Flake8: + script: + - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh + - ". ./prepare-and-run-flake8.sh loopy test" + tags: + - python3.5 + except: + - tags diff --git a/loopy/__init__.py b/loopy/__init__.py index 6bd764f8df93f1b4b2ae5755c1c90ccddc654fe6..6cbb3362ef91b27c3b7b1cf6a591f7f9a20c2f7a 100644 --- a/loopy/__init__.py +++ b/loopy/__init__.py @@ -457,8 +457,8 @@ def _set_up_default_target(): set_default_target(target) -_set_up_default_target() +_set_up_default_target() # }}} diff --git a/loopy/kernel/__init__.py b/loopy/kernel/__init__.py index 5b192934c8f56ccf364d1b9ba58d81fa8c28ff63..5dff5e53c04521bcd2f53cb2fc971ec12227149c 100644 --- a/loopy/kernel/__init__.py +++ b/loopy/kernel/__init__.py @@ -1175,8 +1175,8 @@ class LoopKernel(ImmutableRecordWithoutPickling): import loopy as lp - Fore = self.options._fore - Style = self.options._style + Fore = self.options._fore # noqa + Style = self.options._style # noqa from loopy.kernel.tools import draw_dependencies_as_unicode_arrows for insn, (arrows, extender) in zip( diff --git a/loopy/kernel/creation.py b/loopy/kernel/creation.py index 024d97c3fed14e9917f9c21be0f17f555947f600..82f7ac5662e7e4f411562a9cbec1b0182835513b 100644 --- a/loopy/kernel/creation.py +++ b/loopy/kernel/creation.py @@ -695,7 +695,9 @@ def parse_instructions(instructions, defines): # {{{ pass 4: parsing insn_options_stack = [get_default_insn_options_dict()] - if_predicates_stack = [{'predicates' : frozenset(), 'insn_predicates' : frozenset()}] + if_predicates_stack = [ + {'predicates': frozenset(), + 'insn_predicates': frozenset()}] for insn in instructions: if isinstance(insn, InstructionBase): @@ -815,7 +817,6 @@ def parse_instructions(instructions, defines): "predicates", frozenset()) last_if_predicates = last_if_predicates - outer_predicates - if elif_match is not None: predicate = elif_match.group("predicate") if not predicate: @@ -861,7 +862,7 @@ def parse_instructions(instructions, defines): obj = insn_options_stack.pop() #if this object is the end of an if statement if obj['predicates'] == if_predicates_stack[-1]["insn_predicates"] and\ - if_predicates_stack[-1]["insn_predicates"]: + if_predicates_stack[-1]["insn_predicates"]: if_predicates_stack.pop() continue diff --git a/loopy/kernel/data.py b/loopy/kernel/data.py index ebadc72df30f6b9fe706d5c1f7d1606d03fdc41c..5195e0a107ad4c7f944f2eb56b5f3b248b5a4997 100644 --- a/loopy/kernel/data.py +++ b/loopy/kernel/data.py @@ -289,7 +289,7 @@ class InameArg(ValueArg): # {{{ temporary variable -class temp_var_scope: +class temp_var_scope: # noqa """Storage location of a temporary .. attribute:: PRIVATE @@ -404,8 +404,7 @@ class TemporaryVariable(ArrayBase): if base_indices is None: base_indices = (0,) * len(shape) - if (not read_only - and initializer is not None): + if not read_only and initializer is not None: raise LoopyError( "temporary variable '%s': " "read-write variables with initializer " diff --git a/loopy/kernel/instruction.py b/loopy/kernel/instruction.py index 93642103e50da5aabfcb7bd86cc50ce6ff903a18..7c82de1358f9bd11eb552a54a1e834317eb59ce5 100644 --- a/loopy/kernel/instruction.py +++ b/loopy/kernel/instruction.py @@ -489,7 +489,7 @@ def _get_assignee_subscript_deps(expr): # {{{ atomic ops -class memory_ordering: +class memory_ordering: # noqa """Ordering of atomic operations, defined as in C11 and OpenCL. .. attribute:: relaxed @@ -517,7 +517,7 @@ class memory_ordering: raise ValueError("Unknown value of memory_ordering") -class memory_scope: +class memory_scope: # noqa """Scope of atomicity, defined as in OpenCL. .. attribute:: auto diff --git a/loopy/schedule/__init__.py b/loopy/schedule/__init__.py index b449c01739a22ac79b2128106207dca51758a543..e23e5f350864a623d2ff05551fc2d559c361d734 100644 --- a/loopy/schedule/__init__.py +++ b/loopy/schedule/__init__.py @@ -416,15 +416,15 @@ def sched_item_to_insn_id(sched_item): # {{{ debug help def format_insn_id(kernel, insn_id): - Fore = kernel.options._fore - Style = kernel.options._style + Fore = kernel.options._fore # noqa + Style = kernel.options._style # noqa return Fore.GREEN + insn_id + Style.RESET_ALL def format_insn(kernel, insn_id): insn = kernel.id_to_insn[insn_id] - Fore = kernel.options._fore - Style = kernel.options._style + Fore = kernel.options._fore # noqa + Style = kernel.options._style # noqa from loopy.kernel.instruction import ( MultiAssignmentBase, NoOpInstruction, BarrierInstruction) if isinstance(insn, MultiAssignmentBase): @@ -645,8 +645,8 @@ def generate_loop_schedules_internal( # to give loops containing high-priority instructions a chance. kernel = sched_state.kernel - Fore = kernel.options._fore - Style = kernel.options._style + Fore = kernel.options._fore # noqa + Style = kernel.options._style # noqa if allow_boost is None: rec_allow_boost = None diff --git a/loopy/target/python.py b/loopy/target/python.py index 09a86665b7d949d7bf35b910cd2a6fd66109c1ec..99ec42f44b49f546cda324dfdb3c6a5b001d2222 100644 --- a/loopy/target/python.py +++ b/loopy/target/python.py @@ -134,7 +134,7 @@ class ExpressionToPythonMapper(StringifyMapper): # Synthesize PREC_IFTHENELSE, make sure it is in the right place in the # operator precedence hierarchy (right above "or"). from pymbolic.mapper.stringifier import PREC_LOGICAL_OR, PREC_NONE - PREC_IFTHENELSE = PREC_LOGICAL_OR - 1 + PREC_IFTHENELSE = PREC_LOGICAL_OR - 1 # noqa return self.parenthesize_if_needed( "{then} if {cond} else {else_}".format( diff --git a/loopy/transform/data.py b/loopy/transform/data.py index 5797b01c3b2822638b6555a8bde4203b856cfecc..6871cdbf46e7b117ea4e9047f0095f303b25667e 100644 --- a/loopy/transform/data.py +++ b/loopy/transform/data.py @@ -431,6 +431,7 @@ def set_array_axis_names(kernel, ary_names, dim_names): return kernel + set_array_dim_names = MovedFunctionDeprecationWrapper(set_array_axis_names) # }}} diff --git a/loopy/transform/padding.py b/loopy/transform/padding.py index 915742fc1003352c2952f27d87dbfd31fb26c9d7..d695e359558894c201f67e4013b25f5f45c19d82 100644 --- a/loopy/transform/padding.py +++ b/loopy/transform/padding.py @@ -245,6 +245,7 @@ def split_array_dim(kernel, arrays_and_axes, count, auto_split_inames=True, return kernel + split_arg_axis = MovedFunctionDeprecationWrapper(split_array_dim) # }}} diff --git a/setup.cfg b/setup.cfg index d34ecdd6d469b931929187c36be61a2ba4be25ad..56341fa9898c17d540e2c83ae4c7270f93049937 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,8 @@ [flake8] -ignore = E126,E127,E128,E123,E226,E241,E242,E265,N802,W503,E402 +ignore = E126,E127,E128,E123,E226,E241,E242,E265,N802,W503,E402,N814 max-line-length=85 +exclude= + loopy/target/c/compyte/ndarray, + loopy/target/c/compyte/array.py, + loopy/statistics.py, + test/test_statistics.py diff --git a/test/gnuma_loopy_transforms.py b/test/gnuma_loopy_transforms.py index 5a55f4a3d7d8bc1ff7580ebf1d79bcd1bd7cf7f6..bb521bd2c3bfe8346876fe9b85c6e53f5eb35fb0 100644 --- a/test/gnuma_loopy_transforms.py +++ b/test/gnuma_loopy_transforms.py @@ -14,7 +14,7 @@ def pick_apart_float_cast(value): return float(fval_match.group(2)) -def fix_euler_parameters(kernel, p_p0, p_Gamma, p_R): +def fix_euler_parameters(kernel, p_p0, p_Gamma, p_R): # noqa return lp.fix_parameters( kernel, p_p0=pick_apart_float_cast(p_p0), @@ -36,7 +36,7 @@ def set_D_storage_format(kernel): return lp.tag_array_axes(kernel, "D", "f,f") -def set_up_volume_loop(kernel, Nq): +def set_up_volume_loop(kernel, Nq): # noqa kernel = lp.fix_parameters(kernel, Nq=Nq) kernel = lp.prioritize_loops(kernel, "e,k,j,i") kernel = lp.tag_inames(kernel, dict(e="g.0", j="l.1", i="l.0")) diff --git a/test/library_for_test.py b/test/library_for_test.py index b2de0d40262babe6a56f0bb076b2d096200e8ed1..2cb4067e0acd6f4a88ff166e0fd460ec925585f2 100644 --- a/test/library_for_test.py +++ b/test/library_for_test.py @@ -1,5 +1,6 @@ # This exists because function handles can't be pickled. + def no_ret_f_mangler(kernel, name, arg_dtypes): if not isinstance(name, str): return None diff --git a/test/test_domain.py b/test/test_domain.py index 531e792704d530d505a789e00344bf9271d0ced5..e01c3a937fd95984a27a7f2490edf4be12d9b57b 100644 --- a/test/test_domain.py +++ b/test/test_domain.py @@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -import six -from six.moves import range +import six # noqa +from six.moves import range # noqa import sys import numpy as np @@ -31,7 +31,7 @@ import loopy as lp import pyopencl as cl import pyopencl.clmath # noqa import pyopencl.clrandom # noqa -import pytest +import pytest # noqa import logging logger = logging.getLogger(__name__) @@ -225,7 +225,6 @@ def test_dependent_loop_bounds_3(ctx_factory): knl = lp.preprocess_kernel(knl, ctx.devices[0]) - import pytest with pytest.raises(RuntimeError): list(lp.generate_loop_schedules(knl_bad)) diff --git a/test/test_from_loopy_import_star.py b/test/test_from_loopy_import_star.py index 02ec1604495e38cb8ba71d02cde96a289c252117..4f339ef96e562ba2fc5ed49236e6c6092df71e95 100644 --- a/test/test_from_loopy_import_star.py +++ b/test/test_from_loopy_import_star.py @@ -1 +1 @@ -from loopy import * +from loopy import * # noqa diff --git a/test/test_numa_diff.py b/test/test_numa_diff.py index c85aa80ec92eb0185d30f96b478ae37043c0d7e0..0de08f5f616937604bc2c93581c5a8a1770164f4 100644 --- a/test/test_numa_diff.py +++ b/test/test_numa_diff.py @@ -46,7 +46,7 @@ __all__ = [ @pytest.mark.parametrize("Nq", [7]) @pytest.mark.parametrize("ilp_multiple", [1, 2]) @pytest.mark.parametrize("opt_level", [11]) -def test_gnuma_horiz_kernel(ctx_factory, ilp_multiple, Nq, opt_level): +def test_gnuma_horiz_kernel(ctx_factory, ilp_multiple, Nq, opt_level): # noqa ctx = ctx_factory() filename = "strongVolumeKernels.f90"