Skip to content

Commit 7c4a67e

Browse files
committed
Add test case for raising NotImplemented
1 parent 652bee0 commit 7c4a67e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

test-data/unit/check-statements.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,13 @@ if object():
519519
raise BaseException from f # E: Exception must be derived from BaseException
520520
[builtins fixtures/exception.pyi]
521521

522+
[case testRaiseNotImplementedFails]
523+
if object():
524+
raise NotImplemented # E: Exception must be derived from BaseException; did you mean "NotImplementedError"?
525+
if object():
526+
raise NotImplemented() # E: NotImplemented? not callable
527+
[builtins fixtures/notimplemented.pyi]
528+
522529
[case testTryFinallyStatement]
523530
import typing
524531
try:
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# builtins stub used in NotImplemented related cases.
2-
from typing import Any, cast
3-
2+
from typing import Any
43

54
class object:
65
def __init__(self) -> None: pass
@@ -10,5 +9,10 @@ class function: pass
109
class bool: pass
1110
class int: pass
1211
class str: pass
13-
NotImplemented = cast(Any, None)
1412
class dict: pass
13+
14+
class _NotImplementedType(Any):
15+
__call__: NotImplemented # type: ignore
16+
NotImplemented = _NotImplementedType()
17+
18+
class BaseException: pass

0 commit comments

Comments
 (0)