Skip to content

Commit

Permalink
Update to py36 plus syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Jul 28, 2021
1 parent 1d8f1ab commit ca5d931
Show file tree
Hide file tree
Showing 64 changed files with 646 additions and 746 deletions.
2 changes: 1 addition & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"
runtime_version = "3.x.x"
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ What is the thing you want to fix? Is it associated with an issue on GitHub? Ple

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.

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

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

Expand Down
4 changes: 2 additions & 2 deletions NOTICES
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The contents of the vendor and patched directories are subject to different licenses
than the rest of this project.
than the rest of this project.

Their respective licenses can be looked up at pypi.python.org or in their
Their respective licenses can be looked up at pypi.python.org or in their
corresponding LICENSE files.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Or, if you\'re using Fedora:
Or, if you\'re using FreeBSD:

# pkg install py36-pipenv

Or, if you\'re using Windows:

# pip install --user pipenv
Expand Down Expand Up @@ -195,8 +195,8 @@ Fish is the best shell. You should use it.
lock Generates Pipfile.lock.
open View a given module in your editor.
run Spawns a command installed into the virtualenv.
scripts Displays the shortcuts in the (optional) [scripts] section of
Pipfile.
scripts Displays the shortcuts in the (optional) [scripts] section of
Pipfile.
shell Spawns a shell within the virtualenv.
sync Installs all packages specified in Pipfile.lock.
uninstall Un-installs a provided package and removes it from Pipfile.
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
4 changes: 2 additions & 2 deletions docs/_static/konami.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ var Konami = function (callback) {
},
touchendHandler: function () {
konami.iphone.input.push(konami.iphone.check_direction());

if (konami.iphone.input.length > konami.iphone.keys.length) konami.iphone.input.shift();

if (konami.iphone.input.length === konami.iphone.keys.length) {
var match = true;
for (var i = 0; i < konami.iphone.keys.length; i++) {
Expand Down
15 changes: 7 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# pipenv documentation build configuration file, created by
# sphinx-quickstart on Mon Jan 30 13:28:36 2017.
Expand Down Expand Up @@ -56,9 +55,9 @@
master_doc = 'index'

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

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


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

Expand All @@ -178,7 +177,7 @@ def setup(app):
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'pipenv', u'pipenv Documentation',
(master_doc, 'pipenv', 'pipenv Documentation',
author, 'pipenv', 'One line description of project.',
'Miscellaneous'),
]
Expand Down
2 changes: 1 addition & 1 deletion peeps/PEEP-003.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Pipenv will be governed by a board of maintainers (trusted collaborators to the

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

PEEP approval will be determined by available members of the board of maintainers, in private or public channels.
PEEP approval will be determined by available members of the board of maintainers, in private or public channels.
18 changes: 9 additions & 9 deletions peeps/PEEP-044.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ pipenv check needs offline, ci, and other output capabilities.


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

## Current implementation:
### Example 1
Expand All @@ -36,9 +36,9 @@ parse error: Invalid numeric literal at line 1, column 9
## Future implementation:
### Example 1
``` bash
pipenv check --db /Users/macbookpro/workspace/test/safety-db/data/ --output json --squelch
pipenv check --db /Users/macbookpro/workspace/test/safety-db/data/ --output json --squelch
[
[
[
"insecure-package",
"<0.2.0",
"0.1.0",
Expand Down
1 change: 0 additions & 1 deletion pipenv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding=utf-8 -*-
# |~~\' |~~
# |__/||~~\|--|/~\\ /
# | ||__/|__| |\/
Expand Down
41 changes: 11 additions & 30 deletions pipenv/_compat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding=utf-8 -*-
"""A compatibility module for pipenv's backports and manipulations.
Exposes a standard API that enables compatibility across python versions,
Expand All @@ -7,26 +6,18 @@
import sys
import warnings

import six
import vistir

from .vendor.vistir.compat import (
NamedTemporaryFile, Path, ResourceWarning, TemporaryDirectory
)


# Backport required for earlier versions of Python.
if sys.version_info < (3, 3):
from .vendor.backports.shutil_get_terminal_size import get_terminal_size
else:
from shutil import get_terminal_size

warnings.filterwarnings("ignore", category=ResourceWarning)


__all__ = [
"NamedTemporaryFile", "Path", "ResourceWarning", "TemporaryDirectory",
"get_terminal_size", "getpreferredencoding", "DEFAULT_ENCODING", "canonical_encoding_name",
"getpreferredencoding", "DEFAULT_ENCODING", "canonical_encoding_name",
"force_encoding", "UNICODE_TO_ASCII_TRANSLATION_MAP", "decode_output", "fix_utf8"
]

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


DEFAULT_ENCODING = getpreferredencoding()
Expand Down Expand Up @@ -69,7 +55,7 @@ def force_encoding():
return DEFAULT_ENCODING, DEFAULT_ENCODING
stdout_encoding = canonical_encoding_name(sys.stdout.encoding)
stderr_encoding = canonical_encoding_name(sys.stderr.encoding)
if sys.platform == "win32" and sys.version_info >= (3, 1):
if sys.platform == "win32":
return DEFAULT_ENCODING, DEFAULT_ENCODING
if stdout_encoding != "utf-8" or stderr_encoding != "utf-8":

Expand Down Expand Up @@ -110,10 +96,10 @@ def force_encoding():


UNICODE_TO_ASCII_TRANSLATION_MAP = {
8230: u"...",
8211: u"-",
10004: u"OK",
10008: u"x",
8230: "...",
8211: "-",
10004: "OK",
10008: "x",
}


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


def decode_output(output):
if not isinstance(output, six.string_types):
if not isinstance(output, str):
return output
try:
output = output.encode(DEFAULT_ENCODING)
except (AttributeError, UnicodeDecodeError, UnicodeEncodeError):
if six.PY2:
output = unicode.translate(vistir.misc.to_text(output), # noqa
UNICODE_TO_ASCII_TRANSLATION_MAP)
else:
output = output.translate(UNICODE_TO_ASCII_TRANSLATION_MAP)
output = output.translate(UNICODE_TO_ASCII_TRANSLATION_MAP)
output = output.encode(DEFAULT_ENCODING, "replace")
return vistir.misc.to_text(output, encoding=DEFAULT_ENCODING, errors="replace")


def fix_utf8(text):
if not isinstance(text, six.string_types):
if not isinstance(text, str):
return text
try:
text = decode_output(text)
except UnicodeDecodeError:
if six.PY2:
text = unicode.translate(vistir.misc.to_text(text), UNICODE_TO_ASCII_TRANSLATION_MAP) # noqa
pass
return text
3 changes: 0 additions & 3 deletions pipenv/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# -*- coding=utf-8 -*-
from __future__ import absolute_import

from .command import cli # noqa
25 changes: 11 additions & 14 deletions pipenv/cli/command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

import os
import sys

Expand Down Expand Up @@ -81,7 +78,7 @@ def cli(
shell = shells.detect_info()[0]
except shells.ShellDetectionFailure:
echo(
"Fail to detect shell. Please provide the {0} environment "
"Fail to detect shell. Please provide the {} environment "
"variable.".format(crayons.normal("PIPENV_SHELL", bold=True)),
err=True,
)
Expand Down Expand Up @@ -115,9 +112,9 @@ def cli(
from .. import environments
for key in environments.__dict__:
if key.startswith("PIPENV"):
echo(" - {0}".format(crayons.normal(key, bold=True)))
echo(f" - {crayons.normal(key, bold=True)}")
echo(
"\nYou can learn more at:\n {0}".format(
"\nYou can learn more at:\n {}".format(
crayons.green(
"https://pipenv.pypa.io/en/latest/advanced/#configuration-with-environment-variables"
)
Expand Down Expand Up @@ -175,7 +172,7 @@ def cli(
loc = project.virtualenv_location
echo(
crayons.normal(
u"{0} ({1})...".format(
"{} ({})...".format(
crayons.normal("Removing virtualenv", bold=True),
crayons.green(loc),
)
Expand Down Expand Up @@ -413,7 +410,7 @@ def shell(
venv_name = os.environ.get("VIRTUAL_ENV", "UNKNOWN_VIRTUAL_ENVIRONMENT")
if not anyway:
echo(
"{0} {1} {2}\nNo action taken to avoid nested environments.".format(
"{} {} {}\nNo action taken to avoid nested environments.".format(
crayons.normal("Shell for"),
crayons.green(venv_name, bold=True),
crayons.normal("already activated.", bold=True),
Expand Down Expand Up @@ -530,9 +527,9 @@ def check(
@cli.command(short_help="Runs lock, then sync.", context_settings=CONTEXT_SETTINGS)
@option("--bare", is_flag=True, default=False, help="Minimal output.")
@option(
"--outdated", is_flag=True, default=False, help=u"List out-of-date dependencies."
"--outdated", is_flag=True, default=False, help="List out-of-date dependencies."
)
@option("--dry-run", is_flag=True, default=None, help=u"List out-of-date dependencies.")
@option("--dry-run", is_flag=True, default=None, help="List out-of-date dependencies.")
@install_options
@pass_state
@pass_context
Expand Down Expand Up @@ -564,7 +561,7 @@ def update(
editable = [p for p in state.installstate.editables if p]
if not packages:
echo(
"{0} {1} {2} {3}{4}".format(
"{} {} {} {}{}".format(
crayons.normal("Running", bold=True),
crayons.yellow("$ pipenv lock", bold=True),
crayons.normal("then", bold=True),
Expand All @@ -576,7 +573,7 @@ def update(
for package in packages + editable:
if package not in project.all_packages:
echo(
"{0}: {1} was not found in your Pipfile! Aborting."
"{}: {} was not found in your Pipfile! Aborting."
"".format(
crayons.red("Warning", bold=True),
crayons.green(package, bold=True),
Expand Down Expand Up @@ -608,7 +605,7 @@ def update(


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

0 comments on commit ca5d931

Please sign in to comment.