Wrangling the typing PEPs
Wrangling the typing PEPs
Posted Dec 16, 2021 21:11 UTC (Thu) by pj (subscriber, #4506)In reply to: Wrangling the typing PEPs by LtWorf
Parent article: Wrangling the typing PEPs
I feel like the correct way to do this would be to explicitly infer the type. Which meand we need some way to refer to 'the type that open()' takes as its first argument, but that's somewhat complicated to obtain:
```
import inspect
def mywrapper(filename: list(inspect.signature(open).parameters.values())[0].annotation):
...
```
...doesn't exactly flow from the fingertips. And I'm not sure if the if the value to the annotation is valid as an annotation itself. *sigh* IWBNI there was like an `infer(open, 1)`.
Posted Dec 17, 2021 6:39 UTC (Fri)
by NYKevin (subscriber, #129325)
[Link]
Wrangling the typing PEPs