mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
refactor: remove redundand parenthesis when return tuple
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
This commit is contained in:
parent
d793193fdf
commit
7e06823e58
11 changed files with 34 additions and 34 deletions
|
@ -127,7 +127,7 @@ class BasicAuthBackend(AuthenticationBackend):
|
||||||
user.nonce = util.make_nonce()
|
user.nonce = util.make_nonce()
|
||||||
user.authenticated = True
|
user.authenticated = True
|
||||||
|
|
||||||
return (AuthCredentials(["authenticated"]), user)
|
return AuthCredentials(["authenticated"]), user
|
||||||
|
|
||||||
|
|
||||||
def _auth_required(auth_goal: bool = True):
|
def _auth_required(auth_goal: bool = True):
|
||||||
|
|
|
@ -52,7 +52,7 @@ def parse_dep(depstring):
|
||||||
depname = re.sub(r"(<|=|>).*", "", dep)
|
depname = re.sub(r"(<|=|>).*", "", dep)
|
||||||
depcond = dep[len(depname) :]
|
depcond = dep[len(depname) :]
|
||||||
|
|
||||||
return (depname, desc, depcond)
|
return depname, desc, depcond
|
||||||
|
|
||||||
|
|
||||||
def create_pkgbase(conn, pkgbase, user):
|
def create_pkgbase(conn, pkgbase, user):
|
||||||
|
|
|
@ -239,12 +239,12 @@ def source_uri(pkgsrc: models.PackageSource) -> Tuple[str, str]:
|
||||||
the package base name.
|
the package base name.
|
||||||
|
|
||||||
:param pkgsrc: PackageSource instance
|
:param pkgsrc: PackageSource instance
|
||||||
:return (text, uri) tuple
|
:return text, uri)tuple
|
||||||
"""
|
"""
|
||||||
if "::" in pkgsrc.Source:
|
if "::" in pkgsrc.Source:
|
||||||
return pkgsrc.Source.split("::", 1)
|
return pkgsrc.Source.split("::", 1)
|
||||||
elif "://" in pkgsrc.Source:
|
elif "://" in pkgsrc.Source:
|
||||||
return (pkgsrc.Source, pkgsrc.Source)
|
return pkgsrc.Source, pkgsrc.Source
|
||||||
path = config.get("options", "source_file_uri")
|
path = config.get("options", "source_file_uri")
|
||||||
pkgbasename = pkgsrc.Package.PackageBase.Name
|
pkgbasename = pkgsrc.Package.PackageBase.Name
|
||||||
return (pkgsrc.Source, path % (pkgsrc.Source, pkgbasename))
|
return pkgsrc.Source, path % (pkgsrc.Source, pkgbasename)
|
||||||
|
|
|
@ -160,9 +160,9 @@ def process_account_form(request: Request, user: models.User, args: dict[str, An
|
||||||
for check in checks:
|
for check in checks:
|
||||||
check(**args, request=request, user=user, _=_)
|
check(**args, request=request, user=user, _=_)
|
||||||
except ValidationError as exc:
|
except ValidationError as exc:
|
||||||
return (False, exc.data)
|
return False, exc.data
|
||||||
|
|
||||||
return (True, [])
|
return True, []
|
||||||
|
|
||||||
|
|
||||||
def make_account_form_context(
|
def make_account_form_context(
|
||||||
|
|
|
@ -213,7 +213,7 @@ async def package(
|
||||||
|
|
||||||
async def packages_unflag(request: Request, package_ids: list[int] = [], **kwargs):
|
async def packages_unflag(request: Request, package_ids: list[int] = [], **kwargs):
|
||||||
if not package_ids:
|
if not package_ids:
|
||||||
return (False, ["You did not select any packages to unflag."])
|
return False, ["You did not select any packages to unflag."]
|
||||||
|
|
||||||
# Holds the set of package bases we're looking to unflag.
|
# Holds the set of package bases we're looking to unflag.
|
||||||
# Constructed below via looping through the packages query.
|
# Constructed below via looping through the packages query.
|
||||||
|
@ -226,14 +226,14 @@ async def packages_unflag(request: Request, package_ids: list[int] = [], **kwarg
|
||||||
creds.PKGBASE_UNFLAG, approved=[pkg.PackageBase.Flagger]
|
creds.PKGBASE_UNFLAG, approved=[pkg.PackageBase.Flagger]
|
||||||
)
|
)
|
||||||
if not has_cred:
|
if not has_cred:
|
||||||
return (False, ["You did not select any packages to unflag."])
|
return False, ["You did not select any packages to unflag."]
|
||||||
|
|
||||||
if pkg.PackageBase not in bases:
|
if pkg.PackageBase not in bases:
|
||||||
bases.update({pkg.PackageBase})
|
bases.update({pkg.PackageBase})
|
||||||
|
|
||||||
for pkgbase in bases:
|
for pkgbase in bases:
|
||||||
pkgbase_actions.pkgbase_unflag_instance(request, pkgbase)
|
pkgbase_actions.pkgbase_unflag_instance(request, pkgbase)
|
||||||
return (True, ["The selected packages have been unflagged."])
|
return True, ["The selected packages have been unflagged."]
|
||||||
|
|
||||||
|
|
||||||
async def packages_notify(request: Request, package_ids: list[int] = [], **kwargs):
|
async def packages_notify(request: Request, package_ids: list[int] = [], **kwargs):
|
||||||
|
@ -271,13 +271,13 @@ async def packages_notify(request: Request, package_ids: list[int] = [], **kwarg
|
||||||
pkgbase_actions.pkgbase_notify_instance(request, pkgbase)
|
pkgbase_actions.pkgbase_notify_instance(request, pkgbase)
|
||||||
|
|
||||||
# TODO: This message does not yet have a translation.
|
# TODO: This message does not yet have a translation.
|
||||||
return (True, ["The selected packages' notifications have been enabled."])
|
return True, ["The selected packages' notifications have been enabled."]
|
||||||
|
|
||||||
|
|
||||||
async def packages_unnotify(request: Request, package_ids: list[int] = [], **kwargs):
|
async def packages_unnotify(request: Request, package_ids: list[int] = [], **kwargs):
|
||||||
if not package_ids:
|
if not package_ids:
|
||||||
# TODO: This error does not yet have a translation.
|
# TODO: This error does not yet have a translation.
|
||||||
return (False, ["You did not select any packages for notification removal."])
|
return False, ["You did not select any packages for notification removal."]
|
||||||
|
|
||||||
# TODO: This error does not yet have a translation.
|
# TODO: This error does not yet have a translation.
|
||||||
error_tuple = (
|
error_tuple = (
|
||||||
|
@ -307,14 +307,14 @@ async def packages_unnotify(request: Request, package_ids: list[int] = [], **kwa
|
||||||
pkgbase_actions.pkgbase_unnotify_instance(request, pkgbase)
|
pkgbase_actions.pkgbase_unnotify_instance(request, pkgbase)
|
||||||
|
|
||||||
# TODO: This message does not yet have a translation.
|
# TODO: This message does not yet have a translation.
|
||||||
return (True, ["The selected packages' notifications have been removed."])
|
return True, ["The selected packages' notifications have been removed."]
|
||||||
|
|
||||||
|
|
||||||
async def packages_adopt(
|
async def packages_adopt(
|
||||||
request: Request, package_ids: list[int] = [], confirm: bool = False, **kwargs
|
request: Request, package_ids: list[int] = [], confirm: bool = False, **kwargs
|
||||||
):
|
):
|
||||||
if not package_ids:
|
if not package_ids:
|
||||||
return (False, ["You did not select any packages to adopt."])
|
return False, ["You did not select any packages to adopt."]
|
||||||
|
|
||||||
if not confirm:
|
if not confirm:
|
||||||
return (
|
return (
|
||||||
|
@ -347,7 +347,7 @@ async def packages_adopt(
|
||||||
for pkgbase in bases:
|
for pkgbase in bases:
|
||||||
pkgbase_actions.pkgbase_adopt_instance(request, pkgbase)
|
pkgbase_actions.pkgbase_adopt_instance(request, pkgbase)
|
||||||
|
|
||||||
return (True, ["The selected packages have been adopted."])
|
return True, ["The selected packages have been adopted."]
|
||||||
|
|
||||||
|
|
||||||
def disown_all(request: Request, pkgbases: list[models.PackageBase]) -> list[str]:
|
def disown_all(request: Request, pkgbases: list[models.PackageBase]) -> list[str]:
|
||||||
|
@ -364,7 +364,7 @@ async def packages_disown(
|
||||||
request: Request, package_ids: list[int] = [], confirm: bool = False, **kwargs
|
request: Request, package_ids: list[int] = [], confirm: bool = False, **kwargs
|
||||||
):
|
):
|
||||||
if not package_ids:
|
if not package_ids:
|
||||||
return (False, ["You did not select any packages to disown."])
|
return False, ["You did not select any packages to disown."]
|
||||||
|
|
||||||
if not confirm:
|
if not confirm:
|
||||||
return (
|
return (
|
||||||
|
@ -397,9 +397,9 @@ async def packages_disown(
|
||||||
|
|
||||||
# Now, disown all the bases if we can.
|
# Now, disown all the bases if we can.
|
||||||
if errors := disown_all(request, bases):
|
if errors := disown_all(request, bases):
|
||||||
return (False, errors)
|
return False, errors
|
||||||
|
|
||||||
return (True, ["The selected packages have been disowned."])
|
return True, ["The selected packages have been disowned."]
|
||||||
|
|
||||||
|
|
||||||
async def packages_delete(
|
async def packages_delete(
|
||||||
|
@ -410,7 +410,7 @@ async def packages_delete(
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
if not package_ids:
|
if not package_ids:
|
||||||
return (False, ["You did not select any packages to delete."])
|
return False, ["You did not select any packages to delete."]
|
||||||
|
|
||||||
if not confirm:
|
if not confirm:
|
||||||
return (
|
return (
|
||||||
|
@ -422,7 +422,7 @@ async def packages_delete(
|
||||||
)
|
)
|
||||||
|
|
||||||
if not request.user.has_credential(creds.PKGBASE_DELETE):
|
if not request.user.has_credential(creds.PKGBASE_DELETE):
|
||||||
return (False, ["You do not have permission to delete packages."])
|
return False, ["You do not have permission to delete packages."]
|
||||||
|
|
||||||
# set-ify package_ids and query the database for related records.
|
# set-ify package_ids and query the database for related records.
|
||||||
package_ids = set(package_ids)
|
package_ids = set(package_ids)
|
||||||
|
@ -432,7 +432,7 @@ async def packages_delete(
|
||||||
# Let the user know there was an issue with their input: they have
|
# Let the user know there was an issue with their input: they have
|
||||||
# provided at least one package_id which does not exist in the DB.
|
# provided at least one package_id which does not exist in the DB.
|
||||||
# TODO: This error has not yet been translated.
|
# TODO: This error has not yet been translated.
|
||||||
return (False, ["One of the packages you selected does not exist."])
|
return False, ["One of the packages you selected does not exist."]
|
||||||
|
|
||||||
# Make a set out of all package bases related to `packages`.
|
# Make a set out of all package bases related to `packages`.
|
||||||
bases = {pkg.PackageBase for pkg in packages}
|
bases = {pkg.PackageBase for pkg in packages}
|
||||||
|
@ -448,7 +448,7 @@ async def packages_delete(
|
||||||
)
|
)
|
||||||
|
|
||||||
util.apply_all(notifs, lambda n: n.send())
|
util.apply_all(notifs, lambda n: n.send())
|
||||||
return (True, ["The selected packages have been deleted."])
|
return True, ["The selected packages have been deleted."]
|
||||||
|
|
||||||
|
|
||||||
# A mapping of action string -> callback functions used within the
|
# A mapping of action string -> callback functions used within the
|
||||||
|
|
|
@ -46,7 +46,7 @@ class FlysprayLinksInlineProcessor(markdown.inlinepatterns.InlineProcessor):
|
||||||
el = Element("a")
|
el = Element("a")
|
||||||
el.set("href", f"https://bugs.archlinux.org/task/{m.group(1)}")
|
el.set("href", f"https://bugs.archlinux.org/task/{m.group(1)}")
|
||||||
el.text = markdown.util.AtomicString(m.group(0))
|
el.text = markdown.util.AtomicString(m.group(0))
|
||||||
return (el, m.start(0), m.end(0))
|
return el, m.start(0), m.end(0)
|
||||||
|
|
||||||
|
|
||||||
class FlysprayLinksExtension(markdown.extensions.Extension):
|
class FlysprayLinksExtension(markdown.extensions.Extension):
|
||||||
|
@ -74,7 +74,7 @@ class GitCommitsInlineProcessor(markdown.inlinepatterns.InlineProcessor):
|
||||||
oid = m.group(1)
|
oid = m.group(1)
|
||||||
if oid not in self._repo:
|
if oid not in self._repo:
|
||||||
# Unknown OID; preserve the orginal text.
|
# Unknown OID; preserve the orginal text.
|
||||||
return (None, None, None)
|
return None, None, None
|
||||||
|
|
||||||
el = Element("a")
|
el = Element("a")
|
||||||
commit_uri = aurweb.config.get("options", "commit_uri")
|
commit_uri = aurweb.config.get("options", "commit_uri")
|
||||||
|
@ -83,7 +83,7 @@ class GitCommitsInlineProcessor(markdown.inlinepatterns.InlineProcessor):
|
||||||
"href", commit_uri % (quote_plus(self._head), quote_plus(oid[:prefixlen]))
|
"href", commit_uri % (quote_plus(self._head), quote_plus(oid[:prefixlen]))
|
||||||
)
|
)
|
||||||
el.text = markdown.util.AtomicString(oid[:prefixlen])
|
el.text = markdown.util.AtomicString(oid[:prefixlen])
|
||||||
return (el, m.start(0), m.end(0))
|
return el, m.start(0), m.end(0)
|
||||||
|
|
||||||
|
|
||||||
class GitCommitsExtension(markdown.extensions.Extension):
|
class GitCommitsExtension(markdown.extensions.Extension):
|
||||||
|
|
|
@ -107,7 +107,7 @@ def sanitize_params(offset: str, per_page: str) -> Tuple[int, int]:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
per_page = defaults.PP
|
per_page = defaults.PP
|
||||||
|
|
||||||
return (offset, per_page)
|
return offset, per_page
|
||||||
|
|
||||||
|
|
||||||
def strtobool(value: Union[str, bool]) -> bool:
|
def strtobool(value: Union[str, bool]) -> bool:
|
||||||
|
@ -187,7 +187,7 @@ def parse_ssh_key(string: str) -> Tuple[str, str]:
|
||||||
if proc.returncode:
|
if proc.returncode:
|
||||||
raise invalid_exc
|
raise invalid_exc
|
||||||
|
|
||||||
return (prefix, key)
|
return prefix, key
|
||||||
|
|
||||||
|
|
||||||
def parse_ssh_keys(string: str) -> list[Tuple[str, str]]:
|
def parse_ssh_keys(string: str) -> list[Tuple[str, str]]:
|
||||||
|
@ -199,4 +199,4 @@ def shell_exec(cmdline: str, cwd: str) -> Tuple[int, str, str]:
|
||||||
args = shlex.split(cmdline)
|
args = shlex.split(cmdline)
|
||||||
proc = Popen(args, cwd=cwd, stdout=PIPE, stderr=PIPE)
|
proc = Popen(args, cwd=cwd, stdout=PIPE, stderr=PIPE)
|
||||||
out, err = proc.communicate()
|
out, err = proc.communicate()
|
||||||
return (proc.returncode, out.decode().strip(), err.decode().strip())
|
return proc.returncode, out.decode().strip(), err.decode().strip()
|
||||||
|
|
|
@ -1149,7 +1149,7 @@ def test_packages_post_unknown_action(client: TestClient, user: User, package: P
|
||||||
|
|
||||||
def test_packages_post_error(client: TestClient, user: User, package: Package):
|
def test_packages_post_error(client: TestClient, user: User, package: Package):
|
||||||
async def stub_action(request: Request, **kwargs):
|
async def stub_action(request: Request, **kwargs):
|
||||||
return (False, ["Some error."])
|
return False, ["Some error."]
|
||||||
|
|
||||||
actions = {"stub": stub_action}
|
actions = {"stub": stub_action}
|
||||||
with mock.patch.dict("aurweb.routers.packages.PACKAGE_ACTIONS", actions):
|
with mock.patch.dict("aurweb.routers.packages.PACKAGE_ACTIONS", actions):
|
||||||
|
@ -1170,7 +1170,7 @@ def test_packages_post_error(client: TestClient, user: User, package: Package):
|
||||||
|
|
||||||
def test_packages_post(client: TestClient, user: User, package: Package):
|
def test_packages_post(client: TestClient, user: User, package: Package):
|
||||||
async def stub_action(request: Request, **kwargs):
|
async def stub_action(request: Request, **kwargs):
|
||||||
return (True, ["Some success."])
|
return True, ["Some success."]
|
||||||
|
|
||||||
actions = {"stub": stub_action}
|
actions = {"stub": stub_action}
|
||||||
with mock.patch.dict("aurweb.routers.packages.PACKAGE_ACTIONS", actions):
|
with mock.patch.dict("aurweb.routers.packages.PACKAGE_ACTIONS", actions):
|
||||||
|
|
|
@ -1315,7 +1315,7 @@ def test_packages_post_unknown_action(client: TestClient, user: User, package: P
|
||||||
|
|
||||||
def test_packages_post_error(client: TestClient, user: User, package: Package):
|
def test_packages_post_error(client: TestClient, user: User, package: Package):
|
||||||
async def stub_action(request: Request, **kwargs):
|
async def stub_action(request: Request, **kwargs):
|
||||||
return (False, ["Some error."])
|
return False, ["Some error."]
|
||||||
|
|
||||||
actions = {"stub": stub_action}
|
actions = {"stub": stub_action}
|
||||||
with mock.patch.dict("aurweb.routers.packages.PACKAGE_ACTIONS", actions):
|
with mock.patch.dict("aurweb.routers.packages.PACKAGE_ACTIONS", actions):
|
||||||
|
@ -1336,7 +1336,7 @@ def test_packages_post_error(client: TestClient, user: User, package: Package):
|
||||||
|
|
||||||
def test_packages_post(client: TestClient, user: User, package: Package):
|
def test_packages_post(client: TestClient, user: User, package: Package):
|
||||||
async def stub_action(request: Request, **kwargs):
|
async def stub_action(request: Request, **kwargs):
|
||||||
return (True, ["Some success."])
|
return True, ["Some success."]
|
||||||
|
|
||||||
actions = {"stub": stub_action}
|
actions = {"stub": stub_action}
|
||||||
with mock.patch.dict("aurweb.routers.packages.PACKAGE_ACTIONS", actions):
|
with mock.patch.dict("aurweb.routers.packages.PACKAGE_ACTIONS", actions):
|
||||||
|
|
|
@ -24,7 +24,7 @@ class FakeProcess:
|
||||||
"""We need this constructor to remain compatible with Popen."""
|
"""We need this constructor to remain compatible with Popen."""
|
||||||
|
|
||||||
def communicate(self) -> Tuple[bytes, bytes]:
|
def communicate(self) -> Tuple[bytes, bytes]:
|
||||||
return (self.stdout, self.stderr)
|
return self.stdout, self.stderr
|
||||||
|
|
||||||
def terminate(self) -> None:
|
def terminate(self) -> None:
|
||||||
raise Exception("Fake termination.")
|
raise Exception("Fake termination.")
|
||||||
|
|
|
@ -42,7 +42,7 @@ def email_pieces(voteinfo: TUVoteInfo) -> Tuple[str, str]:
|
||||||
f"[1]. The voting period\nends in less than 48 hours.\n\n"
|
f"[1]. The voting period\nends in less than 48 hours.\n\n"
|
||||||
f"[1] {aur_location}/tu/?id={voteinfo.ID}"
|
f"[1] {aur_location}/tu/?id={voteinfo.ID}"
|
||||||
)
|
)
|
||||||
return (subject, content)
|
return subject, content
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
Loading…
Add table
Reference in a new issue