Giter Club home page Giter Club logo

Comments (5)

hramezani avatar hramezani commented on September 28, 2024

@kschwab could you please take a look?

from pydantic-settings.

kschwab avatar kschwab commented on September 28, 2024

@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.

isc-patrick avatar isc-patrick commented on September 28, 2024

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.

kschwab avatar kschwab commented on September 28, 2024

@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.

isc-patrick avatar isc-patrick commented on September 28, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.