Skip to content

Commit d426a79

Browse files
authored
Merge pull request #7645 from bluetech/pylint-abc
Don't use NotImplementedError in `@overload`s
2 parents 2c5403b + f28af14 commit d426a79

File tree

13 files changed

+41
-40
lines changed

13 files changed

+41
-40
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ exclude_lines =
2727
^\s*assert False(,|$)
2828

2929
^\s*if TYPE_CHECKING:
30+
^\s*@overload( |$)

src/_pytest/_code/code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,11 @@ def cut(
334334

335335
@overload
336336
def __getitem__(self, key: int) -> TracebackEntry:
337-
raise NotImplementedError()
337+
...
338338

339339
@overload # noqa: F811
340340
def __getitem__(self, key: slice) -> "Traceback": # noqa: F811
341-
raise NotImplementedError()
341+
...
342342

343343
def __getitem__( # noqa: F811
344344
self, key: Union[int, slice]

src/_pytest/_code/source.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ def __eq__(self, other: object) -> bool:
4444

4545
@overload
4646
def __getitem__(self, key: int) -> str:
47-
raise NotImplementedError()
47+
...
4848

4949
@overload # noqa: F811
5050
def __getitem__(self, key: slice) -> "Source": # noqa: F811
51-
raise NotImplementedError()
51+
...
5252

5353
def __getitem__(self, key: Union[int, slice]) -> Union[str, "Source"]: # noqa: F811
5454
if isinstance(key, int):

src/_pytest/compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,13 @@ def __init__(self, func: Callable[[_S], _T]) -> None:
378378
def __get__(
379379
self, instance: None, owner: Optional["Type[_S]"] = ...
380380
) -> "cached_property[_S, _T]":
381-
raise NotImplementedError()
381+
...
382382

383383
@overload # noqa: F811
384384
def __get__( # noqa: F811
385385
self, instance: _S, owner: Optional["Type[_S]"] = ...
386386
) -> _T:
387-
raise NotImplementedError()
387+
...
388388

389389
def __get__(self, instance, owner=None): # noqa: F811
390390
if instance is None:

src/_pytest/fixtures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ def fixture(
12301230
] = ...,
12311231
name: Optional[str] = ...
12321232
) -> _FixtureFunction:
1233-
raise NotImplementedError()
1233+
...
12341234

12351235

12361236
@overload # noqa: F811
@@ -1248,7 +1248,7 @@ def fixture( # noqa: F811
12481248
] = ...,
12491249
name: Optional[str] = None
12501250
) -> FixtureFunctionMarker:
1251-
raise NotImplementedError()
1251+
...
12521252

12531253

