-
Notifications
You must be signed in to change notification settings - Fork 354
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
feat: Use TypeAliasType
to define aliases
#4701
base: main
Are you sure you want to change the base?
Conversation
Hello. To be honest, I'm not sure we wanted these type aliased to be exported and used outside. We wanted the type aliases to be inlined so that function signatures are fully resolved to actually importable types, not union aliases. Since, AFAIK, this does not make any SDK surface changes and is not breaking backwards compatibility, I think I can approve this change. However I think it might be best to find a better and more robust long-term workaround (e.g. not using these internal type aliases from other libraries). |
016b80e
to
678e790
Compare
Hello, indeed it seems that these aliases are only used for function annotations in this project (and not as Pydantic fields annotations). It might be best getting in touch with the maintainers at https://github.com/langchain-ai/langchain-google to discuss this. |
The unit test infra builds are failing with the following error (due to bumping the lower bound of typing_extensions): The conflict is caused by: Can you adjust the bounds and verify that the google-cloud-aiplatform[testing] extras installation works? |
I'm not sure what's reason to have the different versions here: Lines 208 to 210 in dfe6d6c
So I see two ways to go forward:
|
Any news on this? Highly sought after |
We aren't planning to drop python 3.8 support at this time. But perhaps we can see if we can mitigate this issue for python >3.8 users. Maybe there is a combination of dependencies for >python 3.8 that we can have typing_extensions>4.6.0? |
https://devguide.python.org/versions/ Python 3.8 reached EOL @matthew29tang . Why keep supporting legacy? |
Testing for #4701 PiperOrigin-RevId: 704506046
Testing for #4701 PiperOrigin-RevId: 704506046
Testing for #4701 PiperOrigin-RevId: 704506046
Testing for #4701 PiperOrigin-RevId: 704506046
Testing for #4701 PiperOrigin-RevId: 704506046
Testing for #4701 PiperOrigin-RevId: 704506046
Testing for #4701 PiperOrigin-RevId: 704506046
Hi @Viicos thank you for the PR (and thank you everyone else for the feedback) -- sorry for my slow response here -- can you make the following changes:
(If you might prefer -- I'm also happy to take over from here in #4761. Otherwise I'd prefer to preserve your authorship of changes and full context in this PR.) |
…tive models Testing for #4701 PiperOrigin-RevId: 704506046
Hi @yeesian, Feel free to pick this up. Maybe it could be worth fixing the issue at https://github.com/langchain-ai/langchain-google instead, as it is importing the private Otherwise, the |
Any news on this ? |
…tive models This is based on the original PR in #4701, just wrapping the typealiases in a try-catch block. PiperOrigin-RevId: 704506046
…tive models This is based on the original PR in #4701, just wrapping the typealiases in a try-catch block. PiperOrigin-RevId: 704506046
…tive models This is based on the original PR in #4701, just wrapping the typealiases in a try-catch block. PiperOrigin-RevId: 704506046
…tive models This is based on the original PR in #4701, just wrapping the typealiases in a try-catch block. PiperOrigin-RevId: 704506046
…tive models This is based on the original PR in #4701, just wrapping the typealiases in a try-catch block. PiperOrigin-RevId: 704506046
…tive models This is based on the original PR in #4701, just wrapping the typealiases in a try-catch block. PiperOrigin-RevId: 704506046
…tive models This is based on the original PR in #4701, just wrapping the typealiases in a try-catch block. PiperOrigin-RevId: 704506046
…tive models This is based on the original PR in #4701, just wrapping the typealiases in a try-catch block. PiperOrigin-RevId: 704506046
…tive models This is based on the original PR in #4701, just wrapping the typealiases in a try-catch block. PiperOrigin-RevId: 708367618
Sorry for the slowness from me here, this change is on the main branch now 2224c83, and will be available in the next release (i.e. |
No worries. Should I close this one then? |
Can I help somehow? this doesn't allow using new |
@yeesian what is the status of this? Is Update: Released, thank you 🙏 |
See langchain-ai/langchain-google#610 (comment) for more context. The TL;DR is that it is very hard (if not impossible) for Pydantic to resolve the forward references inside these aliases. Taking the following simplified example:
It is strictly equivalent to:
because
Alias
is just a simple variable.By using
TypeAliasType
instead (or the new type syntax once support for 3.11 is dropped), we can access the__module__
attribute of theTypeAliasType
instance and grab theSomeType
alias from there.Moreover, due to how Python caches the evaluated value of forward references, this led to a bug in https://github.com/langchain-ai/langchain-google, see my comment for more details.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Note: do not merge your PR from GitHub. Adding the "ready to pull" label is the final step in the review process.
After approvals, the changes in your PR will be committed to the
main
branch and this PR will be closed.Fixes #<issue_number_goes_here> 🦕