Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf51d61b

Browse files
committed
Improve signature of __exit__
1 parentbb6eda8 commitf51d61b

File tree

5 files changed

+40
-12
lines changed

5 files changed

+40
-12
lines changed

‎bpython/curtsiesfrontend/_internal.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
# THE SOFTWARE.
2222

2323
importpydoc
24+
fromtypesimportTracebackType
25+
fromtypingimportOptional,Literal,Type
26+
2427
from ..import_internal
2528

2629

@@ -29,8 +32,14 @@ def __enter__(self):
2932
self._orig_pager=pydoc.pager
3033
pydoc.pager=self
3134

32-
def__exit__(self,*args):
35+
def__exit__(
36+
self,
37+
exc_type:Optional[Type[BaseException]],
38+
exc_val:Optional[BaseException],
39+
exc_tb:Optional[TracebackType],
40+
)->Literal[False]:
3341
pydoc.pager=self._orig_pager
42+
returnFalse
3443

3544
def__call__(self,text):
3645
returnNone

‎bpython/curtsiesfrontend/repl.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
importtime
1313
importunicodedata
1414
fromenumimportEnum
15-
16-
fromtypingimportDict,Any,List,Optional,Tuple,Union,cast
15+
fromtypesimportTracebackType
16+
fromtypingimportDict,Any,List,Optional,Tuple,Union,cast,Literal,Type
1717

1818
importblessings
1919
importgreenlet
@@ -573,7 +573,12 @@ def __enter__(self):
573573
sitefix.monkeypatch_quit()
574574
returnself
575575

576-
def__exit__(self,*args):
576+
def__exit__(
577+
self,
578+
exc_type:Optional[Type[BaseException]],
579+
exc_val:Optional[BaseException],
580+
exc_tb:Optional[TracebackType],
581+
)->Literal[False]:
577582
sys.stdin=self.orig_stdin
578583
sys.stdout=self.orig_stdout
579584
sys.stderr=self.orig_stderr
@@ -584,6 +589,7 @@ def __exit__(self, *args):
584589
signal.signal(signal.SIGTSTP,self.orig_sigtstp_handler)
585590

586591
sys.meta_path=self.orig_meta_path
592+
returnFalse
587593

588594
defsigwinch_handler(self,signum,frame):
589595
old_rows,old_columns=self.height,self.width

‎bpython/filelock.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222

23-
fromtypingimportOptional,Type,IO
23+
fromtypingimportOptional,Type,IO,Literal
2424
fromtypesimportTracebackType
2525

2626
has_fcntl=True
@@ -59,9 +59,10 @@ def __exit__(
5959
exc_type:Optional[Type[BaseException]],
6060
exc:Optional[BaseException],
6161
exc_tb:Optional[TracebackType],
62-
)->None:
62+
)->Literal[False]:
6363
ifself.locked:
6464
self.release()
65+
returnFalse
6566

6667
def__del__(self)->None:
6768
ifself.locked:

‎bpython/inspection.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
importpydoc
2727
importre
2828
fromcollectionsimportnamedtuple
29+
fromtypingimportAny,Optional,Literal,Type
30+
fromtypesimportMemberDescriptorType,TracebackType
2931

3032
frompygments.tokenimportToken
3133
frompygments.lexersimportPython3Lexer
32-
fromtypingimportAny
33-
fromtypesimportMemberDescriptorType
3434

3535
from .lazyreimportLazyReCompile
3636

@@ -88,7 +88,12 @@ def __enter__(self):
8888
self.attribs= (__getattribute__,__getattr__)
8989
# /Dark magic
9090

91-
def__exit__(self,exc_type,exc_val,exc_tb):
91+
def__exit__(
92+
self,
93+
exc_type:Optional[Type[BaseException]],
94+
exc_val:Optional[BaseException],
95+
exc_tb:Optional[TracebackType],
96+
)->Literal[False]:
9297
"""Restore an object's magic methods."""
9398
type_=type(self.obj)
9499
__getattribute__,__getattr__=self.attribs
@@ -98,6 +103,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
98103
if__getattr__isnotNone:
99104
setattr(type_,"__getattr__",__getattr__)
100105
# /Dark magic
106+
returnFalse
101107

102108

103109
class_Repr:

‎bpython/repl.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@
3636
fromabcimportabstractmethod
3737
fromitertoolsimporttakewhile
3838
frompathlibimportPath
39+
fromtypesimportModuleType,TracebackType
40+
fromtypingimportcast,Tuple,Any,Optional,Literal,Type
41+
3942
frompygments.lexersimportPython3Lexer
4043
frompygments.tokenimportToken
41-
fromtypesimportModuleType
42-
fromtypingimportcast,Tuple,Any
4344

4445
have_pyperclip=True
4546
try:
@@ -68,7 +69,12 @@ def __init__(self):
6869
def__enter__(self):
6970
self.start=self.time()
7071

71-
def__exit__(self,ty,val,tb):
72+
def__exit__(
73+
self,
74+
exc_type:Optional[Type[BaseException]],
75+
exc_val:Optional[BaseException],
76+
exc_tb:Optional[TracebackType],
77+
)->Literal[False]:
7278
self.last_command=self.time()-self.start
7379
self.running_time+=self.last_command
7480
returnFalse

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp