[New-bugs-announce] [issue42610] Get the type of from a var
dimitri.wei
report at bugs.python.org
Wed Dec 9 08:39:46 EST 2020
New submission from dimitri.wei <dimitri.wei.lingfeng at gmail.com>:
**Feature**
A similar feature in typescript
```ts
const foo: number = 1
type Foo = typeof foo // type Foo = number
function bar(x: string): void {
}
type Bar = typeof bar // type Bar = (x: string) => void
```
**Pitch**
The expected way in future python.
```py
from typing import Type
foo: int = 1
Foo = Type[foo] # equivalent to Foo = int
def bar(x: string) -> None :
...
Bar = Type[bar] # equivalent to Bar = Callable[[str], None]
```
----------
components: Demos and Tools
messages: 382792
nosy: wlf100220
priority: normal
severity: normal
status: open
title: Get the type of from a var
type: enhancement
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42610>
_______________________________________
More information about the New-bugs-announce
mailing list