mirror of https://github.com/zulip/zulip.git
ruff: Fix UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
0fa5e7f629
commit
1464009fae
|
@ -500,7 +500,7 @@ def catch_stripe_errors(func: Callable[ParamT, ReturnT]) -> Callable[ParamT, Ret
|
||||||
err.get("code"),
|
err.get("code"),
|
||||||
err.get("param"),
|
err.get("param"),
|
||||||
)
|
)
|
||||||
if isinstance(e, (stripe.RateLimitError, stripe.APIConnectionError)): # nocoverage TODO
|
if isinstance(e, stripe.RateLimitError | stripe.APIConnectionError): # nocoverage TODO
|
||||||
raise StripeConnectionError(
|
raise StripeConnectionError(
|
||||||
"stripe connection error",
|
"stripe connection error",
|
||||||
_("Something went wrong. Please wait a few seconds and try again."),
|
_("Something went wrong. Please wait a few seconds and try again."),
|
||||||
|
@ -3252,7 +3252,7 @@ class BillingSession(ABC):
|
||||||
def get_sponsorship_request_context(self) -> dict[str, Any] | None:
|
def get_sponsorship_request_context(self) -> dict[str, Any] | None:
|
||||||
customer = self.get_customer()
|
customer = self.get_customer()
|
||||||
is_remotely_hosted = isinstance(
|
is_remotely_hosted = isinstance(
|
||||||
self, (RemoteRealmBillingSession, RemoteServerBillingSession)
|
self, RemoteRealmBillingSession | RemoteServerBillingSession
|
||||||
)
|
)
|
||||||
|
|
||||||
plan_name = "Zulip Cloud Free"
|
plan_name = "Zulip Cloud Free"
|
||||||
|
|
|
@ -6495,7 +6495,7 @@ class TestRemoteBillingWriteAuditLog(StripeTestCase):
|
||||||
audit_log_model = cast(
|
audit_log_model = cast(
|
||||||
type[RemoteRealmAuditLog] | type[RemoteZulipServerAuditLog], audit_log_class
|
type[RemoteRealmAuditLog] | type[RemoteZulipServerAuditLog], audit_log_class
|
||||||
)
|
)
|
||||||
assert isinstance(remote_user, (RemoteRealmBillingUser, RemoteServerBillingUser))
|
assert isinstance(remote_user, RemoteRealmBillingUser | RemoteServerBillingUser)
|
||||||
# No acting user:
|
# No acting user:
|
||||||
session = session_class(remote_object)
|
session = session_class(remote_object)
|
||||||
session.write_to_audit_log(
|
session.write_to_audit_log(
|
||||||
|
|
|
@ -113,7 +113,7 @@ class NumberType:
|
||||||
OpenAPI, because isinstance(4, float) == False"""
|
OpenAPI, because isinstance(4, float) == False"""
|
||||||
|
|
||||||
def check_data(self, var_name: str, val: Any | None) -> None:
|
def check_data(self, var_name: str, val: Any | None) -> None:
|
||||||
if isinstance(val, (int, float)):
|
if isinstance(val, int | float):
|
||||||
return
|
return
|
||||||
raise AssertionError(f"{var_name} is not a number")
|
raise AssertionError(f"{var_name} is not a number")
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ class TupleType:
|
||||||
sub_types: Sequence[Any]
|
sub_types: Sequence[Any]
|
||||||
|
|
||||||
def check_data(self, var_name: str, val: Any) -> None:
|
def check_data(self, var_name: str, val: Any) -> None:
|
||||||
if not isinstance(val, (list, tuple)):
|
if not isinstance(val, list | tuple):
|
||||||
raise AssertionError(f"{var_name} is not a list/tuple")
|
raise AssertionError(f"{var_name} is not a list/tuple")
|
||||||
|
|
||||||
if len(val) != len(self.sub_types):
|
if len(val) != len(self.sub_types):
|
||||||
|
|
|
@ -624,7 +624,7 @@ def check_string_or_int_list(var_name: str, val: object) -> str | list[int]:
|
||||||
|
|
||||||
|
|
||||||
def check_string_or_int(var_name: str, val: object) -> str | int:
|
def check_string_or_int(var_name: str, val: object) -> str | int:
|
||||||
if isinstance(val, (str, int)):
|
if isinstance(val, str | int):
|
||||||
return val
|
return val
|
||||||
|
|
||||||
raise ValidationError(_("{var_name} is not a string or integer").format(var_name=var_name))
|
raise ValidationError(_("{var_name} is not a string or integer").format(var_name=var_name))
|
||||||
|
@ -654,7 +654,7 @@ class WildValue:
|
||||||
return self.value == other
|
return self.value == other
|
||||||
|
|
||||||
def __len__(self) -> int:
|
def __len__(self) -> int:
|
||||||
if not isinstance(self.value, (dict, list, str)):
|
if not isinstance(self.value, dict | list | str):
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_("{var_name} does not have a length").format(var_name=self.var_name)
|
_("{var_name} does not have a length").format(var_name=self.var_name)
|
||||||
)
|
)
|
||||||
|
|
|
@ -254,7 +254,7 @@ cURL example."""
|
||||||
|
|
||||||
# Booleans are effectively JSON-encoded, in that we pass
|
# Booleans are effectively JSON-encoded, in that we pass
|
||||||
# true/false, not the Python str(True) = "True"
|
# true/false, not the Python str(True) = "True"
|
||||||
if parameter.json_encoded or isinstance(example_value, (bool, float, int)):
|
if parameter.json_encoded or isinstance(example_value, bool | float | int):
|
||||||
example_value = json.dumps(example_value)
|
example_value = json.dumps(example_value)
|
||||||
else:
|
else:
|
||||||
assert isinstance(example_value, str)
|
assert isinstance(example_value, str)
|
||||||
|
|
|
@ -175,7 +175,7 @@ def check_prereg_key(
|
||||||
prereg_object = get_object_from_key(
|
prereg_object = get_object_from_key(
|
||||||
confirmation_key, confirmation_types, mark_object_used=False
|
confirmation_key, confirmation_types, mark_object_used=False
|
||||||
)
|
)
|
||||||
assert isinstance(prereg_object, (PreregistrationRealm, PreregistrationUser))
|
assert isinstance(prereg_object, PreregistrationRealm | PreregistrationUser)
|
||||||
|
|
||||||
confirmation_obj = prereg_object.confirmation.get()
|
confirmation_obj = prereg_object.confirmation.get()
|
||||||
realm_creation = confirmation_obj.type == Confirmation.REALM_CREATION
|
realm_creation = confirmation_obj.type == Confirmation.REALM_CREATION
|
||||||
|
|
|
@ -100,7 +100,7 @@ def sentry_tunnel(
|
||||||
# failing to connect at the TCP level will report as
|
# failing to connect at the TCP level will report as
|
||||||
# ProxyErrors.
|
# ProxyErrors.
|
||||||
def open_circuit_for(exc_type: type[Exception], exc_value: Exception) -> bool:
|
def open_circuit_for(exc_type: type[Exception], exc_value: Exception) -> bool:
|
||||||
if issubclass(exc_type, (ProxyError, Timeout)):
|
if issubclass(exc_type, ProxyError | Timeout):
|
||||||
return True
|
return True
|
||||||
if isinstance(exc_value, HTTPError):
|
if isinstance(exc_value, HTTPError):
|
||||||
response = exc_value.response
|
response = exc_value.response
|
||||||
|
|
Loading…
Reference in New Issue