Skip to content

Fix type annotation for _internal_arguments and _read_internal_argument #1465

@cotovanu-cristian

Description

@cotovanu-cristian

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:

  1. Misleading to readers — code like self._read_internal_argument("isDebug") is True looks like a bug (comparing str | None to True can never succeed), even though it works correctly at runtime.
  2. Type checkers would flag downstream is True comparisons as always-False, since the declared return type is str | 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:
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions