Skip to content

Commit 72318c5

Browse files
committed
Allow shadowing of 'id' built-in
1 parent b078ca3 commit 72318c5

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

minfraud/request.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ def prepare_report(request: dict[str, Any], validate: bool) -> dict[str, Any]:
271271
try:
272272
validate_report(cleaned_request)
273273
except MultipleInvalid as ex:
274-
raise InvalidRequestError(f"Invalid report data: {ex}") from ex
274+
msg = f"Invalid report data: {ex}"
275+
raise InvalidRequestError(msg) from ex
275276
return cleaned_request
276277

277278

@@ -286,7 +287,8 @@ def prepare_transaction(
286287
try:
287288
validate_transaction(cleaned_request)
288289
except MultipleInvalid as ex:
289-
raise InvalidRequestError(f"Invalid transaction data: {ex}") from ex
290+
msg = f"Invalid transaction data: {ex}"
291+
raise InvalidRequestError(msg) from ex
290292

291293
if hash_email:
292294
maybe_hash_email(cleaned_request)

minfraud/validation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ def _credit_card_token(s: str) -> str:
307307
def _uri(s: str) -> str:
308308
parsed = urllib.parse.urlparse(s)
309309
if parsed.scheme not in ["http", "https"] or not parsed.netloc:
310-
raise UrlInvalid("URL is invalid")
310+
msg = "URL is invalid"
311+
raise UrlInvalid(msg)
311312
return s
312313

313314

minfraud/webservice.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def _exception_for_4xx_status(
144144
except ValueError:
145145
return HTTPError(
146146
f"Received a {status} error but it did not "
147-
+ f"include the expected JSON body: {raw_body}",
147+
f"include the expected JSON body: {raw_body}",
148148
status,
149149
uri,
150150
raw_body,
@@ -288,7 +288,7 @@ async def factors(
288288
InvalidRequestError, HTTPError, MinFraudError,
289289
"""
290290
return cast(
291-
Factors,
291+
"Factors",
292292
await self._response_for(
293293
self._factors_uri,
294294
partial(Factors, self._locales),
@@ -327,7 +327,7 @@ async def insights(
327327
InvalidRequestError, HTTPError, MinFraudError,
328328
"""
329329
return cast(
330-
Insights,
330+
"Insights",
331331
await self._response_for(
332332
self._insights_uri,
333333
partial(Insights, self._locales),
@@ -366,7 +366,7 @@ async def score(
366366
InvalidRequestError, HTTPError, MinFraudError,
367367
"""
368368
return cast(
369-
Score,
369+
"Score",
370370
await self._response_for(
371371
self._score_uri,
372372
Score,
@@ -546,7 +546,7 @@ def factors(
546546
InvalidRequestError, HTTPError, MinFraudError,
547547
"""
548548
return cast(
549-
Factors,
549+
"Factors",
550550
self._response_for(
551551
self._factors_uri,
552552
partial(Factors, self._locales),
@@ -585,7 +585,7 @@ def insights(
585585
InvalidRequestError, HTTPError, MinFraudError,
586586
"""
587587
return cast(
588-
Insights,
588+
"Insights",
589589
self._response_for(
590590
self._insights_uri,
591591
partial(Insights, self._locales),
@@ -624,7 +624,7 @@ def score(
624624
InvalidRequestError, HTTPError, MinFraudError,
625625
"""
626626
return cast(
627-
Score,
627+
"Score",
628628
self._response_for(
629629
self._score_uri,
630630
Score,

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ ignore = [
8686
"PT027",
8787
]
8888

89+
[tool.ruff.lint.flake8-builtins]
90+
ignorelist = ["id"]
91+
8992
[tool.ruff.lint.per-file-ignores]
9093
"minfraud/models,.py" = [ "D107", "PLR0913" ]
9194
"tests/*" = ["ANN201", "D"]

tests/test_webservice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def test_200(self) -> None:
218218
response = json.loads(self.response)
219219
cls = self.cls
220220
if self.has_ip_location():
221-
cls = cast(Callable, partial(cls, ("en",)))
221+
cls = cast("Callable", partial(cls, ("en",)))
222222
self.assertEqual(cls(**response), model)
223223
if self.has_ip_location():
224224
self.assertEqual("United Kingdom", model.ip_address.country.name)

0 commit comments

Comments
 (0)