Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db: disable DQS on Python >= 3.12 #5235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions beets/dbcore/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import os
import re
import sqlite3
import sys
import threading
import time
from abc import ABC
Expand Down Expand Up @@ -286,7 +287,7 @@
"""The flex field SQLite table name.
"""

_fields: Dict[str, types.Type] = {}

Check failure on line 290 in beets/dbcore/db.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "Type"
"""A mapping indicating available "fixed" fields on this type. The
keys are field names and the values are `Type` objects.
"""
Expand All @@ -296,7 +297,7 @@
terms.
"""

_types: Dict[str, types.Type] = {}

Check failure on line 300 in beets/dbcore/db.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "Type"
"""Optional Types for non-fixed (i.e., flexible and computed) fields.
"""

Expand All @@ -305,7 +306,7 @@
are subclasses of `Sort`.
"""

_queries: Dict[str, Type[FieldQuery]] = {}

Check failure on line 309 in beets/dbcore/db.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "FieldQuery"
"""Named queries that use a field-like `name:value` syntax but which
do not relate to any specific field.
"""
Expand All @@ -324,7 +325,7 @@
@cached_classproperty
def _relation(cls) -> type[Model]:
"""The model that this model is closely related to."""
return cls

Check failure on line 328 in beets/dbcore/db.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Incompatible return value type (got "Model", expected "Type[Model]")

@cached_classproperty
def relation_join(cls) -> str:
Expand Down Expand Up @@ -439,7 +440,7 @@
# Essential field accessors.

@classmethod
def _type(cls, key) -> types.Type:

Check failure on line 443 in beets/dbcore/db.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "Type"
"""Get the type of a field, a `Type` instance.

If the field has no explicit type, it is given the base `Type`,
Expand Down Expand Up @@ -730,16 +731,16 @@
cls,
field,
pattern,
query_cls: Type[FieldQuery] = MatchQuery,

Check failure on line 734 in beets/dbcore/db.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "FieldQuery"
) -> FieldQuery:

Check failure on line 735 in beets/dbcore/db.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "FieldQuery"
"""Get a `FieldQuery` for this model."""
return query_cls(field, pattern, field in cls._fields)

@classmethod
def all_fields_query(
cls: Type["Model"],
pats: Mapping,

Check failure on line 742 in beets/dbcore/db.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "Mapping"
query_cls: Type[FieldQuery] = MatchQuery,

Check failure on line 743 in beets/dbcore/db.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "FieldQuery"
):
"""Get a query that matches many fields with different patterns.

Expand All @@ -765,7 +766,7 @@
def __init__(
self,
model_class: Type[AnyModel],
rows: List[Mapping],

Check failure on line 769 in beets/dbcore/db.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "Mapping"
db: "Database",
flex_rows,
query: Optional[Query] = None,
Expand Down Expand Up @@ -1091,6 +1092,12 @@
# call conn.close() in _close()
check_same_thread=False,
)

if sys.version_info >= (3, 12) and sqlite3.sqlite_version_info >= (3, 29, 0):
# If possible, disable double-quoted strings
conn.setconfig(sqlite3.SQLITE_DBCONFIG_DQS_DDL, 0)
conn.setconfig(sqlite3.SQLITE_DBCONFIG_DQS_DML, 0)

self.add_functions(conn)

if self.supports_extensions:
Expand Down
Loading