From 19d458aba46eb7f64c677e5c1b1b40b64ebf56e7 Mon Sep 17 00:00:00 2001 From: rdimaio Date: Tue, 12 Mar 2024 17:34:57 +0100 Subject: [PATCH] Typing: Add type annotations to vo.py; #6454 --- lib/rucio/core/vo.py | 12 ++++++------ lib/rucio/daemons/automatix/automatix.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/rucio/core/vo.py b/lib/rucio/core/vo.py index f2d8a643dad..b451464eb2a 100644 --- a/lib/rucio/core/vo.py +++ b/lib/rucio/core/vo.py @@ -13,7 +13,7 @@ # limitations under the License. import re -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Any from sqlalchemy.exc import DatabaseError, IntegrityError from sqlalchemy.orm.exc import NoResultFound @@ -33,7 +33,7 @@ @read_session -def vo_exists(vo, *, session: "Session"): +def vo_exists(vo: str, *, session: "Session") -> bool: """ Verify that the vo exists. @@ -46,7 +46,7 @@ def vo_exists(vo, *, session: "Session"): @transactional_session -def add_vo(vo, description, email, *, session: "Session"): +def add_vo(vo: str, description: str, email: str, *, session: "Session") -> None: """ Add a VO and setup a new root user. New root user will have account name 'root' and a userpass identity with username: 'root@' and password: 'password' @@ -88,7 +88,7 @@ def add_vo(vo, description, email, *, session: "Session"): @read_session -def list_vos(*, session: "Session"): +def list_vos(*, session: "Session") -> list[dict[str, Any]]: """ List all the VOs in the db. @@ -113,7 +113,7 @@ def list_vos(*, session: "Session"): @transactional_session -def update_vo(vo, parameters, *, session: "Session"): +def update_vo(vo: str, parameters: dict[str, Any], *, session: "Session") -> None: """ Update VO properties (email, description). @@ -135,7 +135,7 @@ def update_vo(vo, parameters, *, session: "Session"): query.update(param) -def map_vo(vo): +def map_vo(vo: str) -> str: """ Converts a long VO name into the internal short (three letter) tag mapping. diff --git a/lib/rucio/daemons/automatix/automatix.py b/lib/rucio/daemons/automatix/automatix.py index 15b6cc06395..217176e35b7 100644 --- a/lib/rucio/daemons/automatix/automatix.py +++ b/lib/rucio/daemons/automatix/automatix.py @@ -165,7 +165,7 @@ def run_once(heartbeat_handler: "HeartbeatHandler", inputfile: str, **_kwargs) - account = config_get("automatix", "account", raise_exception=False, default="root") scope = config_get("automatix", "scope", raise_exception=False, default="test") client = Client(account=account) - vo = map_vo(client.vo) + vo = map_vo(client.vo) # type: ignore filters = {"scope": InternalScope("*", vo=vo)} scopes = list_scopes(filter_=filters) if InternalScope(scope, vo=vo) not in scopes: