Remove django-stubs

It's just not quite there yet for a lot of things, and makes certain things a right pain!
This commit is contained in:
Jake Howard 2022-07-28 20:15:20 +01:00
parent 30135e53be
commit d995b412a0
Signed by: jake
GPG key ID: 57AFB45680EDD477
7 changed files with 13 additions and 36 deletions

View file

@ -3,10 +3,10 @@
pip-tools
honcho
django-stubs[compatible-mypy]
flake8
isort
black
django-browser-reload
django-debug-toolbar
types-requests
mypy

View file

@ -15,7 +15,7 @@ certifi==2022.6.15 # via -r requirements/base.txt, requests
charset-normalizer==2.1.0 # via -r requirements/base.txt, requests
click==8.1.3 # via -r requirements/base.txt, black, pip-tools, rq
deprecated==1.2.13 # via -r requirements/base.txt, redis
django==4.0.6 # via -r requirements/base.txt, django-browser-reload, django-debug-toolbar, django-filter, django-modelcluster, django-permissionedforms, django-redis, django-rq, django-stubs, django-stubs-ext, django-taggit, django-treebeard, djangorestframework, wagtail
django==4.0.6 # via -r requirements/base.txt, django-browser-reload, django-debug-toolbar, django-filter, django-modelcluster, django-permissionedforms, django-redis, django-rq, django-taggit, django-treebeard, djangorestframework, wagtail
django-browser-reload==1.6.0 # via -r requirements/dev.in
django-debug-toolbar==3.5.0 # via -r requirements/dev.in
django-environ==0.9.0 # via -r requirements/base.txt
@ -24,8 +24,6 @@ django-modelcluster==6.0 # via -r requirements/base.txt, wagtail
django-permissionedforms==0.1 # via -r requirements/base.txt, wagtail
django-redis==5.2.0 # via -r requirements/base.txt
django-rq==2.5.1 # via -r requirements/base.txt
django-stubs[compatible-mypy]==1.12.0 # via -r requirements/dev.in
django-stubs-ext==0.5.0 # via django-stubs
django-taggit==2.1.0 # via -r requirements/base.txt, wagtail
django-treebeard==4.5.1 # via -r requirements/base.txt, wagtail
djangorestframework==3.13.1 # via -r requirements/base.txt, wagtail
@ -41,7 +39,7 @@ l18n==2021.3 # via -r requirements/base.txt, wagtail
lxml==4.9.1 # via -r requirements/base.txt
mccabe==0.6.1 # via flake8
more-itertools==8.13.0 # via -r requirements/base.txt
mypy==0.961 # via django-stubs
mypy==0.971 # via -r requirements/dev.in
mypy-extensions==0.4.3 # via black, mypy
openpyxl==3.0.10 # via -r requirements/base.txt, tablib
packaging==21.3 # via -r requirements/base.txt, build, redis
@ -63,12 +61,10 @@ soupsieve==2.3.2.post1 # via -r requirements/base.txt, beautifulsoup4
sqlparse==0.4.2 # via -r requirements/base.txt, django, django-debug-toolbar
tablib[xls,xlsx]==3.2.1 # via -r requirements/base.txt, wagtail
telepath==0.2 # via -r requirements/base.txt, wagtail
tomli==2.0.1 # via black, build, django-stubs, mypy
types-pytz==2022.1.2 # via django-stubs
types-pyyaml==6.0.11 # via django-stubs
tomli==2.0.1 # via black, build, mypy
types-requests==2.28.5 # via -r requirements/dev.in
types-urllib3==1.26.17 # via types-requests
typing-extensions==4.3.0 # via django-stubs, django-stubs-ext, mypy
typing-extensions==4.3.0 # via mypy
urllib3==1.26.11 # via -r requirements/base.txt, requests
wagtail==3.0.1 # via -r requirements/base.txt, wagtail-draftail-snippet
wagtail-draftail-snippet==0.4.1 # via -r requirements/base.txt

View file

@ -7,10 +7,6 @@ ignore_missing_imports = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
plugins = mypy_django_plugin.main
[mypy.plugins.django-stubs]
django_settings_module = "website.settings"
[isort]
multi_line_output=3

View file

@ -46,9 +46,7 @@ class BlogListPage(BaseContentMixin, RoutablePageMixin, BasePage): # type: igno
return [TocEntry(post_month, post_month, 0, []) for post_month in post_months]
def get_blog_posts(self) -> PageQuerySet:
return BlogPostPage.objects.descendant_of( # type:ignore[attr-defined]
self
).live()
return BlogPostPage.objects.descendant_of(self).live()
def get_context(self, request: HttpRequest) -> dict:
context = super().get_context(request)
@ -117,9 +115,7 @@ class BlogPostTagPage(BaseContentMixin, RoutablePageMixin, BasePage): # type: i
]
def get_blog_posts(self) -> PageQuerySet:
blog_list_page = (
BlogListPage.objects.all().live().get() # type:ignore[attr-defined]
)
blog_list_page = BlogListPage.objects.all().live().get()
return blog_list_page.get_blog_posts().filter(tags=self).order_by("-date")
def get_context(self, request: HttpRequest) -> dict:
@ -150,12 +146,8 @@ class BlogCollectionListPage(BaseContentMixin, BasePage): # type: ignore[misc]
]
def get_collections(self) -> PageQuerySet:
blog_list_page = (
BlogListPage.objects.all().live().get() # type:ignore[attr-defined]
)
return BlogCollectionPage.objects.child_of( # type:ignore[attr-defined]
blog_list_page
).live()
blog_list_page = BlogListPage.objects.all().live().get()
return BlogCollectionPage.objects.child_of(blog_list_page).live()
def get_context(self, request: HttpRequest) -> dict:
context = super().get_context(request)
@ -176,9 +168,7 @@ class BlogCollectionPage(BaseContentMixin, BasePage): # type: ignore[misc]
]
def get_blog_posts(self) -> PageQuerySet:
return BlogPostPage.objects.child_of( # type:ignore[attr-defined]
self
).order_by("-date")
return BlogPostPage.objects.child_of(self).order_by("-date")
def get_context(self, request: HttpRequest) -> dict:
context = super().get_context(request)

View file

@ -15,9 +15,7 @@ class BlogPostTagsMenuItem(MenuItem):
def is_shown(self, request: HttpRequest) -> bool:
if not self.url:
blog_post_tag_list_id = (
BlogPostTagListPage.objects.live() # type:ignore[attr-defined]
.values_list("id", flat=True)
.first()
BlogPostTagListPage.objects.live().values_list("id", flat=True).first()
)
self.url = (
reverse("wagtailadmin_explore", args=[blog_post_tag_list_id])

View file

@ -91,7 +91,7 @@ class BaseContentMixin(models.Model):
@cached_property
def hero_image_url(self) -> Optional[str]:
if self.hero_unsplash_photo_id is not None:
return self.hero_unsplash_photo.get_hero_image_url() # type: ignore
return self.hero_unsplash_photo.get_hero_image_url()
elif self.hero_image_id is not None:
return generate_image_url(self.hero_image, "width-1200")
return None

View file

@ -23,9 +23,6 @@ class HomePage(BasePage):
def get_context(self, request: HttpRequest) -> dict:
context = super().get_context(request)
context["latest_blog_post"] = (
BlogPostPage.objects.live() # type:ignore[attr-defined]
.defer_streamfields()
.order_by("-date")
.first()
BlogPostPage.objects.live().defer_streamfields().order_by("-date").first()
)
return context