fix: unwrap original key when its wrapped to not duplicate dependency
When working with dependency_provider.override I had problems when trying to override a dependency function. During debugging, I noticed that dependency_provider was creating a new dependency with override instead of override the original function, see the image below:
After getting deeper into the library code, I realised that when a dependency was created, the function name (used as key) was unwrapped so as not to register the @inject instead of the dependency function. See the image below to understand the injection structure:
This pull request adds an unwrapping handler to the Provider.__get_original_key method to ensure that the key is treated in the same way as build_call_model does.
@lucasfrancaid thank you for the report, but I am not sure, that you are using FastDepends correctly. You shouldn't wrap a function to @inject to use it as a dependency
Please, read https://github.com/Lancetnik/FastDepends/issues/179#issuecomment-3004138336
@Lancetnik, got it. But n the real scenario, I need to wrap the function with @inject because sometimes I need to call it directly from the code as a normal function. Even though I can work around this by creating another wrapped function to get just what I need, it starts to feel a bit messy.
The problem I faced was solved by using dependency_provider.override(get_service, unwrap(get_service_mock), and I opened the PR to handle this case, as it is not a big problem and can be used in different ways.
Anyway, if it does not make any sense, sorry for waste your time.
@lucasfrancaid np, I'll review and merge the PR. Just wanted to know about your case