Skip to content

Commit 9f02733

Browse files
committed
Use Flake8 on the test of pip's Python files
1 parent 9efff55 commit 9f02733

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2305
-1015
lines changed

contrib/build-installer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def bootstrap(tmpdir=None):
5454
# We want to see if setuptools is available before attempting to
5555
# install it
5656
try:
57-
import setuptools
57+
import setuptools # noqa
5858
except ImportError:
5959
packages += ["setuptools"]
6060

contrib/get-pip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20304,7 +20304,7 @@ def bootstrap(tmpdir=None):
2030420304
# We want to see if setuptools is available before attempting to
2030520305
# install it
2030620306
try:
20307-
import setuptools
20307+
import setuptools # noqa
2030820308
except ImportError:
2030920309
packages += ["setuptools"]
2031020310

docs/conf.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# pip documentation build configuration file, created by
44
# sphinx-quickstart on Tue Apr 22 22:08:49 2008
55
#
6-
# This file is execfile()d with the current directory set to its containing dir.
6+
# This file is execfile()d with the current directory set to its containing dir
77
#
88
# Note that not all possible configuration values are present in this
99
# autogenerated file.
@@ -22,10 +22,10 @@
2222
sys.path.insert(0, os.path.abspath(os.pardir))
2323
#sys.path.append(os.path.join(os.path.dirname(__file__), '../'))
2424

25-
# -- General configuration -----------------------------------------------------
25+
# -- General configuration ----------------------------------------------------
2626

27-
# Add any Sphinx extension module names here, as strings. They can be extensions
28-
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
27+
# Add any Sphinx extension module names here, as strings. They can be
28+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
2929
#extensions = ['sphinx.ext.autodoc']
3030
extensions = ['docs.pipext']
3131

@@ -76,7 +76,7 @@
7676
# for source files.
7777
exclude_trees = ['build']
7878

79-
# The reST default role (used for this markup: `text`) to use for all documents.
79+
# The reST default role (used for this markup: `text`) to use for all documents
8080
#default_role = None
8181

8282
# If true, '()' will be appended to :func: etc. cross-reference text.
@@ -96,7 +96,7 @@
9696
# A list of ignored prefixes for module index sorting.
9797
#modindex_common_prefix = []
9898

99-
# -- Options for HTML output ---------------------------------------------------
99+
# -- Options for HTML output --------------------------------------------------
100100

101101
# The theme to use for HTML and HTML Help pages. Major themes that come with
102102
# Sphinx are currently 'default' and 'sphinxdoc'.
@@ -176,7 +176,7 @@
176176
htmlhelp_basename = 'pipdocs'
177177

178178

179-
# -- Options for LaTeX output --------------------------------------------------
179+
# -- Options for LaTeX output -------------------------------------------------
180180

181181
# The paper size ('letter' or 'a4').
182182
#latex_paper_size = 'letter'
@@ -185,10 +185,15 @@
185185
#latex_font_size = '10pt'
186186

187187
# Grouping the document tree into LaTeX files. List of tuples
188-
# (source start file, target name, title, author, documentclass [howto/manual]).
188+
# (source start file, target name, title, author, documentclass [howto/manual])
189189
latex_documents = [
190-
('index', 'pip.tex', u'pip Documentation',
191-
u'The pip developers', 'manual'),
190+
(
191+
'index',
192+
'pip.tex',
193+
u'pip Documentation',
194+
u'The pip developers',
195+
'manual',
196+
),
192197
]
193198

194199
# The name of an image file (relative to this directory) to place at the top of

docs/pipext.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ def _format_option(self, option, cmd_name=None):
5959
opt_help = option.help.replace('%default', str(option.default))
6060
#fix paths with sys.prefix
6161
opt_help = opt_help.replace(sys.prefix, "<sys.prefix>")
62-
opt_help = opt_help.replace(default_log_file, "<see :ref:`FileLogging`>")
62+
opt_help = opt_help.replace(
63+
default_log_file,
64+
"<see :ref:`FileLogging`>",
65+
)
6366
return [bookmark_line, "", line, "", " %s" % opt_help, ""]
6467

6568
def _format_options(self, options, cmd_name=None):
@@ -80,20 +83,27 @@ def run(self):
8083

8184
class PipGeneralOptions(PipOptions):
8285
def process_options(self):
83-
self._format_options([o.make() for o in cmdoptions.general_group['options']])
86+
self._format_options(
87+
[o.make() for o in cmdoptions.general_group['options']]
88+
)
8489

8590

8691
class PipIndexOptions(PipOptions):
8792
def process_options(self):
88-
self._format_options([o.make() for o in cmdoptions.index_group['options']])
93+
self._format_options(
94+
[o.make() for o in cmdoptions.index_group['options']]
95+
)
8996

