mmerickel / wired

A service locator implementation for Python.
https://wired.readthedocs.io
MIT License
17 stars 9 forks source link

Add more type hinting #4

Open pauleveritt opened 5 years ago

pauleveritt commented 5 years ago

Look at ways to get some more type hinting into the core. Gonna be some type theory.

pauleveritt commented 5 years ago

@mmerickel Can you assign this to me (or change my permissions to let me assign tickets)?

mmerickel commented 5 years ago

I feel like wired can be fairly strongly typed right now. For example, I think it's basically:

from typing import Type, TypeVar

ServiceType = TypeVar('Service')
ContextType = TypeVar('Context')

class ServiceContainer:
    def get(service_type: Type[ServiceType], context: ContextType, name: str) -> ServiceType:
        pass

I imagine there's open questions about whether you can go further than a generic TypeVar by requiring it to be a class-or-interface, etc. Hmm.

pauleveritt commented 4 years ago

@mmerickel FWIW this comment describes some interesting typing related, I believe, to your comment in the DI code about something you'd like for type hinting.