Skip to content

Conversation

waketzheng
Copy link

@waketzheng waketzheng commented Sep 15, 2025

Description

  1. Only install typing_extensions for python '<3.10'

This comment was marked as outdated.

@svlandeg svlandeg added the feature New feature, enhancement or request label Sep 16, 2025
@github-actions github-actions bot added the conflicts Automatically generated when a PR has a merge conflict label Sep 16, 2025

This comment was marked as resolved.

@github-actions github-actions bot removed the conflicts Automatically generated when a PR has a merge conflict label Sep 16, 2025

This comment was marked as outdated.

@svlandeg svlandeg changed the title ➖ Only install typing_extensions for python '<3.10' ➖ Only install typing_extensions for Python '<3.10' Sep 16, 2025
Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! This makes sense to me. Just a few questions/comments:

  • I removed bumping the dependencies as this was causing conflicts and CI errors. Let's keep the PR atomic (dealing with one functionality only).
  • Why < 3.10? Looking at _typing.py, it seems like typing_extensions is only used up to and including 3.8.
  • What is a bit unfortunate is that many of our tutorial examples use from typing_extensions import Annotated. I worry that users won't be able to execute this code directly if they haven't got typing_extensions installed in their normal typer environment.

This comment was marked as outdated.

@svlandeg
Copy link
Member

Hi @waketzheng, I see you're running into the same typing error we've encountered before: #1048 (comment)

Basically this happens when reimporting Literal. For now, it's find to leave that bit of duplicated code as-is.

@waketzheng waketzheng changed the title ➖ Only install typing_extensions for Python '<3.10' ➖ Only install typing_extensions for Python '<3.9' Sep 17, 2025

This comment was marked as outdated.

@waketzheng
Copy link
Author

many of our tutorial examples use from typing_extensions import Annotated

How about use from typer._typing import Annotated instead?

Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks good to me - it's a good idea not to install typing_extensions when we don't need it for Python 3.9 and above.

What is a bit unfortunate is that many of our tutorial examples use from typing_extensions import Annotated. I worry that users won't be able to execute this code directly if they haven't got typing_extensions installed in their normal typer environment.

How about use from typer._typing import Annotated instead?

As I see it, our options are:

  • keep the examples as they are, and update them to from typing import Annotated when we drop Python 3.8
  • update the examples to from typer._typing import Annotated as you suggest but this feels like adding unnecessary complexity to the tutorial examples (exposing what should be an implementation detail)
  • we can have explicit Python 3.9+ examples for all tutorial examples, that import from typing instead. While I wouldn't mind working on this, it feels like a lot of wasted effort, especially if we plan on dropping Python 3.8 soon.

I'll leave this decision with Tiangolo 🙏

@github-actions github-actions bot added the conflicts Automatically generated when a PR has a merge conflict label Sep 19, 2025

This comment was marked as resolved.

@github-actions github-actions bot removed the conflicts Automatically generated when a PR has a merge conflict label Sep 19, 2025
Copy link
Contributor

📝 Docs preview for commit a3bdc86 at: https://58407af1.typertiangolo.pages.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature, enhancement or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants