Skip to content

PermissionHandler.approve_all has incorrect return type annotation #612

@madebygps

Description

@madebygps

The PermissionHandler.approve_all static method in types.py uses -> dict as its return type, but SessionConfig.on_permission_request expects a callable returning PermissionRequestResult. This causes a type checker error when using the SDK's own built-in handler:

Invalid argument to key "on_permission_request" with declared type
`(PermissionRequest, dict[str, str]) -> PermissionRequestResult | Awaitable[PermissionRequestResult]`
on TypedDict `SessionConfig`: value of type `def approve_all(request: Any, invocation: Any) -> dict[Unknown, Unknown]`

Current code:

class PermissionHandler:
    @staticmethod
    def approve_all(request: Any, invocation: Any) -> dict:
        return {"kind": "approved"}

Suggested change:

class PermissionHandler:
    @staticmethod
    def approve_all(request: PermissionRequest, invocation: dict[str, str]) -> PermissionRequestResult:
        return {"kind": "approved"}

Both types are already defined in the same file. The runtime behavior is unchanged, this is purely a type annotation fix.

SDK version: 0.1.29

Happy to pr, just let me know.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions