Remove django stubs as they conflict with PyCharm

This commit is contained in:
Gabriel Augendre 2021-12-29 16:12:55 +01:00
parent ceb159a343
commit 0266a32b5b
7 changed files with 14 additions and 88 deletions

65
poetry.lock generated
View file

@ -253,35 +253,6 @@ Django = ">=2.2"
phonenumbers = ["phonenumbers (>=7.0.2)"]
phonenumberslite = ["phonenumberslite (>=7.0.2)"]
[[package]]
name = "django-stubs"
version = "1.9.0"
description = "Mypy stubs for Django"
category = "dev"
optional = false
python-versions = ">=3.6"
[package.dependencies]
django = "*"
django-stubs-ext = ">=0.3.0"
mypy = ">=0.910"
toml = "*"
types-pytz = "*"
types-PyYAML = "*"
typing-extensions = "*"
[[package]]
name = "django-stubs-ext"
version = "0.3.1"
description = "Monkey-patching and extensions for django-stubs"
category = "main"
optional = false
python-versions = ">=3.6"
[package.dependencies]
django = "*"
typing-extensions = "*"
[[package]]
name = "django-two-factor-auth"
version = "1.13"
@ -836,22 +807,6 @@ category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "types-pytz"
version = "2021.3.3"
description = "Typing stubs for pytz"
category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "types-pyyaml"
version = "6.0.1"
description = "Typing stubs for PyYAML"
category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "types-requests"
version = "2.26.3"
@ -880,7 +835,7 @@ python-versions = "*"
name = "typing-extensions"
version = "4.0.1"
description = "Backported and Experimental Type Hints for Python 3.6+"
category = "main"
category = "dev"
optional = false
python-versions = ">=3.6"
@ -975,7 +930,7 @@ multidict = ">=4.0"
[metadata]
lock-version = "1.1"
python-versions = "^3.10"
content-hash = "f98d2a4ae15821bd9d0247980743235129a22295abf136ae59f89568a329180e"
content-hash = "17e06d5348b12d6c12a95b1a9ba60278cddae6d15f80d4eba7173a67e5b5b123"
[metadata.files]
asgiref = [
@ -1141,14 +1096,6 @@ django-phonenumber-field = [
{file = "django-phonenumber-field-5.2.0.tar.gz", hash = "sha256:52b2e5970133ec5ab701218b802f7ab237229854dc95fd239b7e9e77dc43731d"},
{file = "django_phonenumber_field-5.2.0-py3-none-any.whl", hash = "sha256:5547fb2b2cc690a306ba77a5038419afc8fa8298a486fb7895008e9067cc7e75"},
]
django-stubs = [
{file = "django-stubs-1.9.0.tar.gz", hash = "sha256:664843091636a917faf5256d028476559dc360fdef9050b6df87ab61b21607bf"},
{file = "django_stubs-1.9.0-py3-none-any.whl", hash = "sha256:59c9f81af64d214b1954eaf90f037778c8d2b9c2de946a3cda177fefcf588fbd"},
]
django-stubs-ext = [
{file = "django-stubs-ext-0.3.1.tar.gz", hash = "sha256:783c198d7e39a41be0b90fd843fa2770243a642922af679be4b19e03b82c8c28"},
{file = "django_stubs_ext-0.3.1-py3-none-any.whl", hash = "sha256:a51a3e9e844d4e1cacaaedbb33bf3def78a3956eed5d9575a640bd97ccd99cec"},
]
django-two-factor-auth = []
filelock = [
{file = "filelock-3.4.2-py3-none-any.whl", hash = "sha256:cf0fc6a2f8d26bd900f19bf33915ca70ba4dd8c56903eeb14e1e7a2fd7590146"},
@ -1578,14 +1525,6 @@ types-pillow = [
{file = "types-Pillow-8.3.11.tar.gz", hash = "sha256:aa96a739184f48f69e6f30218400623fc5a95f5fec199c447663a32538440405"},
{file = "types_Pillow-8.3.11-py3-none-any.whl", hash = "sha256:998189334e616b1dd42c9634669efbf726184039e96e9a23ec95246e0ecff3fc"},
]
types-pytz = [
{file = "types-pytz-2021.3.3.tar.gz", hash = "sha256:f6d21d6687935a1615db464b1e1df800d19502c36bc0486f43be7dfd2c404947"},
{file = "types_pytz-2021.3.3-py3-none-any.whl", hash = "sha256:75859c64c9a97d68259af6da208e8f5aaf4be4536e4d431a82a6e8b848fc183d"},
]
types-pyyaml = [
{file = "types-PyYAML-6.0.1.tar.gz", hash = "sha256:2e27b0118ca4248a646101c5c318dc02e4ca2866d6bc42e84045dbb851555a76"},
{file = "types_PyYAML-6.0.1-py3-none-any.whl", hash = "sha256:d5b318269652e809b5c30a5fe666c50159ab80bfd41cd6bafe655bf20b29fcba"},
]
types-requests = [
{file = "types-requests-2.26.3.tar.gz", hash = "sha256:d63fa617846dcefff5aa2d59e47ab4ffd806e4bb0567115f7adbb5e438302fe4"},
{file = "types_requests-2.26.3-py3-none-any.whl", hash = "sha256:ad18284931c5ddbf050ccdd138f200d18fd56f88aa3567019d8da9b2d4fe0344"},

View file

@ -24,7 +24,6 @@ django-csp = "^3.7"
django-two-factor-auth = {extras = ["phonenumberslite"], git = "https://github.com/Bouke/django-two-factor-auth.git", rev = "ffe4422e"}
beautifulsoup4 = "^4.10.0"
django-environ = "^0.8.1"
django-stubs-ext = "^0.3.1"
[tool.poetry.dev-dependencies]
pre-commit = "^2.7"
@ -38,7 +37,6 @@ pytest-env = "^0.6.2"
poetry-deps-scanner = "^1.0.1"
invoke = "^1.6.0"
mypy = "^0.930"
django-stubs = "^1.9.0"
types-Markdown = "^3.3.10"
types-requests = "^2.26.3"
types-setuptools = "^57.4.5"
@ -64,12 +62,12 @@ env = [
]
[tool.mypy]
plugins = ["mypy_django_plugin.main"]
mypy_path = "$MYPY_CONFIG_FILE_DIR/stubs:$MYPY_CONFIG_FILE_DIR/src"
exclude = "/migrations/"
[[tool.mypy.overrides]]
module = [
"django.*",
"environ",
"django_otp.plugins.otp_static.models",
"two_factor.models",
@ -78,9 +76,6 @@ module = [
]
ignore_missing_imports = true
[tool.django-stubs]
django_settings_module = "blog.settings"
[tool.flakehell]
max_complexity = 10
format = "grouped"

View file

@ -1,7 +1,7 @@
from typing import Any
from django.conf import settings
from django.core.handlers.wsgi import WSGIRequest
from django.http import HttpRequest
from articles.models import Article
from attachments.models import Attachment
@ -11,7 +11,7 @@ IGNORED_PATHS = [
]
def drafts_count(request: WSGIRequest) -> dict[str, Any]:
def drafts_count(request: HttpRequest) -> dict[str, Any]:
if request.path in IGNORED_PATHS:
return {}
if not request.user.is_authenticated:
@ -19,13 +19,13 @@ def drafts_count(request: WSGIRequest) -> dict[str, Any]:
return {"drafts_count": Article.objects.filter(status=Article.DRAFT).count()}
def date_format(request: WSGIRequest) -> dict[str, Any]:
def date_format(request: HttpRequest) -> dict[str, Any]:
if request.path in IGNORED_PATHS:
return {}
return {"CUSTOM_ISO": r"Y-m-d\TH:i:sO", "ISO_DATE": "Y-m-d"}
def git_version(request: WSGIRequest) -> dict[str, Any]:
def git_version(request: HttpRequest) -> dict[str, Any]:
if request.path in IGNORED_PATHS:
return {}
try:
@ -39,13 +39,13 @@ def git_version(request: WSGIRequest) -> dict[str, Any]:
return {"git_version": version, "git_version_url": url}
def analytics(request: WSGIRequest) -> dict[str, Any]:
def analytics(request: HttpRequest) -> dict[str, Any]:
return {
"goatcounter_domain": settings.GOATCOUNTER_DOMAIN,
}
def open_graph_image_url(request: WSGIRequest) -> dict[str, Any]:
def open_graph_image_url(request: HttpRequest) -> dict[str, Any]:
if request.path in IGNORED_PATHS:
return {}
open_graph_image = Attachment.objects.get_open_graph_image()
@ -55,7 +55,7 @@ def open_graph_image_url(request: WSGIRequest) -> dict[str, Any]:
return {"open_graph_image_url": url}
def blog_metadata(request: WSGIRequest) -> dict[str, Any]:
def blog_metadata(request: HttpRequest) -> dict[str, Any]:
return {
"blog_title": settings.BLOG["title"],
"blog_description": settings.BLOG["description"],

View file

@ -1,7 +1,6 @@
from typing import Any
from django.contrib.auth.decorators import login_required
from django.core.handlers.wsgi import WSGIRequest
from django.http import HttpResponse
from django.shortcuts import render
from django.views.decorators.http import require_POST
@ -11,7 +10,7 @@ from articles.models import Article, Tag
@login_required
@require_POST
def render_article(request: WSGIRequest, article_pk: int) -> HttpResponse:
def render_article(request, article_pk: int) -> HttpResponse:
template = "articles/article_detail.html"
article = Article.objects.get(pk=article_pk)
article.content = request.POST.get("content", article.content)

View file

@ -2,7 +2,6 @@ from datetime import datetime
from typing import Iterable
from django.contrib.syndication.views import Feed
from django.core.handlers.wsgi import WSGIRequest
from django.db.models import QuerySet
from articles.models import Article, Tag
@ -13,7 +12,7 @@ class BaseFeed(Feed):
FEED_LIMIT = 15
description = settings.BLOG["description"]
def item_description(self, item: Article) -> str: # type: ignore[override]
def item_description(self, item: Article) -> str:
return item.get_formatted_content
def item_pubdate(self, item: Article) -> datetime | None:
@ -34,7 +33,7 @@ class CompleteFeed(BaseFeed):
class TagFeed(BaseFeed):
def get_object(self, request: WSGIRequest, *args, **kwargs) -> Tag: # type: ignore[override]
def get_object(self, request, *args, **kwargs) -> Tag:
return Tag.objects.get(slug=kwargs.get("slug"))
def title(self, tag: Tag) -> str:

View file

@ -4,7 +4,6 @@ from typing import Any
from django.conf import settings
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.handlers.wsgi import WSGIRequest
from django.core.paginator import Page
from django.db.models import F, Q
from django.shortcuts import get_object_or_404
@ -20,7 +19,6 @@ class BaseArticleListView(generic.ListView):
paginate_by = 10
main_title = "Blog posts"
html_title = ""
request: WSGIRequest
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
@ -125,11 +123,10 @@ class DraftsListView(LoginRequiredMixin, BaseArticleListView):
return context
class ArticleDetailView(DetailView[Article]):
class ArticleDetailView(DetailView):
model = Article
context_object_name = "article"
template_name = "articles/article_detail.html"
request: WSGIRequest
def get_queryset(self):
key = self.request.GET.get("draft_key")

View file

@ -12,7 +12,6 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
import os
from pathlib import Path
import django_stubs_ext
import environ
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@ -40,8 +39,6 @@ env_file = os.getenv("ENV_FILE", None)
if env_file:
environ.Env.read_env(env_file)
django_stubs_ext.monkeypatch()
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/