diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2020-06-09 21:40:06 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2020-06-09 21:40:06 +0200 |
commit | 2b4c89ada87b126bfd6b70048e98e1ec0a528867 (patch) | |
tree | abd62ed3d4d10dde308f01247a7864fe81ae4c31 | |
parent | 2f6c69b1e3d344239399f4f7188a52d5f29b51c3 (diff) | |
download | cython-linting.tar.gz |
Clean up some operator usages and style issues, and enforce them with pycodestyle.linting
-rw-r--r-- | Cython/Build/Tests/TestCythonizeArgsParser.py | 6 | ||||
-rw-r--r-- | Cython/Compiler/Annotate.py | 2 | ||||
-rw-r--r-- | Cython/Compiler/Buffer.py | 6 | ||||
-rw-r--r-- | Cython/Compiler/Code.py | 2 | ||||
-rw-r--r-- | Cython/Compiler/ExprNodes.py | 4 | ||||
-rw-r--r-- | Cython/Compiler/FlowControl.py | 2 | ||||
-rw-r--r-- | Cython/Compiler/ModuleNode.py | 2 | ||||
-rw-r--r-- | Cython/Compiler/Nodes.py | 2 | ||||
-rw-r--r-- | Cython/Compiler/ParseTreeTransforms.py | 2 | ||||
-rw-r--r-- | Cython/Compiler/Parsing.py | 4 | ||||
-rw-r--r-- | Cython/Compiler/Symtab.py | 2 | ||||
-rw-r--r-- | Cython/Distutils/old_build_ext.py | 4 | ||||
-rw-r--r-- | Demos/benchmarks/richards.py | 6 | ||||
-rw-r--r-- | setup.cfg | 9 |
14 files changed, 27 insertions, 26 deletions
diff --git a/Cython/Build/Tests/TestCythonizeArgsParser.py b/Cython/Build/Tests/TestCythonizeArgsParser.py index 374661446..c5a682dd6 100644 --- a/Cython/Build/Tests/TestCythonizeArgsParser.py +++ b/Cython/Build/Tests/TestCythonizeArgsParser.py @@ -27,14 +27,14 @@ class TestCythonizeArgsParser(TestCase): empty_containers = ['directives', 'compile_time_env', 'options', 'excludes'] are_none = ['language_level', 'annotate', 'build', 'build_inplace', 'force', 'quiet', 'lenient', 'keep_going', 'no_docstrings'] for opt_name in empty_containers: - if len(getattr(options, opt_name))!=0 and (not opt_name in skip): + if len(getattr(options, opt_name))!=0 and (opt_name not in skip): self.assertEqual(opt_name,"", msg="For option "+opt_name) return False for opt_name in are_none: - if (getattr(options, opt_name) is not None) and (not opt_name in skip): + if (getattr(options, opt_name) is not None) and (opt_name not in skip): self.assertEqual(opt_name,"", msg="For option "+opt_name) return False - if options.parallel!=parallel_compiles and (not 'parallel' in skip): + if options.parallel!=parallel_compiles and ('parallel' not in skip): return False return True diff --git a/Cython/Compiler/Annotate.py b/Cython/Compiler/Annotate.py index c79bd7f96..6e2d2a53b 100644 --- a/Cython/Compiler/Annotate.py +++ b/Cython/Compiler/Annotate.py @@ -294,7 +294,7 @@ class AnnotationCCodeWriter(CCodeWriter): # now the whole c-code if needed: if self.show_entire_c_code: outlist.append(u'<p><div class="cython">') - onclick_title = u"<pre class='cython line'{onclick}>+ {title}</pre>\n"; + onclick_title = u"<pre class='cython line'{onclick}>+ {title}</pre>\n" outlist.append(onclick_title.format( onclick=self._onclick_attr, title=AnnotationCCodeWriter.COMPLETE_CODE_TITLE, diff --git a/Cython/Compiler/Buffer.py b/Cython/Compiler/Buffer.py index 75aa7b0c0..79687163c 100644 --- a/Cython/Compiler/Buffer.py +++ b/Cython/Compiler/Buffer.py @@ -146,12 +146,12 @@ def analyse_buffer_options(globalpos, env, posargs, dictargs, defaults=None, nee options = {} for name, (value, pos) in dictargs.items(): - if not name in buffer_options: + if name not in buffer_options: raise CompileError(pos, ERR_BUF_OPTION_UNKNOWN % name) options[name] = value for name, (value, pos) in zip(buffer_options, posargs): - if not name in buffer_options: + if name not in buffer_options: raise CompileError(pos, ERR_BUF_OPTION_UNKNOWN % name) if name in options: raise CompileError(pos, ERR_BUF_DUP % name) @@ -159,7 +159,7 @@ def analyse_buffer_options(globalpos, env, posargs, dictargs, defaults=None, nee # Check that they are all there and copy defaults for name in buffer_options: - if not name in options: + if name not in options: try: options[name] = defaults[name] except KeyError: diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index a52269b12..6f507eb66 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -891,7 +891,7 @@ class FunctionState(object): """ return [(name, type) for name, type, manage_ref in self.temps_in_use() - if manage_ref and type.is_pyobject] + if manage_ref and type.is_pyobject] def all_managed_temps(self): """Return a list of (cname, type) tuples of refcount-managed Python objects. diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index dc2fd5f53..c39e0b18a 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -11330,8 +11330,8 @@ class NumBinopNode(BinopNode): def c_types_okay(self, type1, type2): #print "NumBinopNode.c_types_okay:", type1, type2 ### - return (type1.is_numeric or type1.is_enum) \ - and (type2.is_numeric or type2.is_enum) + return (type1.is_numeric or type1.is_enum) \ + and (type2.is_numeric or type2.is_enum) def generate_evaluation_code(self, code): if self.overflow_check: diff --git a/Cython/Compiler/FlowControl.py b/Cython/Compiler/FlowControl.py index 45ce2dd09..ec38ed164 100644 --- a/Cython/Compiler/FlowControl.py +++ b/Cython/Compiler/FlowControl.py @@ -455,7 +455,7 @@ class GVContext(object): start = min(block.positions) stop = max(block.positions) srcdescr = start[0] - if not srcdescr in self.sources: + if srcdescr not in self.sources: self.sources[srcdescr] = list(srcdescr.get_lines()) lines = self.sources[srcdescr] return '\\n'.join([l.strip() for l in lines[start[1] - 1:stop[1]]]) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index c9363d92e..1e1774d54 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -185,7 +185,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): h_vars = h_entries(env.var_entries) h_funcs = h_entries(env.cfunc_entries) h_extension_types = h_entries(env.c_class_entries) - if h_types or h_vars or h_funcs or h_extension_types: + if h_types or h_vars or h_funcs or h_extension_types: result.h_file = replace_suffix_encoded(result.c_file, ".h") h_code = Code.CCodeWriter() c_code_config = generate_c_code_config(env, options) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index c9bea7ca8..6e9428a05 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1052,7 +1052,7 @@ class CSimpleBaseTypeNode(CBaseTypeNode): self.arg_name = EncodedString(self.name) else: if self.templates: - if not self.name in self.templates: + if self.name not in self.templates: error(self.pos, "'%s' is not a type identifier" % self.name) type = PyrexTypes.TemplatePlaceholderType(self.name) else: diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index ae73801ab..7ccee4fb7 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -2539,7 +2539,7 @@ class AlignFunctionDefinitions(CythonTransform): return None node = node.as_cfunction(pxd_def) elif (self.scope.is_module_scope and self.directives['auto_cpdef'] - and not node.name in self.imported_names + and node.name not in self.imported_names and node.is_cdef_func_compatible()): # FIXME: cpdef-ing should be done in analyse_declarations() node = node.as_cfunction(scope=self.scope) diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 99ae8a10e..466300c67 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -2654,7 +2654,7 @@ def p_memoryviewslice_access(s, base_type_node): return result def looking_at_name(s): - return s.sy == 'IDENT' and not s.systring in calling_convention_words + return s.sy == 'IDENT' and s.systring not in calling_convention_words def looking_at_expr(s): if s.systring in base_type_start_words: @@ -2914,7 +2914,7 @@ def p_c_simple_declarator(s, ctx, empty, is_type, cmethod_flag, fatal=False) name += op elif op == 'IDENT': - op = s.systring; + op = s.systring if op not in supported_overloaded_operators: s.error("Overloading operator '%s' not yet supported." % op, fatal=False) diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 75ac72b0f..081b4ec23 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -1465,7 +1465,7 @@ class ModuleScope(Scope): # object type, and not declared with cdef, it will live # in the module dictionary, otherwise it will be a C # global variable. - if not visibility in ('private', 'public', 'extern'): + if visibility not in ('private', 'public', 'extern'): error(pos, "Module-level variable cannot be declared %s" % visibility) if not is_cdef: if type is unspecified_type: diff --git a/Cython/Distutils/old_build_ext.py b/Cython/Distutils/old_build_ext.py index 04314a5d3..7c2774aa2 100644 --- a/Cython/Distutils/old_build_ext.py +++ b/Cython/Distutils/old_build_ext.py @@ -242,7 +242,7 @@ class old_build_ext(_build_ext.build_ext): includes = list(self.cython_include_dirs) try: for i in extension.cython_include_dirs: - if not i in includes: + if i not in includes: includes.append(i) except AttributeError: pass @@ -251,7 +251,7 @@ class old_build_ext(_build_ext.build_ext): # result extension.include_dirs = list(extension.include_dirs) for i in extension.include_dirs: - if not i in includes: + if i not in includes: includes.append(i) # Set up Cython compiler directives: diff --git a/Demos/benchmarks/richards.py b/Demos/benchmarks/richards.py index 24fd35bf8..76a92c3a0 100644 --- a/Demos/benchmarks/richards.py +++ b/Demos/benchmarks/richards.py @@ -382,9 +382,9 @@ class Richards(object): wkq = Packet(wkq , I_DEVB, K_DEV) HandlerTask(I_HANDLERB, 3000, wkq, TaskState().waitingWithPacket(), HandlerTaskRec()) - wkq = None; - DeviceTask(I_DEVA, 4000, wkq, TaskState().waiting(), DeviceTaskRec()); - DeviceTask(I_DEVB, 5000, wkq, TaskState().waiting(), DeviceTaskRec()); + wkq = None + DeviceTask(I_DEVA, 4000, wkq, TaskState().waiting(), DeviceTaskRec()) + DeviceTask(I_DEVB, 5000, wkq, TaskState().waiting(), DeviceTaskRec()) schedule() @@ -2,19 +2,20 @@ max-complexity = 10 [pycodestyle] -exclude = .git,build,__pycache__,venv*,TEST* +exclude = .git,build,__pycache__,venv*,TEST*,tests/run/test*.py,Cython/Debugger/libpython.py max-line-length = 150 format = pylint # See https://pycodestyle.pycqa.org/en/latest/intro.html#configuration select = - E711, E714, E501, W291, E502, + E711, E713, E714, E501, W291, E502, E703, # indentation E101, E111, E112, E113, E117 E121, E125, E129, # E114, E115, E116, E122, # whitespace - E223, E224, E228, E261, - # E201, E202, E203, E211 + E223, E224, E228, E261, E273, E274, E275, + # E201, E202, E203, E211, E265 + # E303, E306, W1, W2, W3 #ignore = W, E ignore = |