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

🖤🖤🖤 (black) #2

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Black

on: [pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
with:
python-version: '3.12' # 3.11 needed for black's use_pyproject
- uses: psf/black@stable
with:
use_pyproject: true
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ testproject = [
"model-bakery",
"time-machine",
]
dev = [
"black<24.5.0"
]
5 changes: 3 additions & 2 deletions src/modelsubquery/functions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tools to build subqueries that produce model instances
"""

from django.db import models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.functions import JSONObject
Expand All @@ -26,6 +27,7 @@ class JSONModelField(models.JSONField):
Any missing fields in the JSON object are marked as "deferred" (and will be
loaded from the db on access).
"""

# TODO: support the "pk" alias
# TODO: support fk fields (recursive __ access)
def __init__(self, model, *args, **kwargs):
Expand Down Expand Up @@ -70,6 +72,5 @@ def ModelSubquery(queryset, fields=None):
"""
jsonobj = model_to_json(queryset.model, fields=fields)
return models.Subquery(
queryset.values_list(jsonobj),
output_field=JSONModelField(queryset.model)
queryset.values_list(jsonobj), output_field=JSONModelField(queryset.model)
)
4 changes: 2 additions & 2 deletions testproject/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'testproject.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand All @@ -18,5 +18,5 @@ def main():
execute_from_command_line(sys.argv)


if __name__ == '__main__':
if __name__ == "__main__":
main()
33 changes: 0 additions & 33 deletions testproject/testapp/migrations/0001_initial.py

This file was deleted.

Empty file.
14 changes: 7 additions & 7 deletions testproject/testproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

BASE_DIR = Path(__file__).resolve().parent.parent

SECRET_KEY = 'insecure'
SECRET_KEY = "insecure"
DEBUG = True

INSTALLED_APPS = [
'testapp',
"testapp",
]

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}

TIME_ZONE = 'UTC'
TIME_ZONE = "UTC"
USE_TZ = True

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
Loading