12541254
def fixture( # noqa: F811

src/_pytest/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,13 @@ def gethookproxy(self, fspath: py.path.local):
501501
def perform_collect(
502502
self, args: Optional[Sequence[str]] = ..., genitems: "Literal[True]" = ...
503503
) -> Sequence[nodes.Item]:
504-
raise NotImplementedError()
504+
...
505505

506506
@overload # noqa: F811
507507
def perform_collect( # noqa: F811
508508
self, args: Optional[Sequence[str]] = ..., genitems: bool = ...
509509
) -> Sequence[Union[nodes.Item, nodes.Collector]]:
510-
raise NotImplementedError()
510+
...
511511

512512
def perform_collect( # noqa: F811
513513
self, args: Optional[Sequence[str]] = None, genitems: bool = True
@@ -528,13 +528,13 @@ def perform_collect( # noqa: F811
528528
def _perform_collect(
529529
self, args: Optional[Sequence[str]], genitems: "Literal[True]"
530530
) -> List[nodes.Item]:
531-
raise NotImplementedError()
531+
...
532532

533533
@overload # noqa: F811
534534
def _perform_collect( # noqa: F811
535535
self, args: Optional[Sequence[str]], genitems: bool
536536
) -> Union[List[Union[nodes.Item]], List[Union[nodes.Item, nodes.Collector]]]:
537-
raise NotImplementedError()
537+
...
538538

539539
def _perform_collect( # noqa: F811
540540
self, args: Optional[Sequence[str]], genitems: bool

src/_pytest/mark/structures.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,13 @@ def with_args(self, *args: object, **kwargs: object) -> "MarkDecorator":
327327
# the first match so it works out even if we break the rules.
328328
@overload
329329
def __call__(self, arg: _Markable) -> _Markable: # type: ignore[misc]
330-
raise NotImplementedError()
330+
pass
331331

332332
@overload # noqa: F811
333333
def __call__( # noqa: F811
334334
self, *args: object, **kwargs: object
335335
) -> "MarkDecorator":
336-
raise NotImplementedError()
336+
pass
337337

338338
def __call__(self, *args: object, **kwargs: object): # noqa: F811
339339
"""Call the MarkDecorator."""
@@ -388,11 +388,11 @@ def store_mark(obj, mark: Mark) -> None:
388388
class _SkipMarkDecorator(MarkDecorator):
389389
@overload # type: ignore[override,misc]
390390
def __call__(self, arg: _Markable) -> _Markable:
391-
raise NotImplementedError()
391+
...
392392

393393
@overload # noqa: F811
394394
def __call__(self, reason: str = ...) -> "MarkDecorator": # noqa: F811
395-
raise NotImplementedError()
395+
...
396396

397397
class _SkipifMarkDecorator(MarkDecorator):
398398
def __call__( # type: ignore[override]
@@ -401,12 +401,12 @@ def __call__( # type: ignore[override]
401401
*conditions: Union[str, bool],
402402
reason: str = ...
403403
) -> MarkDecorator:
404-
raise NotImplementedError()
404+
...
405405

406406
class _XfailMarkDecorator(MarkDecorator):
407407
@overload # type: ignore[override,misc]
408408
def __call__(self, arg: _Markable) -> _Markable:
409-
raise NotImplementedError()
409+
...
410410

411411
@overload # noqa: F811
412412
def __call__( # noqa: F811
@@ -420,7 +420,7 @@ def __call__( # noqa: F811
420420
] = ...,
421421
strict: bool = ...
422422
) -> MarkDecorator:
423-
raise NotImplementedError()
423+
...
424424

425425
class _ParametrizeMarkDecorator(MarkDecorator):
426426
def __call__( # type: ignore[override]
@@ -437,19 +437,19 @@ def __call__( # type: ignore[override]
437437
] = ...,
438438
scope: Optional[_Scope] = ...
439439
) -> MarkDecorator:
440-
raise NotImplementedError()
440+
...
441441

442442
class _UsefixturesMarkDecorator(MarkDecorator):
443443
def __call__( # type: ignore[override]
444444
self, *fixtures: str
445445
) -> MarkDecorator:
446-
raise NotImplementedError()
446+
...
447447

448448
class _FilterwarningsMarkDecorator(MarkDecorator):
449449
def __call__( # type: ignore[override]
450450
self, *filters: str
451451
) -> MarkDecorator:
452-
raise NotImplementedError()
452+
...
453453

454454

455455
class MarkGenerator:

src/_pytest/monkeypatch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ def test_partial(monkeypatch):
152152
def setattr(
153153
self, target: str, name: object, value: Notset = ..., raising: bool = ...,
154154
) -> None:
155-
raise NotImplementedError()
155+
...
156156

157157
@overload # noqa: F811
158158
def setattr( # noqa: F811
159159
self, target: object, name: str, value: object, raising: bool = ...,
160160
) -> None:
161-
raise NotImplementedError()
161+
...
162162

163163
def setattr( # noqa: F811
164164
self,

src/_pytest/nodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,11 @@ def iter_markers_with_node(
311311

312312
@overload
313313
def get_closest_marker(self, name: str) -> Optional[Mark]:
314-
raise NotImplementedError()
314+
...
315315

316316
@overload # noqa: F811
317317
def get_closest_marker(self, name: str, default: Mark) -> Mark: # noqa: F811
318-
raise NotImplementedError()
318+
...
319319

320320
def get_closest_marker( # noqa: F811
321321
self, name: str, default: Optional[Mark] = None

src/_pytest/pytester.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def __repr__(self) -> str:
201201
if TYPE_CHECKING:
202202
# The class has undetermined attributes, this tells mypy about it.
203203
def __getattr__(self, key: str):
204-
raise NotImplementedError()
204+
...
205205

206206

207207
class HookRecorder:
@@ -274,13 +274,13 @@ def getcall(self, name: str) -> ParsedCall:
274274
def getreports(
275275
self, names: "Literal['pytest_collectreport']",
276276
) -> Sequence[CollectReport]:
277-
raise NotImplementedError()
277+
...
278278

279279
@overload # noqa: F811
280280
def getreports( # noqa: F811
281281
self, names: "Literal['pytest_runtest_logreport']",
282282
) -> Sequence[TestReport]:
283-
raise NotImplementedError()
283+
...
284284

285285
@overload # noqa: F811
286286
def getreports( # noqa: F811
@@ -290,7 +290,7 @@ def getreports( # noqa: F811
290290
"pytest_runtest_logreport",
291291
),
292292
) -> Sequence[Union[CollectReport, TestReport]]:
293-
raise NotImplementedError()
293+
...
294294

295295
def getreports( # noqa: F811
296296
self,
@@ -337,13 +337,13 @@ def matchreport(
337337
def getfailures(
338338
self, names: "Literal['pytest_collectreport']",
339339
) -> Sequence[CollectReport]:
340-
raise NotImplementedError()
340+
...
341341

342342
@overload # noqa: F811
343343
def getfailures( # noqa: F811
344344
self, names: "Literal['pytest_runtest_logreport']",
345345
) -> Sequence[TestReport]:
346-
raise NotImplementedError()
346+
...
347347

348348
@overload # noqa: F811
349349
def getfailures( # noqa: F811
@@ -353,7 +353,7 @@ def getfailures( # noqa: F811
353353
"pytest_runtest_logreport",
354354
),
355355
) -> Sequence[Union[CollectReport, TestReport]]:
356-
raise NotImplementedError()
356+
...
357357

358358
def getfailures( # noqa: F811
359359
self,

src/_pytest/python_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ def raises(
529529
*,
530530
match: "Optional[Union[str, Pattern[str]]]" = ...
531531
) -> "RaisesContext[_E]":
532-
... # pragma: no cover
532+
...
533533

534534

535535
@overload # noqa: F811
@@ -539,7 +539,7 @@ def raises( # noqa: F811
539539
*args: Any,
540540
**kwargs: Any
541541
) -> _pytest._code.ExceptionInfo[_E]:
542-
... # pragma: no cover
542+
...
543543

544544

545545
def raises( # noqa: F811

src/_pytest/recwarn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ def recwarn() -> Generator["WarningsRecorder", None, None]:
4242
def deprecated_call(
4343
*, match: Optional[Union[str, "Pattern[str]"]] = ...
4444
) -> "WarningsRecorder":
45-
raise NotImplementedError()
45+
...
4646

4747

4848
@overload # noqa: F811
4949
def deprecated_call( # noqa: F811
5050
func: Callable[..., T], *args: Any, **kwargs: Any
5151
) -> T:
52-
raise NotImplementedError()
52+
...
5353

5454

5555
def deprecated_call( # noqa: F811
@@ -89,7 +89,7 @@ def warns(
8989
*,
9090
match: "Optional[Union[str, Pattern[str]]]" = ...
9191
) -> "WarningsChecker":
92-
raise NotImplementedError()
92+
...
9393

9494

9595
@overload # noqa: F811
@@ -99,7 +99,7 @@ def warns( # noqa: F811
9999
*args: Any,
100100
**kwargs: Any
101101
) -> T:
102-
raise NotImplementedError()
102+
...
103103

104104

105105
def warns( # noqa: F811

src/_pytest/reports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(self, **kw: Any) -> None:
7171
if TYPE_CHECKING:
7272
# Can have arbitrary fields given to __init__().
7373
def __getattr__(self, key: str) -> Any:
74-
raise NotImplementedError()
74+
...
7575

7676
def toterminal(self, out: TerminalWriter) -> None:
7777
if hasattr(self, "node"):

0 commit comments

Comments
 (0)