From 7d36f3fbdab6fcf8340df8a2cf157bef9a8713ce Mon Sep 17 00:00:00 2001 From: frostming Date: Fri, 6 Sep 2019 16:07:54 +0800 Subject: [PATCH] Reformat codes --- pipenv/__init__.py | 4 +- pipenv/_compat.py | 6 +-- pipenv/cli/__init__.py | 2 +- pipenv/cli/command.py | 12 +++--- pipenv/core.py | 47 ++++++++++------------- pipenv/environment.py | 9 ++--- pipenv/exceptions.py | 15 ++++---- pipenv/project.py | 23 +++++------ pipenv/resolver.py | 9 ----- pipenv/utils.py | 38 ++++++++---------- pytest.ini | 25 ------------ setup.cfg | 33 +++++++++++++++- setup.py | 1 + tasks/__init__.py | 2 - tasks/release.py | 3 -- tasks/vendoring/__init__.py | 12 +----- tasks/vendoring/vendor_passa.py | 2 +- tests/integration/conftest.py | 25 ++++++------ tests/integration/test_cli.py | 2 +- tests/integration/test_dot_venv.py | 4 +- tests/integration/test_install_markers.py | 1 - tests/integration/test_install_twists.py | 2 - tests/integration/test_lock.py | 2 +- tests/integration/test_project.py | 1 - tests/integration/test_windows.py | 1 - tests/pytest-pypi/pytest_pypi/app.py | 1 - tests/pytest-pypi/pytest_pypi/certs.py | 1 + tests/pytest-pypi/pytest_pypi/plugin.py | 2 + tests/unit/test_patched.py | 1 + tests/unit/test_utils.py | 13 ++----- 30 files changed, 126 insertions(+), 173 deletions(-) delete mode 100644 pytest.ini diff --git a/pipenv/__init__.py b/pipenv/__init__.py index 31d49fc1..624397c5 100644 --- a/pipenv/__init__.py +++ b/pipenv/__init__.py @@ -8,7 +8,7 @@ import os import sys import warnings -from .__version__ import __version__ +from .__version__ import __version__ # noqa PIPENV_ROOT = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) @@ -53,7 +53,7 @@ sys.stdout = stdout sys.stderr = stderr from .cli import cli -from . import resolver +from . import resolver # noqa if __name__ == "__main__": cli() diff --git a/pipenv/_compat.py b/pipenv/_compat.py index caba80fe..fdcca7f5 100644 --- a/pipenv/_compat.py +++ b/pipenv/_compat.py @@ -4,8 +4,6 @@ Exposes a standard API that enables compatibility across python versions, operating systems, etc. """ - -import os import sys import warnings @@ -132,7 +130,7 @@ def decode_output(output): output = output.encode(DEFAULT_ENCODING) except (AttributeError, UnicodeDecodeError, UnicodeEncodeError): if six.PY2: - output = unicode.translate(vistir.misc.to_text(output), + output = unicode.translate(vistir.misc.to_text(output), # noqa UNICODE_TO_ASCII_TRANSLATION_MAP) else: output = output.translate(UNICODE_TO_ASCII_TRANSLATION_MAP) @@ -147,5 +145,5 @@ def fix_utf8(text): text = decode_output(text) except UnicodeDecodeError: if six.PY2: - text = unicode.translate(vistir.misc.to_text(text), UNICODE_TO_ASCII_TRANSLATION_MAP) + text = unicode.translate(vistir.misc.to_text(text), UNICODE_TO_ASCII_TRANSLATION_MAP) # noqa return text diff --git a/pipenv/cli/__init__.py b/pipenv/cli/__init__.py index d1819953..0f57e306 100644 --- a/pipenv/cli/__init__.py +++ b/pipenv/cli/__init__.py @@ -1,4 +1,4 @@ # -*- coding=utf-8 -*- from __future__ import absolute_import -from .command import cli +from .command import cli # noqa diff --git a/pipenv/cli/command.py b/pipenv/cli/command.py index 3fa6b611..293822a8 100644 --- a/pipenv/cli/command.py +++ b/pipenv/cli/command.py @@ -8,17 +8,15 @@ from click import ( argument, echo, edit, group, option, pass_context, secho, version_option ) -from ..vendor import click_completion -from ..vendor import delegator -from ..patched import crayons - from ..__version__ import __version__ +from ..patched import crayons +from ..vendor import click_completion, delegator from .options import ( CONTEXT_SETTINGS, PipenvGroup, code_option, common_options, deploy_option, general_options, install_options, lock_options, pass_state, - pypi_mirror_option, python_option, requirementstxt_option, - skip_lock_option, sync_options, system_option, three_option, - uninstall_options, verbose_option, site_packages_option + pypi_mirror_option, python_option, site_packages_option, skip_lock_option, + sync_options, system_option, three_option, uninstall_options, + verbose_option ) diff --git a/pipenv/core.py b/pipenv/core.py index e92b762c..3e299c8d 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -1,49 +1,48 @@ # -*- coding=utf-8 -*- from __future__ import absolute_import, print_function + import io import json as simplejson import logging import os -import shutil import sys import time import warnings import click import six -import urllib3.util as urllib3_util -import vistir -from click_completion import init as init_completion import delegator import dotenv import pipfile +import vistir + +from click_completion import init as init_completion -from .patched import crayons from . import environments, exceptions, pep508checker, progress -from ._compat import fix_utf8, decode_for_output +from ._compat import decode_for_output, fix_utf8 from .cmdparse import Script from .environments import ( - PIPENV_CACHE_DIR, PIPENV_COLORBLIND, PIPENV_DEFAULT_PYTHON_VERSION, - PIPENV_DONT_USE_PYENV, PIPENV_HIDE_EMOJIS, PIPENV_MAX_SUBPROCESS, - PIPENV_PYUP_API_KEY, PIPENV_SHELL_FANCY, PIPENV_SKIP_VALIDATION, - PIPENV_YES, SESSION_IS_INTERACTIVE, PIP_EXISTS_ACTION, PIPENV_RESOLVE_VCS, - is_type_checking + PIP_EXISTS_ACTION, PIPENV_CACHE_DIR, PIPENV_COLORBLIND, + PIPENV_DEFAULT_PYTHON_VERSION, PIPENV_DONT_USE_PYENV, PIPENV_HIDE_EMOJIS, + PIPENV_MAX_SUBPROCESS, PIPENV_PYUP_API_KEY, PIPENV_RESOLVE_VCS, + PIPENV_SHELL_FANCY, PIPENV_SKIP_VALIDATION, PIPENV_YES, + SESSION_IS_INTERACTIVE, is_type_checking ) -from .project import Project, SourceNotFound +from .patched import crayons +from .project import Project from .utils import ( - convert_deps_to_pip, create_mirror_source, create_spinner, download_file, - escape_cmd, escape_grouped_arguments, find_windows_executable, - get_canonical_names, is_pinned, is_pypi_url, is_required_version, is_star, - is_valid_url, parse_indexes, pep423_name, prepare_pip_source_args, - proper_case, python_version, venv_resolve_deps, run_command, - is_python_command, find_python, make_posix, interrupt_handled_subprocess, - get_indexes_from_requirement, get_source_list, get_project_index, + convert_deps_to_pip, create_spinner, download_file, + escape_grouped_arguments, find_python, find_windows_executable, + get_canonical_names, get_source_list, interrupt_handled_subprocess, + is_pinned, is_python_command, is_required_version, is_star, is_valid_url, + parse_indexes, pep423_name, prepare_pip_source_args, proper_case, + python_version, run_command, venv_resolve_deps ) if is_type_checking(): - from typing import Dict, List, Mapping, Optional, Union, Text + from typing import Dict, List, Optional, Union, Text from pipenv.vendor.requirementslib.models.requirements import Requirement TSourceDict = Dict[Text, Union[Text, bool]] @@ -711,8 +710,6 @@ def batch_install(deps_list, procs, failed_deps_queue, label=label ) - - indexes = [] trusted_hosts = [] # Install these because for dep in deps_list_bar: @@ -723,9 +720,6 @@ def batch_install(deps_list, procs, failed_deps_queue, dep.markers = str(strip_extras_markers_from_requirement(dep.get_markers())) # Install the module. is_artifact = False - if no_deps: - link = getattr(dep.req, "link", None) - is_wheel = getattr(link, "is_wheel", False) if link else False if dep.is_file_or_url and (dep.is_direct_url or any( dep.req.uri.endswith(ext) for ext in ["zip", "tar.gz"] )): @@ -1053,7 +1047,6 @@ def do_lock( # Resolve dev-package dependencies, with pip-tools. for is_dev in [True, False]: pipfile_section = "dev-packages" if is_dev else "packages" - lockfile_section = "develop" if is_dev else "default" if project.pipfile_exists: packages = project.parsed_pipfile.get(pipfile_section, {}) else: @@ -1355,7 +1348,7 @@ def get_requirement_line( return ["-e", line] return '-e {0}'.format(line) if not format_for_file: - return [line,] + return [line] return line return requirement.as_line(include_hashes=include_hashes, as_list=not format_for_file) diff --git a/pipenv/environment.py b/pipenv/environment.py index 4a694019..a1a28bf5 100644 --- a/pipenv/environment.py +++ b/pipenv/environment.py @@ -10,7 +10,6 @@ import os import site import sys -from distutils.sysconfig import get_python_lib from sysconfig import get_paths, get_python_version import itertools @@ -620,7 +619,7 @@ class Environment(object): else: d['required_version'] = d['installed_version'] - get_children = lambda n: key_tree.get(n.key, []) + get_children = lambda n: key_tree.get(n.key, []) # noqa d['dependencies'] = [ cls._get_requirements_for_package(c, key_tree, parent=node, @@ -805,7 +804,7 @@ class Environment(object): sys.path = self.sys_path sys.prefix = self.sys_prefix site.addsitedir(self.base_paths["purelib"]) - pip = self.safe_import("pip") + pip = self.safe_import("pip") # noqa pip_vendor = self.safe_import("pip._vendor") pep517_dir = os.path.join(os.path.dirname(pip_vendor.__file__), "pep517") site.addsitedir(pep517_dir) @@ -865,7 +864,7 @@ class Environment(object): def install(self, requirements): if not isinstance(requirements, (tuple, list)): - requirements = [requirements,] + requirements = [requirements] with self.get_finder() as finder: args = [] for format_control in ('no_binary', 'only_binary'): @@ -925,7 +924,7 @@ class Environment(object): pathset.remove(auto_confirm=auto_confirm, verbose=verbose) try: yield pathset - except Exception as e: + except Exception: if pathset is not None: pathset.rollback() else: diff --git a/pipenv/exceptions.py b/pipenv/exceptions.py index c8ca0dc8..6e0032ad 100644 --- a/pipenv/exceptions.py +++ b/pipenv/exceptions.py @@ -84,7 +84,7 @@ class PipenvException(ClickException): file = vistir.misc.get_text_stderr() if self.extra: if isinstance(self.extra, STRING_TYPES): - self.extra = [self.extra,] + self.extra = [self.extra] for extra in self.extra: extra = "[pipenv.exceptions.{0!s}]: {1}".format( self.__class__.__name__, extra @@ -163,14 +163,13 @@ class PipenvUsageError(UsageError): color = self.ctx.color if self.extra: if isinstance(self.extra, STRING_TYPES): - self.extra = [self.extra,] + self.extra = [self.extra] for extra in self.extra: if color: extra = getattr(crayons, color, "blue")(extra) click_echo(decode_for_output(extra, file), file=file) hint = '' - if (self.cmd is not None and - self.cmd.get_help_option(self.ctx) is not None): + if self.cmd is not None and self.cmd.get_help_option(self.ctx) is not None: hint = ('Try "%s %s" for help.\n' % (self.ctx.command_path, self.ctx.help_option_names[0])) if self.ctx is not None: @@ -199,7 +198,7 @@ class PipenvFileError(FileError): file = vistir.misc.get_text_stderr() if self.extra: if isinstance(self.extra, STRING_TYPES): - self.extra = [self.extra,] + self.extra = [self.extra] for extra in self.extra: click_echo(decode_for_output(extra, file), file=file) click_echo(self.message, file=file) @@ -312,7 +311,7 @@ class VirtualenvCreationException(VirtualenvException): extra = ANSI_REMOVAL_RE.sub("", "{0}".format(extra)) if "KeyboardInterrupt" in extra: extra = crayons.red("Virtualenv creation interrupted by user", bold=True) - self.extra = extra = [extra,] + self.extra = extra = [extra] VirtualenvException.__init__(self, message, extra=extra) @@ -321,9 +320,9 @@ class UninstallError(PipenvException): extra = [ "{0} {1}".format( crayons.blue("Attempted to run command: "), - crayons.yellow("$ {0!r}".format(command), bold=True + crayons.yellow("$ {0!r}".format(command), bold=True) ) - )] + ] extra.extend([crayons.blue(line.strip()) for line in return_values.splitlines()]) if isinstance(package, (tuple, list, set)): package = " ".join(package) diff --git a/pipenv/project.py b/pipenv/project.py index c4b0c941..5b14106e 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -15,8 +15,6 @@ import toml import tomlkit import vistir -from first import first - import pipfile import pipfile.api @@ -209,14 +207,12 @@ class Project(object): # First exclude anything that is a vcs entry either in the key or value if not ( any(is_vcs(i) for i in [k, v]) - or # Then exclude any installable files that are not directories # Because pip-tools can resolve setup.py for example - any(is_installable_file(i) for i in [k, v]) - or + or any(is_installable_file(i) for i in [k, v]) # Then exclude any URLs because they need to be editable also # Things that are excluded can only be 'shallow resolved' - any(is_valid_url(i) for i in [k, v]) + or any(is_valid_url(i) for i in [k, v]) ): ps.update({k: v}) return ps @@ -337,7 +333,7 @@ class Project(object): if not self._environment: prefix = self.virtualenv_location is_venv = is_in_virtualenv() - sources = self.sources if self.sources else [DEFAULT_SOURCE,] + sources = self.sources if self.sources else [DEFAULT_SOURCE] self._environment = Environment( prefix=prefix, is_venv=is_venv, sources=sources, pipfile=self.parsed_pipfile, project=self @@ -421,8 +417,10 @@ class Project(object): def virtualenv_location(self): # if VIRTUAL_ENV is set, use that. virtualenv_env = os.getenv("VIRTUAL_ENV") - if ("PIPENV_ACTIVE" not in os.environ and - not PIPENV_IGNORE_VIRTUALENVS and virtualenv_env): + if ( + "PIPENV_ACTIVE" not in os.environ + and not PIPENV_IGNORE_VIRTUALENVS and virtualenv_env + ): return virtualenv_env if not self._virtualenv_location: # Use cached version, if available. @@ -542,7 +540,6 @@ class Project(object): def build_requires(self): return self._build_system.get("requires", ["setuptools>=40.8.0", "wheel"]) - @property def build_backend(self): return self._build_system.get("build-backend", get_default_pyproject_backend()) @@ -688,7 +685,7 @@ class Project(object): .lstrip("\n") .split("\n") ) - sources = [DEFAULT_SOURCE,] + sources = [DEFAULT_SOURCE] for i, index in enumerate(indexes): if not index: continue @@ -756,7 +753,7 @@ class Project(object): if not sources: sources = self.pipfile_sources elif not isinstance(sources, list): - sources = [sources,] + sources = [sources] lockfile_dict["_meta"]["sources"] = [ self.populate_source(s) for s in sources ] @@ -775,7 +772,7 @@ class Project(object): else: sources = [dict(source) for source in self.parsed_pipfile["source"]] if not isinstance(sources, list): - sources = [sources,] + sources = [sources] return { "hash": {"sha256": self.calculate_pipfile_hash()}, "pipfile-spec": PIPFILE_SPEC_CURRENT, diff --git a/pipenv/resolver.py b/pipenv/resolver.py index 1219cc24..cd04fccb 100644 --- a/pipenv/resolver.py +++ b/pipenv/resolver.py @@ -516,7 +516,6 @@ class Entry(object): :raises: :exc:`~pipenv.exceptions.DependencyConflict` if resolution is impossible """ # ensure that we satisfy the parent dependencies of this dep - from pipenv.vendor.packaging.specifiers import Specifier parent_dependencies = set() has_mismatch = False can_use_original = True @@ -527,7 +526,6 @@ class Entry(object): # parents with no requirements can't conflict if not p.requirements: continue - needed = p.requirements.get("dependencies", []) entry_ref = p.get_dependency(self.name) required = entry_ref.get("required_version", "*") required = self.clean_specifier(required) @@ -633,7 +631,6 @@ def clean_results(results, resolver, project, dev=False): return results lockfile = project.lockfile_content section = "develop" if dev else "default" - pipfile_section = "dev-packages" if dev else "packages" reverse_deps = project.environment.reverse_dependencies() new_results = [r for r in results if r["name"] not in lockfile[section]] for result in results: @@ -646,17 +643,11 @@ def clean_results(results, resolver, project, dev=False): def clean_outdated(results, resolver, project, dev=False): - from pipenv.vendor.requirementslib.models.requirements import Requirement - from pipenv.environments import is_verbose if not project.lockfile_exists: return results lockfile = project.lockfile_content section = "develop" if dev else "default" - pipfile_section = "dev-packages" if dev else "packages" - pipfile = project.parsed_pipfile[pipfile_section] reverse_deps = project.environment.reverse_dependencies() - deptree = project.environment.get_package_requirements() - overlapping_results = [r for r in results if r["name"] in lockfile[section]] new_results = [r for r in results if r["name"] not in lockfile[section]] for result in results: name = result.get("name") diff --git a/pipenv/utils.py b/pipenv/utils.py index 2b0a8cdb..f263ee9f 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -1,46 +1,41 @@ # -*- coding: utf-8 -*- from __future__ import print_function + import contextlib import errno import logging import os import posixpath import re -import signal import shutil +import signal import stat import sys import warnings - from contextlib import contextmanager from distutils.spawn import find_executable import six import toml -import tomlkit - from click import echo as click_echo from six.moves.urllib.parse import urlparse -from .vendor.vistir.compat import ResourceWarning, lru_cache, Mapping, Sequence, Set -from .vendor.vistir.misc import fs_str, run import crayons import parse +import tomlkit from . import environments -from .exceptions import ( - PipenvUsageError, RequirementError, PipenvCmdError, ResolutionFailure -) +from .exceptions import PipenvCmdError, PipenvUsageError, RequirementError, ResolutionFailure from .pep508checker import lookup +from .vendor.packaging.markers import Marker from .vendor.urllib3 import util as urllib3_util - +from .vendor.vistir.compat import Mapping, ResourceWarning, Sequence, Set, lru_cache +from .vendor.vistir.misc import fs_str, run if environments.MYPY_RUNNING: from typing import Tuple, Dict, Any, List, Union, Optional, Text from .vendor.requirementslib.models.requirements import Requirement, Line from .vendor.requirementslib.models.pipfile import Pipfile - from .vendor.packaging.markers import Marker - from .vendor.packaging.specifiers import Specifier from .project import Project, TSource @@ -316,7 +311,7 @@ def get_source_list( sources.append(get_project_index(index)) if extra_indexes: if isinstance(extra_indexes, six.string_types): - extra_indexes = [extra_indexes,] + extra_indexes = [extra_indexes] for source in extra_indexes: extra_src = get_project_index(source) if not sources or extra_src["url"] != sources[0]["url"]: @@ -555,8 +550,8 @@ class Resolver(object): # but leave it on for local, installable folders on the filesystem if environments.PIPENV_RESOLVE_VCS or ( req.editable or parsed_line.is_wheel or ( - req.is_file_or_url and parsed_line.is_local and - is_installable_dir(parsed_line.path) + req.is_file_or_url and parsed_line.is_local + and is_installable_dir(parsed_line.path) ) ): requirements = [v for v in getattr(setup_info, "requires", {}).values()] @@ -920,8 +915,10 @@ class Resolver(object): # We also don't want to try to hash directories as this will fail # as these are editable deps and are not hashable. - if (ireq.link.scheme == "file" and - Path(to_native_string(url_to_path(ireq.link.url))).is_dir()): + if ( + ireq.link.scheme == "file" + and Path(to_native_string(url_to_path(ireq.link.url))).is_dir() + ): return False return True @@ -1069,7 +1066,6 @@ def actually_resolve_deps( req_dir=None, ): from pipenv.vendor.vistir.path import create_tracked_tempdir - from pipenv.vendor.requirementslib.models.requirements import Requirement if not req_dir: req_dir = create_tracked_tempdir(suffix="-requirements", prefix="pipenv-") @@ -1889,7 +1885,7 @@ def translate_markers(pipfile_entry): """ if not isinstance(pipfile_entry, Mapping): raise TypeError("Entry is not a pipfile formatted mapping.") - from .vendor.packaging.markers import Marker, default_environment + from .vendor.packaging.markers import default_environment from .vendor.vistir.misc import dedup allowed_marker_keys = ["markers"] + list(default_environment().keys()) @@ -2217,8 +2213,8 @@ def is_python_command(line): from pipenv.vendor.pythonfinder.utils import PYTHON_IMPLEMENTATIONS is_version = re.match(r'[\d\.]+', line) - if (line.startswith("python") or is_version or - any(line.startswith(v) for v in PYTHON_IMPLEMENTATIONS)): + if (line.startswith("python") or is_version + or any(line.startswith(v) for v in PYTHON_IMPLEMENTATIONS)): return True # we are less sure about this but we can guess if line.startswith("py"): diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index da966ec9..00000000 --- a/pytest.ini +++ /dev/null @@ -1,25 +0,0 @@ -[pytest] -addopts = -ra -n auto -plugins = xdist -testpaths = tests -; Add vendor and patched in addition to the default list of ignored dirs -; Additionally, ignore tasks, news, test subdirectories and peeps directory -norecursedirs = - .* build - dist - CVS - _darcs - {arch} - *.egg - vendor - patched - news - tasks - docs - tests/test_artifacts - tests/pytest-pypi - tests/pypi - peeps -filterwarnings = - ignore::DeprecationWarning - ignore::PendingDeprecationWarning diff --git a/setup.cfg b/setup.cfg index 896a5a91..fbc691d4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,7 +4,9 @@ license = MIT license_file = LICENSE [flake8] -exclude = .git,__pycache__,docs/,pipenv/vendor/,get-pipenv.py,setup.py +exclude = + .git,__pycache__,docs/,pipenv/vendor/,pipenv/patched,get-pipenv.py, + .eggs/,setup.py,tests/fixtures/ ignore = # The default ignore list: E121,E123,E126,E226,E24,E704, @@ -17,13 +19,14 @@ ignore = # E402: module level import not at top of file # E501: line too long # W503: line break before binary operator - E402,E501,W503 + E402,E501,W503,E203 [isort] atomic=true lines_after_imports=2 lines_between_types=1 multi_line_output=5 +line_length=80 not_skip=__init__.py known_first_party = pipenv @@ -36,3 +39,29 @@ follow_imports=skip html_report=mypyhtml python_version=3.6 mypy_path=typeshed/pyi:typeshed/imports + +[tool:pytest] +addopts = -ra -n auto +plugins = xdist +testpaths = tests +; Add vendor and patched in addition to the default list of ignored dirs +; Additionally, ignore tasks, news, test subdirectories and peeps directory +norecursedirs = + .* build + dist + CVS + _darcs + {arch} + *.egg + vendor + patched + news + tasks + docs + tests/test_artifacts + tests/pytest-pypi + tests/pypi + peeps +filterwarnings = + ignore::DeprecationWarning + ignore::PendingDeprecationWarning diff --git a/setup.py b/setup.py index d86d85e0..dd8d4f71 100644 --- a/setup.py +++ b/setup.py @@ -45,6 +45,7 @@ extras = { "tests": ["pytest<5.0", "pytest-tap", "pytest-xdist", "flaky", "mock"], } + # https://pypi.python.org/pypi/stdeb/0.8.5#quickstart-2-just-tell-me-the-fastest-way-to-make-a-deb class DebCommand(Command): """Support for setup.py deb""" diff --git a/tasks/__init__.py b/tasks/__init__.py index 63fe1388..d81d101d 100644 --- a/tasks/__init__.py +++ b/tasks/__init__.py @@ -1,8 +1,6 @@ # -*- coding=utf-8 -*- # Copied from pip's vendoring process # see https://github.com/pypa/pip/blob/95bcf8c5f6394298035a7332c441868f3b0169f4/tasks/__init__.py -import re - from pathlib import Path import invoke diff --git a/tasks/release.py b/tasks/release.py index 610a36a9..c43a7c85 100644 --- a/tasks/release.py +++ b/tasks/release.py @@ -3,7 +3,6 @@ import datetime import os import pathlib import re -import sys import invoke @@ -240,8 +239,6 @@ def bump_version(ctx, dry_run=False, dev=False, pre=False, tag=None, commit=Fals current_version = Version.parse(__version__) today = datetime.date.today() tomorrow = today + datetime.timedelta(days=1) - next_month = datetime.date.today().replace(month=today.month + 1, day=1) - next_year = datetime.date.today().replace(year=today.year + 1, month=1, day=1) if pre and not tag: print('Using "pre" requires a corresponding tag.') return diff --git a/tasks/vendoring/__init__.py b/tasks/vendoring/__init__.py index 69398450..8329ba4e 100644 --- a/tasks/vendoring/__init__.py +++ b/tasks/vendoring/__init__.py @@ -41,7 +41,7 @@ LIBRARY_DIRNAMES = { 'enum': 'backports/enum' } -PY2_DOWNLOAD = ['enum34',] +PY2_DOWNLOAD = ['enum34'] # from time to time, remove the no longer needed ones HARDCODED_LICENSE_URLS = { @@ -93,7 +93,6 @@ LICENSE_RENAMES = { } - def drop_dir(path): if path.exists() and path.is_dir(): shutil.rmtree(str(path), ignore_errors=True) @@ -379,7 +378,6 @@ def vendor(ctx, vendor_dir, package=None, rewrite=True): post_install_cleanup(ctx, vendor_dir) # Detect the vendored packages/modules vendored_libs = detect_vendored_libs(_get_vendor_dir(ctx)) - patched_libs = detect_vendored_libs(_get_patched_dir(ctx)) log("Detected vendored libraries: %s" % ", ".join(vendored_libs)) # Apply pre-patches @@ -509,14 +507,6 @@ def download_licenses( new_requirements_file = fh.name new_requirements_file = Path(new_requirements_file) log(requirements) - requirement = "-r {0}".format(new_requirements_file.as_posix()) - if package: - if not only: - # for packages we want to add to the requirements file - requirement = _ensure_package_in_requirements(ctx, requirements_file, package) - else: - # for packages we want to get the license for by themselves - requirement = package tmp_dir = vendor_dir / '__tmp__' # TODO: Fix this whenever it gets sorted out (see https://github.com/pypa/pip/issues/5739) cmd = "pip download --no-binary :all: --only-binary requests_download --no-deps" diff --git a/tasks/vendoring/vendor_passa.py b/tasks/vendoring/vendor_passa.py index f2c58745..2da91259 100644 --- a/tasks/vendoring/vendor_passa.py +++ b/tasks/vendoring/vendor_passa.py @@ -2,7 +2,7 @@ import invoke from pipenv._compat import TemporaryDirectory -from . import _get_git_root, _get_vendor_dir, log +from . import _get_vendor_dir, log @invoke.task diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index b05eacfa..53973d34 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -1,30 +1,34 @@ # -*- coding=utf-8 -*- from __future__ import absolute_import, print_function + import errno import json import logging import os import shutil -import signal -import socket import sys -import time import warnings -from shutil import copyfileobj, rmtree as _rmtree +from shutil import rmtree as _rmtree import pytest import requests -from pipenv.vendor.vistir.compat import ResourceWarning, fs_str, fs_encode, FileNotFoundError, PermissionError, TemporaryDirectory -from pipenv.vendor.vistir.misc import run -from pipenv.vendor.vistir.contextmanagers import temp_environ -from pipenv.vendor.vistir.path import mkdir_p, create_tracked_tempdir, handle_remove_readonly - from pipenv._compat import Path from pipenv.exceptions import VirtualenvActivationException from pipenv.vendor import delegator, toml, tomlkit -from pytest_pypi.app import prepare_fixtures, prepare_packages as prepare_pypi_packages +from pipenv.vendor.vistir.compat import ( + FileNotFoundError, PermissionError, ResourceWarning, TemporaryDirectory, + fs_encode, fs_str +) +from pipenv.vendor.vistir.contextmanagers import temp_environ +from pipenv.vendor.vistir.misc import run +from pipenv.vendor.vistir.path import ( + create_tracked_tempdir, handle_remove_readonly, mkdir_p +) +from pytest_pypi.app import prepare_fixtures +from pytest_pypi.app import prepare_packages as prepare_pypi_packages + log = logging.getLogger(__name__) warnings.simplefilter("default", category=ResourceWarning) @@ -399,7 +403,6 @@ class _PipenvInstance(object): def _rmtree_func(path, ignore_errors=True, onerror=None): directory = fs_encode(path) - global _rmtree shutil_rmtree = _rmtree if onerror is None: onerror = handle_remove_readonly diff --git a/tests/integration/test_cli.py b/tests/integration/test_cli.py index 137ae892..04253fc5 100644 --- a/tests/integration/test_cli.py +++ b/tests/integration/test_cli.py @@ -223,7 +223,7 @@ def test_install_parse_error(PipenvInstance): [dev-packages] """.strip() f.write(contents) - c = p.pipenv('install requests u/\\/p@r\$34b13+pkg') + c = p.pipenv('install requests u/\\/p@r\\$34b13+pkg') assert c.return_code != 0 assert 'u/\\/p@r$34b13+pkg' not in p.pipfile['packages'] diff --git a/tests/integration/test_dot_venv.py b/tests/integration/test_dot_venv.py index aa52dd5e..3cbc88db 100644 --- a/tests/integration/test_dot_venv.py +++ b/tests/integration/test_dot_venv.py @@ -5,9 +5,7 @@ import os import pytest from pipenv._compat import Path, TemporaryDirectory -from pipenv.project import Project -from pipenv.utils import get_windows_path, normalize_drive, temp_environ -from pipenv.vendor import delegator +from pipenv.utils import normalize_drive, temp_environ @pytest.mark.dotvenv diff --git a/tests/integration/test_install_markers.py b/tests/integration/test_install_markers.py index 00f9c789..de3ba193 100644 --- a/tests/integration/test_install_markers.py +++ b/tests/integration/test_install_markers.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function import os -import sys import pytest diff --git a/tests/integration/test_install_twists.py b/tests/integration/test_install_twists.py index 44973df5..4fcbd4c5 100644 --- a/tests/integration/test_install_twists.py +++ b/tests/integration/test_install_twists.py @@ -9,7 +9,6 @@ import pytest from flaky import flaky from pipenv._compat import Path -from pipenv.project import Project from pipenv.utils import mkdir_p, temp_environ from pipenv.vendor import delegator @@ -40,7 +39,6 @@ setup( """.strip() fh.write(contents) line = "-e .[dev]" - pipfile = {"testpipenv": {"path": ".", "editable": True, "extras": ["dev"]}} with open(os.path.join(p.path, 'Pipfile'), 'w') as fh: fh.write(""" [packages] diff --git a/tests/integration/test_lock.py b/tests/integration/test_lock.py index 4c227395..5c6af0fa 100644 --- a/tests/integration/test_lock.py +++ b/tests/integration/test_lock.py @@ -659,4 +659,4 @@ six = "*" c = p.pipenv("lock --clear") assert c.return_code == 0 assert "index" in p.lockfile["default"]["six"] - assert p.lockfile["default"]["six"]["index"] == "custom", Path(p.lockfile_path).read_text() # p.lockfile["default"]["six"] + assert p.lockfile["default"]["six"]["index"] == "custom", Path(p.lockfile_path).read_text() # p.lockfile["default"]["six"] diff --git a/tests/integration/test_project.py b/tests/integration/test_project.py index f7b0e460..bef9912f 100644 --- a/tests/integration/test_project.py +++ b/tests/integration/test_project.py @@ -11,7 +11,6 @@ from pipenv.project import Project from pipenv.utils import temp_environ from pipenv.vendor.vistir.path import is_in_path from pipenv.vendor.delegator import run as delegator_run -import pipenv.environments @pytest.mark.project diff --git a/tests/integration/test_windows.py b/tests/integration/test_windows.py index b303d0ab..a74be386 100644 --- a/tests/integration/test_windows.py +++ b/tests/integration/test_windows.py @@ -5,7 +5,6 @@ import os import pytest from pipenv._compat import Path -from pipenv.project import Project # This module is run only on Windows. diff --git a/tests/pytest-pypi/pytest_pypi/app.py b/tests/pytest-pypi/pytest_pypi/app.py index 95dbd076..5484eeb7 100644 --- a/tests/pytest-pypi/pytest_pypi/app.py +++ b/tests/pytest-pypi/pytest_pypi/app.py @@ -4,7 +4,6 @@ import contextlib import io import json import os -import sys from tarfile import is_tarfile from zipfile import is_zipfile diff --git a/tests/pytest-pypi/pytest_pypi/certs.py b/tests/pytest-pypi/pytest_pypi/certs.py index f9e33870..b73fc63a 100644 --- a/tests/pytest-pypi/pytest_pypi/certs.py +++ b/tests/pytest-pypi/pytest_pypi/certs.py @@ -17,5 +17,6 @@ def where(): # vendored bundle inside Requests return os.path.join(os.path.abspath(os.path.dirname(__file__)), 'certs', 'cacert.pem') + if __name__ == '__main__': print(where()) diff --git a/tests/pytest-pypi/pytest_pypi/plugin.py b/tests/pytest-pypi/pytest_pypi/plugin.py index a17fcb24..83cd73fb 100644 --- a/tests/pytest-pypi/pytest_pypi/plugin.py +++ b/tests/pytest-pypi/pytest_pypi/plugin.py @@ -3,6 +3,7 @@ import pytest from .app import app as pypi_app from . import serve, certs + @pytest.fixture(scope='session') def pypi(request): server = serve.Server(application=pypi_app) @@ -31,6 +32,7 @@ def pypi_both(request, pypi, pypi_secure): def class_based_pypi(request, pypi): request.cls.pypi = pypi + @pytest.fixture(scope='class') def class_based_pypi_secure(request, pypi_secure): request.cls.pypi_secure = pypi_secure diff --git a/tests/unit/test_patched.py b/tests/unit/test_patched.py index 249292b4..03e1c039 100644 --- a/tests/unit/test_patched.py +++ b/tests/unit/test_patched.py @@ -122,6 +122,7 @@ get_extras_links_scenarios = { ), } + @pytest.mark.parametrize( 'scenarios,expected', list(get_extras_links_scenarios.values()), diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 18cb94a8..f3a567da 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -3,11 +3,7 @@ import os import pytest -from first import first -from mock import Mock, patch - import pipenv.utils -import pythonfinder.utils from pipenv.exceptions import PipenvUsageError @@ -129,11 +125,8 @@ def test_convert_deps_to_pip(monkeypatch, deps, expected): ), ], ) -def test_convert_deps_to_pip_one_way(monkeypatch, deps, expected): - with monkeypatch.context() as m: - import pip_shims - # m.setattr(pip_shims.shims, "unpack_url", mock_unpack) - assert pipenv.utils.convert_deps_to_pip(deps, r=False) == [expected.lower()] +def test_convert_deps_to_pip_one_way(deps, expected): + assert pipenv.utils.convert_deps_to_pip(deps, r=False) == [expected.lower()] @pytest.mark.skipif(isinstance(u"", str), reason="don't need to test if unicode is str") @@ -218,7 +211,7 @@ class TestUtils: @pytest.mark.windows @pytest.mark.skipif(os.name != "nt", reason="Windows test only") def test_windows_shellquote(self): - test_path = "C:\Program Files\Python36\python.exe" + test_path = r"C:\Program Files\Python36\python.exe" expected_path = '"C:\\\\Program Files\\\\Python36\\\\python.exe"' assert pipenv.utils.escape_grouped_arguments(test_path) == expected_path