(3.1.0)
- improved version logic - now using hatch and hatch-vcs to automatically generate versions based on git tag / git commit / distance from last tag - raise an error if the voices cache is not populated correctly - lint with mypy in actions - use pyproject.toml for pylint configuration
This commit is contained in:
parent
a7113babb7
commit
c4205fc4f1
10 changed files with 66 additions and 28 deletions
|
@ -45,7 +45,7 @@ jobs:
|
||||||
password: ${{ secrets.PYPI_API_TOKEN }}
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
name: Lint with Ruff & Pylint
|
name: Lint with Ruff, Pylint, & MyPy
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container: www.coastalcommits.com/cswimr/actions:uv
|
container: www.coastalcommits.com/cswimr/actions:uv
|
||||||
steps:
|
steps:
|
||||||
|
@ -65,7 +65,16 @@ jobs:
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Analysing code with Pylint
|
- name: Analysing code with Pylint
|
||||||
run: uv run pylint --rcfile=.forgejo/workflows/config/.pylintrc $(git ls-files '*.py')
|
run: uv run pylint $(git ls-files '*.py')
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Type checking with MyPy
|
||||||
|
run: uv run mypy $(git ls-files '*.py')
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Running tests # this will be moved to a separate job once I actually migrate to a dedicated test suite
|
||||||
|
run: uv run tests/tests.py
|
||||||
|
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
name: Build Documentation
|
name: Build Documentation
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[MESSAGES CONTROL]
|
|
||||||
disable=
|
|
||||||
line-too-long,
|
|
||||||
missing-module-docstring,
|
|
||||||
too-many-arguments,
|
|
||||||
too-few-public-methods,
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -167,3 +167,6 @@ test.mp3
|
||||||
|
|
||||||
# actions artifacts
|
# actions artifacts
|
||||||
1/
|
1/
|
||||||
|
|
||||||
|
# automatically generated version file
|
||||||
|
pyflowery/version.py
|
||||||
|
|
|
@ -7,7 +7,7 @@ from pyflowery.exceptions import (
|
||||||
)
|
)
|
||||||
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",
|
||||||
|
@ -15,7 +15,7 @@ __all__ = [
|
||||||
"Language",
|
"Language",
|
||||||
"Result",
|
"Result",
|
||||||
"Voice",
|
"Voice",
|
||||||
"VERSION",
|
"__version__",
|
||||||
"ResponseError",
|
"ResponseError",
|
||||||
"ClientError",
|
"ClientError",
|
||||||
"InternalServerError",
|
"InternalServerError",
|
||||||
|
|
|
@ -3,7 +3,7 @@ from logging import Logger, getLogger
|
||||||
from sys import version as pyversion
|
from sys import version as pyversion
|
||||||
from typing import Dict, List, Union
|
from typing import Dict, List, Union
|
||||||
|
|
||||||
from pyflowery.version import VERSION
|
from pyflowery.version import version
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
@ -79,4 +79,4 @@ class FloweryAPIConfig:
|
||||||
@property
|
@property
|
||||||
def prepended_user_agent(self) -> str:
|
def prepended_user_agent(self) -> str:
|
||||||
"""Return the user_agent with the PyFlowery module version prepended"""
|
"""Return the user_agent with the PyFlowery module version prepended"""
|
||||||
return f"PyFlowery/{VERSION} {self.user_agent} (Python {pyversion})"
|
return f"PyFlowery/{version} {self.user_agent} (Python {pyversion})"
|
||||||
|
|
|
@ -31,10 +31,9 @@ class FloweryAPI:
|
||||||
async def _populate_voices_cache(self) -> None:
|
async def _populate_voices_cache(self) -> None:
|
||||||
"""Populate the voices cache. This method is called automatically when the FloweryAPI object is created, and should not be called directly."""
|
"""Populate the voices cache. This method is called automatically when the FloweryAPI object is created, and should not be called directly."""
|
||||||
self._voices_cache = tuple([voice async for voice in self.fetch_voices()]) # pylint: disable=consider-using-generator
|
self._voices_cache = tuple([voice async for voice in self.fetch_voices()]) # pylint: disable=consider-using-generator
|
||||||
if self._voices_cache == ():
|
if not self._voices_cache:
|
||||||
raise ValueError("Failed to populate voices cache! Please report this issue at https://www.coastalcommits.com/cswimr/PyFlowery/issues.")
|
raise ValueError("Failed to populate voices cache! Please report this issue at https://www.coastalcommits.com/cswimr/PyFlowery/issues.")
|
||||||
else:
|
self.config.logger.info("Voices cache populated!")
|
||||||
self.config.logger.info("Voices cache populated!")
|
|
||||||
|
|
||||||
def get_voices(self, voice_id: str | None = None, name: str | None = None) -> Tuple[Voice, ...] | None:
|
def get_voices(self, voice_id: str | None = None, name: str | None = None) -> Tuple[Voice, ...] | None:
|
||||||
"""Get a set of voices from the cache.
|
"""Get a set of voices from the cache.
|
||||||
|
@ -150,7 +149,5 @@ class FloweryAPI:
|
||||||
if request is not None:
|
if request is not None:
|
||||||
if isinstance(request.data, bytes):
|
if isinstance(request.data, bytes):
|
||||||
return request.data
|
return request.data
|
||||||
else:
|
raise ResponseError(f"Invalid response from Flowery API: {request.data!r}")
|
||||||
raise ResponseError(f"Invalid response from Flowery API: {request.data!r}")
|
raise ResponseError("Invalid response from Flowery API: Empty Response!}")
|
||||||
else:
|
|
||||||
raise ResponseError("Invalid response from Flowery API: Empty Response!}")
|
|
||||||
|
|
|
@ -1 +1,16 @@
|
||||||
VERSION = "3.0.1"
|
# file generated by setuptools_scm
|
||||||
|
# don't change, don't track in version control
|
||||||
|
TYPE_CHECKING = False
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from typing import Tuple, Union
|
||||||
|
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
||||||
|
else:
|
||||||
|
VERSION_TUPLE = object
|
||||||
|
|
||||||
|
version: str
|
||||||
|
__version__: str
|
||||||
|
__version_tuple__: VERSION_TUPLE
|
||||||
|
version_tuple: VERSION_TUPLE
|
||||||
|
|
||||||
|
__version__ = version = '3.0.2.dev0+ga7113ba.d20241115'
|
||||||
|
__version_tuple__ = version_tuple = (3, 0, 2, 'dev0', 'ga7113ba.d20241115')
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
[project]
|
[project]
|
||||||
name = "pyflowery"
|
name = "pyflowery"
|
||||||
version = "3.0.1"
|
|
||||||
description = "A Python API wrapper for the Flowery API"
|
description = "A Python API wrapper for the Flowery API"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = "<4.0,>=3.11"
|
requires-python = "<4.0,>=3.11"
|
||||||
|
@ -16,6 +15,7 @@ classifiers = [
|
||||||
"Programming Language :: Python :: 3.12",
|
"Programming Language :: Python :: 3.12",
|
||||||
"Programming Language :: Python :: 3.13",
|
"Programming Language :: Python :: 3.13",
|
||||||
]
|
]
|
||||||
|
dynamic = ["version", "urls"]
|
||||||
|
|
||||||
[dependency-groups]
|
[dependency-groups]
|
||||||
dev = [
|
dev = [
|
||||||
|
@ -35,6 +35,26 @@ docs = [
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
line-length = 160
|
line-length = 160
|
||||||
|
|
||||||
|
[tool.pylint]
|
||||||
|
max-line-length = 200
|
||||||
|
disable = [
|
||||||
|
"missing-module-docstring",
|
||||||
|
"too-many-arguments",
|
||||||
|
"too-many-positional-arguments",
|
||||||
|
"too-few-public-methods",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.hatch.version]
|
||||||
|
source = "vcs"
|
||||||
|
|
||||||
|
[tool.hatch.build.hooks.vcs]
|
||||||
|
version-file = "pyflowery/version.py"
|
||||||
|
|
||||||
|
[tool.hatch.metadata.hooks.vcs.urls]
|
||||||
|
Homepage = "https://www.coastalcommits.com/cswimr/PyFlowery"
|
||||||
|
Issues = "https://www.coastalcommits.com/cswimr/PyFlowery/issues"
|
||||||
|
source_archive = "https://www.coastalcommits.com/cswimr/PyFlowery/archive/{commit_hash}.tar.gz"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["hatchling"]
|
requires = ["hatchling", "hatch-vcs"]
|
||||||
build-backend = "hatchling.build"
|
build-backend = "hatchling.build"
|
||||||
|
|
|
@ -2,7 +2,7 @@ import asyncio
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from pyflowery import VERSION, FloweryAPI, FloweryAPIConfig
|
from pyflowery import FloweryAPI, FloweryAPIConfig, __version__
|
||||||
|
|
||||||
root = logging.getLogger()
|
root = logging.getLogger()
|
||||||
root.setLevel(level=logging.DEBUG)
|
root.setLevel(level=logging.DEBUG)
|
||||||
|
@ -13,7 +13,7 @@ formatter = logging.Formatter(fmt="%(asctime)s - %(name)s - %(levelname)s - %(me
|
||||||
handler.setFormatter(fmt=formatter)
|
handler.setFormatter(fmt=formatter)
|
||||||
root.addHandler(hdlr=handler)
|
root.addHandler(hdlr=handler)
|
||||||
|
|
||||||
api = FloweryAPI(config=FloweryAPIConfig(user_agent=f"PyFloweryTests/{VERSION}"))
|
api = FloweryAPI(config=FloweryAPIConfig(user_agent=f"PyFloweryTests/{__version__}"))
|
||||||
|
|
||||||
ALEXANDER = "fa3ea565-121f-5efd-b4e9-59895c77df23" # TikTok
|
ALEXANDER = "fa3ea565-121f-5efd-b4e9-59895c77df23" # TikTok
|
||||||
JACOB = "38f45366-68e8-5d39-b1ef-3fd4eeb61cdb" # Microsoft Azure
|
JACOB = "38f45366-68e8-5d39-b1ef-3fd4eeb61cdb" # Microsoft Azure
|
||||||
|
|
8
uv.lock
8
uv.lock
|
@ -754,11 +754,11 @@ wheels = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "packaging"
|
name = "packaging"
|
||||||
version = "24.1"
|
version = "24.2"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/51/65/50db4dda066951078f0a96cf12f4b9ada6e4b811516bf0262c0f4f7064d4/packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002", size = 148788 }
|
sdist = { url = "https://files.pythonhosted.org/packages/d0/63/68dbb6eb2de9cb10ee4c9c14a0148804425e13c4fb20d61cce69f53106da/packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f", size = 163950 }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/08/aa/cc0199a5f0ad350994d660967a8efb233fe0416e4639146c089643407ce6/packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124", size = 53985 },
|
{ url = "https://files.pythonhosted.org/packages/88/ef/eb23f262cca3c0c4eb7ab1933c3b1f03d021f2c48f54763065b6f0e321be/packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759", size = 65451 },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -897,7 +897,7 @@ wheels = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pyflowery"
|
name = "pyflowery"
|
||||||
version = "3.0.0"
|
version = "3.0.2.dev0+ga7113ba.d20241115"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "aiohttp" },
|
{ name = "aiohttp" },
|
||||||
|
|
Loading…
Reference in a new issue