Skip to content

Commit

Permalink
Typing: Add type annotations to distance.py; #6454
Browse files Browse the repository at this point in the history
  • Loading branch information
rdimaio committed Mar 12, 2024
1 parent c8316a5 commit 95f480d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/rucio/core/distance.py
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Optional

from sqlalchemy.exc import DatabaseError, IntegrityError
from sqlalchemy.orm import aliased
Expand All @@ -27,7 +27,7 @@


@transactional_session
def add_distance(src_rse_id, dest_rse_id, distance=None, *, session: "Session"):
def add_distance(src_rse_id: str, dest_rse_id: str, distance: Optional[int] = None, *, session: "Session") -> None:
"""
Add a src-dest distance.
Expand All @@ -47,9 +47,9 @@ def add_distance(src_rse_id, dest_rse_id, distance=None, *, session: "Session"):


@read_session
def get_distances(src_rse_id=None, dest_rse_id=None, *, session: "Session") -> list[dict]:
def get_distances(src_rse_id: Optional[str] = None, dest_rse_id: Optional[str] = None, *, session: "Session") -> list[dict[str, Any]]:
"""
Get distances between rses.
Get distances between RSEs.
:param src_rse_id: The source RSE ID.
:param dest_rse_id: The destination RSE ID.
Expand Down Expand Up @@ -78,9 +78,9 @@ def get_distances(src_rse_id=None, dest_rse_id=None, *, session: "Session") -> l


@transactional_session
def delete_distances(src_rse_id=None, dest_rse_id=None, *, session: "Session"):
def delete_distances(src_rse_id: Optional[str] = None, dest_rse_id: Optional[str] = None, *, session: "Session") -> None:
"""
Delete distances with the given RSE ids.
Delete distances with the given RSE IDs.
:param src_rse_id: The source RSE ID.
:param dest_rse_id: The destination RSE ID.
Expand All @@ -101,9 +101,9 @@ def delete_distances(src_rse_id=None, dest_rse_id=None, *, session: "Session"):


@transactional_session
def update_distances(src_rse_id=None, dest_rse_id=None, distance=None, *, session: "Session"):
def update_distances(src_rse_id: Optional[str] = None, dest_rse_id: Optional[str] = None, distance: Optional[str] = None, *, session: "Session") -> None:
"""
Update distances with the given RSE ids.
Update distances with the given RSE IDs.
:param src_rse_id: The source RSE ID.
:param dest_rse_id: The destination RSE ID.
Expand All @@ -122,7 +122,7 @@ def update_distances(src_rse_id=None, dest_rse_id=None, distance=None, *, sessio


@read_session
def list_distances(filter_={}, *, session: "Session"):
def list_distances(filter_: dict[str, Any] = {}, *, session: "Session") -> list[dict[str, Any]]:
"""
Get distances between all the RSEs.
Expand All @@ -133,7 +133,7 @@ def list_distances(filter_={}, *, session: "Session"):


@read_session
def export_distances(vo='def', *, session: "Session"):
def export_distances(vo: str = 'def', *, session: "Session") -> dict[str, Any]:
"""
Export distances between all the RSEs using RSE ids.
:param vo: The VO to export.
Expand Down

0 comments on commit 95f480d

Please sign in to comment.