➖ Only install typing_extensions for Python '<3.9'#1306
➖ Only install typing_extensions for Python '<3.9'#1306waketzheng wants to merge 7 commits intofastapi:masterfrom
typing_extensions for Python '<3.9'#1306Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
typing_extensions for python '<3.10'typing_extensions for Python '<3.10'
svlandeg
left a comment
There was a problem hiding this comment.
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 liketyping_extensionsis 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 gottyping_extensionsinstalled in their normaltyperenvironment.
This comment was marked as outdated.
This comment was marked as outdated.
|
Hi @waketzheng, I see you're running into the same typing error we've encountered before: #1048 (comment) Basically this happens when reimporting |
typing_extensions for Python '<3.10'typing_extensions for Python '<3.9'
This comment was marked as outdated.
This comment was marked as outdated.
How about use |
svlandeg
left a comment
There was a problem hiding this comment.
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 Annotatedinstead?
As I see it, our options are:
- keep the examples as they are, and update them to
from typing import Annotatedwhen we drop Python 3.8 - update the examples to
from typer._typing import Annotatedas 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
typinginstead. 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 🙏
This comment was marked as resolved.
This comment was marked as resolved.
|
📝 Docs preview for commit a3bdc86 at: https://58407af1.typertiangolo.pages.dev |
|
This pull request has a merge conflict that needs to be resolved. |
Description
typing_extensionsfor python '<3.10'