Skip to content

Commit 08fbc32

Browse files
committed
style: Protocols should use ... for method bodies
The pyright type checker didn't like empty bodies, it checked the "None" return against the declared type.
1 parent bc7b0e3 commit 08fbc32

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎coverage/parser.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ def __call__(
529529
10" or "exit from function 'fooey'."
530530
531531
"""
532+
...
532533

533534

534535
TArcFragments = dict[TArc, list[tuple[str | None, str | None]]]

‎coverage/report_core.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Reporter(Protocol):
2727

2828
def report(self, morfs: TMorfs, outfile: IO[str]) -> float:
2929
"""Generate a report of `morfs`, written to `outfile`."""
30+
...
3031

3132

3233
def render_report(

‎coverage/types.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,23 @@ def __init__(self) -> None: ...
100100

101101
def start(self) -> TTraceFn | None:
102102
"""Start this tracer, return a trace function if based on sys.settrace."""
103+
...
103104

104105
def stop(self) -> None:
105106
"""Stop this tracer."""
107+
...
106108

107109
def activity(self) -> bool:
108110
"""Has there been any activity?"""
111+
...
109112

110113
def reset_activity(self) -> None:
111114
"""Reset the activity() flag."""
115+
...
112116

113117
def get_stats(self) -> dict[str, int] | None:
114118
"""Return a dictionary of statistics, or None."""
119+
...
115120

116121

117122
## Coverage
@@ -143,6 +148,7 @@ def get_option(self, option_name: str) -> TConfigValueOut | None:
143148
Returns the value of the option.
144149
145150
"""
151+
...
146152

147153
def set_option(self, option_name: str, value: TConfigValueIn | TConfigSectionIn) -> None:
148154
"""Set an option in the configuration.
@@ -154,13 +160,15 @@ def set_option(self, option_name: str, value: TConfigValueIn | TConfigSectionIn)
154160
`value` is the new value for the option.
155161
156162
"""
163+
...
157164

158165

159166
class TPluginConfig(Protocol):
160167
"""Something that can provide options to a plugin."""
161168

162169
def get_plugin_options(self, plugin: str) -> TConfigSectionOut:
163170
"""Get the options for a plugin."""
171+
...
164172

165173

166174
## Parsing
@@ -185,13 +193,16 @@ class TDebugCtl(Protocol):
185193

186194
def should(self, option: str) -> bool:
187195
"""Decide whether to output debug information in category `option`."""
196+
...
188197

189198
def write(self, msg: str) -> None:
190199
"""Write a line of debug output."""
200+
...
191201

192202

193203
class TWritable(Protocol):
194204
"""Anything that can be written to."""
195205

196206
def write(self, msg: str) -> None:
197207
"""Write a message."""
208+
...

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ disable = [
9090
"too-many-lines",
9191
"use-implicit-booleaness-not-comparison",
9292
"too-many-positional-arguments",
93+
"unnecessary-ellipsis",
9394
# Formatting stuff
9495
"superfluous-parens",
9596
"line-too-long",

0 commit comments

Comments
 (0)