More mypy

This commit is contained in:
Gabriel Augendre 2021-12-31 12:29:13 +01:00
parent 880985dfe0
commit 31d07c6656
5 changed files with 5 additions and 71 deletions

63
poetry.lock generated
View file

@ -253,35 +253,6 @@ Django = ">=2.2"
phonenumbers = ["phonenumbers (>=7.0.2)"] phonenumbers = ["phonenumbers (>=7.0.2)"]
phonenumberslite = ["phonenumberslite (>=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]] [[package]]
name = "django-two-factor-auth" name = "django-two-factor-auth"
version = "1.13" version = "1.13"
@ -836,22 +807,6 @@ category = "dev"
optional = false optional = false
python-versions = "*" 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]] [[package]]
name = "types-requests" name = "types-requests"
version = "2.26.3" version = "2.26.3"
@ -975,7 +930,7 @@ multidict = ">=4.0"
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.10" python-versions = "^3.10"
content-hash = "35d359b39bfd7c907a1119797a4badf33b3f3c964a5ec90e85c781cf99fecf7e" content-hash = "17e06d5348b12d6c12a95b1a9ba60278cddae6d15f80d4eba7173a67e5b5b123"
[metadata.files] [metadata.files]
asgiref = [ 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.tar.gz", hash = "sha256:52b2e5970133ec5ab701218b802f7ab237229854dc95fd239b7e9e77dc43731d"},
{file = "django_phonenumber_field-5.2.0-py3-none-any.whl", hash = "sha256:5547fb2b2cc690a306ba77a5038419afc8fa8298a486fb7895008e9067cc7e75"}, {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 = [] django-two-factor-auth = []
filelock = [ filelock = [
{file = "filelock-3.4.2-py3-none-any.whl", hash = "sha256:cf0fc6a2f8d26bd900f19bf33915ca70ba4dd8c56903eeb14e1e7a2fd7590146"}, {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.tar.gz", hash = "sha256:aa96a739184f48f69e6f30218400623fc5a95f5fec199c447663a32538440405"},
{file = "types_Pillow-8.3.11-py3-none-any.whl", hash = "sha256:998189334e616b1dd42c9634669efbf726184039e96e9a23ec95246e0ecff3fc"}, {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 = [ types-requests = [
{file = "types-requests-2.26.3.tar.gz", hash = "sha256:d63fa617846dcefff5aa2d59e47ab4ffd806e4bb0567115f7adbb5e438302fe4"}, {file = "types-requests-2.26.3.tar.gz", hash = "sha256:d63fa617846dcefff5aa2d59e47ab4ffd806e4bb0567115f7adbb5e438302fe4"},
{file = "types_requests-2.26.3-py3-none-any.whl", hash = "sha256:ad18284931c5ddbf050ccdd138f200d18fd56f88aa3567019d8da9b2d4fe0344"}, {file = "types_requests-2.26.3-py3-none-any.whl", hash = "sha256:ad18284931c5ddbf050ccdd138f200d18fd56f88aa3567019d8da9b2d4fe0344"},

View file

@ -43,7 +43,6 @@ types-setuptools = "^57.4.5"
types-toml = "^0.10.1" types-toml = "^0.10.1"
types-beautifulsoup4 = "^4.10.7" types-beautifulsoup4 = "^4.10.7"
types-Pillow = "^8.3.11" types-Pillow = "^8.3.11"
django-stubs = "^1.9.0"
[tool.black] [tool.black]
target-version = ['py38'] target-version = ['py38']
@ -64,16 +63,12 @@ env = [
[tool.mypy] [tool.mypy]
mypy_path = "$MYPY_CONFIG_FILE_DIR/stubs:$MYPY_CONFIG_FILE_DIR/src" mypy_path = "$MYPY_CONFIG_FILE_DIR/stubs:$MYPY_CONFIG_FILE_DIR/src"
plugins = ["mypy_django_plugin.main"]
disallow_untyped_defs = true disallow_untyped_defs = true
warn_redundant_casts = true warn_redundant_casts = true
strict_equality = true strict_equality = true
disallow_untyped_calls = true disallow_untyped_calls = true
warn_unreachable = true warn_unreachable = true
enable_error_code = ["redundant-expr", "truthy-bool"] enable_error_code = ["redundant-expr"]
[tool.django-stubs]
django_settings_module = "blog.settings"
[[tool.mypy.overrides]] [[tool.mypy.overrides]]
module = [ module = [

View file

@ -50,7 +50,7 @@ def open_graph_image_url(request: HttpRequest) -> dict[str, Any]:
return {} return {}
open_graph_image = Attachment.objects.get_open_graph_image() open_graph_image = Attachment.objects.get_open_graph_image()
url = "" 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) url = open_graph_image.processed_file.get_full_absolute_url(request)
return {"open_graph_image_url": url} return {"open_graph_image_url": url}

View file

@ -96,7 +96,7 @@ class SearchArticlesListView(PublicArticleListView):
class TagArticlesListView(PublicArticleListView): class TagArticlesListView(PublicArticleListView):
tag = None tag: Tag
main_title = "" main_title = ""
html_title = "" html_title = ""

View file

@ -45,7 +45,7 @@ class Attachment(models.Model):
return f"{self.description} ({self.original_file.name})" return f"{self.description} ({self.original_file.name})"
def reprocess(self) -> None: def reprocess(self) -> None:
self.processed_file = None self.processed_file = None # type: ignore
self.save() self.save()
def save(self, *args: Any, **kwargs: Any) -> None: def save(self, *args: Any, **kwargs: Any) -> None: