Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typing_extensions dep. #507

Closed
wants to merge 3 commits into from
Closed

Conversation

Icantjuddle
Copy link

@Icantjuddle Icantjuddle commented Nov 17, 2022

Currently, when running on older versions of python before 3.8, Typer requires the use of typing_extensions for the Literal type.

https://github.com/tiangolo/typer/blob/6208b5b2087d3474023cdf650a246c9a6c8327c3/typer/core.py#L30-L33

This was added to that library after typing_extensions 3.6.6 release (diff here).

When I run on python3.7 I'm seeing issues when testing my typer clis due to this missing dep.

I'm not the most familiar with the python packaging ecosystem but I pulled the syntax from here:
https://flit.pypa.io/en/stable/pyproject_toml.html#dependencies

@github-actions
Copy link

📝 Docs preview for commit 7320fc5 at: https://63767105747f9411682c20d3--typertiangolo.netlify.app

@github-actions
Copy link

📝 Docs preview for commit b4b07eb at: https://639ce9d92c118d0a1647f762--typertiangolo.netlify.app

@Icantjuddle
Copy link
Author

@tiangolo Let me know if there is anything more I can add/test/show here to help.

@Icantjuddle
Copy link
Author

@tiangolo adding a repro to demonstrate the issue, would be great if we could merge. Let me know if there is anything else I can do to help, test, etc.


❯ python -m venv ./test_env
❯ source ./test_env/bin/activate
❯ python --version
Python 3.7.9
❯ pip install click==7.1.2
Collecting click==7.1.2
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Installing collected packages: click
Successfully installed click-7.1.2
WARNING: You are using pip version 20.1.1; however, version 22.3.1 is available.
You should consider upgrading via the '/home/bjudd/code/typer_example/test_env/bin/python -m pip install --upgrade pip' command.
❯ pip install typer
Collecting typer
  Using cached typer-0.7.0-py3-none-any.whl (38 kB)
Requirement already satisfied: click<9.0.0,>=7.1.1 in ./test_env/lib/python3.7/site-packages (from typer) (7.1.2)
Installing collected packages: typer
Successfully installed typer-0.7.0
WARNING: You are using pip version 20.1.1; however, version 22.3.1 is available.
You should consider upgrading via the '/home/bjudd/code/typer_example/test_env/bin/python -m pip install --upgrade pip' command.
❯ python -m typer
Traceback (most recent call last):
  File "/home/bjudd/.local/apps/pyenv/versions/3.7.9/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/home/bjudd/.local/apps/pyenv/versions/3.7.9/lib/python3.7/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/home/bjudd/.local/apps/pyenv/versions/3.7.9/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/home/bjudd/code/typer_example/test_env/lib/python3.7/site-packages/typer/__init__.py", line 30, in <module>
    from .main import Typer as Typer
  File "/home/bjudd/code/typer_example/test_env/lib/python3.7/site-packages/typer/main.py", line 17, in <module>
    from .core import MarkupMode, TyperArgument, TyperCommand, TyperGroup, TyperOption
  File "/home/bjudd/code/typer_example/test_env/lib/python3.7/site-packages/typer/core.py", line 33, in <module>
    from typing_extensions import Literal
ModuleNotFoundError: No module named 'typing_extensions'
❯ pip install pipdeptree
Collecting pipdeptree
  Using cached pipdeptree-2.3.3-py3-none-any.whl (16 kB)
Installing collected packages: pipdeptree
Successfully installed pipdeptree-2.3.3
WARNING: You are using pip version 20.1.1; however, version 22.3.1 is available.
You should consider upgrading via the '/home/bjudd/code/typer_example/test_env/bin/python -m pip install --upgrade pip' command.
❯ pipdeptree
pip==20.1.1
pipdeptree==2.3.3
setuptools==47.1.0
typer==0.7.0
  - click [required: >=7.1.1,<9.0.0, installed: 7.1.2]

If you update the version of click to something newer, click itself a transitive dependency on typing-extensions so typer can get away with not declaring its own, but for older versions of click this does not work and the dependency is missing.

@ryangalamb
Copy link
Contributor

This change seems reasonable. If #584 is merged in its current state, we can close this. (#584 currently adds typing_extensions to the deps.)

If #584 doesn't get merged, or it gets changed not to include typing_extensions, I'll take another look at this one.

@Icantjuddle
Copy link
Author

Thanks @ryangalamb, looks like your PR got merged so this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants