From eb983f6d89fe19465f40eeb9f6270235f8c035dd Mon Sep 17 00:00:00 2001 From: James Van Dyne Date: Sat, 26 Oct 2024 09:20:13 +0900 Subject: [PATCH 1/6] Upgrade extruct to 0.17.0 --- requirements.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.lock b/requirements.lock index 447aaca5..68ce9e44 100644 --- a/requirements.lock +++ b/requirements.lock @@ -15,7 +15,7 @@ django-picklefield==3.1 ftfy==6.1.1 ronkyuu==0.9 ninka==0.3.4 -extruct==0.14.0 +extruct==0.17.0 django-turbo-response==0.0.48 phpserialize==1.3 django-debug-toolbar==3.2.1 From 04cf4976b3116ed2ef3062bfa3746a01c95853f0 Mon Sep 17 00:00:00 2001 From: James Van Dyne Date: Sat, 26 Oct 2024 09:23:09 +0900 Subject: [PATCH 2/6] Upgrade Django to latest LTS --- requirements.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.lock b/requirements.lock index 68ce9e44..42ba063f 100644 --- a/requirements.lock +++ b/requirements.lock @@ -1,6 +1,6 @@ arrow==1.2.3 asgiref==3.7.2 -Django==4.2.7 +Django==4.2.16 pytz==2022.7 sqlparse==0.4.1 django-webmention==3.0.0 From d43acf56ec450fc53be50c5e06e0a7d90890fd4d Mon Sep 17 00:00:00 2001 From: James Van Dyne Date: Sat, 26 Oct 2024 09:30:42 +0900 Subject: [PATCH 3/6] Remove pytz Pytz is deprecated and python builtins are faster. Win-win. --- apps/domain/wordpress/extract.py | 5 ++--- requirements.lock | 1 - tests/test_wordpress/test_extract.py | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/domain/wordpress/extract.py b/apps/domain/wordpress/extract.py index 8bc6216a..8eddc774 100644 --- a/apps/domain/wordpress/extract.py +++ b/apps/domain/wordpress/extract.py @@ -1,7 +1,6 @@ -from datetime import datetime +from datetime import datetime, timezone import phpserialize -import pytz from bs4 import BeautifulSoup from django.contrib.gis.geos import Point from django.utils.timezone import make_aware @@ -27,7 +26,7 @@ def extract_post_status(soup: BeautifulSoup) -> str: def extract_published_date(soup: BeautifulSoup) -> datetime | None: try: pub_date = datetime.strptime(soup.find("post_date_gmt").text, "%Y-%m-%d %H:%M:%S") - return make_aware(pub_date, pytz.utc) + return make_aware(pub_date, timezone.utc) except ValueError: # draft posts return None diff --git a/requirements.lock b/requirements.lock index 42ba063f..da7a995c 100644 --- a/requirements.lock +++ b/requirements.lock @@ -1,7 +1,6 @@ arrow==1.2.3 asgiref==3.7.2 Django==4.2.16 -pytz==2022.7 sqlparse==0.4.1 django-webmention==3.0.0 django-taggit==5.0.1 diff --git a/tests/test_wordpress/test_extract.py b/tests/test_wordpress/test_extract.py index 3b16292a..3dd3067d 100644 --- a/tests/test_wordpress/test_extract.py +++ b/tests/test_wordpress/test_extract.py @@ -1,7 +1,6 @@ -from datetime import datetime +from datetime import datetime, timezone import pytest -import pytz from bs4 import BeautifulSoup from django.contrib.gis.geos import Point @@ -91,7 +90,7 @@ def target(self): return extract_published_date def test_extract_published_date(self, target, post_xml_soup): - assert datetime(year=2020, month=9, day=14, hour=20, minute=30, second=23, tzinfo=pytz.utc) == target( + assert datetime(year=2020, month=9, day=14, hour=20, minute=30, second=23, tzinfo=timezone.utc) == target( post_xml_soup ) From ffa1f8ae14d629933ea942aab279f28c5ab5149b Mon Sep 17 00:00:00 2001 From: James Van Dyne Date: Sat, 26 Oct 2024 09:34:45 +0900 Subject: [PATCH 4/6] Upgrade DRF --- requirements.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.lock b/requirements.lock index da7a995c..d7a4f5a6 100644 --- a/requirements.lock +++ b/requirements.lock @@ -4,7 +4,7 @@ Django==4.2.16 sqlparse==0.4.1 django-webmention==3.0.0 django-taggit==5.0.1 -djangorestframework==3.14.0 +djangorestframework==3.15.2 beautifulsoup4==4.11.1 exif==1.4.2 Pillow==10.0.1 From fbff2f7129f9356cea8b370e9c97b81c8e37029b Mon Sep 17 00:00:00 2001 From: James Van Dyne Date: Sat, 26 Oct 2024 09:35:36 +0900 Subject: [PATCH 5/6] Reformat with black Upgrade formatted to match latest black standards. Include new E203,E701 to flake8 ignores as it conflicts with the latest black standards. --- apps/application/entry/_post_to_bridgy.py | 3 +-- apps/domain/files/operations.py | 3 +-- apps/domain/gis/queries.py | 1 + apps/tanzawa_plugin/exercise/interfaces/dashboard/_strava.py | 1 + requirements.lock | 2 +- tox.ini | 3 ++- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/application/entry/_post_to_bridgy.py b/apps/application/entry/_post_to_bridgy.py index a8b864d4..93f95cf2 100644 --- a/apps/application/entry/_post_to_bridgy.py +++ b/apps/application/entry/_post_to_bridgy.py @@ -8,8 +8,7 @@ from data.post import models as post_models -class AlreadySentWebmention(Exception): - ... +class AlreadySentWebmention(Exception): ... def post_to_mastodon(t_entry: entry_models.TEntry, entry_absolute_url: str): diff --git a/apps/domain/files/operations.py b/apps/domain/files/operations.py index 84c9ec9c..d21227c9 100644 --- a/apps/domain/files/operations.py +++ b/apps/domain/files/operations.py @@ -3,8 +3,7 @@ from domain.images import images as image_ops -class UnprocessableFile(Exception): - ... +class UnprocessableFile(Exception): ... def get_file( diff --git a/apps/domain/gis/queries.py b/apps/domain/gis/queries.py index 3a722458..35774be9 100644 --- a/apps/domain/gis/queries.py +++ b/apps/domain/gis/queries.py @@ -2,6 +2,7 @@ Mercator calculations used to fix the projection from geo-coordinate to x,y (flat) coordinates. Adapted from: https://wiki.openstreetmap.org/wiki/Mercator """ + import math EARTH_RADIUS_KM = 6378137.0 diff --git a/apps/tanzawa_plugin/exercise/interfaces/dashboard/_strava.py b/apps/tanzawa_plugin/exercise/interfaces/dashboard/_strava.py index 64cd7044..a74e3740 100644 --- a/apps/tanzawa_plugin/exercise/interfaces/dashboard/_strava.py +++ b/apps/tanzawa_plugin/exercise/interfaces/dashboard/_strava.py @@ -1,6 +1,7 @@ """ API Views for interacting with Strava """ + import logging from urllib import parse as url_parse diff --git a/requirements.lock b/requirements.lock index d7a4f5a6..0ed004af 100644 --- a/requirements.lock +++ b/requirements.lock @@ -24,7 +24,7 @@ types-requests==2.28.11.7 typing-extensions==4.4.0 mypy-extensions==0.4.3 mkdocs==1.2.2 -isort==5.11.2 +isort==5.13.2 django-meta==2.1.0 factory_boy==3.2.1 envparse==0.2.0 diff --git a/tox.ini b/tox.ini index 10746ffa..5b56247e 100644 --- a/tox.ini +++ b/tox.ini @@ -38,6 +38,7 @@ commands = mypy --config-file=tox.ini apps [testenv:lint] +profile = black deps = {[testenv]deps} commands = @@ -56,7 +57,7 @@ commands = exclude = migrations,urls.py,manage.py,settings.py,admin.py,.tox,venv max-line-length = 120 max-complexity = 10 -ignore = E203,W503,W504,I001 +ignore = E203,W503,W504,I001,E203,E701 enable-extensions=G per-file-ignores = */__init__.py: F401 From 06669358b4d0cb72b2432ca4a124bcb9b8b599db Mon Sep 17 00:00:00 2001 From: James Van Dyne Date: Sat, 26 Oct 2024 10:18:02 +0900 Subject: [PATCH 6/6] Lock pytest to versions below 8 As pytest-lazy-fixture is incompatible --- requirements.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.lock b/requirements.lock index 0ed004af..0f9a4ce6 100644 --- a/requirements.lock +++ b/requirements.lock @@ -32,3 +32,4 @@ django-htmx==1.13.0 polyline==1.4.0 cairosvg==2.5.2 PyMuPDF==1.22.2 +pytest<8 \ No newline at end of file