From 29d51f8d1ac472456d93ac84b6106153e9089ada Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Fri, 28 Nov 2025 23:39:35 +0100 Subject: [PATCH] Fix types @ `galaxy.collection.galaxy_api_proxy` This includes enforcing `strict_optional` for the `ansible.galaxy.collection.galaxy_api_proxy` module in MyPy. --- lib/ansible/galaxy/collection/galaxy_api_proxy.py | 4 ++-- test/sanity/code-smell/mypy/ansible-core.ini | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/galaxy/collection/galaxy_api_proxy.py b/lib/ansible/galaxy/collection/galaxy_api_proxy.py index 046354a395d..18c6e6304e1 100644 --- a/lib/ansible/galaxy/collection/galaxy_api_proxy.py +++ b/lib/ansible/galaxy/collection/galaxy_api_proxy.py @@ -34,7 +34,7 @@ class MultiGalaxyAPIProxy: self._offline = offline # Prevent all GalaxyAPI calls @property - def is_offline_mode_requested(self): + def is_offline_mode_requested(self) -> bool: return self._offline def _assert_that_offline_mode_is_not_requested(self) -> None: @@ -117,7 +117,7 @@ class MultiGalaxyAPIProxy: else self._apis ) - last_err: t.Optional[Exception] + last_err: Exception for api in api_lookup_order: try: diff --git a/test/sanity/code-smell/mypy/ansible-core.ini b/test/sanity/code-smell/mypy/ansible-core.ini index 24414954c69..1fe3d751389 100644 --- a/test/sanity/code-smell/mypy/ansible-core.ini +++ b/test/sanity/code-smell/mypy/ansible-core.ini @@ -23,6 +23,9 @@ ignore_missing_imports = True [mypy-ansible_test.*] ignore_missing_imports = True +[mypy-ansible.galaxy.collection.galaxy_api_proxy] +strict_optional = True + [mypy-ansible.galaxy.dependency_resolution.*] strict_optional = True