Comments (5)
@kschwab could you please take a look?
from pydantic-settings.
@hramezani this is similar request as #391. I've added a config option that will ignore unknown args.
The docs still need to be updated to cover the different use cases of mixing a CliSettingsSource
with other parsers (e.g., pytest, uvicorn, etc.). I'll try to get back to it here in the next few days.
from pydantic-settings.
The solutions in #391 can work but require hard coding things to work with specific apps or just turn off CLI parsing if using certain apps. It is very common with Python apps to have another app load it - pytest, uvicorn, fastapi, memray - to just name a few I use off the top of my head, so these solutions are not ideal as they don't really acknowledge this common type of usage. I don't want application code that is specific to running tests so I am just turning off CLI parsing for these cases and will have to change the code if I need to use different launching apps.
from pydantic-settings.
@isc-patrick the similarity with #391 relates to mixing multiple parsers in a single app. This is a general problem. e.g., #405 will add an option to ignore unknown CLI arguments. This is a great request and a good feature to have 👍
However, while this resolves not blowing up for unknown arguments, it now also parses any common arguments. If pytest, uvicorn, etc. have a flag --enable int
and CliSettingsSource
also has a flag --enable dict
, it will blow up. So, what constitutes "blowing up" is specific to the app and requires app specific logic to correctly resolve. This may mean turning off the CLI, integrating the CLI, ignoring unknown arguments, etc., but these are all app specific details.
@hramezani, unfortunately, I am tight on time this week. I've updated the docs with respect to the new flag. I'll try to get back to a broader summary of this issue and #391 in the docs at a later time.
from pydantic-settings.
@kschwab Thanks for the clarification. I mistook the disabling of the cli parsing via searching the argv[0] as that implementation. I completely agree that there is no way to avoid some of these issues because of the potentialof common arguments in different apps.
from pydantic-settings.
Related Issues (20)
- Mypy reports error when passing a list to YamlConfigSettingsSource through yaml_file HOT 1
- Mypy plugin reports false positives and not existing lines HOT 1
- Support dash-separated CLI arguments and underscore-separated ENV variables HOT 4
- context not passed to field validators HOT 4
- Order of alias given in AliasChoices yield different results HOT 3
- add an option to not validate a model if all configuration options it contains are empty HOT 2
- reconsider adding Singleton option for BaseSettings HOT 4
- AzureKeyVaultSettingsSource ignoring SettingsSource Priority HOT 3
- PyprojectTomlConfigSettingsSource overwrite `toml_file` Path from `model_config` HOT 2
- Feature: Make argument flag configurable HOT 5
- support regex to load config that falls under the same roof HOT 2
- Regression of case sensitive environment variable support HOT 7
- Regression - .env nested optional model support HOT 4
- Add SOPS settings source for secrets HOT 1
- pydantic-settings new version can't handle scenario HOT 2
- Allow to load a settings without validation HOT 3
- nested_model_default_partial_update documentation isn't clear
- env_prefix Ignored in Some Cases in Pydantic Settings
- Separate tests related to specific settings sources
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pydantic-settings.