0

I have a poetry file with

[tool.poetry.dependencies]
python = "^3.6"

which I can't change.

I would like to add pre-commit as a depdenency, but I get

$ poetry add pre-commit --dev
Using version ^2.11.1 for pre-commit

Updating dependencies
Resolving dependencies... (0.1s)

  SolverProblemError

  The current project's Python requirement (>=3.6,<4.0) is not compatible with some of the required packages Python requirement:
    - pre-commit requires Python >=3.6.1, so it will not be satisfied for Python >=3.6,<3.6.1
  
  Because no versions of pre-commit match >2.11.1,<3.0.0
   and pre-commit (2.11.1) requires Python >=3.6.1, pre-commit is forbidden.
  So, because wemake-python-styleguide depends on pre-commit (^2.11.1), version solving failed.

  at ~/.cache/pypoetry/virtualenvs/wemake-python-styleguide-ns1zFlbl-py3.8/lib/python3.8/site-packages/poetry/puzzle/solver.py:241 in _solve
      237│             packages = result.packages
      238│         except OverrideNeeded as e:
      239│             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
      240│         except SolveFailure as e:
    → 241│             raise SolverProblemError(e)
      242│ 
      243│         results = dict(
      244│             depth_first_search(
      245│                 PackageNode(self._package, packages), aggregate_package_nodes

  • Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties
    
    For pre-commit, a possible solution would be to set the `python` property to ">=3.6.1,<4.0"

    https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
    https://python-poetry.org/docs/dependency-specification/#using-environment-markers

What command should I run?

ignoring_gravity
  • 6,677
  • 4
  • 32
  • 65
  • According to Pypi, all of [poetry](https://pypi.org/project/poetry/), [pre-commit](https://pypi.org/project/pre-commit/) and [wemake-python-styleguide](https://pypi.org/project/wemake-python-styleguide/) should work with all of Python3.6, 3.7, 3.8 and 3.9. Which version of Python do you use? What are the limitations imposed by your dependencies? And above all, why you couldn't change [tool.poetry.dependencies]? – Lenka Čížková Mar 21 '21 at 14:26
  • pre-commit is 3.6.1+, it doesn't work with 3.6.0 – ignoring_gravity Mar 21 '21 at 14:51
  • What limits you to change to 3.6.1 or higher? Why you couldn't change [tool.poetry.dependencies]? – Lenka Čížková Mar 21 '21 at 15:26
  • it's not my project, I'm just submitting a PR – ignoring_gravity Mar 21 '21 at 16:08
  • including the change to `3.6.1` in the PR is not an option? `3.6.0` is, at this point, over 4 years old, and the most recent release is `3.6.13`. – Arne Mar 21 '21 at 18:32
  • Indeed, I agree with @Arne; Python 3.6 is at the end of its [lifespan](https://www.python.org/dev/peps/pep-0494/#lifespan), got its very last bugfix on February 15, 2021, and there may be some security fixes till the end of 2021 - but then, there will be no support anymore for Python 3.6. For any projects still using 3.6, it would be wise to switch to a newer version anyway if you want to keep it going on after 2021. – Lenka Čížková Mar 21 '21 at 18:49

0 Answers0