Skip to content

Commit 995a60c

Browse files
committed
Enable deferred UP rules, require annotations future import
1 parent ebf5579 commit 995a60c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+301
-75
lines changed

accounts/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import annotations
2+
3+
14
__copyright__ = "Copyright (C) 2014 Andreas Kloeckner"
25

36
__license__ = """

accounts/apps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from django.apps import AppConfig
24
from django.utils.translation import gettext_lazy as _
35

accounts/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import annotations
2+
3+
14
__copyright__ = "Copyright (C) 2014 Andreas Kloeckner"
25

36
__license__ = """

accounts/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import annotations
2+
3+
14
__copyright__ = "Copyright (C) 2018 Dong Zhuang"
25

36
__license__ = """
@@ -143,7 +146,7 @@ def check_email_appellation_priority_list(self):
143146
if not custom_email_appellation_priority_list:
144147
return errors
145148

146-
if not isinstance(custom_email_appellation_priority_list, (list, tuple)):
149+
if not isinstance(custom_email_appellation_priority_list, list | tuple):
147150
errors.append(Warning(
148151
msg=("{}, {}".format(
149152
INSTANCE_ERROR_PATTERN

course/admin.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import annotations
2+
3+
14
__copyright__ = "Copyright (C) 2014 Andreas Kloeckner"
25

36
__license__ = """
@@ -20,7 +23,7 @@
2023
THE SOFTWARE.
2124
"""
2225

23-
from typing import Any, Tuple
26+
from typing import Any
2427

2528
from django import forms
2629
from django.contrib import admin
@@ -85,7 +88,7 @@ def _filter_participation_linked_obj_for_user(queryset, user):
8588

8689
# {{{ list filter helper
8790

88-
def _filter_related_only(filter_arg: str) -> Tuple[str, Any]:
91+
def _filter_related_only(filter_arg: str) -> tuple[str, Any]:
8992
return (filter_arg, admin.RelatedOnlyFieldListFilter)
9093

9194
# }}}

course/analytics.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import annotations
2+
3+
14
__copyright__ = "Copyright (C) 2014 Andreas Kloeckner"
25

36
__license__ = """

course/apps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from django.apps import AppConfig
24
from django.utils.translation import gettext_lazy as _
35

course/calendar.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import annotations
2+
3+
14
__copyright__ = "Copyright (C) 2014 Andreas Kloeckner"
25

36
__license__ = """

course/constants.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import annotations
2+
3+
14
__copyright__ = "Copyright (C) 2014 Andreas Kloeckner"
25

36
__license__ = """
@@ -20,7 +23,6 @@
2023
THE SOFTWARE.
2124
"""
2225

23-
import typing
2426

2527
from django.utils.translation import gettext, pgettext_lazy
2628

@@ -296,7 +298,7 @@ class flow_session_expiration_mode: # noqa
296298

297299

298300
def is_expiration_mode_allowed(
299-
expmode: str, permissions: typing.FrozenSet[str]
301+
expmode: str, permissions: frozenset[str]
300302
) -> bool:
301303
if expmode == flow_session_expiration_mode.roll_over:
302304
if (flow_permission.set_roll_over_expiration_mode

course/content.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import os
2929
import re
3030
import sys
31-
from typing import Union, cast
31+
from typing import cast
3232

3333
import dulwich.objects
3434
import dulwich.repo
@@ -51,10 +51,10 @@
5151

5252
# {{{ mypy
5353

54+
from collections.abc import Callable
5455
from typing import (
5556
TYPE_CHECKING,
5657
Any,
57-
Callable,
5858
)
5959

6060

@@ -67,8 +67,8 @@
6767
from course.validation import FileSystemFakeRepoTree, ValidationContext
6868
from relate.utils import Repo_ish
6969

70-
Date_ish = Union[datetime.datetime, datetime.date]
71-
Datespec = Union[datetime.datetime, datetime.date, str]
70+
Date_ish = datetime.datetime | datetime.date
71+
Datespec = datetime.datetime | datetime.date | str
7272

7373

7474
class ChunkRulesDesc(Struct):
@@ -662,7 +662,7 @@ def look_up_git_object(repo: dulwich.repo.Repo,
662662

663663
from stat import S_ISLNK
664664
while name_parts:
665-
if not isinstance(cur_lookup, (Tree, FileSystemFakeRepoTree)):
665+
if not isinstance(cur_lookup, Tree | FileSystemFakeRepoTree):
666666
raise ObjectDoesNotExist(
667667
_("'%s' is not a directory, cannot lookup nested names")
668668
% os.sep.join(processed_name_parts))
@@ -719,7 +719,7 @@ def get_repo_tree(repo: Repo_ish, full_name: str, commit_sha: bytes) -> Tree_ish
719719

720720
msg_full_name = full_name if full_name else _("(repo root)")
721721

722-
if isinstance(git_obj, (Tree, FileSystemFakeRepoTree)):
722+
if isinstance(git_obj, Tree | FileSystemFakeRepoTree):
723723
return git_obj
724724
else:
725725
raise ObjectDoesNotExist(_("resource '%s' is not a tree") % msg_full_name)
@@ -749,7 +749,7 @@ def get_repo_blob(repo: Repo_ish, full_name: str, commit_sha: bytes) -> Blob_ish
749749

750750
msg_full_name = full_name if full_name else _("(repo root)")
751751

752-
if isinstance(git_obj, (Blob, FileSystemFakeRepoFile)):
752+
if isinstance(git_obj, Blob | FileSystemFakeRepoFile):
753753
return git_obj
754754
else:
755755
raise ObjectDoesNotExist(_("resource '%s' is not a file") % msg_full_name)

0 commit comments

Comments
 (0)