Browse Source

Fix incorrect use of flake8:noqa

Adding the comment flake8:noqa in a file will skip linting the entire
file. Most of the time, the intent was just to skip individual lines to
handle exception cases.

This gets rid of the "flake8:" prefix where it was used incorrectly and
fixes a few legitimate errors that were being hidden by the entire file
being skipped.

The behavior is change in flake8 to handle this better, which will
result in pep8 job failures if these are not fixes first. See more
information in the 3.6.0 release notes:

http://flake8.pycqa.org/en/latest/release-notes/3.6.0.html#features

Change-Id: I1af4eb8bef9d0d0e3aa3bbbfd66a2fcb8ab336cb
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
tags/5.1.1
Sean McGinnis 7 months ago
parent
commit
8080c62f81
2 changed files with 32 additions and 32 deletions
  1. 4
    5
      pbr/core.py
  2. 28
    27
      pbr/util.py

+ 4
- 5
pbr/core.py View File

@@ -43,13 +43,13 @@
43 43
 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
44 44
 # DAMAGE.
45 45
 
46
-from distutils import core
47
-from distutils import errors
48 46
 import logging
49 47
 import os
50 48
 import sys
51 49
 import warnings
52 50
 
51
+from distutils import errors
52
+
53 53
 from pbr import util
54 54
 
55 55
 
@@ -57,8 +57,8 @@ if sys.version_info[0] == 3:
57 57
     string_type = str
58 58
     integer_types = (int,)
59 59
 else:
60
-    string_type = basestring  # flake8: noqa
61
-    integer_types = (int, long)  # flake8: noqa
60
+    string_type = basestring  # noqa
61
+    integer_types = (int, long)  # noqa
62 62
 
63 63
 
64 64
 def pbr(dist, attr, value):
@@ -103,7 +103,6 @@ def pbr(dist, attr, value):
103 103
         raise errors.DistutilsSetupError(
104 104
             'Error parsing %s: %s: %s' % (path, e.__class__.__name__, e))
105 105
 
106
-
107 106
     # There are some metadata fields that are only supported by
108 107
     # setuptools and not distutils, and hence are not in
109 108
     # dist.metadata.  We are OK to write these in.  For gory details

+ 28
- 27
pbr/util.py View File

@@ -56,24 +56,21 @@ to be an installation dependency for our packages yet--it is still too unstable
56 56
 # irritating Python bug that can crop up when using ./setup.py test.
57 57
 # See: http://www.eby-sarna.com/pipermail/peak/2010-May/003355.html
58 58
 try:
59
-    import multiprocessing  # flake8: noqa
59
+    import multiprocessing  # noqa
60 60
 except ImportError:
61 61
     pass
62
-import logging  # flake8: noqa
62
+import logging  # noqa
63 63
 
64
+from collections import defaultdict
64 65
 import os
65 66
 import re
66 67
 import sys
67 68
 import traceback
68 69
 
69
-from collections import defaultdict
70
-
71 70
 import distutils.ccompiler
72
-import pkg_resources
73
-
74
-from distutils import log
75 71
 from distutils import errors
76
-from setuptools.command.egg_info import manifest_maker
72
+from distutils import log
73
+import pkg_resources
77 74
 from setuptools import dist as st_dist
78 75
 from setuptools import extension
79 76
 
@@ -244,11 +241,11 @@ def cfg_to_args(path='setup.cfg', script_args=()):
244 241
                 if hook != 'pbr.hooks.setup_hook']
245 242
             for hook in setup_hooks:
246 243
                 hook_fn = resolve_name(hook)
247
-                try :
244
+                try:
248 245
                     hook_fn(config)
249 246
                 except SystemExit:
250 247
                     log.error('setup hook %s terminated the installation')
251
-                except:
248
+                except Exception:
252 249
                     e = sys.exc_info()[1]
253 250
                     log.error('setup hook %s raised exception: %s\n' %
254 251
                               (hook, e))
@@ -288,7 +285,9 @@ def cfg_to_args(path='setup.cfg', script_args=()):
288 285
 
289 286
 
290 287
 def setup_cfg_to_setup_kwargs(config, script_args=()):
291
-    """Processes the setup.cfg options and converts them to arguments accepted
288
+    """Convert config options to kwargs.
289
+
290
+    Processes the setup.cfg options and converts them to arguments accepted
292 291
     by setuptools' setup() function.
