From 7b9571440c30ddfeefe68261d44a14f76b8780b1 Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Mon, 28 Oct 2024 11:21:04 -0400 Subject: [PATCH] chore: address some nits and lints (#16974) --- pyproject.toml | 4 +--- tests/functional/manage/test_views.py | 4 +++- warehouse/filters.py | 2 +- warehouse/integrations/vulnerabilities/__init__.py | 4 ++-- warehouse/logging.py | 2 +- warehouse/utils/sns.py | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e44f6a68e802..fc00bdd4de53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,6 @@ cache_dir = "dev/.mypy_cache" [[tool.mypy.overrides]] # These modules do not yet have types available. module = [ - "alembic_postgresql_enum.*", "automat.*", "bpython.*", # https://github.com/bpython/bpython/issues/892 "b2sdk.*", # https://github.com/Backblaze/b2-sdk-python/issues/148 @@ -60,7 +59,6 @@ module = [ "google.cloud.*", "forcediphttpsadapter.*", "IPython.*", # has types, but only installed in dev - "linehaul.*", "packaging_legacy.*", "paginate.*", "paginate_sqlalchemy.*", @@ -77,7 +75,6 @@ module = [ "transaction.*", "ua_parser.*", # https://github.com/ua-parser/uap-python/issues/110 "venusian.*", - "whitenoise.*", "zope.sqlalchemy.*", ] ignore_missing_imports = true @@ -97,6 +94,7 @@ markers = [ ] filterwarnings = [ 'ignore::warehouse.admin.services.InsecureStorageWarning', + 'ignore::warehouse.utils.exceptions.InsecureIntegrityServiceWarning', 'ignore::warehouse.utils.exceptions.InsecureOIDCPublisherWarning', 'ignore::warehouse.packaging.services.InsecureStorageWarning', 'error:SELECT statement has a cartesian product:sqlalchemy.exc.SAWarning', diff --git a/tests/functional/manage/test_views.py b/tests/functional/manage/test_views.py index 545f78426b32..f41e62a4bd95 100644 --- a/tests/functional/manage/test_views.py +++ b/tests/functional/manage/test_views.py @@ -81,7 +81,9 @@ def test_changing_password_succeeds(self, webtest, socket_enabled): ) logged_in = two_factor_form.submit().follow(status=HTTPStatus.OK) - assert logged_in.html.find("title", text="Warehouse · The Python Package Index") + assert logged_in.html.find( + "title", string="Warehouse · The Python Package Index" + ) # Now visit the change password page change_password_page = logged_in.goto("/manage/account/", status=HTTPStatus.OK) diff --git a/warehouse/filters.py b/warehouse/filters.py index 2033ea683b99..68364adfc6d3 100644 --- a/warehouse/filters.py +++ b/warehouse/filters.py @@ -129,7 +129,7 @@ def format_tags(tags): def format_classifiers(classifiers): - structured = collections.OrderedDict() + structured: collections.OrderedDict[str, list[str]] = collections.OrderedDict() # Split up our classifiers into our data structure for classifier in classifiers: diff --git a/warehouse/integrations/vulnerabilities/__init__.py b/warehouse/integrations/vulnerabilities/__init__.py index 9d149ada3580..f0ecac0026c3 100644 --- a/warehouse/integrations/vulnerabilities/__init__.py +++ b/warehouse/integrations/vulnerabilities/__init__.py @@ -27,8 +27,8 @@ def __init__( vulnerability_id: str, advisory_link: str, aliases: list[str], - details: str, - summary: str, + details: str | None, + summary: str | None, fixed_in: list[str], withdrawn: str | None, ): diff --git a/warehouse/logging.py b/warehouse/logging.py index d374c96f9cfd..47a74ac7d992 100644 --- a/warehouse/logging.py +++ b/warehouse/logging.py @@ -37,7 +37,7 @@ def format(self, record): "event": record.msg, "thread": threading.get_ident(), } - record.msg = RENDERER(None, None, event_dict) + record.msg = RENDERER(None, record.levelname, event_dict) return super().format(record) diff --git a/warehouse/utils/sns.py b/warehouse/utils/sns.py index 3b1fc43c4d21..ed9eb8af444a 100644 --- a/warehouse/utils/sns.py +++ b/warehouse/utils/sns.py @@ -80,7 +80,7 @@ def _get_pubkey(self, cert_url): cert_host = cert_url_p.netloc if cert_scheme != "https": raise InvalidMessageError("Invalid scheme for SigningCertURL") - if _signing_url_host_re.fullmatch(cert_host) is None: + if not cert_host or _signing_url_host_re.fullmatch(cert_host) is None: raise InvalidMessageError("Invalid location for SigningCertURL") resp = self.http.get(cert_url)