9097

9198
class PipCommandOptions(PipOptions):
9299
required_arguments = 1
93100

94101
def process_options(self):
95102
cmd = commands[self.arguments[0]]()
96-
self._format_options(cmd.parser.option_groups[0].option_list, cmd_name=cmd.name)
103+
self._format_options(
104+
cmd.parser.option_groups[0].option_list,
105+
cmd_name=cmd.name,
106+
)
97107

98108

99109
def setup(app):

setup.py

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def run_tests(self):
2525

2626

2727
def read(*parts):
28-
# intentionally *not* adding an encoding option to open
29-
# see here: https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
28+
# intentionally *not* adding an encoding option to open, See:
29+
# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
3030
return codecs.open(os.path.join(here, *parts), 'r').read()
3131

3232

@@ -43,40 +43,46 @@ def find_version(*file_paths):
4343

4444
tests_require = ['pytest', 'virtualenv>=1.10', 'scripttest>=1.3', 'mock']
4545

46-
setup(name="pip",
47-
version=find_version('pip', '__init__.py'),
48-
description="A tool for installing and managing Python packages.",
49-
long_description=long_description,
50-
classifiers=[
51-
'Development Status :: 5 - Production/Stable',
52-
'Intended Audience :: Developers',
53-
'License :: OSI Approved :: MIT License',
54-
'Topic :: Software Development :: Build Tools',
55-
'Programming Language :: Python :: 2',
56-
'Programming Language :: Python :: 2.6',
57-
'Programming Language :: Python :: 2.7',
58-
'Programming Language :: Python :: 3',
59-
'Programming Language :: Python :: 3.1',
60-
'Programming Language :: Python :: 3.2',
61-
'Programming Language :: Python :: 3.3',
62-
],
63-
keywords='easy_install distutils setuptools egg virtualenv',
64-
author='The pip developers',
65-
author_email='[email protected]',
66-
url='http://www.pip-installer.org',
67-
license='MIT',
68-
packages=find_packages(exclude=["contrib", "docs", "tests*"]),
69-
package_data={
70-
'pip._vendor.requests': ['*.pem'],
71-
'pip._vendor.distlib._backport': ['sysconfig.cfg'],
72-
'pip._vendor.distlib': ['t32.exe', 't64.exe', 'w32.exe', 'w64.exe'],
73-
},
74-
entry_points=dict(console_scripts=['pip=pip:main', 'pip%s=pip:main' % sys.version[:1],
75-
'pip%s=pip:main' % sys.version[:3]]),
76-
tests_require=tests_require,
77-
zip_safe=False,
78-
extras_require={
79-
'testing': tests_require,
80-
},
81-
cmdclass = {'test': PyTest},
46+
setup(
47+
name="pip",
48+
version=find_version("pip", "__init__.py"),
49+
description="A tool for installing and managing Python packages.",
50+
long_description=long_description,
51+
classifiers=[
52+
"Development Status :: 5 - Production/Stable",
53+
"Intended Audience :: Developers",
54+
"License :: OSI Approved :: MIT License",
55+
"Topic :: Software Development :: Build Tools",
56+
"Programming Language :: Python :: 2",
57+
"Programming Language :: Python :: 2.6",
58+
"Programming Language :: Python :: 2.7",
59+
"Programming Language :: Python :: 3",
60+
"Programming Language :: Python :: 3.1",
61+
"Programming Language :: Python :: 3.2",
62+
"Programming Language :: Python :: 3.3",
63+
],
64+
keywords='easy_install distutils setuptools egg virtualenv',
65+
author='The pip developers',
66+
author_email='[email protected]',
67+
url='http://www.pip-installer.org',
68+
license='MIT',
69+
packages=find_packages(exclude=["contrib", "docs", "tests*"]),
70+
package_data={
71+
'pip._vendor.requests': ['*.pem'],
72+
'pip._vendor.distlib._backport': ['sysconfig.cfg'],
73+
'pip._vendor.distlib': ['t32.exe', 't64.exe', 'w32.exe', 'w64.exe'],
74+
},
75+
entry_points={
76+
"console_scripts": [
77+
"pip=pip:main",
78+
"pip%s=pip:main" % sys.version[:1],
79+
"pip%s=pip:main" % sys.version[:3],
80+
],
81+
},
82+
tests_require=tests_require,
83+
zip_safe=False,
84+
extras_require={
85+
'testing': tests_require,
86+
},
87+
cmdclass={'test': PyTest},
8288
)

tests/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def virtualenv(tmpdir, monkeypatch):
4040
# Copy over our source tree so that each virtual environment is self
4141
# contained
4242
pip_src = tmpdir.join("pip_src").abspath
43-
shutil.copytree(SRC_DIR, pip_src,
43+
shutil.copytree(
44+
SRC_DIR,
45+
pip_src,
4446
ignore=shutil.ignore_patterns(
4547
"*.pyc", "tests", "pip.egg-info", "build", "dist", ".tox",
4648
),

tests/functional/test_bundle.py

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import zipfile
22
import textwrap
3-
from os.path import abspath, exists, join
3+
from os.path import exists, join
44
from pip.download import path_to_url
55
from tests.lib.local_repos import local_checkout
66

@@ -14,13 +14,27 @@ def test_create_bundle(script, tmpdir, data):
1414
"""
1515
fspkg = path_to_url(data.packages/'FSPkg')
1616
script.pip('install', '-e', fspkg)
17-
pkg_lines = textwrap.dedent('''\
17+
pkg_lines = textwrap.dedent(
18+
'''
1819
-e %s
1920
-e %s#egg=initools-dev
20-
pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache"))))
21+
pip
22+
''' %
23+
(
24+
fspkg,
25+
local_checkout(
26+
'svn+http://svn.colorstudy.com/INITools/trunk',
27+
tmpdir.join("cache"),
28+
),
29+
),
30+
)
2131
script.scratch_path.join("bundle-req.txt").write(pkg_lines)
2232
# Create a bundle in env.scratch_path/ test.pybundle
23-
result = script.pip('bundle', '--no-use-wheel', '-r', script.scratch_path/ 'bundle-req.txt', script.scratch_path/ 'test.pybundle')
33+
result = script.pip(
34+
'bundle', '--no-use-wheel', '-r',
35+
script.scratch_path / 'bundle-req.txt',
36+
script.scratch_path / 'test.pybundle',
37+
)
2438
bundle = result.files_after.get(join('scratch', 'test.pybundle'), None)
2539
assert bundle is not None
2640

@@ -32,14 +46,20 @@ def test_create_bundle(script, tmpdir, data):
3246

3347
def test_cleanup_after_create_bundle(script, tmpdir, data):
3448
"""
35-
Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/.
49+
Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are
50+
removed but not src/.
3651
3752
"""
3853
# Install an editable to create a src/ dir.
3954
args = ['install']
40-
args.extend(['-e',
41-
'%s#egg=pip-test-package' %
42-
local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache"))])
55+
args.extend([
56+
'-e',
57+
'%s#egg=pip-test-package' %
58+
local_checkout(
59+
'git+http://github.com/pypa/pip-test-package.git',
60+
tmpdir.join("cache"),
61+
),
62+
])
4363
script.pip(*args)
4464
build = script.venv_path/"build"
4565
src = script.venv_path/"src"
@@ -48,16 +68,32 @@ def test_cleanup_after_create_bundle(script, tmpdir, data):
4868

4969
# Make the bundle.
5070
fspkg = path_to_url(data.packages/'FSPkg')
51-
pkg_lines = textwrap.dedent('''\
71+
pkg_lines = textwrap.dedent(
72+
'''
5273
-e %s
5374
-e %s#egg=initools-dev
54-
pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache"))))
75+
pip
76+
''' %
77+
(
78+
fspkg,
79+
local_checkout(
80+
'svn+http://svn.colorstudy.com/INITools/trunk',
81+
tmpdir.join("cache"),
82+
),
83+
),
84+
)
5585
script.scratch_path.join("bundle-req.txt").write(pkg_lines)
56-
script.pip('bundle', '--no-use-wheel', '-r', 'bundle-req.txt', 'test.pybundle')
86+
script.pip(
87+
'bundle', '--no-use-wheel', '-r', 'bundle-req.txt', 'test.pybundle',
88+
)
5789
build_bundle = script.scratch_path/"build-bundle"
5890
src_bundle = script.scratch_path/"src-bundle"
59-
assert not exists(build_bundle), "build-bundle/ dir still exists: %s" % build_bundle
60-
assert not exists(src_bundle), "src-bundle/ dir still exists: %s" % src_bundle
91+
assert not exists(build_bundle), (
92+
"build-bundle/ dir still exists: %s" % build_bundle
93+
)
94+
assert not exists(src_bundle), "src-bundle/ dir still exists: %s" % (
95+
src_bundle
96+
)
6197
script.assert_no_temp()
6298

6399
# Make sure previously created src/ from editable still exists

tests/functional/test_completion.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ def setup_completion(script, words, cword):
6262
script.environ['COMP_CWORD'] = cword
6363

6464
# expect_error is True because autocomplete exists with 1 status code
65-
result = script.run('python', '-c', 'import pip;pip.autocomplete()',
66-
expect_error=True)
65+
result = script.run(
66+
'python', '-c', 'import pip;pip.autocomplete()',
67+
expect_error=True,
68+
)
6769

6870
return result, script
6971

0 commit comments

Comments
 (0)