pylint fixes
All checks were successful
Actions / build (push) Successful in 11s
Actions / lint (push) Successful in 18s

This commit is contained in:
Seaswimmer 2024-09-15 23:18:56 -04:00
parent 78b87fd940
commit 997fd5437e
Signed by: cswimr
GPG key ID: 3813315477F26F82
6 changed files with 13 additions and 8 deletions

View file

@ -1,3 +1,6 @@
[MESSAGES CONTROL] [MESSAGES CONTROL]
disable= disable=
line-too-long, line-too-long,
missing-module-docstring,
too-many-arguments,
too-few-public-methods,

View file

@ -1,6 +1,6 @@
from pyflowery.models import FloweryAPIConfig, Language, Result, Voice from pyflowery.models import FloweryAPIConfig, Language, Result, Voice
from pyflowery.pyflowery import FloweryAPI from pyflowery.pyflowery import FloweryAPI
from pyflowery.version import version from pyflowery.version import VERSION
__all__ = [ __all__ = [
'FloweryAPI', 'FloweryAPI',
@ -8,5 +8,5 @@ __all__ = [
'Result', 'Result',
'Voice', 'Voice',
'Language', 'Language',
'version', 'VERSION',
] ]

View file

@ -2,7 +2,7 @@ from dataclasses import dataclass, field
from logging import Logger, getLogger from logging import Logger, getLogger
from typing import Dict, List, Union from typing import Dict, List, Union
from pyflowery.version import version from pyflowery.version import VERSION
@dataclass @dataclass
@ -57,6 +57,6 @@ class FloweryAPIConfig:
user_agent (str): User-Agent string to use for the HTTP requests user_agent (str): User-Agent string to use for the HTTP requests
logger (Logger): Logger to use for logging messages logger (Logger): Logger to use for logging messages
""" """
user_agent: str = f"PyFlowery/{version}" user_agent: str = f"PyFlowery/{VERSION}"
logger: Logger = getLogger('pyflowery') logger: Logger = getLogger('pyflowery')
allow_truncation: bool = False allow_truncation: bool = False

View file

@ -37,7 +37,7 @@ class RestAdapter:
'User-Agent': self._user_agent, 'User-Agent': self._user_agent,
} }
sanitized_params = {k: str(v) if isinstance(v, bool) else v for k, v in params.items()} if params else None sanitized_params = {k: str(v) if isinstance(v, bool) else v for k, v in params.items()} if params else None
self._logger.debug(f"Making {http_method} request to {full_url} with params {sanitized_params}") self._logger.debug("Making %s request to %s with params %s", http_method, full_url, sanitized_params)
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.request(method=http_method, url=full_url, params=sanitized_params, headers=headers, timeout=timeout) as response: async with session.request(method=http_method, url=full_url, params=sanitized_params, headers=headers, timeout=timeout) as response:
@ -52,7 +52,7 @@ class RestAdapter:
message=response.reason, message=response.reason,
data=data, data=data,
) )
self._logger.debug(f"Received response: {result.status_code} {result.message}") self._logger.debug("Received response: %s %s", response.status, response.reason)
return result return result
async def get(self, endpoint: str, params: dict = None, timeout: float = 60) -> Result: async def get(self, endpoint: str, params: dict = None, timeout: float = 60) -> Result:

View file

@ -1 +1 @@
version = "1.0.0" VERSION = "1.0.0"

View file

@ -17,16 +17,18 @@ root.addHandler(handler)
api = FloweryAPI(FloweryAPIConfig()) api = FloweryAPI(FloweryAPIConfig())
async def test_get_voices(): async def test_get_voices():
"""Test the get_voices method"""
async for voice in api.get_voices(): async for voice in api.get_voices():
if 'en' in voice.language.code: if 'en' in voice.language.code:
api.config.logger.info(voice) api.config.logger.info(voice)
async def test_get_tts(): async def test_get_tts():
"""Test the get_tts method"""
tts = await api.get_tts(text="BLAST HIM!", voice="191c5adc-a092-5eea-b4ff-ce01f66153ae") tts = await api.get_tts(text="BLAST HIM!", voice="191c5adc-a092-5eea-b4ff-ce01f66153ae")
try: try:
with open('test.mp3', 'wb') as f: with open('test.mp3', 'wb') as f:
f.write(tts) f.write(tts)
except Exception as e: except Exception as e: # pylint: disable=broad-except
api.config.logger.error(e, exc_info=True) api.config.logger.error(e, exc_info=True)
long_string = 'a' * 2049 long_string = 'a' * 2049
try: try: