Skip to content

Commit 71b8052

Browse files
committed
Allow shadowing of 'id' built-in
1 parent 28cb679 commit 71b8052

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
@@ -149,7 +149,7 @@ def _exception_for_4xx_status(
149149
except ValueError:
150150
return HTTPError(
151151
f"Received a {status} error but it did not "
152-
+ f"include the expected JSON body: {raw_body}",
152+
f"include the expected JSON body: {raw_body}",
153153
status,
154154
uri,
155155
raw_body,
@@ -293,7 +293,7 @@ async def factors(
293293
InvalidRequestError, HTTPError, MinFraudError,
294294
"""
295295
return cast(
296-
Factors,
296+
"Factors",
297297
await self._response_for(
298298
self._factors_uri,
299299
partial(Factors, self._locales),
@@ -332,7 +332,7 @@ async def insights(
332332
InvalidRequestError, HTTPError, MinFraudError,
333333
"""
334334
return cast(
335-
Insights,
335+
"Insights",
336336
await self._response_for(
337337
self._insights_uri,
338338
partial(Insights, self._locales),
@@ -371,7 +371,7 @@ async def score(
371371
InvalidRequestError, HTTPError, MinFraudError,
372372
"""
373373
return cast(
374-
Score,
374+
"Score",
375375
await self._response_for(
376376
self._score_uri,
377377
Score,
@@ -551,7 +551,7 @@ def factors(
551551
InvalidRequestError, HTTPError, MinFraudError,
552552
"""
553553
return cast(
554-
Factors,
554+
"Factors",
555555
self._response_for(
556556
self._factors_uri,
557557
partial(Factors, self._locales),
@@ -590,7 +590,7 @@ def insights(
590590
InvalidRequestError, HTTPError, MinFraudError,
591591
"""
592592
return cast(
593-
Insights,
593+
"Insights",
594594
self._response_for(
595595
self._insights_uri,
596596
partial(Insights, self._locales),
@@ -629,7 +629,7 @@ def score(
629629
InvalidRequestError, HTTPError, MinFraudError,
630630
"""
631631
return cast(
632-
Score,
632+
"Score",
633633
self._response_for(
634634
self._score_uri,
635635
Score,

pyproject.toml

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

91+
[tool.ruff.lint.flake8-builtins]
92+
ignorelist = ["id"]
93+
9194
[tool.ruff.lint.per-file-ignores]
9295
"minfraud/models,.py" = [ "D107", "PLR0913" ]
9396
"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)