Skip to content

Commit c2d1bc3

Browse files
authored
Add py.typed marker file to support PEP 561 typing (#5906)
Add `py.typed` marker file to support PEP 561 typing This PR adds a `py.typed` marker file to the package directory to indicate that the package includes inline type hints and is PEP 561 compliant.
1 parent 78c3611 commit c2d1bc3

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
uses: liskin/gh-problem-matcher-wrap@v3
108108
with:
109109
linters: mypy
110-
run: poe check-types --show-column-numbers --no-error-summary ${{ needs.changed-files.outputs.changed_python_files }}
110+
run: poe check-types --show-column-numbers --no-error-summary .
111111

112112
docs:
113113
if: needs.changed-files.outputs.any_docs_changed == 'true'

beets/py.typed

Whitespace-only changes.

docs/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ For plugin developers:
9292

9393
Old imports are now deprecated and will be removed in version ``3.0.0``.
9494
* ``beets.ui.decargs`` is deprecated and will be removed in version ``3.0.0``.
95+
* Beets is now pep 561 compliant, which means that it provides type hints
96+
for all public APIs. This allows IDEs to provide better autocompletion and
97+
type checking for downstream users of the beets API.
98+
9599

96100
Other changes:
97101

test/test_dbcore.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from beets import dbcore
2626
from beets.library import LibModel
2727
from beets.test import _common
28+
from beets.util import cached_classproperty
2829

2930
# Fixture: concrete database and model classes. For migration tests, we
3031
# have multiple models with different numbers of fields.
@@ -53,15 +54,22 @@ class ModelFixture1(LibModel):
5354
"field_one": dbcore.types.INTEGER,
5455
"field_two": dbcore.types.STRING,
5556
}
56-
_types = {
57-
"some_float_field": dbcore.types.FLOAT,
58-
}
57+
5958
_sorts = {
6059
"some_sort": SortFixture,
6160
}
62-
_queries = {
63-
"some_query": QueryFixture,
64-
}
61+
62+
@cached_classproperty
63+
def _types(cls):
64+
return {
65+
"some_float_field": dbcore.types.FLOAT,
66+
}
67+
68+
@cached_classproperty
69+
def _queries(cls):
70+
return {
71+
"some_query": QueryFixture,
72+
}
6573

6674
@classmethod
6775
def _getters(cls):

0 commit comments

Comments
 (0)