summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGinnis <sean.mcginnis@gmail.com>2018-10-26 13:42:49 -0500
committerSean McGinnis <sean.mcginnis@gmail.com>2018-10-26 13:43:14 -0500
commit8080c62f816d2f4932f8f7ba7331a6b5a6cb21ab (patch)
treed4e52c6f8077b8b375a9e882a64849d75e819002
parentbd300d07ee016bf04b5da783fa696754b8a49af8 (diff)
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>
Notes
Notes (review): Code-Review+2: Ben Nemec <openstack@nemebean.com> Code-Review+2: ChangBo Guo(gcb) <glongwave@gmail.com> Workflow+1: ChangBo Guo(gcb) <glongwave@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Sun, 28 Oct 2018 14:16:05 +0000 Reviewed-on: https://review.openstack.org/613665 Project: openstack-dev/pbr Branch: refs/heads/master
-rw-r--r--pbr/core.py9
-rw-r--r--pbr/util.py55
2 files changed, 32 insertions, 32 deletions
diff --git a/pbr/core.py b/pbr/core.py
index 0760ab9..645a2ef 100644
--- a/pbr/core.py
+++ b/pbr/core.py
@@ -43,13 +43,13 @@
43# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 43# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
44# DAMAGE. 44# DAMAGE.
45 45
46from distutils import core
47from distutils import errors
48import logging 46import logging
49import os 47import os
50import sys 48import sys
51import warnings 49import warnings
52 50
51from distutils import errors
52
53from pbr import util 53from pbr import util
54 54
55 55
@@ -57,8 +57,8 @@ if sys.version_info[0] == 3:
57 string_type = str 57 string_type = str
58 integer_types = (int,) 58 integer_types = (int,)
59else: 59else:
60 string_type = basestring # flake8: noqa 60 string_type = basestring # noqa
61 integer_types = (int, long) # flake8: noqa 61 integer_types = (int, long) # noqa
62 62
63 63
64def pbr(dist, attr, value): 64def pbr(dist, attr, value):
@@ -103,7 +103,6 @@ def pbr(dist, attr, value):
103 raise errors.DistutilsSetupError( 103 raise errors.DistutilsSetupError(
104 'Error parsing %s: %s: %s' % (path, e.__class__.__name__, e)) 104 'Error parsing %s: %s: %s' % (path, e.__class__.__name__, e))
105 105
106
107 # There are some metadata fields that are only supported by 106 # There are some metadata fields that are only supported by
108 # setuptools and not distutils, and hence are not in 107 # setuptools and not distutils, and hence are not in
109 # dist.metadata. We are OK to write these in. For gory details 108 # dist.metadata. We are OK to write these in. For gory details
diff --git a/pbr/util.py b/pbr/util.py
index 45a3aed..47869f8 100644
--- a/pbr/util.py
+++ b/pbr/util.py
@@ -56,24 +56,21 @@ to be an installation dependency for our packages yet--it is still too unstable
56# irritating Python bug that can crop up when using ./setup.py test. 56# irritating Python bug that can crop up when using ./setup.py test.
57# See: http://www.eby-sarna.com/pipermail/peak/2010-May/003355.html 57# See: http://www.eby-sarna.com/pipermail/peak/2010-May/003355.html
58try: 58try:
59 import multiprocessing # flake8: noqa 59 import multiprocessing # noqa
60except ImportError: 60except ImportError:
61 pass 61 pass
62import logging # flake8: noqa 62import logging # noqa
63 63
64from collections import defaultdict
64import os 65import os
65import re 66import re
66import sys 67import sys
67import traceback 68import traceback
68 69
69from collections import defaultdict
70
71import distutils.ccompiler 70import distutils.ccompiler
72import pkg_resources
73
74from distutils import log
75from distutils import errors 71from distutils import errors
76from setuptools.command.egg_info import manifest_maker 72from distutils import log
73import pkg_resources
77from setuptools import dist as st_dist 74from setuptools import dist as st_dist
78from setuptools import extension 75from setuptools import extension
79 76
@@ -244,11 +241,11 @@ def cfg_to_args(path='setup.cfg', script_args=()):
244 if hook != 'pbr.hooks.setup_hook'] 241 if hook != 'pbr.hooks.setup_hook']
245 for hook in setup_hooks: 242 for hook in setup_hooks:
246 hook_fn = resolve_name(hook) 243 hook_fn = resolve_name(hook)
247 try : 244 try:
248 hook_fn(config) 245 hook_fn(config)
249 except SystemExit: 246 except SystemExit:
250 log.error('setup hook %s terminated the installation') 247 log.error('setup hook %s terminated the installation')
251 except: 248 except Exception:
252 e = sys.exc_info()[1] 249 e = sys.exc_info()[1]
253 log.error('setup hook %s raised exception: %s\n' % 250 log.error('setup hook %s raised exception: %s\n' %
254 (hook, e)) 251 (hook, e))
@@ -288,7 +285,9 @@ def cfg_to_args(path='setup.cfg', script_args=()):
288 285
289 286
290def setup_cfg_to_setup_kwargs(config, script_args=()): 287def 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 by setuptools' setup() function. 291 by setuptools' setup() function.
293 """ 292 """
294 293
@@ -354,12 +353,13 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
354 # Split install_requires into package,env_marker tuples 353 # Split install_requires into package,env_marker tuples
355 # These will be re-assembled later 354 # These will be re-assembled later
356 install_requires = [] 355 install_requires = []
357 requirement_pattern = '(?P<package>[^;]*);?(?P<env_marker>[^#]*?)(?:\s*#.*)?$' 356 requirement_pattern = (
357 r'(?P<package>[^;]*);?(?P<env_marker>[^#]*?)(?:\s*#.*)?$')
358 for requirement in in_cfg_value: 358 for requirement in in_cfg_value:
359 m = re.match(requirement_pattern, requirement) 359 m = re.match(requirement_pattern, requirement)
360 requirement_package = m.group('package').strip() 360 requirement_package = m.group('package').strip()
361 env_marker = m.group('env_marker').strip() 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 all_requirements[''] = install_requires 363 all_requirements[''] = install_requires
364 elif arg == 'package_dir': 364 elif arg == 'package_dir':
365 in_cfg_value = {'': in_cfg_value} 365 in_cfg_value = {'': in_cfg_value}
@@ -414,7 +414,8 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
414 # -> {'fred': ['bar'], 'fred:marker':['foo']} 414 # -> {'fred': ['bar'], 'fred:marker':['foo']}
415 415
416 if 'extras' in config: 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 extras = config['extras'] 419 extras = config['extras']
419 # Add contents of test-requirements, if any, into an extra named 420 # Add contents of test-requirements, if any, into an extra named
420 # 'test' if one does not already exist. 421 # 'test' if one does not already exist.
@@ -430,7 +431,7 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
430 m = re.match(requirement_pattern, requirement) 431 m = re.match(requirement_pattern, requirement)
431 extras_value = m.group('package').strip() 432 extras_value = m.group('package').strip()
432 env_marker = m.group('env_marker') 433 env_marker = m.group('env_marker')
433 extra_requirements.append((extras_value,env_marker)) 434 extra_requirements.append((extras_value, env_marker))
434 all_requirements[extra] = extra_requirements 435 all_requirements[extra] = extra_requirements
435 436
436 # Transform the full list of requirements into: 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
475def register_custom_compilers(config): 476def register_custom_compilers(config):
476 """Handle custom compilers; this has no real equivalent in distutils, where 477 """Handle custom compilers.
477 additional compilers could only be added programmatically, so we have to 478
478 hack it in somehow. 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 compilers = has_get_option(config, 'global', 'compilers') 483 compilers = has_get_option(config, 'global', 'compilers')
@@ -497,7 +499,7 @@ def register_custom_compilers(config):
497 499
498 module_name = compiler.__module__ 500 module_name = compiler.__module__
499 # Note; this *will* override built in compilers with the same name 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 cc = distutils.ccompiler.compiler_class 503 cc = distutils.ccompiler.compiler_class
502 cc[name] = (module_name, compiler.__name__, desc) 504 cc[name] = (module_name, compiler.__name__, desc)
503 505
@@ -560,13 +562,14 @@ def get_extension_modules(config):
560 562
561 563
562def get_entry_points(config): 564def get_entry_points(config):
563 """Process the [entry_points] section of setup.cfg to handle setuptools 565 """Process the [entry_points] section of setup.cfg.
564 entry points. This is, of course, not a standard feature of 566
565 distutils2/packaging, but as there is not currently a standard alternative 567 Processes setup.cfg to handle setuptools entry points. This is, of course,
566 in packaging, we provide support for them. 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 return {} 573 return {}
571 574
572 return dict((option, split_multiline(value)) 575 return dict((option, split_multiline(value))
@@ -600,9 +603,7 @@ def split_csv(value):
600 603
601# The following classes are used to hack Distribution.command_options a bit 604# The following classes are used to hack Distribution.command_options a bit
602class DefaultGetDict(defaultdict): 605class DefaultGetDict(defaultdict):
603 """Like defaultdict, but the get() method also sets and returns the default 606 """Like defaultdict, but get() also sets and returns the default value."""
604 value.
605 """
606 607
607 def get(self, key, default=None): 608 def get(self, key, default=None):
608 if default is None: 609 if default is None: