Skip to content

Commit 6fecebd

Browse files
Ben-Regsebastinas
authored andcommitted
Did the forward_if_not_current decorator function. Not 100% sure about the types.
1 parent 7ae4c79 commit 6fecebd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

bpython/cli.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
import struct
5353
import sys
5454
import time
55-
from typing import Iterator, NoReturn, List, MutableMapping, Any, Callable
55+
from typing import Iterator, NoReturn, List, MutableMapping, Any, Callable, TypeVar, cast
5656
import unicodedata
5757
from dataclasses import dataclass
5858

@@ -84,6 +84,7 @@
8484
from .pager import page
8585
from .args import parse as argsparse
8686

87+
F = TypeVar('F', bound=Callable[..., Any])
8788

8889
# --- module globals ---
8990
stdscr = None
@@ -118,16 +119,16 @@ def calculate_screen_lines(
118119
return lines
119120

120121

121-
def forward_if_not_current(func: Callable) -> Callable:
122+
def forward_if_not_current(func: F) -> F:
122123
@functools.wraps(func)
123-
def newfunc(self, *args: Any, **kwargs: Any) -> Any:
124+
def newfunc(self, *args, **kwargs): # type: ignore
124125
dest = self.get_dest()
125126
if self is dest:
126127
return func(self, *args, **kwargs)
127128
else:
128129
return getattr(self.get_dest(), newfunc.__name__)(*args, **kwargs)
129130

130-
return newfunc
131+
return cast(F, newfunc)
131132

132133

133134
class FakeStream:

0 commit comments

Comments
 (0)