ivankorobkov / python-inject

Python dependency injection
Apache License 2.0
694 stars 79 forks source link

Type hints mismatch? #45

Closed 45deg closed 4 years ago

45deg commented 4 years ago

Hello, I caught a type error with IntelliJ IDE caused by the inferred type of inject.attr(IFoo) is not IFoo but Type[IFoo]. Inspecting the library, I found the two different annotation of type:

def attr(cls: T) -> T:
    # type: (Binding) -> T
    """Return a attribute injection (descriptor)."""
    return _AttributeInjection(cls)

After changing cls: T with cls: Binding, the inference goes right.

Is there any reason for these different annotations (backward compatibility, etc.)? I should have made a PR for that if it is an unintentional mistake but asked at first for clarification.

Thanks for your works.

ivankorobkov commented 4 years ago

Hi,

I think it's a typo. Please, make a PR and I'll make a new release.

45deg commented 4 years ago

Thanks, I'll prepare for PR.