Skip to content

Commit 994d2ec

Browse files
committed
mypy
1 parent 9e5a959 commit 994d2ec

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

packages/settings-library/src/settings_library/utils_service.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
""" Helpers to build settings for services with http API
1+
"""Helpers to build settings for services with http API"""
22

3-
4-
"""
53
from enum import Enum, auto
4+
from typing import Any
65

76
from pydantic.networks import AnyUrl
87
from pydantic.types import SecretStr
@@ -97,7 +96,7 @@ def _compose_url(
9796

9897
port_value = self._safe_getattr(f"{prefix}_PORT", port)
9998

100-
parts = {
99+
parts: dict[str, Any] = {
101100
"scheme": (
102101
"https"
103102
if self._safe_getattr(f"{prefix}_SECURE", URLPart.OPTIONAL)
@@ -114,21 +113,18 @@ def _compose_url(
114113
parts["path"] = f"{v}"
115114

116115
# post process parts dict
117-
kwargs = {}
118-
for k, v in parts.items(): # type: ignore[assignment]
119-
if isinstance(v, SecretStr):
120-
value = v.get_secret_value()
121-
else:
122-
value = v
116+
kwargs: dict[str, Any] = {}
117+
for k, v in parts.items():
118+
value = v.get_secret_value() if isinstance(v, SecretStr) else v
123119

124120
if value is not None:
125121
kwargs[k] = value
126122

127123
assert all(
128-
isinstance(v, (str, int)) or v is None for v in kwargs.values()
124+
isinstance(v, str | int) or v is None for v in kwargs.values()
129125
) # nosec
130126

131-
composed_url: str = str(AnyUrl.build(**kwargs)) # type: ignore[arg-type] # pylint: disable=missing-kwoa
127+
composed_url = str(AnyUrl.build(**kwargs))
132128
return composed_url.rstrip("/")
133129

134130
def _build_api_base_url(self, *, prefix: str) -> str:

0 commit comments

Comments
 (0)