Skip to content

Commit

Permalink
feat(pyproject): add N rule to ruff config
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Dec 2, 2024
1 parent 34095d8 commit a91be64
Show file tree
Hide file tree
Showing 36 changed files with 373 additions and 411 deletions.
6 changes: 4 additions & 2 deletions diracx-core/src/diracx/core/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from cachetools import Cache, LRUCache, TTLCache, cachedmethod
from pydantic import AnyUrl, BeforeValidator, TypeAdapter, UrlConstraints

from ..exceptions import BadConfigurationVersion
from ..exceptions import BadConfigurationVersionError
from ..extensions import select_from_extension
from .schema import Config

Expand Down Expand Up @@ -136,7 +136,9 @@ def latest_revision(self) -> tuple[str, datetime]:
try:
rev = self.repo.rev_parse(DEFAULT_GIT_BRANCH)
except git.exc.ODBError as e: # type: ignore
raise BadConfigurationVersion(f"Error parsing latest revision: {e}") from e
raise BadConfigurationVersionError(
f"Error parsing latest revision: {e}"
) from e
modified = rev.committed_datetime.astimezone(timezone.utc)
logger.debug(
"Latest revision for %s is %s with mtime %s", self, rev.hexsha, modified
Expand Down
1 change: 0 additions & 1 deletion diracx-core/src/diracx/core/config/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class DIRACConfig(BaseModel):

class JobMonitoringConfig(BaseModel):
GlobalJobsInfo: bool = True
useESForJobParametersFlag: bool = False


class JobSchedulingConfig(BaseModel):
Expand Down
6 changes: 3 additions & 3 deletions diracx-core/src/diracx/core/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from http import HTTPStatus


class DiracHttpResponse(RuntimeError):
class DiracHttpResponseError(RuntimeError):
def __init__(self, status_code: int, data):
self.status_code = status_code
self.data = data
Expand Down Expand Up @@ -30,15 +30,15 @@ class ConfigurationError(DiracError):
"""Used whenever we encounter a problem with the configuration."""


class BadConfigurationVersion(ConfigurationError):
class BadConfigurationVersionError(ConfigurationError):
"""The requested version is not known."""


class InvalidQueryError(DiracError):
"""It was not possible to build a valid database query from the given input."""


class JobNotFound(Exception):
class JobNotFoundError(Exception):
def __init__(self, job_id: int):
self.job_id: int = job_id
super().__init__(f"Job {job_id} not found")
2 changes: 1 addition & 1 deletion diracx-db/src/diracx/db/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
class DBUnavailable(Exception):
class DBUnavailableError(Exception):
pass
6 changes: 3 additions & 3 deletions diracx-db/src/diracx/db/os/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from diracx.core.exceptions import InvalidQueryError
from diracx.core.extensions import select_from_extension
from diracx.db.exceptions import DBUnavailable
from diracx.db.exceptions import DBUnavailableError

logger = logging.getLogger(__name__)

Expand All @@ -25,7 +25,7 @@ class OpenSearchDBError(Exception):
pass


class OpenSearchDBUnavailable(DBUnavailable, OpenSearchDBError):
class OpenSearchDBUnavailableError(DBUnavailableError, OpenSearchDBError):
pass


Expand Down Expand Up @@ -152,7 +152,7 @@ async def ping(self):
be ran at every query.
"""
if not await self.client.ping():
raise OpenSearchDBUnavailable(
raise OpenSearchDBUnavailableError(
f"Failed to connect to {self.__class__.__qualname__}"
)

Expand Down
4 changes: 2 additions & 2 deletions diracx-db/src/diracx/db/sql/dummy/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DummyDB(BaseSQLDB):
async def summary(self, group_by, search) -> list[dict[str, str | int]]:
columns = [Cars.__table__.columns[x] for x in group_by]

stmt = select(*columns, func.count(Cars.licensePlate).label("count"))
stmt = select(*columns, func.count(Cars.license_plate).label("count"))
stmt = apply_search_filters(Cars.__table__.columns.__getitem__, stmt, search)
stmt = stmt.group_by(*columns)

Expand All @@ -44,7 +44,7 @@ async def insert_owner(self, name: str) -> int:

async def insert_car(self, license_plate: UUID, model: str, owner_id: int) -> int:
stmt = insert(Cars).values(
licensePlate=license_plate, model=model, ownerID=owner_id
license_plate=license_plate, model=model, owner_id=owner_id
)

result = await self.conn.execute(stmt)
Expand Down
6 changes: 3 additions & 3 deletions diracx-db/src/diracx/db/sql/dummy/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

class Owners(Base):
__tablename__ = "Owners"
ownerID = Column(Integer, primary_key=True, autoincrement=True)
owner_id = Column(Integer, primary_key=True, autoincrement=True)
creation_time = DateNowColumn()
name = Column(String(255))


class Cars(Base):
__tablename__ = "Cars"
licensePlate = Column(Uuid(), primary_key=True)
license_plate = Column(Uuid(), primary_key=True)
model = Column(String(255))
ownerID = Column(Integer, ForeignKey(Owners.ownerID))
owner_id = Column(Integer, ForeignKey(Owners.owner_id))
Loading

0 comments on commit a91be64

Please sign in to comment.