injector
injector copied to clipboard
Inject[] does not let the interface show up.
Hello @alecthomas,
first of all let me to say Thank you! for this outstanding package.
I try to utilize the feature of PEP 593 which actually works fine, but let speak the pictures.

As you can see, when I use Inject[], the PyCharm doesn't show the interface's methods.
But it works when I use the Annotated[interface: Type[T], ...].

Thanks for your help in advance!
Hey @mozesa. I'll answer in @alecthomas's stead as I maintain this project right now – I think you need to take this up with the PyCharm folks, I don't use it and I'm afraid I can't help much here, everything seems good on our side.
Hello @jstasiak,
Thanks for your reply. I will create a ticket on PyCharm's side.
I keep open this issue and later will update.
Sure thing!
issue created.
Yes, the JetBrains folks unfortunately lag very much behind updating their type checker. I could go on another rant, but I'll be civil and leave it at that.
The problem is that the Annotated feature has not been created with "regular" __class_getitem__ classmethods, but instead another one of these _SpecialForms. I just spent 30 minutes trying to come up with a workaround, but I couldn't come up with anything better than def PyCharmCompatibleInject(typ: T) -> T: ... which could somehow patch that missing behavior, but it looks ugly as hell: def foo(bar: PChInject(Bar)). meh.