question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Q: Can Configuration values be made required?

See original GitHub issue

Couldn’t find an example of this in the docs but I am trying to ensure that the system fails fast if the container hasn’t been properly configured when the necessary provider is called. For example:

class MyContainer(DeclarativeContainer):

    config = Configuration()

    some_client = Singleton(SomeClient, config.something_important)

Right now, if I forget to set mycontainer.config.something_important before calling mycontainer.some_client(), then SomeClient will be given None as its parameter which is actually worse than forgetting to pass the argument at all because Python will allow it even if it’s not an optional parameter. I don’t want to sprinkle my classes with something_important is None checks.

What I really want is to be able to specify the exact keys I would expect in a Configuration provider and have the Container initialization fail if those values are not provided. Do you have any suggestions?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rmk135commented, Jan 16, 2021

I have released version 4.10.0 with strict mode and required modifier features for the Configuration provider. Here is a doc: https://python-dependency-injector.ets-labs.org/providers/configuration.html#strict-mode-and-required-options

0reactions
rmk135commented, Jan 16, 2021

Glad to hear that! Thank you again

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mapping configuration to objects - Quarkus
When a Quarkus application starts, a config mapping can be registered twice. ... For instance, if the mapping requires values from a custom...
Read more >
Configuration — Django Q 1.3.6 documentation - Read the Docs
The value must be bigger than the time it takes to complete longest task, i.e. timeout must be less than retry value and...
Read more >
Power Apps system requirements and limits - Microsoft Learn
This article contains information on supported device platforms, web browser requirements, limits, and configuration values for Power Apps.
Read more >
Dynamic Configuration - CircleCI
How dynamic config works · The setup phase requires version: 2.1 or higher. · A pipeline can only be continued once (that is,...
Read more >
Understanding the differences between configuration history ...
As the demand for your application keeps growing, so does your need to keep track of your AWS resources. AWS Config tracks changes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found