fix(zipline): pylint fix
Some checks failed
Actions / Build Documentation (MkDocs) (push) Failing after 12s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 13s

This commit is contained in:
SeaswimmerTheFsh 2024-03-28 11:29:26 -04:00
parent 35abc609a7
commit 60680e4c51
Signed by: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -1,34 +1,15 @@
"""This module contains the ZiplineApi class, which is the main class used to interact with the Zipline API."""
import logging
from datetime import datetime, timedelta
from typing import List, Union
from pydantic import BaseModel, ConfigDict
from pyzipline.exceptions import (FeatureDisabledError, Forbidden, NotFound,
PyZiplineError)
from pyzipline.models import File, Invite, Result, Stats, User, Version
from pyzipline.models import (File, Invite, Result, Stats, User, Version,
ZiplineApiConfig)
from pyzipline.rest_adapter import RestAdapter
from pyzipline.utils import convert_datetime_to_str
class ZiplineApiConfig(BaseModel):
"""Represents a configuration instance for the ZiplineApi class.
Args:
hostname (str): The hostname of your Zipline instance, WITHOUT https or http.
token (str): String used for authentication when making requests.
ssl (bool): Normally set to True, but if your Zipline instance doesn't use SSL/TLS, set this to False.
enforced_signing (bool): Normally set to True, but if having SSL/TLS cert validation issues, can turn off with False.
logger (logging.Logger): If your app has a logger, pass it in here.
"""
model_config = ConfigDict(arbitrary_types_allowed=True)
hostname: str
token: str = ''
ssl: bool = True
enforced_signing: bool = True
logger: logging.Logger = logging.getLogger(__name__)
# pylint: disable=not-a-mapping
class ZiplineApi:
"""Represents an instance of the Zipline API.
@ -494,3 +475,15 @@ class ZiplineApi:
if result.status_code == 401:
raise Forbidden(result.message)
raise PyZiplineError(f"{result.status_code}: {result.message}\n{result.data}")
Forbidden: The user is not authenticated
PyZiplineError: Raised if the API changes, causing a breaking change in this method
Returns:
Version: The version of the Zipline instance
"""
result = self._rest_adapter.get(endpoint="version")
if result.status_code == 200:
return Version(**result.data)
if result.status_code == 401:
raise Forbidden(result.message)
raise PyZiplineError(f"{result.status_code}: {result.message}\n{result.data}")