Skip to content

Commit ca5d931

Browse files
committed
Update to py36 plus syntax
1 parent 1d8f1ab commit ca5d931

Some content is hidden

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

64 files changed

+646
-746
lines changed

.deepsource.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ name = "python"
1313
enabled = true
1414

1515
[analyzers.meta]
16-
runtime_version = "3.x.x"
16+
runtime_version = "3.x.x"

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ What is the thing you want to fix? Is it associated with an issue on GitHub? Ple
77

88
Always consider opening an issue first to describe your problem, so we can discuss what is the best way to amend it. Note that if you do not describe the goal of this change or link to a related issue, the maintainers may close the PR without further review.
99

10-
If your pull request makes a non-insignificant change to Pipenv, such as the user interface or intended functionality, please file a PEEP.
10+
If your pull request makes a non-insignificant change to Pipenv, such as the user interface or intended functionality, please file a PEEP.
1111

1212
https://github.com/pypa/pipenv/blob/master/peeps/PEEP-000.md
1313

NOTICES

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The contents of the vendor and patched directories are subject to different licenses
2-
than the rest of this project.
2+
than the rest of this project.
33

4-
Their respective licenses can be looked up at pypi.python.org or in their
4+
Their respective licenses can be looked up at pypi.python.org or in their
55
corresponding LICENSE files.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Or, if you\'re using Fedora:
5252
Or, if you\'re using FreeBSD:
5353

5454
# pkg install py36-pipenv
55-
55+
5656
Or, if you\'re using Windows:
5757

