langchain icon indicating copy to clipboard operation
langchain copied to clipboard

core: [env.py/get_from_env] change default value None -> sentinel object

Open morgandiverrez opened this issue 1 year ago • 3 comments

Description Install sentinel value by default in get_from_env and get_from_dict_and_env function in env.py for let's None value by default and not raise ValueError in this case.

Issue : [Partners-HuggingFace] Breaking Change - impossible to skip login after PR #23309 #26085

morgandiverrez avatar Sep 06 '24 16:09 morgandiverrez

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 8:06am

vercel[bot] avatar Sep 06 '24 16:09 vercel[bot]

I changed the code to only return a string as you asked. Do you think I can further improve this code?

morgandiverrez avatar Sep 06 '24 17:09 morgandiverrez

Thanks @morgandiverrez , as mentionned in the issue :

Introducing a sentinel value may be considered as a breaking change, get_from_env will then accept None as default value without raising any exception which is currently not accepted 🤔. This would assume that users rely on this exception being raised, which I my opinion shouldn't be considered as "nominal" usage of this method.

https://github.com/langchain-ai/langchain/issues/26085#issuecomment-2331968516

What do you think about this @eyurtsev ?

Benvii avatar Sep 09 '24 10:09 Benvii

Moved to needs status since there was no activity on this.

Developers can use the existing from_env and secret_from_env in langchain_core.utils to get factories for this use case.

eyurtsev avatar Sep 30 '24 20:09 eyurtsev

Closing the PR due to lack of activity. Will be happy to re-review if folks want to tackle and can get the type annotations working correctly.

eyurtsev avatar Oct 08 '24 20:10 eyurtsev