Skip to content

Commit

Permalink
Improve type annotations, remove flake8 exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjacob committed Jan 4, 2024
1 parent fba6b79 commit 34b0166
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,3 @@ pytest11 = {pytest_tiny_api_client = "pytest_tiny_api_client"}

[tool.isort]
length_sort = true

[tool.flake8]
ignore = ['E731']
max-line-length = 88
15 changes: 10 additions & 5 deletions pytest_tiny_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,28 @@
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA


import pytest
from unittest import mock

from typing import Any
from collections.abc import Generator
from collections.abc import Generator, Callable


def _api_call(endpoint: str, **kwargs) -> Any:
def _api_call(endpoint: str, **kwargs: Any) -> Any:
"""Placeholder function to patch when testing"""
return None


# Patch the method decorators with a call to `_api_call`
_method = lambda route, **k: lambda fn: lambda self: fn(self, _api_call(route, **k))
def _method(route: str, **k: Any) -> Callable[[Callable], Callable]:
return lambda fn: lambda self, *args, **_: fn(
self, _api_call(route, **k), *args
)


mock.patch('tiny_api_client.get', _method).start()
mock.patch('tiny_api_client.post', _method).start()
Expand All @@ -41,7 +46,7 @@ def _api_call(endpoint: str, **kwargs) -> Any:
mock.patch('tiny_api_client.delete', _method).start()


def pytest_sessionfinish(session, exitstatus):
def pytest_sessionfinish(session: pytest.Session, exitstatus: int) -> None:
mock.patch.stopall()


Expand Down

0 comments on commit 34b0166

Please sign in to comment.