From 224c73605496a423aeccc2556b6a6a6a41f84ff9 Mon Sep 17 00:00:00 2001 From: Rob Hudson Date: Mon, 16 Sep 2024 12:17:07 -0700 Subject: [PATCH] Run `pyupgrade --py312-plus **/*.py` --- bedrock/base/tests/test_views.py | 2 +- bedrock/cms/tests/test_rendering.py | 2 +- .../mozorg/management/commands/update_root_store_policy_page.py | 2 +- bedrock/pocketfeed/api.py | 2 +- bedrock/pocketfeed/tests/test_api.py | 2 +- bin/check-pinned-requirements.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bedrock/base/tests/test_views.py b/bedrock/base/tests/test_views.py index 3a315619985..1154683a965 100644 --- a/bedrock/base/tests/test_views.py +++ b/bedrock/base/tests/test_views.py @@ -51,7 +51,7 @@ def test_no_country(self): @pytest.mark.django_db def test_get_contentful_sync_info(mock_timeago_format, mock_tz_now): mock_timeago_format.return_value = "mock-formatted-time-delta" - _now = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc) + _now = datetime.datetime.utcnow().replace(tzinfo=datetime.UTC) mock_tz_now.return_value = _now middle = tz_now() diff --git a/bedrock/cms/tests/test_rendering.py b/bedrock/cms/tests/test_rendering.py index 5a3042c2c1d..9d0226490ba 100644 --- a/bedrock/cms/tests/test_rendering.py +++ b/bedrock/cms/tests/test_rendering.py @@ -109,5 +109,5 @@ def test_locales_are_drawn_from_page_translations(minimal_site, rf, serving_meth page_content = str(resp.content) assert "Test Page" in page_content assert '' in page_content - assert ''.encode("utf-8") in resp.content + assert ''.encode() in resp.content assert '' not in page_content diff --git a/bedrock/mozorg/management/commands/update_root_store_policy_page.py b/bedrock/mozorg/management/commands/update_root_store_policy_page.py index dcff6e2a94b..64c22164bfd 100644 --- a/bedrock/mozorg/management/commands/update_root_store_policy_page.py +++ b/bedrock/mozorg/management/commands/update_root_store_policy_page.py @@ -59,7 +59,7 @@ def _wrap_html_with_django_template(self, html): # Note: we don't want to render the actual template at this stage, # we just want to augment what's IN the template with the HTML from # the Policy doc, rendered from Markdown - with open(WRAPPING_TEMPLATE_PATH, "r") as fp: + with open(WRAPPING_TEMPLATE_PATH) as fp: template = fp.read() wrapped_html = template.replace("__HTML_POLICY_CONTENT_PLACEHOLDER__", html) return wrapped_html diff --git a/bedrock/pocketfeed/api.py b/bedrock/pocketfeed/api.py index 6eea92a60f7..3d5bed5e968 100644 --- a/bedrock/pocketfeed/api.py +++ b/bedrock/pocketfeed/api.py @@ -35,7 +35,7 @@ def complete_articles_data(articles): article["pocket_id"] = article["id"] # convert time_shared from unix timestamp to datetime - article["time_shared"] = make_aware(datetime.datetime.fromtimestamp(int(article["time_shared"])), datetime.timezone.utc) + article["time_shared"] = make_aware(datetime.datetime.fromtimestamp(int(article["time_shared"])), datetime.UTC) # remove data points we don't need del article["comment"] diff --git a/bedrock/pocketfeed/tests/test_api.py b/bedrock/pocketfeed/tests/test_api.py index c0e08c06612..5cc2aa99f8d 100644 --- a/bedrock/pocketfeed/tests/test_api.py +++ b/bedrock/pocketfeed/tests/test_api.py @@ -54,7 +54,7 @@ def test_complete_articles_data(req_mock): assert "quote" not in articles[0][1] # 'time_shared' should be converted to a datetime value - assert articles[0][1]["time_shared"] == make_aware(datetime.datetime(2018, 7, 18, 11, 14, 18), datetime.timezone.utc) + assert articles[0][1]["time_shared"] == make_aware(datetime.datetime(2018, 7, 18, 11, 14, 18), datetime.UTC) # should have attempted to GET request against image_src req_mock.get.assert_called_once_with("https://www.test.com/test.png") diff --git a/bin/check-pinned-requirements.py b/bin/check-pinned-requirements.py index 21460799201..9979dc46634 100755 --- a/bin/check-pinned-requirements.py +++ b/bin/check-pinned-requirements.py @@ -11,7 +11,7 @@ def extract_pinned(requirements_file): """Extract pinned dependencies from a requirements file.""" pinned_deps = {} - with open(requirements_file, "r") as file: + with open(requirements_file) as file: for line in file: # Skip comments and empty lines if line.strip() and not line.startswith("#"):