Skip to content

Commit

Permalink
style: pyupgrade --py311-plus
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Aug 29, 2024
1 parent f8660c1 commit df532ab
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 22 deletions.
6 changes: 3 additions & 3 deletions diracx-core/src/diracx/core/config/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import os
from datetime import datetime
from typing import Annotated, Any, Optional, TypeVar
from typing import Annotated, Any, TypeVar

from pydantic import BaseModel as _BaseModel
from pydantic import ConfigDict, EmailStr, Field, PrivateAttr, model_validator
Expand Down Expand Up @@ -65,10 +65,10 @@ class GroupConfig(BaseModel):
AutoUploadProxy: bool = False
JobShare: int = 1000
Properties: SerializableSet[SecurityProperty]
Quota: Optional[int] = None
Quota: int | None = None
Users: SerializableSet[str]
AllowBackgroundTQs: bool = False
VOMSRole: Optional[str] = None
VOMSRole: str | None = None
AutoSyncVOMS: bool = False


Expand Down
3 changes: 2 additions & 1 deletion diracx-core/src/diracx/core/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import inspect
import operator
from typing import Any, Callable
from collections.abc import Callable
from typing import Any

from pydantic import GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
Expand Down
3 changes: 2 additions & 1 deletion diracx-core/src/diracx/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
)

import contextlib
from collections.abc import AsyncIterator
from pathlib import Path
from typing import Annotated, Any, AsyncIterator, Self, TypeVar
from typing import Annotated, Any, Self, TypeVar

from authlib.jose import JsonWebKey
from cryptography.fernet import Fernet
Expand Down
3 changes: 2 additions & 1 deletion diracx-db/src/diracx/db/os/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import logging
import os
from abc import ABCMeta, abstractmethod
from collections.abc import AsyncIterator
from contextvars import ContextVar
from datetime import datetime
from typing import Any, AsyncIterator, Self
from typing import Any, Self

from opensearchpy import AsyncOpenSearch

Expand Down
4 changes: 1 addition & 3 deletions diracx-db/src/diracx/db/sql/job/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,7 @@ async def set_properties(
"""
# Check that all we always update the same set of properties
required_parameters_set = set(
[tuple(sorted(k.keys())) for k in properties.values()]
)
required_parameters_set = {tuple(sorted(k.keys())) for k in properties.values()}

if len(required_parameters_set) != 1:
raise NotImplementedError(
Expand Down
3 changes: 2 additions & 1 deletion diracx-db/src/diracx/db/sql/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import logging
import os
from abc import ABCMeta
from collections.abc import AsyncIterator
from contextvars import ContextVar
from datetime import datetime, timedelta, timezone
from functools import partial
from typing import TYPE_CHECKING, AsyncIterator, Self, cast
from typing import TYPE_CHECKING, Self, cast

from pydantic import TypeAdapter
from sqlalchemy import Column as RawColumn
Expand Down
16 changes: 7 additions & 9 deletions diracx-routers/src/diracx/routers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import inspect
import logging
import os
from collections.abc import AsyncGenerator
from collections.abc import AsyncGenerator, Awaitable, Callable, Iterable, Sequence
from functools import partial
from logging import Formatter, StreamHandler
from typing import Any, Awaitable, Callable, Iterable, Sequence, TypeVar, cast
from typing import Any, TypeVar, cast

import dotenv
from cachetools import TTLCache
Expand Down Expand Up @@ -346,12 +346,10 @@ def create_app() -> DiracFastAPI:

# Find all the access policies

available_access_policy_names = set(
[
entry_point.name
for entry_point in select_from_extension(group="diracx.access_policies")
]
)
available_access_policy_names = {
entry_point.name
for entry_point in select_from_extension(group="diracx.access_policies")
}

all_access_policies = {}

Expand Down Expand Up @@ -428,7 +426,7 @@ async def is_db_unavailable(db: BaseSQLDB | BaseOSDB) -> str:
return _db_alive_cache[db]


async def db_transaction(db: T2) -> AsyncGenerator[T2, None]:
async def db_transaction(db: T2) -> AsyncGenerator[T2]:
"""Initiate a DB transaction."""
# Entering the context already triggers a connection to the DB
# that may fail
Expand Down
3 changes: 2 additions & 1 deletion diracx-routers/src/diracx/routers/access_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import os
import time
from abc import ABCMeta, abstractmethod
from typing import Annotated, Callable, Self
from collections.abc import Callable
from typing import Annotated, Self

from fastapi import Depends

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

from collections.abc import Callable
from enum import StrEnum, auto
from typing import Annotated, Callable
from typing import Annotated

from fastapi import Depends, HTTPException, status

Expand Down
3 changes: 2 additions & 1 deletion diracx-routers/src/diracx/routers/job_manager/sandboxes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

import contextlib
from collections.abc import AsyncIterator
from http import HTTPStatus
from typing import TYPE_CHECKING, Annotated, AsyncIterator, Literal
from typing import TYPE_CHECKING, Annotated, Literal

from aiobotocore.session import get_session
from botocore.config import Config
Expand Down

0 comments on commit df532ab

Please sign in to comment.