5858
# pip install --user pipenv
@@ -195,8 +195,8 @@ Fish is the best shell. You should use it.
195195
lock Generates Pipfile.lock.
196196
open View a given module in your editor.
197197
run Spawns a command installed into the virtualenv.
198-
scripts Displays the shortcuts in the (optional) [scripts] section of
199-
Pipfile.
198+
scripts Displays the shortcuts in the (optional) [scripts] section of
199+
Pipfile.
200200
shell Spawns a shell within the virtualenv.
201201
sync Installs all packages specified in Pipfile.lock.
202202
uninstall Un-installs a provided package and removes it from Pipfile.

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ help:
1717
# Catch-all target: route all unknown targets to Sphinx using the new
1818
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1919
%: Makefile
20-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/_static/konami.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ var Konami = function (callback) {
8484
},
8585
touchendHandler: function () {
8686
konami.iphone.input.push(konami.iphone.check_direction());
87-
87+
8888
if (konami.iphone.input.length > konami.iphone.keys.length) konami.iphone.input.shift();
89-
89+
9090
if (konami.iphone.input.length === konami.iphone.keys.length) {
9191
var match = true;
9292
for (var i = 0; i < konami.iphone.keys.length; i++) {

docs/conf.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# pipenv documentation build configuration file, created by
43
# sphinx-quickstart on Mon Jan 30 13:28:36 2017.
@@ -56,9 +55,9 @@
5655
master_doc = 'index'
5756

5857
# General information about the project.
59-
project = u'pipenv'
60-
copyright = u'2020. A project founded by <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a>'
61-
author = u'Python Packaging Authority'
58+
project = 'pipenv'
59+
copyright = '2020. A project founded by <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a>'
60+
author = 'Python Packaging Authority'
6261

6362
# The version info for the project you're documenting, acts as replacement for
6463
# |version| and |release|, also used in various other places throughout the
@@ -157,8 +156,8 @@ def setup(app):
157156
# (source start file, target name, title,
158157
# author, documentclass [howto, manual, or own class]).
159158
latex_documents = [
160-
(master_doc, 'pipenv.tex', u'pipenv Documentation',
161-
u'Kenneth Reitz', 'manual'),
159+
(master_doc, 'pipenv.tex', 'pipenv Documentation',
160+
'Kenneth Reitz', 'manual'),
162161
]
163162

164163

@@ -167,7 +166,7 @@ def setup(app):
167166
# One entry per manual page. List of tuples
168167
# (source start file, name, description, authors, manual section).
169168
man_pages = [
170-
(master_doc, 'pipenv', u'pipenv Documentation',
169+
(master_doc, 'pipenv', 'pipenv Documentation',
171170
[author], 1)
172171
]
173172

@@ -178,7 +177,7 @@ def setup(app):
178177
# (source start file, target name, title, author,
179178
# dir menu entry, description, category)
180179
texinfo_documents = [
181-
(master_doc, 'pipenv', u'pipenv Documentation',
180+
(master_doc, 'pipenv', 'pipenv Documentation',
182181
author, 'pipenv', 'One line description of project.',
183182
'Miscellaneous'),
184183
]

peeps/PEEP-003.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Pipenv will be governed by a board of maintainers (trusted collaborators to the
66

77
The BDFL retains his title, however, revokes himself of his powers.
88

9-
PEEP approval will be determined by available members of the board of maintainers, in private or public channels.
9+
PEEP approval will be determined by available members of the board of maintainers, in private or public channels.

peeps/PEEP-044.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ pipenv check needs offline, ci, and other output capabilities.
44

55
66

7-
Not everyone can utilize pipenv check and access the internet. Safety check knew this
7+
Not everyone can utilize pipenv check and access the internet. Safety check knew this
88
and that is why they created safety-db. This repository contains a json database that
99
is updated monthly. Safety check allows you to pass a --db flag that is a local directory
10-
containing that database. Safety check also allows you to pass --json, --bare, and
10+
containing that database. Safety check also allows you to pass --json, --bare, and
1111
--full-report. Pipenv check has their own way of displaying the results that is why I
12-
believe there should be a --output flag that allows users to specify json, bare,
12+
believe there should be a --output flag that allows users to specify json, bare,
1313
and full-report from safety check and default for the current pipenv check output.
1414
Currently, pipenv check has a lot of stdout messages and makes it harder to pipe
15-
the results into something to be checked (especially for continuous integration
16-
pipelines). That is why adding a --squelch switch is also important. This will be
17-
default False (display all stdout); however, the user has the option to add the
18-
--squelch switch to make the output only come from safety check.
15+
the results into something to be checked (especially for continuous integration
16+
pipelines). That is why adding a --squelch switch is also important. This will be
17+
default False (display all stdout); however, the user has the option to add the
18+
--squelch switch to make the output only come from safety check.
1919

2020
## Current implementation:
2121
### Example 1
@@ -36,9 +36,9 @@ parse error: Invalid numeric literal at line 1, column 9
3636
## Future implementation:
3737
### Example 1
3838
``` bash
39-
pipenv check --db /Users/macbookpro/workspace/test/safety-db/data/ --output json --squelch
39+
pipenv check --db /Users/macbookpro/workspace/test/safety-db/data/ --output json --squelch
4040
[
41-
[
41+
[
4242
"insecure-package",
4343
"<0.2.0",
4444
"0.1.0",

pipenv/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding=utf-8 -*-
21
# |~~\' |~~
32
# |__/||~~\|--|/~\\ /
43
# | ||__/|__| |\/

pipenv/_compat.py

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding=utf-8 -*-
21
"""A compatibility module for pipenv's backports and manipulations.
32
43
Exposes a standard API that enables compatibility across python versions,
@@ -7,26 +6,18 @@
76
import sys
87
import warnings
98

10-
import six
119
import vistir
1210

1311
from .vendor.vistir.compat import (
1412
NamedTemporaryFile, Path, ResourceWarning, TemporaryDirectory
1513
)
1614

17-
18-
# Backport required for earlier versions of Python.
19-
if sys.version_info < (3, 3):
20-
from .vendor.backports.shutil_get_terminal_size import get_terminal_size
21-
else:
22-
from shutil import get_terminal_size
23-
2415
warnings.filterwarnings("ignore", category=ResourceWarning)
2516

2617

2718
__all__ = [
2819
"NamedTemporaryFile", "Path", "ResourceWarning", "TemporaryDirectory",
29-
"get_terminal_size", "getpreferredencoding", "DEFAULT_ENCODING", "canonical_encoding_name",
20+
"getpreferredencoding", "DEFAULT_ENCODING", "canonical_encoding_name",
3021
"force_encoding", "UNICODE_TO_ASCII_TRANSLATION_MAP", "decode_output", "fix_utf8"
3122
]
3223

@@ -35,12 +26,7 @@ def getpreferredencoding():
3526
import locale
3627
# Borrowed from Invoke
3728
# (see https://github.com/pyinvoke/invoke/blob/93af29d/invoke/runners.py#L881)
38-
_encoding = locale.getpreferredencoding(False)
39-
if six.PY2 and sys.platform != "win32":
40-
_default_encoding = locale.getdefaultlocale()[1]
41-
if _default_encoding is not None:
42-
_encoding = _default_encoding
43-
return _encoding
29+
return locale.getpreferredencoding(False)
4430

4531

4632
DEFAULT_ENCODING = getpreferredencoding()
@@ -69,7 +55,7 @@ def force_encoding():
6955
return DEFAULT_ENCODING, DEFAULT_ENCODING
7056
stdout_encoding = canonical_encoding_name(sys.stdout.encoding)
7157
stderr_encoding = canonical_encoding_name(sys.stderr.encoding)
72-
if sys.platform == "win32" and sys.version_info >= (3, 1):
58+
if sys.platform == "win32":
7359
return DEFAULT_ENCODING, DEFAULT_ENCODING
7460
if stdout_encoding != "utf-8" or stderr_encoding != "utf-8":
7561

@@ -110,10 +96,10 @@ def force_encoding():
11096

11197

11298
UNICODE_TO_ASCII_TRANSLATION_MAP = {
113-
8230: u"...",
114-
8211: u"-",
115-
10004: u"OK",
116-
10008: u"x",
99+
8230: "...",
100+
8211: "-",
101+
10004: "OK",
102+
10008: "x",
117103
}
118104

119105

@@ -124,26 +110,21 @@ def decode_for_output(output, target=sys.stdout):
124110

125111

126112
def decode_output(output):
127-
if not isinstance(output, six.string_types):
113+
if not isinstance(output, str):
128114
return output
129115
try:
130116
output = output.encode(DEFAULT_ENCODING)
131117
except (AttributeError, UnicodeDecodeError, UnicodeEncodeError):
132-
if six.PY2:
133-
output = unicode.translate(vistir.misc.to_text(output), # noqa
134-
UNICODE_TO_ASCII_TRANSLATION_MAP)
135-
else:
136-
output = output.translate(UNICODE_TO_ASCII_TRANSLATION_MAP)
118+
output = output.translate(UNICODE_TO_ASCII_TRANSLATION_MAP)
137119
output = output.encode(DEFAULT_ENCODING, "replace")
138120
return vistir.misc.to_text(output, encoding=DEFAULT_ENCODING, errors="replace")
139121

140122

141123
def fix_utf8(text):
142-
if not isinstance(text, six.string_types):
124+
if not isinstance(text, str):
143125
return text
144126
try:
145127
text = decode_output(text)
146128
except UnicodeDecodeError:
147-
if six.PY2:
148-
text = unicode.translate(vistir.misc.to_text(text), UNICODE_TO_ASCII_TRANSLATION_MAP) # noqa
129+
pass
149130
return text

pipenv/cli/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
# -*- coding=utf-8 -*-
2-
from __future__ import absolute_import
3-
41
from .command import cli # noqa

pipenv/cli/command.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import
3-
41
import os
52
import sys
63

@@ -81,7 +78,7 @@ def cli(
8178
shell = shells.detect_info()[0]
8279
except shells.ShellDetectionFailure:
8380
echo(
84-
"Fail to detect shell. Please provide the {0} environment "
81+
"Fail to detect shell. Please provide the {} environment "
8582
"variable.".format(crayons.normal("PIPENV_SHELL", bold=True)),
8683
err=True,
8784
)
@@ -115,9 +112,9 @@ def cli(
115112
from .. import environments
116113
for key in environments.__dict__:
117114
if key.startswith("PIPENV"):
118-
echo(" - {0}".format(crayons.normal(key, bold=True)))
115+
echo(f" - {crayons.normal(key, bold=True)}")
119116
echo(
120-
"\nYou can learn more at:\n {0}".format(
117+
"\nYou can learn more at:\n {}".format(
121118
crayons.green(
122119
"https://pipenv.pypa.io/en/latest/advanced/#configuration-with-environment-variables"
123120
)
@@ -175,7 +172,7 @@ def cli(
175172
loc = project.virtualenv_location
176173
echo(
177174
crayons.normal(
178-
u"{0} ({1})...".format(
175+
"{} ({})...".format(
179176
crayons.normal("Removing virtualenv", bold=True),
180177
crayons.green(loc),
181178
)
@@ -413,7 +410,7 @@ def shell(
413410
venv_name = os.environ.get("VIRTUAL_ENV", "UNKNOWN_VIRTUAL_ENVIRONMENT")
414411
if not anyway:
415412
echo(
416-
"{0} {1} {2}\nNo action taken to avoid nested environments.".format(
413+
"{} {} {}\nNo action taken to avoid nested environments.".format(
417414
crayons.normal("Shell for"),
418415
crayons.green(venv_name, bold=True),
419416
crayons.normal("already activated.", bold=True),
@@ -530,9 +527,9 @@ def check(
530527
@cli.command(short_help="Runs lock, then sync.", context_settings=CONTEXT_SETTINGS)
531528
@option("--bare", is_flag=True, default=False, help="Minimal output.")
532529
@option(
533-
"--outdated", is_flag=True, default=False, help=u"List out-of-date dependencies."
530+
"--outdated", is_flag=True, default=False, help="List out-of-date dependencies."
534531
)
535-
@option("--dry-run", is_flag=True, default=None, help=u"List out-of-date dependencies.")
532+
@option("--dry-run", is_flag=True, default=None, help="List out-of-date dependencies.")
536533
@install_options
537534
@pass_state
538535
@pass_context
@@ -564,7 +561,7 @@ def update(
564561
editable = [p for p in state.installstate.editables if p]
565562
if not packages:
566563
echo(
567-
"{0} {1} {2} {3}{4}".format(
564+
"{} {} {} {}{}".format(
568565
crayons.normal("Running", bold=True),
569566
crayons.yellow("$ pipenv lock", bold=True),
570567
crayons.normal("then", bold=True),
@@ -576,7 +573,7 @@ def update(
576573
for package in packages + editable:
577574
if package not in project.all_packages:
578575
echo(
579-
"{0}: {1} was not found in your Pipfile! Aborting."
576+
"{}: {} was not found in your Pipfile! Aborting."
580577
"".format(
581578
crayons.red("Warning", bold=True),
582579
crayons.green(package, bold=True),
@@ -608,7 +605,7 @@ def update(
608605

609606

610607
@cli.command(
611-
short_help=u"Displays currently-installed dependency graph information.",
608+
short_help="Displays currently-installed dependency graph information.",
612609
context_settings=CONTEXT_SETTINGS
613610
)
614611
@option("--bare", is_flag=True, default=False, help="Minimal output.")
@@ -656,7 +653,7 @@ def run_open(state, module, *args, **kwargs):
656653
p = os.path.dirname(c.out.strip().rstrip("cdo"))
657654
else:
658655
p = c.out.strip().rstrip("cdo")
659-
echo(crayons.normal("Opening {0!r} in your EDITOR.".format(p), bold=True))
656+
echo(crayons.normal(f"Opening {p!r} in your EDITOR.", bold=True))
660657
inline_activate_virtual_environment()
661658
edit(filename=p)
662659
return 0

0 commit comments

Comments
 (0)