This commit is contained in:
Serhii Tereshchenko 2024-08-13 17:47:06 +03:00
parent 89c51096bc
commit 9a3aebf6cd
3 changed files with 6 additions and 3 deletions

View file

@ -37,5 +37,4 @@ def monkeypatch() -> None:
return cls
for cls in classes:
if not hasattr(cls, "__class_getitem__"):
cls.__class_getitem__ = classmethod(class_getitem) # type: ignore[attr-defined]
cls.__class_getitem__ = classmethod(class_getitem) # type: ignore[attr-defined]

View file

@ -2,9 +2,11 @@ import os
import warnings
import django_stubs_ext
from modeltranslation._typing import monkeypatch
warnings.simplefilter("always", DeprecationWarning)
django_stubs_ext.monkeypatch()
monkeypatch()
def _get_database_config():

View file

@ -2912,11 +2912,13 @@ class TranslationAdminTest(ModeltranslationTestBase):
assert tuple(ma.get_form(request, self.test_obj).base_fields.keys()) == tuple(fields)
def test_class_attribute_access_raises_type_error(self):
# Test for django-cms compatibility
# https://github.com/django-cms/django-cms/issues/7948
class TestModelAdmin(admin.TranslationAdmin[models.TestModel]):
allow_children = True
with pytest.raises(KeyError):
TestModelAdmin["allow_children"] # type: ignore
TestModelAdmin["allow_children"]
class ThirdPartyAppIntegrationTest(ModeltranslationTestBase):