Skip to content

Commit

Permalink
Testing: Add type annotations to core/permission; #6588
Browse files Browse the repository at this point in the history
  • Loading branch information
rdimaio authored and bari12 committed Apr 26, 2024
1 parent 695c4bc commit d4781f8
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 77 deletions.
14 changes: 11 additions & 3 deletions lib/rucio/core/permission/__init__.py
Expand Up @@ -15,7 +15,7 @@
import importlib
from configparser import NoOptionError, NoSectionError
from os import environ
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

from rucio.common import config, exception
from rucio.common.utils import check_policy_package_version
Expand All @@ -25,6 +25,8 @@

from sqlalchemy.orm import Session

from rucio.common.types import InternalAccount

# dictionary of permission modules for each VO
permission_modules = {}

Expand Down Expand Up @@ -72,7 +74,7 @@
permission_modules["def"] = module


def load_permission_for_vo(vo):
def load_permission_for_vo(vo: str) -> None:
GENERIC_FALLBACK = 'generic_multi_vo'
if config.config_has_section('policy'):
try:
Expand Down Expand Up @@ -101,7 +103,13 @@ def load_permission_for_vo(vo):
permission_modules[vo] = module


def has_permission(issuer, action, kwargs, *, session: "Optional[Session]" = None):
def has_permission(
issuer: "InternalAccount",
action: str,
kwargs: dict[str, Any],
*,
session: "Optional[Session]" = None
) -> bool:
if issuer.vo not in permission_modules:
load_permission_for_vo(issuer.vo)
return permission_modules[issuer.vo].has_permission(issuer, action, kwargs, session=session)

0 comments on commit d4781f8

Please sign in to comment.