293 292
     """
294 293
 
@@ -354,12 +353,13 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
354 353
                 # Split install_requires into package,env_marker tuples
355 354
                 # These will be re-assembled later
356 355
                 install_requires = []
357
-                requirement_pattern = '(?P<package>[^;]*);?(?P<env_marker>[^#]*?)(?:\s*#.*)?$'
356
+                requirement_pattern = (
357
+                    r'(?P<package>[^;]*);?(?P<env_marker>[^#]*?)(?:\s*#.*)?$')
358 358
                 for requirement in in_cfg_value:
359 359
                     m = re.match(requirement_pattern, requirement)
360 360
                     requirement_package = m.group('package').strip()
361 361
                     env_marker = m.group('env_marker').strip()
362
-                    install_requires.append((requirement_package,env_marker))
362
+                    install_requires.append((requirement_package, env_marker))
363 363
                 all_requirements[''] = install_requires
364 364
             elif arg == 'package_dir':
365 365
                 in_cfg_value = {'': in_cfg_value}
@@ -414,7 +414,8 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
414 414
     # -> {'fred': ['bar'], 'fred:marker':['foo']}
415 415
 
416 416
     if 'extras' in config:
417
-        requirement_pattern = '(?P<package>[^:]*):?(?P<env_marker>[^#]*?)(?:\s*#.*)?$'
417
+        requirement_pattern = (
418
+            r'(?P<package>[^:]*):?(?P<env_marker>[^#]*?)(?:\s*#.*)?$')
418 419
         extras = config['extras']
419 420
         # Add contents of test-requirements, if any, into an extra named
420 421
         # 'test' if one does not already exist.
@@ -430,7 +431,7 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
430 431
                 m = re.match(requirement_pattern, requirement)
431 432
                 extras_value = m.group('package').strip()
432 433
                 env_marker = m.group('env_marker')
433
-                extra_requirements.append((extras_value,env_marker))
434
+                extra_requirements.append((extras_value, env_marker))
434 435
             all_requirements[extra] = extra_requirements
435 436
 
436 437
     # Transform the full list of requirements into:
@@ -473,9 +474,10 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
473 474
 
474 475
 
475 476
 def register_custom_compilers(config):
476
-    """Handle custom compilers; this has no real equivalent in distutils, where
477
-    additional compilers could only be added programmatically, so we have to
478
-    hack it in somehow.
477
+    """Handle custom compilers.
478
+
479
+    This has no real equivalent in distutils, where additional compilers could
480
+    only be added programmatically, so we have to hack it in somehow.
479 481
     """
480 482
 
481 483
     compilers = has_get_option(config, 'global', 'compilers')
@@ -497,7 +499,7 @@ def register_custom_compilers(config):
497 499
 
498 500
             module_name = compiler.__module__
499 501
             # Note; this *will* override built in compilers with the same name
500
-            # TODO: Maybe display a warning about this?
502
+            # TODO(embray): Maybe display a warning about this?
501 503
             cc = distutils.ccompiler.compiler_class
502 504
             cc[name] = (module_name, compiler.__name__, desc)
503 505
 
@@ -560,13 +562,14 @@ def get_extension_modules(config):
560 562
 
561 563
 
562 564
 def get_entry_points(config):
563
-    """Process the [entry_points] section of setup.cfg to handle setuptools
564
-    entry points.  This is, of course, not a standard feature of
565
-    distutils2/packaging, but as there is not currently a standard alternative
566
-    in packaging, we provide support for them.
565
+    """Process the [entry_points] section of setup.cfg.
566
+
567
+    Processes setup.cfg to handle setuptools entry points. This is, of course,
568
+    not a standard feature of distutils2/packaging, but as there is not
569
+    currently a standard alternative in packaging, we provide support for them.
567 570
     """
568 571
 
569
-    if not 'entry_points' in config:
572
+    if 'entry_points' not in config:
570 573
         return {}
571 574
 
572 575
     return dict((option, split_multiline(value))
@@ -600,9 +603,7 @@ def split_csv(value):
600 603
 
601 604
 # The following classes are used to hack Distribution.command_options a bit
602 605
 class DefaultGetDict(defaultdict):
603
-    """Like defaultdict, but the get() method also sets and returns the default
604
-    value.
605
-    """
606
+    """Like defaultdict, but get() also sets and returns the default value."""
606 607
 
607 608
     def get(self, key, default=None):
608 609
         if default is None:

Loading…
Cancel
Save