From 60680e4c518be05a7822103d5b973ba2a16b1283 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 28 Mar 2024 11:29:26 -0400 Subject: [PATCH] fix(zipline): pylint fix --- pyzipline/zipline.py | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/pyzipline/zipline.py b/pyzipline/zipline.py index 6bf5608..66b5d42 100644 --- a/pyzipline/zipline.py +++ b/pyzipline/zipline.py @@ -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}")