piptools-sync

A pre-commit plugin that syncs the pre-commit package versions with the versions generated by pip-tools

https://github.com/stephen-ra-king/piptools-sync

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.8%) to scientific vocabulary

Keywords

dependency-manager pip-tools pre-commit pre-commit-hooks python3 version-sync
Last synced: 4 months ago · JSON representation ·

Repository

A pre-commit plugin that syncs the pre-commit package versions with the versions generated by pip-tools

Basic Info
  • Host: GitHub
  • Owner: Stephen-RA-King
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 174 KB
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • Open Issues: 4
  • Releases: 9
Topics
dependency-manager pip-tools pre-commit pre-commit-hooks python3 version-sync
Created over 3 years ago · Last pushed 5 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security Authors

README.md

Piptools-sync


A pre-commit plugin to align pre-commit repository versions with those derived by pip-tools.

PyPI Downloads Status Python Version tests Codecov CodeQl pre-commit.ci status readthedocs CodeFactor Codeclimate Imports: isort Code style: black Checked with mypy security: bandit Commitizen friendly Conventional Commits DeepSource license pydough

pip-tools and Pre-Commit are two of my favourite development tools. However, they don't always necessarily agree on what versions of packages should be installed. This lack of consolidation can lead to problems with pre-commit. This pre-commit plugin syncs the pre-commit package versions with the versions generated by pip-tools' compile process.

Introduction


Project Rationale

A while ago I came across an issue committing files to my local git repository. The issue occured at the flake8 linting stage using pre-commit. There was however no problem manually running flake8 from the command line. Upon investigation It was found that flake8 had an incompatibility issue with one of its plugins. With further investigation I noticed that pip-tools had pinned flake8 to an earlier version to what pre-commit was caching.

In short - pip-tools does a spectacularly good job pinning your dependencies and the dependencies of these dependencies. It has one job to do and it does it perfectly. The pre-commit autoupdate command just updates the "rev" for the "repo" in the .pre-commit-config.yaml file to the latest version available and ignores the dependencies.

The following example displays the way flake8 and a few plugins are configured by the two tools :

  • pip-tools (via requirements.txt)

shell flake8==4.0.1 # via ... flake8-bugbear==22.8.23 # via ... flake8-comprehensions==3.10.0 # via ... flake8-eradicate==1.3.0 # via ... flake8-simplify==0.19.3 # via ...

  • pre-commit (via .pre-commit-config.yaml)

shell - repo: https://github.com/pycqa/flake8 rev 5.0.4 hooks: - id: flake8 additional_dependencies: - flake8-bugbear - flake8-comprehensions - flake8-eradicate - flake8-simplify args: ["--ignore=E800,F842,F841,W503"]

If we force pip-tools to use a later version of flake8 (e,g 5.0.4) by manually pinning the version in the ".in" file and recompiling it is clear pip-tools is unhappy... A quick look at the dependencies shows why.

shell Could not find a version that matches flake8!=3.2.0,<5.0.0,<6,==5.0.4,>=3.0.0,>=3.3.0,>=3.5,>=3.7,>=3.9.1,>=4.0.1 (from -r requirements\development.in (line 12)) Tried: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.3.1, 1.4, 1.5, 1.6, 1.6.1, 1.6.2, 1.7.0, 2.0, 2.1.0, 2.2.0, 2.2.0, 2.2.1, 2.2.1, 2.2.2, 2.2.2, 2.2.3, 2.2.3, 2.2.4, 2.2.5, 2.3.0, 2.3.0, 2.4.0, 2.4.0, 2.4.1, 2.4.1, 2.5.0, 2.5.0, 2.5.1, 2.5.1, 2.5.2, 2.5.2, 2.5.3, 2.5.3, 2.5.4, 2.5.4, 2.5.5, 2.5.5, 2.6.0, 2.6.0, 2.6.1, 2.6.1, 2.6.2, 2.6.2, 3.0.0, 3.0.0, 3.0.1, 3.0.1, 3.0.2, 3.0.2, 3.0.3, 3.0.3, 3.0.4, 3.0.4, 3.1.0, 3.1.0, 3.1.1, 3.1.1, 3.2.0, 3.2.0, 3.2.1, 3.2.1, 3.3.0, 3.3.0, 3.4.0, 3.4.0, 3.4.1, 3.4.1, 3.5.0, 3.5.0, 3.6.0, 3.6.0, 3.7.0, 3.7.0, 3.7.1, 3.7.1, 3.7.2, 3.7.2, 3.7.3, 3.7.3, 3.7.4, 3.7.4, 3.7.5, 3.7.5, 3.7.6, 3.7.6, 3.7.7, 3.7.7, 3.7.8, 3.7.8, 3.7.9, 3.7.9, 3.8.0, 3.8.0, 3.8.1, 3.8.1, 3.8.2, 3.8.2, 3.8.3, 3.8.3, 3.8.4, 3.8.4, 3.9.0, 3.9.0, 3.9.1, 3.9.1, 3.9.2, 3.9.2, 4.0.0, 4.0.0, 4.0.1, 4.0.1, 5.0.0, 5.0.0, 5.0.1, 5.0.1, 5.0.2, 5.0.2, 5.0.3, 5.0.3, 5.0.4, 5.0.4 Skipped pre-versions: 3.0.0b1, 3.0.0b1, 3.0.0b2, 3.0.0b2, 3.0.2.dev0, 3.0.2.dev0, 3.0.2.dev1, 3.3.0.dev0, 3.8.0a1, 3.8.0a1, 3.8.0a2, 3.8.0a2 There are incompatible versions in the resolved dependencies: flake8==5.0.4 (from -r requirements\development.in (line 12)) flake8>=3.7 (from flake8-simplify==0.19.3->-r requirements\development.in (line 20)) flake8<5.0.0 (from flake8-bugbear==22.8.23->-r requirements\development.in (line 14)) flake8!=3.2.0,>=3.0 (from flake8-comprehensions==3.10.0->-r requirements\development.in (line 15)) flake8<6,>=3.5 (from flake8-eradicate==1.3.0->-r requirements\development.in (line 17))

The tools store packages in different areas on the file system. Pre-commit uses a cache area in the user folder, whereas pip-tools uses the usual site-packages area.

It should be noted that not all pre-commit hooks are written in Python for Python, so it makes sense that it has its own cache file system independent of pip. Therefore, not all pre-commit repositories have an entry in PyPI. They can simply be defined by a GitHub repository URL.

Lastly, browsing the internet looking for a solution I came across the following issue raised under the pip-tools project (dated 24 Jun 2021). The issue is still open and describes the exact same problem.

https://github.com/jazzband/pip-tools/issues/1437

Installation


1 - Install into pre-commit

Just add to the pre-commit configuration file (.pre-commit-config.yaml). I have configured it to run at every commit at the pre-commit stage of git.

shell - repo: https://github.com/Stephen-RA-King/piptools-sync rev: 0.3.1 hooks: - id: piptools_sync

2 - Install by pip

Installing by pip enables the package to be run from the command line at any time.

sh pip install piptools-sync

Usage


1 - Automatic running by pre-commit

Passing example.

shell piptools_sync............................................................Passed

Failing example.

```shell piptoolssync............................................................Failed - hook id: piptoolssync - exit code: 1 - files were modified by this hook

INFO:init:flake8 - piptools: 4.0.1 != pre-commit: 5.0.4 ```

Note: In this case piptools-sync will automatically update the pre-commit config file with pip-tools version. However, the commit with fail and will need to be re-run.

2 - Running from the command line

Passing example.

shell $ piptools_sync Success! - pre-commit is in sync with piptools

Failing example.

shell $ piptools_sync flake8 - piptools: 4.0.1 != pre-commit: 5.0.4

Note: In this case piptools-sync will automatically update the pre-commit config file with pip-tools version

For more examples and usage, please refer to the Wiki.

Documentation


Read the Docs

Wiki

Future Enhancements


  • Move some global variables into a separate settings file (toml).
  • Settings configurable from the command line (and therefore configurable from the pre-commit.yaml file).
  • Improve web request performance with asyncio / aiohttp libraries.

Meta


Stephen R A King : sking.github@gmail.com

Distributed under the MIT license. See for more information.

Created with Cookiecutter template: pydough version 1.2.1

Digital Object Identifier: DOI

Owner

  • Name: Stephen King
  • Login: Stephen-RA-King
  • Kind: user
  • Location: Exeter, Devon, England

Software Engineer / Python Developer

Citation (CITATION.cff)

cff-version: 1.2.0
title: pynamer
message: >-
    If you use this software, please cite it using the
    metadata from this file.
type: software
authors:
    - given-names: Stephen
      family-names: King
      email: sking.github@gmail.com
      orcid: "https://orcid.org/0009-0001-1939-6012"
identifiers:
    - type: doi
      value: 10.5281/zenodo.8027457

GitHub Events

Total
  • Push event: 43
Last Year
  • Push event: 43

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 107
  • Total Committers: 4
  • Avg Commits per committer: 26.75
  • Development Distribution Score (DDS): 0.037
Top Committers
Name Email Commits
Stephen-RA-King 3****g@u****m 103
pre-commit-ci[bot] 6****]@u****m 2
dependabot[bot] 4****]@u****m 1
deepsource-autofix[bot] 6****]@u****m 1

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 1
  • Total pull requests: 29
  • Average time to close issues: N/A
  • Average time to close pull requests: about 1 month
  • Total issue authors: 1
  • Total pull request authors: 4
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.93
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 27
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Stephen-RA-King (1)
Pull Request Authors
  • pre-commit-ci[bot] (18)
  • dependabot[bot] (13)
  • deepsource-autofix[bot] (1)
  • covracer (1)
Top Labels
Issue Labels
enhancement (1)
Pull Request Labels
dependencies (12) python (6)

Dependencies

docs/requirements.txt pypi
  • myst-nb *
  • sphinx-autoapi *
  • sphinx-rtd-theme *
requirements/base.in pypi
  • click *
requirements/base.txt pypi
  • click ==8.1.3
  • colorama ==0.4.5
requirements/development.in pypi
  • bandit * development
  • black * development
  • build * development
  • colorama * development
  • commitizen * development
  • coverage * development
  • coverage-conditional-plugin * development
  • flake8 * development
  • flake8-bandit * development
  • flake8-bugbear * development
  • flake8-comprehensions * development
  • flake8-docstrings * development
  • flake8-eradicate * development
  • flake8-html * development
  • flake8-pytest-style * development
  • flake8-simplify * development
  • flakeheaven * development
  • invoke * development
  • isort * development
  • jupyter * development
  • keyring * development
  • lxml * development
  • mypy * development
  • myst-nb * development
  • pep8-naming * development
  • pre-commit * development
  • pynacl * development
  • pytest * development
  • pytest-clarity * development
  • pytest-cov * development
  • pytest-html * development
  • pytest-randomly * development
  • pytest-tldr * development
  • pytest-xdist * development
  • python-semantic-release * development
  • pyyaml * development
  • requests * development
  • safety * development
  • sphinx * development
  • sphinx-autoapi * development
  • sphinx-rtd-theme * development
  • tox * development
  • twine * development
  • types-requests * development
  • watchdog * development
requirements/development.txt pypi
  • 198 dependencies
requirements/production.txt pypi
  • click ==8.1.3
  • colorama ==0.4.5
requirements/requirements_tox.txt pypi
  • black *
  • click *
  • flake8 *
  • lxml *
  • mypy *
  • pytest *
  • pyyaml *
  • safety *
requirements/test.in pypi
  • pytest * test
  • pytest-clarity * test
  • pytest-cov * test
  • pytest-randomly * test
  • pytest-sugar * test
  • pytest-tldr * test
requirements/test.txt pypi
  • atomicwrites ==1.4.1 test
  • attrs ==22.1.0 test
  • click ==8.1.3 test
  • colorama ==0.4.5 test
  • commonmark ==0.9.1 test
  • coverage ==6.4.2 test
  • importlib-metadata ==4.12.0 test
  • iniconfig ==1.1.1 test
  • packaging ==21.3 test
  • pluggy ==1.0.0 test
  • pprintpp ==0.4.0 test
  • py ==1.11.0 test
  • pygments ==2.12.0 test
  • pyparsing ==3.0.9 test
  • pytest ==7.1.2 test
  • pytest-clarity ==1.0.1 test
  • pytest-cov ==3.0.0 test
  • pytest-randomly ==3.12.0 test
  • pytest-sugar ==0.9.5 test
  • pytest-tldr ==0.2.4 test
  • rich ==12.5.1 test
  • termcolor ==1.1.0 test
  • tomli ==2.0.1 test
  • zipp ==3.8.1 test
.github/workflows/codeql-analysis.yml actions
  • actions/checkout v3 composite
  • github/codeql-action/analyze v2 composite
  • github/codeql-action/autobuild v2 composite
  • github/codeql-action/init v2 composite
.github/workflows/tests.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v3 composite
Dockerfile docker
  • python 3.9-alpine build