Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exclude: '^(pipenv/patched/|pipenv/vendor/|tests/|pipenv/pipenv.1)'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.4.0
hooks:
- id: check-builtin-literals
- id: check-added-large-files
Expand All @@ -17,30 +17,19 @@ repos:
- id: trailing-whitespace
exclude: .patch

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.259
hooks:
- id: flake8
additional_dependencies: [
'flake8-bugbear==20.1.4',
'flake8-logging-format==0.6.0',
'flake8-implicit-str-concat==0.2.0',
]
exclude: tests/data
- id: ruff
# args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: isort
files: \.py$
- id: black

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.7.0
rev: v1.10.0
hooks:
- id: python-no-log-warn
- id: python-no-eval
Expand All @@ -58,7 +47,12 @@ repos:
files: ^news/

- repo: https://github.com/mgedmin/check-manifest
rev: '0.46'
rev: '0.49'
hooks:
- id: check-manifest
stages: [manual]

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.12.2
hooks:
- id: validate-pyproject
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pre-bump:

.PHONY: lint
lint:
flake8 .
ruff .

man:
$(MAKE) -C docs $@
Expand Down
10 changes: 5 additions & 5 deletions docs/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -383,20 +383,20 @@ Alternatively, you can configure a ``tox.ini`` like the one below for both local
and external testing::

[tox]
envlist = flake8-py3, py26, py27, py33, py34, py35, py36, pypy
envlist = py37, py38, py39, py310, py311, pypy3, ruff

[testenv]
deps = pipenv
commands=
pipenv install --dev
pipenv run pytest tests

[testenv:flake8-py3]
basepython = python3.4
[testenv:ruff]
basepython = python3.11
commands=
pipenv install --dev
pipenv run flake8 --version
pipenv run flake8 setup.py docs project test
pipenv run ruff --version
pipenv run ruff .

Pipenv will automatically use the virtualenv provided by ``tox``. If ``pipenv install --dev`` installs e.g. ``pytest``, then installed command ``pytest`` will be present in given virtualenv and can be called directly by ``pytest tests`` instead of ``pipenv run pytest tests``.

Expand Down
1 change: 1 addition & 0 deletions news/ruff.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace flake8 and isort with `ruff <https://beta.ruff.rs>`_.
4 changes: 2 additions & 2 deletions pipenv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
if not os.getenv("NO_COLOR") or no_color:
colorama.just_fix_windows_console()

from . import resolver # noqa
from .cli import cli
from . import resolver # noqa: F401,E402
from .cli import cli # noqa: E402

if __name__ == "__main__":
cli()
1 change: 0 additions & 1 deletion pipenv/routines/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def upgrade(
dev=False,
lock_only=False,
):

