Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing: Add type annotations to importer.py #6560

Merged
merged 1 commit into from Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/rucio/core/importer.py
Expand Up @@ -13,7 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any

from rucio.common.config import config_get
from rucio.common.exception import RSEOperationNotSupported
Expand All @@ -28,7 +29,7 @@


@transactional_session
def import_rses(rses, rse_sync_method='edit', attr_sync_method='edit', protocol_sync_method='edit', vo='def', *, session: "Session"):
def import_rses(rses: dict[str, dict[str, Any]], rse_sync_method: str = 'edit', attr_sync_method: str = 'edit', protocol_sync_method: str = 'edit', vo: str = 'def', *, session: "Session") -> None:
new_rses = []
for rse_name in rses:
rse = rses[rse_name]
Expand Down Expand Up @@ -136,7 +137,7 @@ def import_rses(rses, rse_sync_method='edit', attr_sync_method='edit', protocol_


@transactional_session
def import_distances(distances, vo='def', *, session: "Session"):
def import_distances(distances, vo: str = 'def', *, session: "Session") -> None:
for src_rse_name in distances:
src = rse_module.get_rse_id(rse=src_rse_name, vo=vo, session=session)
for dest_rse_name in distances[src_rse_name]:
Expand All @@ -156,7 +157,7 @@ def import_distances(distances, vo='def', *, session: "Session"):


@transactional_session
def import_identities(identities, account_name, old_identities, old_identity_account, account_email, *, session: "Session"):
def import_identities(identities: Iterable[dict[str, Any]], account_name: str, old_identities: Iterable[tuple], old_identity_account: tuple[str, str, str], account_email: str, *, session: "Session") -> None:
for identity in identities:
identity['type'] = IdentityType[identity['type'].upper()]

Expand Down Expand Up @@ -185,7 +186,7 @@ def import_identities(identities, account_name, old_identities, old_identity_acc


@transactional_session
def import_accounts(accounts, vo='def', *, session: "Session"):
def import_accounts(accounts: Iterable[dict[str, Any]], vo: str = 'def', *, session: "Session") -> None:
vo_filter = {'account': InternalAccount(account='*', vo=vo)}
old_accounts = {account['account']: account for account in account_module.list_accounts(filter_=vo_filter, session=session)}
missing_accounts = [account for account in accounts if account['account'] not in old_accounts]
Expand Down Expand Up @@ -222,7 +223,7 @@ def import_accounts(accounts, vo='def', *, session: "Session"):


@transactional_session
def import_data(data, vo='def', *, session: "Session"):
def import_data(data: dict[str, Any], vo: str = 'def', *, session: "Session") -> None:
"""
Import data to add and update records in Rucio.

Expand Down