Replies: 1 comment 1 reply
-
Oh cool our Pyright config made it pointless for our test, because this is still passing: https://github.com/hynek/svcs/blob/main/tests/typing/core.py#L144-L152 This is unfortunate but I guess the only way forward is to stop recommending Annotated? We might add a side-note I guess. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Calls of the form
are recommended by the svcs docs for the case of multiple factories for the same type (here,
int
).Pyright has recently started complaining about this, with a (slightly unhelpful) message of the form
error: Argument of type "type[int]" cannot be assigned to parameter "svc_type" of type "type" in function "register_value" (reportArgumentType)
. (gist)Some interesting related conversations came up in a search:
microsoft/pyright#7238 (Typing issue with Annotated)
https://discuss.python.org/t/is-annotated-compatible-with-type-t/43898 (Is
Annotated
compatible withtype[T]
?) (spoiler: "no")python/typing-council#18 (Typing spec change for Annotated special form)
I think this means that the svcs docs should not recommend the Annotated construct. I think the alternative is weakening the declared type of svc_type to Any, which doesn't seem great. Does that sound right to you?
Beta Was this translation helpful? Give feedback.
All reactions