typer-cli icon indicating copy to clipboard operation
typer-cli copied to clipboard

Typer-cli (0.0.12) depends on typer (>=0.3.0,<0.4.0), so typer 0.4.0 AND typer-cli 0.0.12 are incompatible

Open stratosgear opened this issue 3 years ago • 10 comments

I get this when I poetry update on my system:

$ poetry update
Updating dependencies
Resolving dependencies... (0.0s)

  SolverProblemError

  Because typer-cli (0.0.12) depends on typer (>=0.3.0,<0.4.0)
   and cb depends on typer (0.4.0), typer-cli is forbidden.
  So, because cb depends on typer-cli (0.0.12), version solving failed.

  at ~/.poetry/lib/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

stratosgear avatar Aug 31 '21 10:08 stratosgear

This is just a note that simply changing the version specification in pyproject.toml will not completely solve the problem.

There is an implicit dependency on click 7.x, which is satisfied because it is also a dependency of typer 0.3.x: typer_cli/main.py imports click._bashcomplete.get_choices and click._bashcomplete.resolve_ctx. It also monkey-patches click._bashcomplete.get_choices.

This part will have to be rewritten in typer-cli to support click 8.x as was done for typer (https://github.com/tiangolo/typer/commit/b97298181bd2a932be70ba417b9a712294fa327c).

musicinmybrain avatar Aug 31 '21 11:08 musicinmybrain

Basically anyone that happened to used typer-cli is creating weaves of incompatibilities with click, which reached v8 long time ago, likely 9 soon.

Luckly typer was updated but not typer-cli.

ssbarnea avatar May 31 '22 11:05 ssbarnea

Our team recently had to upgrade to typer 0.4.1 in order to fix https://github.com/tiangolo/typer/issues/377 and are now waiting for this issue to be fixed. It would be great to have this issue resolved so that we can continue to auto-generate our typer CLI docs. Adding this comment in order to link the two issues in case others arrive here via the same issue.

lucinvitae avatar Jun 02 '22 20:06 lucinvitae

TL;DR - don't try this

A project can run into this problem if it depends on both typer (project libs) and typer-cli (dev libs). One possibility to avoid this conflict is to use the pipx project to install typer-cli as a global utility that is independent of the project dependency tree. This might avoid "contaminating" the project virtual env with too many utility libraries that all have their own dependency tree issues. (This approach also works well for poetry installations.)

$ pipx install typer-cli
  installed package typer-cli 0.0.12, installed using Python 3.8.10
  These apps are now globally available
    - typer
done! ✨ 🌟 ✨

Of course, this makes the project less portable. There are trade-offs to consider for this approach, esp. if any CI/CD systems also depend on the typer-cli as a dev lib.

Also, as I discovered, after a poetry remove -D typer-cli and then using typer to build CLI docs, this approach does not work great. The problem is that typer will import the CLI modules in order to build the CLI docs. When it does so, using a global pipx installation, it is failing to import project libs from the project venv.

dazza-codes avatar Jun 22 '22 03:06 dazza-codes

@tiangolo, this still persists even after releasing 0.5.0 of Typer: https://github.com/tiangolo/typer/releases/tag/0.5.0. Any comments? :thinking:

usrme avatar Jul 07 '22 03:07 usrme

ATM I can't install typer-cli within my typer project. When installing typer-cli globally, leaving alone the dependencies issues, it's not possible to generate docs.

@tiangolo ?

jony89 avatar Jul 27 '22 12:07 jony89

Hi @tiangolo ! I have the same issue. typer-cli can't be installed with an up to date typer version.

danielgafni avatar Aug 07 '22 17:08 danielgafni

+1 @tiangolo it would be great to get a fix for this! 🙏

ghost avatar Aug 10 '22 09:08 ghost

I’ll try to get the other contributors attention…

@juanmapf97 @ovezovs 🙏

danielgafni avatar Aug 10 '22 19:08 danielgafni

+1 Still an ongoing issue after typer 0.6

mpurdon avatar Sep 20 '22 01:09 mpurdon

Still an issue here too, all I want from typer-cli is autocomplete so I'll gladly take suggestions.

miska-ship-it avatar Oct 11 '22 15:10 miska-ship-it

$ poetry add typer typer-cli
Using version ^0.6.1 for typer
Using version ^0.0.12 for typer-cli

Updating dependencies
Resolving dependencies... (0.0s)

Because typer-cli (0.0.12) depends on typer (>=0.3.0,<0.4.0)
 and no versions of typer-cli match >0.0.12,<0.0.13, typer-cli (>=0.0.12,<0.0.13) requires typer (>=0.3.0,<0.4.0).
So, because testapp depends on both typer (^0.6.1) and typer-cli (^0.0.12), version solving failed.

kurtabersold avatar Oct 26 '22 18:10 kurtabersold

Yep same issue, I wanted to use Typer-CLI to generate documentation :)

lambda-science avatar Nov 19 '22 13:11 lambda-science

(Would anyone know how to generate automatic CLI doc for arg and option without Typer-CLI ? 👀)

lambda-science avatar Nov 19 '22 21:11 lambda-science

(Would anyone know how to generate automatic CLI doc for arg and option without Typer-CLI ? eyes)

https://github.com/tiangolo/typer-cli/pull/67#issuecomment-1271983950

maxb2 avatar Nov 19 '22 22:11 maxb2

Thanks for the discussion, everyone! :coffee: This should be solved by Typer-CLI 0.0.13, just released. :tada:

Sorry for the long delay! 🙈 I wanted to personally address each issue/PR and they piled up through time, but now I'm checking each one in order.

tiangolo avatar Feb 16 '23 19:02 tiangolo

Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs.

github-actions[bot] avatar Feb 27 '23 00:02 github-actions[bot]

@tiangolo Hey there! :) Still having issue with installing typer and typer-cli with poetry.

This is how my current pyproject.toml looks like:

[tool.poetry] name = "cumana" version = "0.1.0" description = "" authors = ["dpren90 [email protected]"] readme = "README.md"

[tool.poetry.dependencies] python = "^3.11" spacy = "^3.6.1" it-core-news-lg = {url = "https://github.com/explosion/spacy-models/releases/download/it_core_news_lg-3.6.0/it_core_news_lg-3.6.0.tar.gz"} fastapi = "^0.103.1" uvicorn = "^0.23.2" typer = {extras = ["all"], version = "^0.9.0"} pandas = "^2.1.0" pydantic = "^2.3.0"

[tool.poetry.group.dev.dependencies] pytest = "^7.4.2" black = "^23.7.0" mypy = "^1.5.1"

[build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api"

Still - when running poetry add typer-cli, I get the following:

Updating dependencies Resolving dependencies... (0.0s)

Because no versions of typer-cli match >0.0.13,<0.0.14 and typer-cli (0.0.13) depends on typer (>=0.4.0,<=0.7.0), typer-cli (>=0.0.13,<0.0.14) requires typer (>=0.4.0,<=0.7.0). And because typer (0.9.0) depends on typer (0.9.0) and no versions of typer match >0.9.0,<0.10.0, typer-cli (>=0.0.13,<0.0.14) is incompatible with typer (>=0.9.0,<0.10.0). So, because cumana depends on both typer (^0.9.0) and typer-cli (^0.0.13), version solving failed.

Any ide why this could fail? Even poetry add typer-cli@latest doesn't make the trick.

darioprencipe avatar Sep 08 '23 10:09 darioprencipe