File: typetest.py

package info (click to toggle)
python-anysqlite 0.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 152 kB
  • sloc: python: 179; sh: 15; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 571 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import typing as tp
import sqlite3

P = tp.ParamSpec("P")
T = tp.TypeVar("T")
RT = tp.TypeVar("RT")

def copy_sig(_: tp.Callable[P, T], returns: tp.Callable[..., RT]) -> tp.Callable[[tp.Callable[..., tp.Any]], tp.Callable[P, RT]]:

    def decorator(fnc: tp.Callable[..., tp.Any]) -> tp.Callable[P, RT]:

        def inner(*args, **kwargs):
            return fnc(*args, **kwargs)
    
        return inner

    return decorator

@copy_sig(sqlite3.connect, int.__new__)
async def connect(*args, **kwargs):
    ...


tp.reveal_type(connect)
a = connect()
tp.reveal_type(a)