mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(python): use standard dict/list type annotation
Since Python 3.9 list/dict can be used as type hint.
This commit is contained in:
parent
28970ccc91
commit
a509e40474
31 changed files with 175 additions and 195 deletions
|
@ -1,4 +1,4 @@
|
|||
from typing import List, Optional, Set
|
||||
from typing import Optional, Set
|
||||
|
||||
from fastapi import Request
|
||||
from sqlalchemy import and_, orm
|
||||
|
@ -139,7 +139,7 @@ def close_pkgreq(pkgreq: PackageRequest, closer: User,
|
|||
|
||||
def handle_request(request: Request, reqtype_id: int,
|
||||
pkgbase: PackageBase,
|
||||
target: PackageBase = None) -> List[notify.Notification]:
|
||||
target: PackageBase = None) -> list[notify.Notification]:
|
||||
"""
|
||||
Handle package requests before performing an action.
|
||||
|
||||
|
@ -158,7 +158,7 @@ def handle_request(request: Request, reqtype_id: int,
|
|||
:param pkgbase: PackageBase which the request is about
|
||||
:param target: Optional target to merge into
|
||||
"""
|
||||
notifs: List[notify.Notification] = []
|
||||
notifs: list[notify.Notification] = []
|
||||
|
||||
# If it's an orphan request, perform further verification
|
||||
# regarding existing requests.
|
||||
|
@ -187,13 +187,13 @@ def handle_request(request: Request, reqtype_id: int,
|
|||
PackageRequest.MergeBaseName == target.Name)
|
||||
|
||||
# Build an accept list out of `accept_query`.
|
||||
to_accept: List[PackageRequest] = accept_query.all()
|
||||
to_accept: list[PackageRequest] = accept_query.all()
|
||||
accepted_ids: Set[int] = set(p.ID for p in to_accept)
|
||||
|
||||
# Build a reject list out of `query` filtered by IDs not found
|
||||
# in `to_accept`. That is, unmatched records of the same base
|
||||
# query properties.
|
||||
to_reject: List[PackageRequest] = query.filter(
|
||||
to_reject: list[PackageRequest] = query.filter(
|
||||
~PackageRequest.ID.in_(accepted_ids)
|
||||
).all()
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from collections import defaultdict
|
||||
from http import HTTPStatus
|
||||
from typing import Dict, List, Tuple, Union
|
||||
from typing import Tuple, Union
|
||||
|
||||
import orjson
|
||||
|
||||
|
@ -15,7 +15,7 @@ from aurweb.models.package_relation import PackageRelation
|
|||
from aurweb.redis import redis_connection
|
||||
from aurweb.templates import register_filter
|
||||
|
||||
Providers = List[Union[PackageRelation, OfficialProvider]]
|
||||
Providers = list[Union[PackageRelation, OfficialProvider]]
|
||||
|
||||
|
||||
def dep_extra_with_arch(dep: models.PackageDependency, annotation: str) -> str:
|
||||
|
@ -123,7 +123,7 @@ def out_of_date(packages: orm.Query) -> orm.Query:
|
|||
|
||||
|
||||
def updated_packages(limit: int = 0,
|
||||
cache_ttl: int = 600) -> List[models.Package]:
|
||||
cache_ttl: int = 600) -> list[models.Package]:
|
||||
""" Return a list of valid Package objects ordered by their
|
||||
ModifiedTS column in descending order from cache, after setting
|
||||
the cache when no key yet exists.
|
||||
|
@ -168,8 +168,8 @@ def updated_packages(limit: int = 0,
|
|||
return packages
|
||||
|
||||
|
||||
def query_voted(query: List[models.Package],
|
||||
user: models.User) -> Dict[int, bool]:
|
||||
def query_voted(query: list[models.Package],
|
||||
user: models.User) -> dict[int, bool]:
|
||||
""" Produce a dictionary of package base ID keys to boolean values,
|
||||
which indicate whether or not the package base has a vote record
|
||||
related to user.
|
||||
|
@ -191,8 +191,8 @@ def query_voted(query: List[models.Package],
|
|||
return output
|
||||
|
||||
|
||||
def query_notified(query: List[models.Package],
|
||||
user: models.User) -> Dict[int, bool]:
|
||||
def query_notified(query: list[models.Package],
|
||||
user: models.User) -> dict[int, bool]:
|
||||
""" Produce a dictionary of package base ID keys to boolean values,
|
||||
which indicate whether or not the package base has a notification
|
||||
record related to user.
|
||||
|
@ -214,8 +214,8 @@ def query_notified(query: List[models.Package],
|
|||
return output
|
||||
|
||||
|
||||
def pkg_required(pkgname: str, provides: List[str]) \
|
||||
-> List[PackageDependency]:
|
||||
def pkg_required(pkgname: str, provides: list[str]) \
|
||||
-> list[PackageDependency]:
|
||||
"""
|
||||
Get dependencies that match a string in `[pkgname] + provides`.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue