From 31d07c66567588d5cfe8fd1aaa2f04ff9f66b916 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Fri, 31 Dec 2021 12:29:13 +0100 Subject: [PATCH] More mypy --- poetry.lock | 63 +----------------------------- pyproject.toml | 7 +--- src/articles/context_processors.py | 2 +- src/articles/views/html.py | 2 +- src/attachments/models.py | 2 +- 5 files changed, 5 insertions(+), 71 deletions(-) diff --git a/poetry.lock b/poetry.lock index b8693ae..3ec4d62 100644 --- a/poetry.lock +++ b/poetry.lock @@ -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 = "dev" -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" @@ -975,7 +930,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.10" -content-hash = "35d359b39bfd7c907a1119797a4badf33b3f3c964a5ec90e85c781cf99fecf7e" +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"}, diff --git a/pyproject.toml b/pyproject.toml index 58147a4..2343c5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,6 @@ types-setuptools = "^57.4.5" types-toml = "^0.10.1" types-beautifulsoup4 = "^4.10.7" types-Pillow = "^8.3.11" -django-stubs = "^1.9.0" [tool.black] target-version = ['py38'] @@ -64,16 +63,12 @@ env = [ [tool.mypy] mypy_path = "$MYPY_CONFIG_FILE_DIR/stubs:$MYPY_CONFIG_FILE_DIR/src" -plugins = ["mypy_django_plugin.main"] disallow_untyped_defs = true warn_redundant_casts = true strict_equality = true disallow_untyped_calls = true warn_unreachable = true -enable_error_code = ["redundant-expr", "truthy-bool"] - -[tool.django-stubs] -django_settings_module = "blog.settings" +enable_error_code = ["redundant-expr"] [[tool.mypy.overrides]] module = [ diff --git a/src/articles/context_processors.py b/src/articles/context_processors.py index d4d010a..dd286f4 100644 --- a/src/articles/context_processors.py +++ b/src/articles/context_processors.py @@ -50,7 +50,7 @@ def open_graph_image_url(request: HttpRequest) -> dict[str, Any]: return {} open_graph_image = Attachment.objects.get_open_graph_image() url = "" - if open_graph_image: + if open_graph_image and open_graph_image.processed_file is not None: url = open_graph_image.processed_file.get_full_absolute_url(request) return {"open_graph_image_url": url} diff --git a/src/articles/views/html.py b/src/articles/views/html.py index 1ad75e1..d08c980 100644 --- a/src/articles/views/html.py +++ b/src/articles/views/html.py @@ -96,7 +96,7 @@ class SearchArticlesListView(PublicArticleListView): class TagArticlesListView(PublicArticleListView): - tag = None + tag: Tag main_title = "" html_title = "" diff --git a/src/attachments/models.py b/src/attachments/models.py index 8eabca9..8758d6a 100644 --- a/src/attachments/models.py +++ b/src/attachments/models.py @@ -45,7 +45,7 @@ class Attachment(models.Model): return f"{self.description} ({self.original_file.name})" def reprocess(self) -> None: - self.processed_file = None + self.processed_file = None # type: ignore self.save() def save(self, *args: Any, **kwargs: Any) -> None: