Skip to content

Incorrect type annotation for get_playlist_contents entities parameter rejects valid model-class arguments #202

Description

@FunctionDJ

Describe the bug

The type annotation of get_playlist_contents appears to require Base instances, but runtime usage and docs pass model classes/expressions (for example DjmdContent, DjmdContent.ID). In strict type checking, this produces a false-positive error.

Location
database.py

Current signature
def get_playlist_contents(self, playlist: PlaylistLike, *entities: models.Base) -> Any:

Why this is a problem
In downstream strict pyright/pylance, calling with a model class errors even though it is valid at runtime.

Minimal example
contents = (
db.get_playlist_contents(playlist, DjmdContent)
.order_by(DjmdContent.Title, DjmdContent.ID)
.all()
)

Type checker error
Argument of type type[DjmdContent] cannot be assigned to parameter entities of type Base in function get_playlist_contents.

Expected behavior
The entities parameter should accept SQLAlchemy model classes / query entities used by self.query(*entities), not only Base instances.

Impact
This currently forces downstream users to add type ignores/casts for otherwise valid calls.

Environment

  • pyrekordbox: editable install from current master
  • Python: 3.12
  • Type checker: pyright/pylance strict mode

Human-written AI disclosure: I'm building something with pyrekordbox and ran into this issue and used AI to further troubleshoot it and to write the issue title and body, but this account is not a bot and if I respond it's a human response and I always clearly mark when I post AI generated text (like I'm doing now).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions