-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
ConfigurationManager._internal_arguments is annotated as dict[str, str] | None, and _read_internal_argument returns str | None. However, the underlying data comes from json.load(), which deserializes JSON values into their native Python types — booleans, ints, floats, lists, nested dicts, and nulls — not just strings.
File: packages/uipath-platform/src/uipath/platform/common/_config.py
def _read_internal_argument(self, key: str) -> str | None:
internal_args = self._internal_arguments
return internal_args.get(key) if internal_args else None
@cached_property
def _internal_arguments(self) -> dict[str, str] | None:
...Problem
The dict[str, str] annotation is too narrow. If the config JSON contains:
{"runtime": {"internalArguments": {"isDebug": true}}}then json.load() returns {"isDebug": True} (Python bool), but the type system says it's a str. This causes two issues:
- Misleading to readers — code like
self._read_internal_argument("isDebug") is Truelooks like a bug (comparingstr | NonetoTruecan never succeed), even though it works correctly at runtime. - Type checkers would flag downstream
is Truecomparisons as always-False, since the declared return type isstr | None.
Suggested Fix
Widen the type annotations to reflect what json.load() actually returns:
from typing import Any
def _read_internal_argument(self, key: str) -> Any:
...
@cached_property
def _internal_arguments(self) -> dict[str, Any] | None:
...Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels