Reverted the change to pycodestyle related to E705 and changed the globl constants in CodeStyleCheckerDialog.py to class variables (constants).

Sun, 06 Nov 2016 13:31:38 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 06 Nov 2016 13:31:38 +0100
changeset 5290
174dae2b91c3
parent 5289
26e4a082ba54
child 5291
e93d14b48c34

Reverted the change to pycodestyle related to E705 and changed the globl constants in CodeStyleCheckerDialog.py to class variables (constants).

Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/CodeStyleChecker/pycodestyle.py file | annotate | diff | comparison | revisions
--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py	Fri Nov 04 22:07:05 2016 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py	Sun Nov 06 13:31:38 2016 +0100
@@ -32,10 +32,6 @@
 except Exception:
     basestring = str    # define for Python3
 
-NO_RESULTS = 0
-NO_FILES = 1
-HAS_RESULTS = 2
-
 
 class CodeStyleCheckerDialog(QDialog, Ui_CodeStyleCheckerDialog):
     """
@@ -53,6 +49,10 @@
         'division', 'absolute_import', 'with_statement',
         'print_function', 'unicode_literals', 'generator_stop']
     
+    noResults = 0
+    noFiles = 1
+    hasResults = 2
+    
     def __init__(self, styleCheckService, parent=None):
         """
         Constructor
@@ -105,7 +105,7 @@
         self.styleCheckService.error.connect(self.__processError)
         self.filename = None
         
-        self.results = NO_RESULTS
+        self.results = CodeStyleCheckerDialog.noResults
         self.cancelled = False
         self.__lastFileItem = None
         self.__batch = False
@@ -447,7 +447,7 @@
                 self.__batch = True
                 self.checkBatch()
         else:
-            self.results = NO_FILES
+            self.results = CodeStyleCheckerDialog.noFiles
             self.__finished = False
             self.__finish()
     
@@ -508,7 +508,7 @@
                     self.filename)
                 source = source.splitlines(True)
             except (UnicodeError, IOError) as msg:
-                self.results = HAS_RESULTS
+                self.results = CodeStyleCheckerDialog.hasResults
                 self.__createResultItem(
                     self.filename, 1, 1,
                     self.tr("Error: {0}").format(str(msg))
@@ -559,7 +559,7 @@
                     filename)
                 source = source.splitlines(True)
             except (UnicodeError, IOError) as msg:
-                self.results = HAS_RESULTS
+                self.results = CodeStyleCheckerDialog.hasResults
                 self.__createResultItem(
                     filename, 1, 1,
                     self.tr("Error: {0}").format(str(msg))
@@ -656,7 +656,7 @@
                         text = self.tr("{0} (ignored)").format(text)
                     else:
                         continue
-                self.results = HAS_RESULTS
+                self.results = CodeStyleCheckerDialog.hasResults
                 self.__createResultItem(
                     fn, lineno, position, text, fixed, autofixing, ignored)
 
@@ -699,8 +699,8 @@
             self.showButton.setEnabled(True)
             self.startButton.setEnabled(True)
             
-            if self.results < HAS_RESULTS:
-                if self.results == NO_RESULTS:
+            if self.results != CodeStyleCheckerDialog.hasResults:
+                if self.results == CodeStyleCheckerDialog.noResults:
                     QTreeWidgetItem(
                         self.resultList, [self.tr('No issues found.')])
                 else:
@@ -762,7 +762,7 @@
                                        self.__data)
         
         self.resultList.clear()
-        self.results = NO_RESULTS
+        self.results = CodeStyleCheckerDialog.noResults
         self.cancelled = False
         self.start(self.__fileOrFileList)
     
@@ -819,7 +819,7 @@
         @param item reference to the activated item (QTreeWidgetItem)
         @param column column the item was activated in (integer)
         """
-        if self.results < HAS_RESULTS:
+        if self.results != CodeStyleCheckerDialog.hasResults:
             return
         
         if item.parent():
--- a/Plugins/CheckerPlugins/CodeStyleChecker/pycodestyle.py	Fri Nov 04 22:07:05 2016 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/pycodestyle.py	Sun Nov 06 13:31:38 2016 +0100
@@ -79,7 +79,7 @@
 except ImportError:
     from ConfigParser import RawConfigParser            # __IGNORE_WARNING__
 
-__version__ = '2.1.0'
+__version__ = '2.1.0-eric'
 
 DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git,__pycache__,.tox'
 DEFAULT_IGNORE = 'E121,E123,E126,E226,E24,E704,W503'
@@ -284,7 +284,7 @@
             yield 0, "E304 blank lines found after function decorator"
     elif blank_lines > 2 or (indent_level and blank_lines == 2):
         yield 0, "E303 too many blank lines (%d)", blank_lines
-    elif logical_line.startswith(('def ', 'async def', 'class ', '@')):
+    elif logical_line.startswith(('def ', 'async def ', 'class ', '@')):
         if indent_level:
             if not (blank_before or previous_indent_level < indent_level or
                     DOCSTRING_REGEX.match(previous_logical)):
@@ -991,6 +991,7 @@
     E702: do_one(); do_two(); do_three()
     E703: do_four();  # useless semicolon
     E704: def f(x): return 2*x
+    E705: async def f(x): return 2*x
     E731: f = lambda x: 2*x
     """
     line = logical_line
@@ -1012,6 +1013,8 @@
                 break
             if line.startswith('def '):
                 yield 0, "E704 multiple statements on one line (def)"
+            elif line.startswith('async def '):
+                yield 0, "E705 multiple statements on one line (async def)"
             else:
                 yield found, "E701 multiple statements on one line (colon)"
         prev_found = found

eric ide

mercurial