lockfile = project._lockfile()
if not pre:
pre = project.settings.get("allow_prereleases")
Expand Down
2 changes: 1 addition & 1 deletion pipenv/utils/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def pip_install_deps(
if project.s.is_verbose():
while True:
line = c.stdout.readline()
if line == "":
if not line:
break
if "Ignoring" in line:
click.secho(line, fg="red", err=True)
Expand Down
3 changes: 0 additions & 3 deletions pipenv/utils/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ def parse_line(
markers_lookup: Dict[str, str] = None,
project: Optional[Project] = None,
) -> Tuple[Requirement, Dict[str, str], Dict[str, str]]:

if index_lookup is None:
index_lookup = {}
if markers_lookup is None:
Expand Down Expand Up @@ -435,7 +434,6 @@ def create(
pre: bool = False,
category: str = None,
) -> "Resolver":

if not req_dir:
req_dir = create_tracked_tempdir(suffix="-requirements", prefix="pipenv-")
if index_lookup is None:
Expand Down Expand Up @@ -705,7 +703,6 @@ def resolve_constraints(self):
requires_python = candidate.link.requires_python
if requires_python:
try:

marker = marker_from_specifier(requires_python)
self.markers[result.name] = marker
result.markers = marker
Expand Down
2 changes: 1 addition & 1 deletion pipenv/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def env_to_bool(val):

def is_env_truthy(name):
"""An environment variable is truthy if it exists and isn't one of (0, false, no, off)"""
return env_to_bool(os.getenv(name, False))
return env_to_bool(os.getenv(name, False)) # noqa: PLW1508


def project_python(project, system=False):
Expand Down
2 changes: 1 addition & 1 deletion pipenv/utils/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def find_a_system_python(line):
if not line:
return next(iter(finder.find_all_python_versions()), None)
# Use the windows finder executable
if (line.startswith("py ") or line.startswith("py.exe ")) and os.name == "nt":
if (line.startswith(("py ", "py.exe "))) and os.name == "nt":
line = line.split(" ", 1)[1].lstrip("-")
python_entry = find_python(finder, line)
return python_entry
Expand Down
63 changes: 52 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ exclude = '''
)
'''

[tool.isort]
atomic = true
lines_after_imports = 2
lines_between_types = 1
multi_line_output = 5
line_length = 80
known_first_party = [
"pipenv",
"tests",
]

[tool.mypy]
ignore_missing_imports = true
follow_imports = "skip"
Expand Down Expand Up @@ -101,6 +90,58 @@ markers = [
"ext: extra non-categorized tests",
]

[tool.ruff]
exclude = [
"pipenv/patched/*",
"pipenv/vendor/*",
]
select = [
"B",
"C9",
"E",
"F",
"G",
"I",
"ISC",
"PIE",
"PL",
"TID",
"W",
"YTT"
]
ignore = [
"B028",
"B904",
"PIE790",
"PLR2004",
"PLR5501",
"PLW2901",
]
line-length = 137
target-version = "py37"

[tool.ruff.mccabe]
max-complexity = 32

[tool.ruff.pylint]
max-args = 18
max-branches = 38
max-returns = 9
max-statements = 155

[tool.ruff.per-file-ignores]
"docs/conf.py" = ["E402", "E501"]
"get-pipenv.py" = ["E402"]
"pipenv/__init__.py" = ["E401"]
"pipenv/cli/command.py" = ["TID252"]
"pipenv/utils/internet.py" = ["PLW0603"]
"tests/*" = ["E501", "F401", "I", "PLC1901", "S101"]
"tests/integration/conftest.py" = ["B003", "PIE800", "PLW0603"]
"tests/integration/test_pipenv.py" = ["E741"]
"tests/integration/test_requirements.py" = ["E741"]
"tests/unit/test_funktools.py" = ["B015"]
"tests/unit/test_utils.py" = ["F811"]

[tool.towncrier]
package = "pipenv"
filename = "CHANGELOG.rst"
Expand Down
24 changes: 0 additions & 24 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,5 @@ long_description = file: README.md
license = MIT
license_files = LICENSE

# Currently flake8 does not support pyproject.toml
[flake8]
extend-exclude =
docs/,
pipenv/vendor/,
pipenv/patched/,
get-pipenv.py,
setup.py,
tests/fixtures/,
tests/test_artifacts/
ignore =
# The default ignore list:
E121,E123,E126,E226,E24,E704,
# Our additions:
# E127: continuation line over-indented for visual indent
# E128: continuation line under-indented for visual indent
# E129: visually indented line with same indent as next logical line
# E222: multiple spaces after operator
# E231: missing whitespace after ','
# E402: module level import not at top of file
# E501: line too long
# W503: line break before binary operator
E402,E501,W503,E203

[coverage:run]
parallel = true
1 change: 0 additions & 1 deletion tasks/vendoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ def download_licenses(
ctx.run(exe_cmd)
except invoke.exceptions.UnexpectedExit as e:
if "ModuleNotFoundErr" in e.result.stderr.strip():

target = parse.parse(
"ModuleNotFoundError: No module named '{backend}'",
e.result.stderr.strip().split("\n")[-1],
Expand Down
5 changes: 3 additions & 2 deletions tests/fixtures/fake-package/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pathlib
import re
import shutil
import subprocess

Expand Down Expand Up @@ -31,7 +32,7 @@ def typecheck(ctx):
def clean(ctx):
"""Clean previously built package artifacts.
"""
ctx.run(f'python setup.py clean')
ctx.run('python setup.py clean')
dist = ROOT.joinpath('dist')
print(f'[clean] Removing {dist}')
if dist.exists():
Expand Down Expand Up @@ -125,7 +126,7 @@ def release(ctx, type_, repo, prebump=PREBUMP):
tag_content = tag_content.replace('"', '\\"')
ctx.run(f'git tag -a {version} -m "Version {version}\n\n{tag_content}"')

ctx.run(f'python setup.py sdist bdist_wheel')
ctx.run('python setup.py sdist bdist_wheel')

dist_pattern = f'{PACKAGE_NAME.replace("-", "[-_]")}-*'
artifacts = list(ROOT.joinpath('dist').glob(dist_pattern))
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/test_install_basic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os, sys
import os
import sys
from pathlib import Path
from tempfile import TemporaryDirectory

Expand Down Expand Up @@ -418,7 +419,7 @@ def test_rewrite_outline_table(pipenv_instance_private_pypi):
url = "{0}"
verify_ssl = false
name = "testindex"

[packages]
six = {1}

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_install_misc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import pytest
import pytest

@pytest.mark.urls
@pytest.mark.extras
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_install_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ def test_vcs_entry_supersedes_non_vcs(pipenv_instance_pypi):
c = p.pipenv("install")
assert c.returncode == 0
installed_packages = ["Flask", "Jinja2"]
assert all([k in p.pipfile["packages"] for k in installed_packages])
assert all([k.lower() in p.lockfile["default"] for k in installed_packages])
assert all([k in p.lockfile["default"]["jinja2"] for k in ["ref", "git"]]), str(p.lockfile["default"])
assert all(k in p.pipfile["packages"] for k in installed_packages)
assert all(k.lower() in p.lockfile["default"] for k in installed_packages)
assert all(k in p.lockfile["default"]["jinja2"] for k in ["ref", "git"]), str(p.lockfile["default"])
assert p.lockfile["default"]["jinja2"].get("ref") is not None
assert (
p.lockfile["default"]["jinja2"]["git"]
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_uninstall_all_dev(pipenv_instance_private_pypi):
name = "pypi"
url = "{0}"
verify_ssl = true

[packages]
tablib = "*"

Expand Down