From 9729a9a9c646f83169477aae38968d3fd1354fc8 Mon Sep 17 00:00:00 2001 From: Sultan Imanhodjaev Date: Mon, 6 Feb 2017 20:16:48 +0100 Subject: [PATCH 1/3] Cleanup: IO and formatting --- pipenv/cli.py | 8 ++++---- pipenv/environments.py | 2 +- pipenv/pep508checker.py | 3 ++- pipenv/project.py | 7 ++++--- pipenv/utils.py | 1 + 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 071892e5..4f62d482 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -209,7 +209,7 @@ def do_install_dependencies(dev=False, only=False, bare=False, requirements=Fals else: if not bare: click.echo(crayons.yellow('Installing dependencies from Pipfile.lock...')) - with open(project.lockfile_location, 'r') as f: + with open(project.lockfile_location) as f: lockfile = json.load(f) # Install default dependencies, always. @@ -224,7 +224,7 @@ def do_install_dependencies(dev=False, only=False, bare=False, requirements=Fals # --requirements was passed. if requirements: - with open(deps_path, 'r') as f: + with open(deps_path) as f: click.echo(f.read()) sys.exit(0) @@ -536,7 +536,7 @@ def do_init(dev=False, requirements=False, skip_virtualenv=False, allow_global=F if project.lockfile_exists: # Open the lockfile. - with codecs.open(project.lockfile_location, 'r') as f: + with codecs.open(project.lockfile_location) as f: lockfile = json.load(f) # Update the lockfile if it is out-of-date. @@ -678,7 +678,7 @@ def format_pip_output(out, r=None): def easter_egg(package_name): if package_name in ['requests', 'maya', 'crayons', 'delegator.py' 'records', 'tablib']: - click.echo('P.S. You have excellent taste! ✨ 🍰 ✨') + click.echo(u'P.S. You have excellent taste! ✨ 🍰 ✨') @click.group(invoke_without_command=True) diff --git a/pipenv/environments.py b/pipenv/environments.py index 82b686da..9bfae82c 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -20,7 +20,7 @@ PIPENV_NOSPIN = os.environ.get('PIPENV_NOSPIN') # User-configuraable max-depth for Pipfile searching. # Note: +1 because of a temporary bug in Pipenv. -PIPENV_MAX_DEPTH = int(os.environ.get('PIPENV_MAX_DEPTH', '3')) + 1 +PIPENV_MAX_DEPTH = int(os.environ.get('PIPENV_MAX_DEPTH', 3)) + 1 # Use shell compatibility mode when using venv in project mode. if PIPENV_VENV_IN_PROJECT: diff --git a/pipenv/pep508checker.py b/pipenv/pep508checker.py index c88ea2ce..5a0cdc0c 100644 --- a/pipenv/pep508checker.py +++ b/pipenv/pep508checker.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import sys import os import platform @@ -16,7 +17,7 @@ def format_full_version(info): if hasattr(sys, 'implementation'): implementation_version = format_full_version(sys.implementation.version) else: - implementation_version = "0" + implementation_version = '0' # Default to cpython for 2.7. if hasattr(sys, 'implementation'): diff --git a/pipenv/project.py b/pipenv/project.py index 5f84b788..40cf7de0 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import json import os @@ -68,7 +69,7 @@ class Project(object): @property def proper_names(self): - with open(self.proper_names_location, 'r') as f: + with open(self.proper_names_location) as f: return f.read().splitlines() def register_proper_name(self, name): @@ -85,7 +86,7 @@ class Project(object): @property def parsed_pipfile(self): - with open(self.pipfile_location, 'r') as f: + with open(self.pipfile_location) as f: # return toml.load(f) return toml.load(f, _dict=OrderedDict) @@ -99,7 +100,7 @@ class Project(object): @property def lockfile_content(self): - with open(self.lockfile_location, 'r') as lock: + with open(self.lockfile_location) as lock: return json.load(lock) def create_pipfile(self): diff --git a/pipenv/utils.py b/pipenv/utils.py index 08fc7c1b..8c50a107 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import os import tempfile From 849a62c4739c1829f670d502508971cea1c6a103 Mon Sep 17 00:00:00 2001 From: Sultan Imanhodjaev Date: Mon, 6 Feb 2017 20:31:59 +0100 Subject: [PATCH 2/3] Put back 'r' for codecs.open --- pipenv/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 4f62d482..9a2087bf 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -536,7 +536,7 @@ def do_init(dev=False, requirements=False, skip_virtualenv=False, allow_global=F if project.lockfile_exists: # Open the lockfile. - with codecs.open(project.lockfile_location) as f: + with codecs.open(project.lockfile_location, 'r') as f: lockfile = json.load(f) # Update the lockfile if it is out-of-date. From 7ed304238a3c30c9dfa9e2dc03c53ec068d78a80 Mon Sep 17 00:00:00 2001 From: Sultan Imanhodjaev Date: Mon, 6 Feb 2017 20:54:17 +0100 Subject: [PATCH 3/3] Use string as a default value for PIPENV_MAX_DEPTH --- pipenv/environments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipenv/environments.py b/pipenv/environments.py index 9bfae82c..82b686da 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -20,7 +20,7 @@ PIPENV_NOSPIN = os.environ.get('PIPENV_NOSPIN') # User-configuraable max-depth for Pipfile searching. # Note: +1 because of a temporary bug in Pipenv. -PIPENV_MAX_DEPTH = int(os.environ.get('PIPENV_MAX_DEPTH', 3)) + 1 +PIPENV_MAX_DEPTH = int(os.environ.get('PIPENV_MAX_DEPTH', '3')) + 1 # Use shell compatibility mode when using venv in project mode. if PIPENV_VENV_IN_PROJECT: