1

So far, I have used tools from the local repo, where everything was run as a system command in the development environment. This works great, but is a bit on the slower side from the overhead of running things through poetry, and prevents running linting without a full setup.

Adjusting black and isort to use their respective repos was easy enough, but flake8's plugin system is causing trouble.

Running it from local, the versions of the plugins are managed by poetry, and can be easily modified in pyproject.toml while locking ensures there are no unexpected version bumps happening, but there's seemingly no way to achieve this when specifying the plugins through additional_dependencies on the flake8 hook.

If the versions are left unconstrained, pre-commit may use a different linting configuration in different environments, but then if an exact constraint is provided, it becomes increasingly more difficult to manage as the version bumps have to be done completely manually.

e.g this possibly won't produce the same environment across different runs if the plugin is updated

  - repo: https://github.com/pycqa/flake8
    rev: 4.0.1
    hooks:
      - id: flake8
        additional_dependencies:
          [
            flake8-plugin,  # or some lower upper bound
          ]

But providing an exact version flake8-plugin==1.2.3, requires me to manually keep track of the updates of all the plugins and bump everything myself.

Is there any way to get a behaviour similar to normal locking, where I'd specify a reasonable version constraint for the plugin (e.g. ~1.2) somewhere, and that'd get locked on autoupdate ?

Numerlor
  • 799
  • 1
  • 3
  • 16
  • you haven't shown any configuration -- what problem are you having and what are you trying to solve? – anthony sottile Feb 19 '22 at 23:34
  • 1
    I'm trying to solve the versioning, where moving flake8 to be managed by pre-commit instead of poetry limits versions on plugins like I explained in the fourth paragraph – Numerlor Feb 19 '22 at 23:38
  • are you looking for [`~=`](https://www.python.org/dev/peps/pep-0440/#compatible-release) ? – anthony sottile Feb 20 '22 at 00:22
  • While that should technically work, not all packages follow the versioning scheme, and a few too many that do use it don't follow it properly, so I'd like to avoid relying on guarantees like that instead of proper locking. And it still leaves a bit to be desired with the tighter constraints – Numerlor Feb 20 '22 at 00:30
  • so you're saying you don't want `==` because it's too tight and you don't want `~=` because it's too loose -- those are the only options so it's really up to you. I'm still not sure what you're having trouble with? – anthony sottile Feb 20 '22 at 01:14
  • I want proper locking while in use, while providing updates with reasonable constraints without having to do it myself -- like provided by a proper dependency provide (i.e. poetry, pipenv) – Numerlor Feb 20 '22 at 12:22
  • then use `==` in `additional_dependencies`, that will give you your locking guarantees. the values are passed opaquely to pip so they won't be updated but that's the best you'll be able to do. in the future read the docs (either flake8's or pre-commit's), it covers this – anthony sottile Feb 20 '22 at 13:19
  • I'm aware I can use == as I have mentioned it in the question, but it's cumbersome to use and I'm looking for some way to get locking without having to use exact constraints when specifying the deps. – Numerlor Feb 20 '22 at 13:41
  • alright well as the maintainer of both the tools I am telling you definitively the answer. stackoverflow isn't the proper place for feature requests – anthony sottile Feb 20 '22 at 13:41

0 Answers0