Skip to content

Commit

Permalink
Use new syntax for isinstance of union (#2036)
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Apr 30, 2024
1 parent e786b48 commit aa0d976
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion funnel/loginproviders/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def callback(self) -> LoginProviderData:

email = None
emails = []
if ghemails and isinstance(ghemails, (list, tuple)):
if ghemails and isinstance(ghemails, list | tuple):
for result in ghemails:
if result.get('verified') and not result['email'].endswith(
'@users.noreply.github.com'
Expand Down
2 changes: 1 addition & 1 deletion funnel/models/shortlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class ShortLinkToBigIntComparator(Comparator): # pylint: disable=abstract-metho

def __eq__(self, other: Any) -> sa.ColumnElement[bool]: # type: ignore[override]
"""Return an expression for column == other."""
if isinstance(other, (str, bytes)):
if isinstance(other, str | bytes):
return self.__clause_element__() == name_to_bigint(
other
) # type: ignore[return-value]
Expand Down
2 changes: 1 addition & 1 deletion funnel/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def do_migrate_table(table: sa.Table) -> bool:
old_instance, new_instance
)
session.flush()
if isinstance(result, (list, tuple, set)):
if isinstance(result, list | tuple | set):
migrated_tables.update(result)
migrated_tables.add(model.__table__.name)
except IncompleteUserMigrationError:
Expand Down
2 changes: 1 addition & 1 deletion funnel/transports/sms/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def send_via_exotel(
if r.status_code in (200, 201):
# All good
jsonresponse = r.json()
if isinstance(jsonresponse, (list, tuple)) and jsonresponse:
if isinstance(jsonresponse, list | tuple) and jsonresponse:
transactionid = jsonresponse[0].get('SMSMessage', {}).get('Sid')
elif isinstance(jsonresponse, dict):
transactionid = jsonresponse.get('SMSMessage', {}).get('Sid')
Expand Down
4 changes: 2 additions & 2 deletions funnel/utils/jinja_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def visit_Include(self, node: nodes.Include, frame: Frame) -> None: # noqa: N80
super().visit_Include(node, frame)
template: str | list[str] | None = None
include_template: Any = node.template
if isinstance(include_template, (nodes.Tuple, nodes.List)):
if isinstance(include_template, nodes.Tuple | nodes.List):
try:
include_template = include_template.as_const(frame.eval_ctx)
except nodes.Impossible:
Expand All @@ -138,7 +138,7 @@ def visit_Include(self, node: nodes.Include, frame: Frame) -> None: # noqa: N80
include_template = include_template.value
if isinstance(include_template, str):
template = include_template
elif isinstance(include_template, (tuple, list)):
elif isinstance(include_template, tuple | list):
template = list(include_template)
else:
warnings.warn(
Expand Down
4 changes: 2 additions & 2 deletions funnel/views/otp.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ def make(
# to this cache entry in the user's cookie session. The cookie never contains
# the actual OTP. See :func:`make_cached_token` for additional documentation.
otp = newpin()
if isinstance(anchor, (AccountPhone, PhoneNumber)):
if isinstance(anchor, AccountPhone | PhoneNumber):
phone = str(anchor)
if isinstance(anchor, (AccountEmail, AccountEmailClaim, EmailAddress)):
if isinstance(anchor, AccountEmail | AccountEmailClaim | EmailAddress):
email = str(anchor)
token = make_cached_token(
{
Expand Down

0 comments on commit aa0d976

Please sign in to comment.