Commit 2d67d862 authored by Jelle van der Waa's avatar Jelle van der Waa 🚧
Browse files

fix(aurweb): make mypy happy about converting list to set

Mypy does not like re-assigning package_ids declared as a List[int]
while we convert it to a set, just convert it to a set when required.
parent 1d633536
Pipeline #23891 passed with stages
in 3 minutes and 54 seconds
......@@ -219,9 +219,8 @@ async def packages_unflag(request: Request, package_ids: list[int] = [],
# Constructed below via looping through the packages query.
bases = set()
package_ids = set(package_ids) # Convert this to a set for O(1).
packages = db.query(models.Package).filter(
models.Package.ID.in_(package_ids)).all()
models.Package.ID.in_(set(package_ids))).all()
for pkg in packages:
has_cred = request.user.has_credential(
creds.PKGBASE_UNFLAG, approved=[pkg.PackageBase.Flagger])
......@@ -247,9 +246,8 @@ async def packages_notify(request: Request, package_ids: list[int] = [],
return error_tuple
bases = set()
package_ids = set(package_ids)
packages = db.query(models.Package).filter(
models.Package.ID.in_(package_ids)).all()
models.Package.ID.in_(set(package_ids))).all()
for pkg in packages:
if pkg.PackageBase not in bases:
......@@ -289,9 +287,8 @@ async def packages_unnotify(request: Request, package_ids: list[int] = [],
)
bases = set()
package_ids = set(package_ids)
packages = db.query(models.Package).filter(
models.Package.ID.in_(package_ids)).all()
models.Package.ID.in_(set(package_ids))).all()
for pkg in packages:
if pkg.PackageBase not in bases:
......@@ -322,9 +319,8 @@ async def packages_adopt(request: Request, package_ids: list[int] = [],
"check the confirmation checkbox."])
bases = set()
package_ids = set(package_ids)
packages = db.query(models.Package).filter(
models.Package.ID.in_(package_ids)).all()
models.Package.ID.in_(set(package_ids))).all()
for pkg in packages:
if pkg.PackageBase not in bases:
......@@ -366,9 +362,8 @@ async def packages_disown(request: Request, package_ids: list[int] = [],
"check the confirmation checkbox."])
bases = set()
package_ids = set(package_ids)
packages = db.query(models.Package).filter(
models.Package.ID.in_(package_ids)).all()
models.Package.ID.in_(set(package_ids))).all()
for pkg in packages:
if pkg.PackageBase not in bases:
......@@ -403,10 +398,8 @@ async def packages_delete(request: Request, package_ids: list[int] = [],
if not request.user.has_credential(creds.PKGBASE_DELETE):
return (False, ["You do not have permission to delete packages."])
# set-ify package_ids and query the database for related records.
package_ids = set(package_ids)
packages = db.query(models.Package).filter(
models.Package.ID.in_(package_ids)).all()
models.Package.ID.in_(set(package_ids))).all()
if len(packages) != len(package_ids):
# Let the user know there was an issue with their input: they have
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment