In the PyCon talk, Tom mentions explicitly injecting external dependencies such as Requests or Now or RandInt.
In the example, he mentions defining Now as:
Now = typing.Callable[, datetime.datetime]
and using it:
def add_billing_record(record: BillingRecord, now: Now) -> BillingRecord: """Below is just an example""" record.timestamp = now() record.save()
I have a custom method that I use to generate timezone aware datetimes. In the slide, he defines the type as a callable but it is not linked to any actual definition. Should I create a component with a
__call__ method? Or is there another way to have the dependency injector call the correct code.