Skip to content

Commit 6eca6b0

Browse files
authored
Merge pull request #194 from maxmind/greg/eng-2244
Fixes for Ruff 0.12.0
2 parents 789a7e8 + a60b063 commit 6eca6b0

File tree

3 files changed

+602
-575
lines changed

3 files changed

+602
-575
lines changed

minfraud/models.py

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

33
from __future__ import annotations
44

5+
import json
56
from typing import TYPE_CHECKING
67

78
import geoip2.models
@@ -18,6 +19,10 @@ def __eq__(self, other: object) -> bool:
1819
def __ne__(self, other: object) -> bool:
1920
return not self.__eq__(other)
2021

22+
def __hash__(self) -> int:
23+
# This is not particularly efficient, but I don't expect it to be used much.
24+
return hash(json.dumps(self.to_dict(), sort_keys=True))
25+
2126
def to_dict(self) -> dict: # noqa: C901
2227
"""Return a dict of the object suitable for serialization."""
2328
result = {}
@@ -322,9 +327,9 @@ def __init__(
322327
self,
323328
domain: dict | None = None,
324329
first_seen: str | None = None,
325-
is_disposable: bool | None = None,
326-
is_free: bool | None = None,
327-
is_high_risk: bool | None = None,
330+
is_disposable: bool | None = None, # noqa: FBT001
331+
is_free: bool | None = None, # noqa: FBT001
332+
is_high_risk: bool | None = None, # noqa: FBT001
328333
) -> None:
329334
"""Initialize an Email instance."""
330335
self.domain = EmailDomain(**(domain or {}))
@@ -376,10 +381,10 @@ def __init__(
376381
issuer: dict | None = None,
377382
country: str | None = None,
378383
brand: str | None = None,
379-
is_business: bool | None = None,
380-
is_issued_in_billing_address_country: bool | None = None,
381-
is_prepaid: bool | None = None,
382-
is_virtual: bool | None = None,
384+
is_business: bool | None = None, # noqa: FBT001
385+
is_issued_in_billing_address_country: bool | None = None, # noqa: FBT001
386+
is_prepaid: bool | None = None, # noqa: FBT001
387+
is_virtual: bool | None = None, # noqa: FBT001
383388
type: str | None = None, # noqa: A002
384389
) -> None:
385390
"""Initialize a CreditCard instance."""

minfraud/request.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ def _clean_domain(domain: str) -> str:
354354

355355
idx = domain.rfind(".")
356356
if idx != -1:
357-
# flake8: noqa: E203
358357
tld = domain[idx + 1 :]
359358
if typo_tld := _TYPO_TLDS.get(tld):
360359
domain = domain[:idx] + "." + typo_tld
@@ -370,7 +369,6 @@ def _clean_email(address: str) -> tuple[str | None, str | None]:
370369
if at_idx == -1:
371370
return None, None
372371

373-
# flake8: noqa: E203
374372
domain = _clean_domain(address[at_idx + 1 :])
375373
local_part = address[:at_idx]
376374

0 commit comments

Comments
 (0)