From a9bb4a7122df6d9d4a764de52244c6ec75789ead Mon Sep 17 00:00:00 2001 From: Paolo Melchiorre Date: Mon, 5 Dec 2022 18:38:37 +0100 Subject: Add pyupgrade with --py310-plus in pre-commit (#103) --- users/models/identity.py | 8 ++++---- users/models/system_actor.py | 4 ++-- users/models/user.py | 4 +--- 3 files changed, 7 insertions(+), 9 deletions(-) (limited to 'users/models') diff --git a/users/models/identity.py b/users/models/identity.py index bbedceb..c674bf4 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -1,5 +1,5 @@ from functools import cached_property, partial -from typing import Dict, Literal, Optional, Tuple +from typing import Literal from urllib.parse import urlparse import httpx @@ -334,7 +334,7 @@ class Identity(StatorModel): ### Actor/Webfinger fetching ### @classmethod - async def fetch_webfinger(cls, handle: str) -> Tuple[Optional[str], Optional[str]]: + async def fetch_webfinger(cls, handle: str) -> tuple[str | None, str | None]: """ Given a username@domain handle, returns a tuple of (actor uri, canonical handle) or None, None if it does not resolve. @@ -458,7 +458,7 @@ class Identity(StatorModel): raise ValueError( f"Could not save Identity at end of actor fetch: {e}" ) - self.pk: Optional[int] = other_row.pk + self.pk: int | None = other_row.pk await sync_to_async(self.save)() return True @@ -468,7 +468,7 @@ class Identity(StatorModel): self, method: Literal["get", "post"], uri: str, - body: Optional[Dict] = None, + body: dict | None = None, ): """ Performs a signed request on behalf of the System Actor. diff --git a/users/models/system_actor.py b/users/models/system_actor.py index c337d78..c4319b9 100644 --- a/users/models/system_actor.py +++ b/users/models/system_actor.py @@ -1,4 +1,4 @@ -from typing import Dict, Literal, Optional +from typing import Literal from django.conf import settings @@ -57,7 +57,7 @@ class SystemActor: self, method: Literal["get", "post"], uri: str, - body: Optional[Dict] = None, + body: dict | None = None, ): """ Performs a signed request on behalf of the System Actor. diff --git a/users/models/user.py b/users/models/user.py index 08a703e..e0cac9d 100644 --- a/users/models/user.py +++ b/users/models/user.py @@ -1,5 +1,3 @@ -from typing import List - from django.contrib.auth.models import AbstractBaseUser, BaseUserManager from django.db import models @@ -42,7 +40,7 @@ class User(AbstractBaseUser): USERNAME_FIELD = "email" EMAIL_FIELD = "email" - REQUIRED_FIELDS: List[str] = [] + REQUIRED_FIELDS: list[str] = [] objects = UserManager() -- cgit v1.2.3