Skip to content

Commit 329c647

Browse files
committed
Improve type hinting slightly
1 parent 569ba46 commit 329c647

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

minfraud/validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def _transaction_id(s: Optional[str]) -> str:
423423
)
424424

425425

426-
def _validate_at_least_one_identifier_field(report) -> bool:
426+
def _validate_at_least_one_identifier_field(report: dict) -> bool:
427427
optional_fields = ["ip_address", "maxmind_id", "minfraud_id", "transaction_id"]
428428
if not any(field in report for field in optional_fields):
429429
# We return MultipleInvalid instead of ValueError to be consistent with what
@@ -442,7 +442,7 @@ def _validate_at_least_one_identifier_field(report) -> bool:
442442
return True
443443

444444

445-
def validate_report(report) -> bool:
445+
def validate_report(report: dict) -> bool:
446446
"""Validate minFraud Transaction Report fields."""
447447
_validate_report_schema(report)
448448
_validate_at_least_one_identifier_field(report)

tests/test_validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import unittest
44
from decimal import Decimal
5-
from typing import Any
5+
from typing import Any, Callable
66

77
from voluptuous import MultipleInvalid
88

@@ -33,7 +33,7 @@ def check_transaction_str_type(self, object: str, key: str) -> None:
3333
self.check_transaction({object: {key: "string"}})
3434
self.check_invalid_transaction({object: {key: 12}})
3535

36-
def check_positive_number(self, f) -> None:
36+
def check_positive_number(self, f: Callable) -> None:
3737
for good in (1, 1.1, Decimal("1.1")):
3838
self.check_transaction(f(good))
3939
for bad in ("1.2", "1", -1, -1.1, 0):

tests/test_webservice.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def test_missing_constructor_args(self) -> None:
201201
self.client_class(license_key="1234567890ab") # type: ignore[call-arg]
202202

203203
with self.assertRaises(TypeError):
204-
self.client_class("47") # type: ignore
204+
self.client_class("47") # type: ignore[arg-type,call-arg]
205205

206206

207207
class BaseTransactionTest(BaseTest):
@@ -385,7 +385,7 @@ def setUp(self) -> None:
385385
super().setUp()
386386

387387
def tearDown(self) -> None:
388-
self._loop.run_until_complete(self.client.close()) # type: ignore
388+
self._loop.run_until_complete(self.client.close()) # type: ignore[attr-defined]
389389
self._loop.close()
390390
super().tearDown()
391391

0 commit comments

Comments
 (0)