diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 696a4f826..c61a4c5f7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -107,7 +107,7 @@ jobs: uses: liskin/gh-problem-matcher-wrap@v3 with: linters: mypy - run: poe check-types --show-column-numbers --no-error-summary ${{ needs.changed-files.outputs.changed_python_files }} + run: poe check-types --show-column-numbers --no-error-summary . docs: if: needs.changed-files.outputs.any_docs_changed == 'true' diff --git a/beets/py.typed b/beets/py.typed new file mode 100644 index 000000000..e69de29bb diff --git a/docs/changelog.rst b/docs/changelog.rst index 15ad4d0db..6a53ee5a3 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -92,6 +92,10 @@ For plugin developers: Old imports are now deprecated and will be removed in version ``3.0.0``. * ``beets.ui.decargs`` is deprecated and will be removed in version ``3.0.0``. +* Beets is now pep 561 compliant, which means that it provides type hints + for all public APIs. This allows IDEs to provide better autocompletion and + type checking for downstream users of the beets API. + Other changes: diff --git a/test/test_dbcore.py b/test/test_dbcore.py index a4bae97c9..3f9a9d45e 100644 --- a/test/test_dbcore.py +++ b/test/test_dbcore.py @@ -25,6 +25,7 @@ import pytest from beets import dbcore from beets.library import LibModel from beets.test import _common +from beets.util import cached_classproperty # Fixture: concrete database and model classes. For migration tests, we # have multiple models with different numbers of fields. @@ -53,15 +54,22 @@ class ModelFixture1(LibModel): "field_one": dbcore.types.INTEGER, "field_two": dbcore.types.STRING, } - _types = { - "some_float_field": dbcore.types.FLOAT, - } + _sorts = { "some_sort": SortFixture, } - _queries = { - "some_query": QueryFixture, - } + + @cached_classproperty + def _types(cls): + return { + "some_float_field": dbcore.types.FLOAT, + } + + @cached_classproperty + def _queries(cls): + return { + "some_query": QueryFixture, + } @classmethod def _getters(cls):