diff --git a/.forgejo/workflows/actions.yaml b/.forgejo/workflows/actions.yaml index 4952534..56e3165 100644 --- a/.forgejo/workflows/actions.yaml +++ b/.forgejo/workflows/actions.yaml @@ -45,7 +45,7 @@ jobs: password: ${{ secrets.PYPI_API_TOKEN }} lint: - name: Lint with Ruff & Pylint + name: Lint with Ruff, Pylint, & MyPy runs-on: docker container: www.coastalcommits.com/cswimr/actions:uv steps: @@ -65,7 +65,16 @@ jobs: continue-on-error: true - 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: name: Build Documentation diff --git a/.forgejo/workflows/config/.pylintrc b/.forgejo/workflows/config/.pylintrc deleted file mode 100644 index 3ea99d4..0000000 --- a/.forgejo/workflows/config/.pylintrc +++ /dev/null @@ -1,6 +0,0 @@ - [MESSAGES CONTROL] - disable= - line-too-long, - missing-module-docstring, - too-many-arguments, - too-few-public-methods, diff --git a/.gitignore b/.gitignore index d1bda94..b9c4f53 100644 --- a/.gitignore +++ b/.gitignore @@ -167,3 +167,6 @@ test.mp3 # actions artifacts 1/ + +# automatically generated version file +pyflowery/version.py diff --git a/pyflowery/__init__.py b/pyflowery/__init__.py index 1b6cb35..6296028 100644 --- a/pyflowery/__init__.py +++ b/pyflowery/__init__.py @@ -7,7 +7,7 @@ from pyflowery.exceptions import ( ) from pyflowery.models import FloweryAPIConfig, Language, Result, Voice from pyflowery.pyflowery import FloweryAPI -from pyflowery.version import VERSION +from pyflowery.version import __version__ __all__ = [ "FloweryAPI", @@ -15,7 +15,7 @@ __all__ = [ "Language", "Result", "Voice", - "VERSION", + "__version__", "ResponseError", "ClientError", "InternalServerError", diff --git a/pyflowery/models.py b/pyflowery/models.py index 4ee4772..6373f61 100644 --- a/pyflowery/models.py +++ b/pyflowery/models.py @@ -3,7 +3,7 @@ from logging import Logger, getLogger from sys import version as pyversion from typing import Dict, List, Union -from pyflowery.version import VERSION +from pyflowery.version import version @dataclass @@ -79,4 +79,4 @@ class FloweryAPIConfig: @property def prepended_user_agent(self) -> str: """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})" diff --git a/pyflowery/pyflowery.py b/pyflowery/pyflowery.py index 74576b3..4374296 100644 --- a/pyflowery/pyflowery.py +++ b/pyflowery/pyflowery.py @@ -31,10 +31,9 @@ class FloweryAPI: 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.""" 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.") - 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: """Get a set of voices from the cache. @@ -150,7 +149,5 @@ class FloweryAPI: if request is not None: if isinstance(request.data, bytes): return request.data - else: - raise ResponseError(f"Invalid response from Flowery API: {request.data!r}") - else: - raise ResponseError("Invalid response from Flowery API: Empty Response!}") + raise ResponseError(f"Invalid response from Flowery API: {request.data!r}") + raise ResponseError("Invalid response from Flowery API: Empty Response!}") diff --git a/pyflowery/version.py b/pyflowery/version.py index ce31092..e2a7983 100644 --- a/pyflowery/version.py +++ b/pyflowery/version.py @@ -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') diff --git a/pyproject.toml b/pyproject.toml index 33189c8..79e12b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,5 @@ [project] name = "pyflowery" -version = "3.0.1" description = "A Python API wrapper for the Flowery API" readme = "README.md" requires-python = "<4.0,>=3.11" @@ -16,6 +15,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", ] +dynamic = ["version", "urls"] [dependency-groups] dev = [ @@ -35,6 +35,26 @@ docs = [ [tool.ruff] 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] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" diff --git a/tests/tests.py b/tests/tests.py index 185f18d..b7c69a7 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -2,7 +2,7 @@ import asyncio import logging import sys -from pyflowery import VERSION, FloweryAPI, FloweryAPIConfig +from pyflowery import FloweryAPI, FloweryAPIConfig, __version__ root = logging.getLogger() root.setLevel(level=logging.DEBUG) @@ -13,7 +13,7 @@ formatter = logging.Formatter(fmt="%(asctime)s - %(name)s - %(levelname)s - %(me handler.setFormatter(fmt=formatter) 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 JACOB = "38f45366-68e8-5d39-b1ef-3fd4eeb61cdb" # Microsoft Azure diff --git a/uv.lock b/uv.lock index a8f0873..6b58e4e 100644 --- a/uv.lock +++ b/uv.lock @@ -754,11 +754,11 @@ wheels = [ [[package]] name = "packaging" -version = "24.1" +version = "24.2" 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 = [ - { 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]] @@ -897,7 +897,7 @@ wheels = [ [[package]] name = "pyflowery" -version = "3.0.0" +version = "3.0.2.dev0+ga7113ba.d20241115" source = { editable = "." } dependencies = [ { name = "aiohttp" },