Skip to content

Commit

Permalink
Issue 4993 Add standard pre commit hooks and apply linting. (#4994)
Browse files Browse the repository at this point in the history
* Add .pre-commit-config.yaml to the project and exclude tests (for now).  This does not include the MyPy linting that pip does but does include everything else.
  • Loading branch information
matteius authored Mar 30, 2022
1 parent 3387881 commit 9a3b3ce
Show file tree
Hide file tree
Showing 48 changed files with 2,327 additions and 1,347 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ jobs:
git submodule update --init --recursive
python -m pip install -e . --upgrade
pipenv install --deploy --dev --python=${{ steps.python-path.outputs.path }}
- name: Lint check of the code
env:
PIPENV_DEFAULT_PYTHON_VERSION: ${{ matrix.python-version }}
PYTHONWARNINGS: ignore:DEPRECATION
PYTHONIOENCODING: "utf-8"
GIT_ASK_YESNO: "false"
run: |
pipenv run pre-commit run --all-files --verbose
- name: Run tests
env:
PIPENV_DEFAULT_PYTHON_VERSION: ${{ matrix.python-version }}
Expand Down Expand Up @@ -109,4 +117,3 @@ jobs:
- run: |
python -m pip install --upgrade wheel invoke parver bs4 vistir towncrier
python -m invoke vendoring.update
2 changes: 2 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile = black
64 changes: 64 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
exclude: '^(pipenv/patched/|pipenv/vendor/|tests/)'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-builtin-literals
- id: check-added-large-files
- id: check-case-conflict
- id: check-ast
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: WHEEL
- id: forbid-new-submodules
- id: trailing-whitespace
exclude: .patch

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

- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
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

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
files: \.py$

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.7.0
hooks:
- id: python-no-log-warn
- id: python-no-eval
- id: rst-backticks
files: .*\.rst$
types: [file]

- repo: local
hooks:
- id: news-fragment-filenames
name: NEWS fragment
language: fail
entry: NEWS fragment files must be named *.(feature|behavior|bugfix|vendor|doc|trivial|removal|process).rst
exclude: ^news/(towncrier_template.rst|.*\.(feature|behavior|bugfix|vendor|doc|trivial|removal|process).rst)
files: ^news/

- repo: https://github.com/mgedmin/check-manifest
rev: '0.46'
hooks:
- id: check-manifest
stages: [manual]
32 changes: 16 additions & 16 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Bug Fixes
---------

- Environment variables were not being loaded when the `--quiet` flag was set `#5010 <https://github.com/pypa/pipenv/issues/5010>`_
- Environment variables were not being loaded when the ``--quiet`` flag was set `#5010 <https://github.com/pypa/pipenv/issues/5010>`_
- It would appear that ``requirementslib`` was not fully specifying the subdirectory to ``build_pep517`` and
and when a new version of ``setuptools`` was released, the test ``test_lock_nested_vcs_direct_url``
broke indicating the Pipfile.lock no longer contained the extra dependencies that should have been resolved.
Expand All @@ -25,7 +25,7 @@ Features & Improvements
-----------------------

- It is now possible to silence the ``Loading .env environment variables`` message on ``pipenv run``
with the ``--quiet`` flag or the `PIPENV_QUIET` environment variable. `#4027 <https://github.com/pypa/pipenv/issues/4027>`_
with the ``--quiet`` flag or the ``PIPENV_QUIET`` environment variable. `#4027 <https://github.com/pypa/pipenv/issues/4027>`_

Bug Fixes
---------
Expand All @@ -43,7 +43,7 @@ Bug Fixes
Features & Improvements
-----------------------

- Use environment variable `PIPENV_SKIP_LOCK` to control the behaviour of lock skipping. `#4797 <https://github.com/pypa/pipenv/issues/4797>`_
- Use environment variable ``PIPENV_SKIP_LOCK`` to control the behaviour of lock skipping. `#4797 <https://github.com/pypa/pipenv/issues/4797>`_
- New CLI command ``verify``, checks the Pipfile.lock is up-to-date `#4893 <https://github.com/pypa/pipenv/issues/4893>`_

Behavior Changes
Expand All @@ -56,15 +56,15 @@ Bug Fixes

- Python versions on Windows can now be installed automatically through pyenv-win `#4525 <https://github.com/pypa/pipenv/issues/4525>`_
- Patched our vendored Pip to fix: Pipenv Lock (Or Install) Does Not Respect Index Specified For A Package. `#4637 <https://github.com/pypa/pipenv/issues/4637>`_
- If `PIP_TARGET` is set to environment variables, Refer specified directory for calculate delta, instead default directory `#4775 <https://github.com/pypa/pipenv/issues/4775>`_
- If ``PIP_TARGET`` is set to environment variables, Refer specified directory for calculate delta, instead default directory `#4775 <https://github.com/pypa/pipenv/issues/4775>`_
- Remove remaining mention of python2 and --two flag from codebase. `#4938 <https://github.com/pypa/pipenv/issues/4938>`_
- Use `CI` environment value, over mere existence of name `#4944 <https://github.com/pypa/pipenv/issues/4944>`_
- Use ``CI`` environment value, over mere existence of name `#4944 <https://github.com/pypa/pipenv/issues/4944>`_
- Environment variables from dot env files are now properly expanded when included in scripts. `#4975 <https://github.com/pypa/pipenv/issues/4975>`_

Vendored Libraries
------------------

- Updated vendor version of `pythonfinder` from `1.2.9` to `1.2.10` which fixes a bug with WSL
- Updated vendor version of ``pythonfinder`` from ``1.2.9`` to ``1.2.10`` which fixes a bug with WSL
(Windows Subsystem for Linux) when a path can not be read and Permission Denied error is encountered. `#4976 <https://github.com/pypa/pipenv/issues/4976>`_

Removals and Deprecations
Expand Down Expand Up @@ -207,7 +207,7 @@ Vendored Libraries
- ``tomli 1.1.0``
- ``wheel 0.36.2`` `#4747 <https://github.com/pypa/pipenv/issues/4747>`_
- Drop the dependencies for Python 2.7 compatibility purpose. `#4751 <https://github.com/pypa/pipenv/issues/4751>`_
- Switch the dependency resolver from ``pip-tools`` to `pip`.
- Switch the dependency resolver from ``pip-tools`` to ``pip``.

Update vendor libraries:
- Update ``requirementslib`` from ``1.5.16`` to ``1.6.1``
Expand Down Expand Up @@ -416,7 +416,7 @@ Features & Improvements
- Allow overriding PIPENV_INSTALL_TIMEOUT environment variable (in seconds). `#3652 <https://github.com/pypa/pipenv/issues/3652>`_
- Allow overriding PIP_EXISTS_ACTION evironment variable (value is passed to pip install).
Possible values here: https://pip.pypa.io/en/stable/reference/pip/#exists-action-option
Useful when you need to `PIP_EXISTS_ACTION=i` (ignore existing packages) - great for CI environments, where you need really fast setup. `#3738 <https://github.com/pypa/pipenv/issues/3738>`_
Useful when you need to ``PIP_EXISTS_ACTION=i`` (ignore existing packages) - great for CI environments, where you need really fast setup. `#3738 <https://github.com/pypa/pipenv/issues/3738>`_
- Pipenv will no longer forcibly override ``PIP_NO_DEPS`` on all vcs and file dependencies as resolution happens on these in a pre-lock step. `#3763 <https://github.com/pypa/pipenv/issues/3763>`_
- Improved verbose logging output during ``pipenv lock`` will now stream output to the console while maintaining a spinner. `#3810 <https://github.com/pypa/pipenv/issues/3810>`_
- Added support for automatic python installs via ``asdf`` and associated ``PIPENV_DONT_USE_ASDF`` environment variable. `#4018 <https://github.com/pypa/pipenv/issues/4018>`_
Expand All @@ -434,7 +434,7 @@ Behavior Changes
Bug Fixes
---------

- Raise `PipenvUsageError` when [[source]] does not contain url field. `#2373 <https://github.com/pypa/pipenv/issues/2373>`_
- Raise ``PipenvUsageError`` when [[source]] does not contain url field. `#2373 <https://github.com/pypa/pipenv/issues/2373>`_
- Fixed a bug which caused editable package resolution to sometimes fail with an unhelpful setuptools-related error message. `#2722 <https://github.com/pypa/pipenv/issues/2722>`_
- Fixed an issue which caused errors due to reliance on the system utilities ``which`` and ``where`` which may not always exist on some systems.
- Fixed a bug which caused periodic failures in python discovery when executables named ``python`` were not present on the target ``$PATH``. `#2783 <https://github.com/pypa/pipenv/issues/2783>`_
Expand Down Expand Up @@ -697,13 +697,13 @@ Bug Fixes
- Fixed an issue in ``delegator.py`` related to subprocess calls when using ``PopenSpawn`` to stream output, which sometimes threw unexpected ``EOF`` errors. `#3102 <https://github.com/pypa/pipenv/issues/3102>`_,
`#3114 <https://github.com/pypa/pipenv/issues/3114>`_,
`#3117 <https://github.com/pypa/pipenv/issues/3117>`_
- Fix the path casing issue that makes `pipenv clean` fail on Windows `#3104 <https://github.com/pypa/pipenv/issues/3104>`_
- Fix the path casing issue that makes ``pipenv clean`` fail on Windows `#3104 <https://github.com/pypa/pipenv/issues/3104>`_
- Pipenv will avoid leaving build artifacts in the current working directory. `#3106 <https://github.com/pypa/pipenv/issues/3106>`_
- Fixed issues with broken subprocess calls leaking resource handles and causing random and sporadic failures. `#3109 <https://github.com/pypa/pipenv/issues/3109>`_
- Fixed an issue which caused ``pipenv clean`` to sometimes clean packages from the base ``site-packages`` folder or fail entirely. `#3113 <https://github.com/pypa/pipenv/issues/3113>`_
- Updated ``pythonfinder`` to correct an issue with unnesting of nested paths when searching for python versions. `#3121 <https://github.com/pypa/pipenv/issues/3121>`_
- Added additional logic for ignoring and replacing non-ascii characters when formatting console output on non-UTF-8 systems. `#3131 <https://github.com/pypa/pipenv/issues/3131>`_
- Fix virtual environment discovery when ``PIPENV_VENV_IN_PROJECT`` is set, but the in-project `.venv` is a file. `#3134 <https://github.com/pypa/pipenv/issues/3134>`_
- Fix virtual environment discovery when ``PIPENV_VENV_IN_PROJECT`` is set, but the in-project ``.venv`` is a file. `#3134 <https://github.com/pypa/pipenv/issues/3134>`_
- Hashes for remote and local non-PyPI artifacts will now be included in ``Pipfile.lock`` during resolution. `#3145 <https://github.com/pypa/pipenv/issues/3145>`_
- Fix project path hashing logic in purpose to prevent collisions of virtual environments. `#3151 <https://github.com/pypa/pipenv/issues/3151>`_
- Fix package installation when the virtual environment path contains parentheses. `#3158 <https://github.com/pypa/pipenv/issues/3158>`_
Expand Down Expand Up @@ -787,7 +787,7 @@ Vendored Libraries
Features & Improvements
-----------------------

- Added environment variables `PIPENV_VERBOSE` and `PIPENV_QUIET` to control
- Added environment variables ``PIPENV_VERBOSE`` and ``PIPENV_QUIET`` to control
output verbosity without needing to pass options. `#2527 <https://github.com/pypa/pipenv/issues/2527>`_

- Updated test-PyPI add-on to better support json-API access (forward compatibility).
Expand Down Expand Up @@ -820,7 +820,7 @@ Behavior Changes
- Add ``COMSPEC`` to fallback option (along with ``SHELL`` and ``PYENV_SHELL``)
if shell detection fails, improving robustness on Windows. `#2651 <https://github.com/pypa/pipenv/issues/2651>`_

- Fallback to shell mode if `run` fails with Windows error 193 to handle non-executable commands. This should improve usability on Windows, where some users run non-executable files without specifying a command, relying on Windows file association to choose the current command. `#2718 <https://github.com/pypa/pipenv/issues/2718>`_
- Fallback to shell mode if ``run`` fails with Windows error 193 to handle non-executable commands. This should improve usability on Windows, where some users run non-executable files without specifying a command, relying on Windows file association to choose the current command. `#2718 <https://github.com/pypa/pipenv/issues/2718>`_


Bug Fixes
Expand Down Expand Up @@ -918,7 +918,7 @@ Bug Fixes
`#2867 <https://github.com/pypa/pipenv/issues/2867>`_,
`#2880 <https://github.com/pypa/pipenv/issues/2880>`_

- Fixed a bug where `pipenv` crashes when the `WORKON_HOME` directory does not exist. `#2877 <https://github.com/pypa/pipenv/issues/2877>`_
- Fixed a bug where ``pipenv`` crashes when the ``WORKON_HOME`` directory does not exist. `#2877 <https://github.com/pypa/pipenv/issues/2877>`_

- Fixed pip is not loaded from pipenv's patched one but the system one `#2912 <https://github.com/pypa/pipenv/issues/2912>`_

Expand Down Expand Up @@ -985,15 +985,15 @@ Improved Documentation

- Added simple example to README.md for installing from git. `#2685 <https://github.com/pypa/pipenv/issues/2685>`_

- Stopped recommending `--system` for Docker contexts. `#2762 <https://github.com/pypa/pipenv/issues/2762>`_
- Stopped recommending ``--system`` for Docker contexts. `#2762 <https://github.com/pypa/pipenv/issues/2762>`_

- Fixed the example url for doing "pipenv install -e
some-repository-url#egg=something", it was missing the "egg=" in the fragment
identifier. `#2792 <https://github.com/pypa/pipenv/issues/2792>`_

- Fixed link to the "be cordial" essay in the contribution documentation. `#2793 <https://github.com/pypa/pipenv/issues/2793>`_

- Clarify `pipenv install` documentation `#2844 <https://github.com/pypa/pipenv/issues/2844>`_
- Clarify ``pipenv install`` documentation `#2844 <https://github.com/pypa/pipenv/issues/2844>`_

- Replace reference to uservoice with PEEP-000 `#2909 <https://github.com/pypa/pipenv/issues/2909>`_

Expand Down
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ click = "*"
pytest_pypi = {path = "./tests/pytest-pypi", editable = true}
stdeb = {version="*", markers="sys_platform == 'linux'"}
dataclasses = {version="*", markers="python_version < '3.7'"}
importlib-resources = {version = "*", markers = "python_version < '3.7'"}
sphinxcontrib-spelling = "<4.3.0"
pre-commit = "*"
atomicwrites = {version = "*", markers="sys_platform == 'win32'"}

[packages]

Expand Down
Loading

0 comments on commit 9a3b3ce

Please sign in to comment.