-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Tagging: More powerful, flexible implementation of get_filtere…
…d_tags() (#92)
- Loading branch information
1 parent
be5d527
commit a8337dd
Showing
17 changed files
with
1,271 additions
and
880 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
""" | ||
Open edX Learning ("Learning Core"). | ||
""" | ||
__version__ = "0.2.6" | ||
__version__ = "0.3.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
Data models used by openedx-tagging | ||
""" | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, Any, TypedDict | ||
|
||
from django.db.models import QuerySet | ||
from typing_extensions import NotRequired, TypeAlias | ||
|
||
|
||
class TagData(TypedDict): | ||
""" | ||
Data about a single tag. Many of the tagging API methods return Django | ||
QuerySets that resolve to these dictionaries. | ||
Even though the data will be in this same format, it will not necessarily | ||
be an instance of this class but rather a plain dictionary. This is more a | ||
type than a class. | ||
""" | ||
value: str | ||
external_id: str | None | ||
child_count: int | ||
depth: int | ||
parent_value: str | None | ||
# Note: usage_count may or may not be present, depending on the request. | ||
usage_count: NotRequired[int] | ||
# Internal database ID, if any. Generally should not be used; prefer 'value' which is unique within each taxonomy. | ||
_id: int | None | ||
|
||
|
||
if TYPE_CHECKING: | ||
from django_stubs_ext import ValuesQuerySet | ||
TagDataQuerySet: TypeAlias = ValuesQuerySet[Any, TagData] | ||
# The following works better for pyright (provides proper VS Code autocompletions), | ||
# but I can't find any way to specify different types for pyright vs mypy :/ | ||
# TagDataQuerySet: TypeAlias = QuerySet[TagData] | ||
else: | ||
TagDataQuerySet = QuerySet[TagData] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.