python-injector / python-injector/injector
[Question] How to provide custom error messages when a type is not available?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Description
I would like to expose a FooCredentials dataclass to users as part of a library.
Ignoring the fact that this could probably be done nicely by asking them to pass it to me via the Module initializer, how could I check whether a specific binding has been overriden by the user at time of first access (not at time of binding as user code might not have run yet)? The reason behind it is that I would like to show improved error messages when they're "using the library wrong".
I'm assuming some combination of CallableProvider and try/except on some binder or injector method, but I'm not sure which one is the right place.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing first-access resolution through the CallableProvider and the binder or injector methods mentioned in the issue. Determine whether a user override can be detected at first access, and document the supported approach for producing a clearer error message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100