Skip to content

Commit

Permalink
move registries types into inlines (#472)
Browse files Browse the repository at this point in the history
* move types into inlines
* coverage
  • Loading branch information
beliaev-maksim committed Jan 18, 2022
1 parent 6b70346 commit 82de5f8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
31 changes: 23 additions & 8 deletions responses/registries.py
@@ -1,15 +1,30 @@
from typing import (
TYPE_CHECKING,
List,
Optional,
Tuple,
)

if TYPE_CHECKING: # pragma: no cover
# import only for linter run
from requests import PreparedRequest
from responses import BaseResponse


class FirstMatchRegistry(object):
def __init__(self):
self._responses = []
def __init__(self) -> None:
self._responses: List["BaseResponse"] = []

@property
def registered(self):
def registered(self) -> List["BaseResponse"]:
return self._responses

def reset(self):
def reset(self) -> None:
self._responses = []

def find(self, request):
def find(
self, request: "PreparedRequest"
) -> Tuple[Optional["BaseResponse"], List[str]]:
found = None
found_match = None
match_failed_reasons = []
Expand All @@ -31,14 +46,14 @@ def find(self, request):
match_failed_reasons.append(reason)
return found_match, match_failed_reasons

def add(self, response):
def add(self, response: "BaseResponse") -> None:
self.registered.append(response)

def remove(self, response):
def remove(self, response: "BaseResponse") -> None:
while response in self.registered:
self.registered.remove(response)

def replace(self, response):
def replace(self, response: "BaseResponse") -> None:
try:
index = self.registered.index(response)
except ValueError:
Expand Down
17 changes: 0 additions & 17 deletions responses/registries.pyi

This file was deleted.

0 comments on commit 82de5f8

Please sign in to comment.