From 0b9aa643ce7d85f976871a3528749b80abfe7655 Mon Sep 17 00:00:00 2001 From: Javed Habib Date: Fri, 7 Jun 2024 17:28:18 +0530 Subject: [PATCH] =?UTF-8?q?nitpick=20(=20=CB=98=E2=96=BD=CB=98)=E3=81=A3?= =?UTF-8?q?=E2=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tesk/api/ga4gh/tes/base/base_tesk_request.py | 4 ++-- tesk/api/ga4gh/tes/controllers.py | 3 ++- tesk/api/ga4gh/tes/models/tes_service_info.py | 6 ++++-- tesk/api/ga4gh/tes/models/validators/base/base_validator.py | 2 +- tesk/api/ga4gh/tes/models/validators/rfc3339_validator.py | 4 +--- tesk/api/ga4gh/tes/service_info/service_info.py | 6 +++++- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/tesk/api/ga4gh/tes/base/base_tesk_request.py b/tesk/api/ga4gh/tes/base/base_tesk_request.py index ec0c8ae..30a234c 100644 --- a/tesk/api/ga4gh/tes/base/base_tesk_request.py +++ b/tesk/api/ga4gh/tes/base/base_tesk_request.py @@ -1,7 +1,7 @@ """Base classes for the TES API request.""" from abc import ABC, abstractmethod -from typing import final +from typing import Any, final from pydantic import BaseModel @@ -32,7 +32,7 @@ def api_response(self) -> BaseModel: pass @final - def response(self) -> dict: + def response(self) -> dict[Any, Any]: """Returns serialized response. Should be invoked by controller. diff --git a/tesk/api/ga4gh/tes/controllers.py b/tesk/api/ga4gh/tes/controllers.py index 7a355b4..80fb999 100644 --- a/tesk/api/ga4gh/tes/controllers.py +++ b/tesk/api/ga4gh/tes/controllers.py @@ -1,6 +1,7 @@ """Controllers for GA4GH TES API endpoints.""" import logging +from typing import Any # from connexion import request # type: ignore from foca.utils.logging import log_traffic # type: ignore @@ -38,7 +39,7 @@ def CreateTask(*args, **kwargs) -> dict: # type: ignore # GET /tasks/service-info @log_traffic -def GetServiceInfo() -> dict: +def GetServiceInfo() -> dict[Any, Any]: """Get service info.""" service_info = ServiceInfo() return service_info.response() diff --git a/tesk/api/ga4gh/tes/models/tes_service_info.py b/tesk/api/ga4gh/tes/models/tes_service_info.py index 70c91fc..abf4ffa 100644 --- a/tesk/api/ga4gh/tes/models/tes_service_info.py +++ b/tesk/api/ga4gh/tes/models/tes_service_info.py @@ -178,7 +178,7 @@ class TesServiceInfo(BaseModel): ) @validator('contactUrl') - def validate_url_and_email(cls, v): + def validate_url_and_email(cls, v: str) -> str: """Validate the contactURL format based on RFC 3986 or 2368 standard.""" url_validator = RFC3986Validator() email_validator = RFC2386Validator() @@ -190,4 +190,6 @@ def validate_url_and_email(cls, v): return url_validator.validate(cls, v) logger.error('contactUrl must be based on RFC 3986 or 2368 standard.') - raise ValidationError('contactUrl must be based on RFC 3986 or 2368 standard.') + raise ValidationError( + 'contactUrl must be based on RFC 3986 or 2368 standard.', model=cls + ) diff --git a/tesk/api/ga4gh/tes/models/validators/base/base_validator.py b/tesk/api/ga4gh/tes/models/validators/base/base_validator.py index dd0206d..f5bf3f9 100644 --- a/tesk/api/ga4gh/tes/models/validators/base/base_validator.py +++ b/tesk/api/ga4gh/tes/models/validators/base/base_validator.py @@ -48,7 +48,7 @@ def validation_logic(self, v: T) -> bool: """ pass - def _raise_error(self, cls: Any, v: T): + def _raise_error(self, cls: Any, v: T) -> None: """Raise a validation error. Args: diff --git a/tesk/api/ga4gh/tes/models/validators/rfc3339_validator.py b/tesk/api/ga4gh/tes/models/validators/rfc3339_validator.py index 05ce59e..4f19093 100644 --- a/tesk/api/ga4gh/tes/models/validators/rfc3339_validator.py +++ b/tesk/api/ga4gh/tes/models/validators/rfc3339_validator.py @@ -52,6 +52,4 @@ def validation_logic(self, v: str) -> bool: # Year 0 is not valid a valid date return False (_, max_day) = calendar.monthrange(year, month) - if not 1 <= day <= max_day: - return False - return True + return 1 <= day <= max_day diff --git a/tesk/api/ga4gh/tes/service_info/service_info.py b/tesk/api/ga4gh/tes/service_info/service_info.py index 57e8955..9a6058e 100644 --- a/tesk/api/ga4gh/tes/service_info/service_info.py +++ b/tesk/api/ga4gh/tes/service_info/service_info.py @@ -1,4 +1,8 @@ -"""Service info for TES API.""" +"""Service info for TES API. + +This module provides the TesServiceInfo class, which is +the response to the service info request for the TES API. +""" from tesk.api.ga4gh.tes.models.tes_service_info import TesServiceInfo from tesk.api.ga4gh.tes.models.tes_service_info_organization import (