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

run test in python 3.12 as well #381

Merged
merged 6 commits into from
May 29, 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
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ['3.11']
python-version: ['3.11', '3.12']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -25,7 +25,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ['3.11']
python-version: ['3.11', '3.12']
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ['3.11']
python-version: ['3.11', '3.12']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
15 changes: 9 additions & 6 deletions catalog/book/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""

from os.path import exists
from typing import TYPE_CHECKING

from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
Expand Down Expand Up @@ -62,6 +63,8 @@ class EditionSchema(EditionInSchema, BaseSchema):


class Edition(Item):
if TYPE_CHECKING:
works: "models.ManyToManyField[Work, Edition]"
category = ItemCategory.Book
url_path = "book"

Expand Down Expand Up @@ -164,17 +167,17 @@ def lookup_id_cleanup(cls, lookup_id_type: str | IdType, lookup_id_value: str):
return detect_isbn_asin(lookup_id_value)
return super().lookup_id_cleanup(lookup_id_type, lookup_id_value)

def merge_to(self, to_item: "Edition | None"):
def merge_to(self, to_item: "Edition | None"): # type: ignore[reportIncompatibleMethodOverride]
super().merge_to(to_item)
if to_item:
for work in self.works.all():
to_item.works.add(work)
self.works.clear()

def delete(self, using=None, soft=True, *args, **kwargs):
def delete(self, using=None, keep_parents=False, soft=True, *args, **kwargs):
if soft:
self.works.clear()
return super().delete(using, soft, *args, **kwargs)
return super().delete(using, soft, keep_parents, *args, **kwargs)

def update_linked_items_from_external_resource(self, resource):
"""add Work from resource.metadata['work'] if not yet"""
Expand Down Expand Up @@ -279,7 +282,7 @@ def lookup_id_type_choices(cls):
]
return [(i.value, i.label) for i in id_types]

def merge_to(self, to_item: "Work | None"):
def merge_to(self, to_item: "Work | None"): # type: ignore[reportIncompatibleMethodOverride]
super().merge_to(to_item)
if to_item:
for edition in self.editions.all():
Expand All @@ -293,10 +296,10 @@ def merge_to(self, to_item: "Work | None"):
to_item.other_title += [self.title] # type: ignore
to_item.save()

def delete(self, using=None, soft=True, *args, **kwargs):
def delete(self, using=None, keep_parents=False, soft=True, *args, **kwargs):
if soft:
self.editions.clear()
return super().delete(using, soft, *args, **kwargs)
return super().delete(using, keep_parents, soft, *args, **kwargs)


class Series(Item):
Expand Down
8 changes: 7 additions & 1 deletion catalog/collection/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from catalog.common import *
from typing import TYPE_CHECKING

from catalog.common import Item, ItemCategory


class Collection(Item):
if TYPE_CHECKING:
from journal.models import Collection as JournalCollection

journal_item: "JournalCollection"
category = ItemCategory.Collection

@property
Expand Down
5 changes: 3 additions & 2 deletions catalog/common/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ def clear(self):
def clear(self):
pass

def delete(self, using=None, soft=True, *args, **kwargs):
def delete(self, using=None, keep_parents=False, soft=True, *args, **kwargs):
if soft:
self.clear()
self.is_deleted = True
self.save(using=using) # type: ignore
return 0, {}
else:
return super().delete(using=using, *args, **kwargs) # type: ignore
return super().delete(using=using, keep_parents=keep_parents, *args, **kwargs) # type: ignore
Loading
Loading