Skip to content

Commit c17aab5

Browse files
committed
Coverage exclusions
1 parent e589a26 commit c17aab5

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,5 @@ show_missing = true
128128
# If not explicitly omitted they will result in warnings in the report.
129129
omit = ["inspect*", "ann*"]
130130
ignore_errors = true
131+
# Exclude 'pass' used as a placeholder function or class body
132+
exclude_lines = ['^\s*(def|class) .*:\n\s*pass']

src/test_typing_extensions.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3918,9 +3918,9 @@ def c(self) -> int: ...
39183918

39193919
class Concrete:
39203920
a: int
3921-
def b(self) -> str: return "capybara"
3921+
def b(self) -> str: raise NotImplementedError
39223922
@property
3923-
def c(self) -> int: return 5
3923+
def c(self) -> int: raise NotImplementedError
39243924

39253925
with self.assertRaisesRegex(TypeError, "not a Protocol"):
39263926
get_protocol_members(Concrete)
@@ -3929,9 +3929,9 @@ def c(self) -> int: return 5
39293929

39303930
class ConcreteInherit(P):
39313931
a: int = 42
3932-
def b(self) -> str: return "capybara"
3932+
def b(self) -> str: raise NotImplementedError
39333933
@property
3934-
def c(self) -> int: return 5
3934+
def c(self) -> int: raise NotImplementedError
39353935

39363936
with self.assertRaisesRegex(TypeError, "not a Protocol"):
39373937
get_protocol_members(ConcreteInherit)
@@ -3955,9 +3955,9 @@ def c(self) -> int: ...
39553955

39563956
class Concrete:
39573957
a: int
3958-
def b(self) -> str: return "capybara"
3958+
def b(self) -> str: raise NotImplementedError
39593959
@property
3960-
def c(self) -> int: return 5
3960+
def c(self) -> int: raise NotImplementedError
39613961

39623962
with self.assertRaisesRegex(TypeError, "not a Protocol"):
39633963
get_protocol_members(Concrete)
@@ -3966,9 +3966,9 @@ def c(self) -> int: return 5
39663966

39673967
class ConcreteInherit(P):
39683968
a: int = 42
3969-
def b(self) -> str: return "capybara"
3969+
def b(self) -> str: raise NotImplementedError
39703970
@property
3971-
def c(self) -> int: return 5
3971+
def c(self) -> int: raise NotImplementedError
39723972

39733973
with self.assertRaisesRegex(TypeError, "not a Protocol"):
39743974
get_protocol_members(ConcreteInherit)
@@ -4095,7 +4095,7 @@ class Vec2D(Protocol):
40954095
y: float
40964096

40974097
def square_norm(self) -> float:
4098-
return self.x ** 2 + self.y ** 2
4098+
raise NotImplementedError
40994099

41004100
self.assertEqual(Vec2D.__protocol_attrs__, {'x', 'y', 'square_norm'})
41014101
expected_error_message = (
@@ -4155,23 +4155,23 @@ class SpecificProtocolTests(BaseTestCase):
41554155
def test_reader_runtime_checkable(self):
41564156
class MyReader:
41574157
def read(self, n: int) -> bytes:
4158-
return b""
4158+
raise NotImplementedError
41594159

41604160
class WrongReader:
41614161
def readx(self, n: int) -> bytes:
4162-
return b""
4162+
raise NotImplementedError
41634163

41644164
self.assertIsInstance(MyReader(), typing_extensions.Reader)
41654165
self.assertNotIsInstance(WrongReader(), typing_extensions.Reader)
41664166

41674167
def test_writer_runtime_checkable(self):
41684168
class MyWriter:
41694169
def write(self, b: bytes) -> int:
4170-
return 0
4170+
raise NotImplementedError
41714171

41724172
class WrongWriter:
41734173
def writex(self, b: bytes) -> int:
4174-
return 0
4174+
raise NotImplementedError
41754175

41764176
self.assertIsInstance(MyWriter(), typing_extensions.Writer)
41774177
self.assertNotIsInstance(WrongWriter(), typing_extensions.Writer)
@@ -9360,5 +9360,5 @@ def test_sentinel_not_picklable(self):
93609360
pickle.dumps(sentinel)
93619361

93629362

9363-
if __name__ == '__main__':
9363+
if __name__ == '__main__': # pragma: no cover
93649364
main()

src/typing_extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165

166166

167167
class _Sentinel:
168-
def __repr__(self):
168+
def __repr__(self): # pragma: no cover
169169
return "<sentinel>"
170170

171171

0 commit comments

Comments
 (0)