Skip to content

Conversation

@BrunodsLilly
Copy link
Contributor

@BrunodsLilly BrunodsLilly commented Oct 26, 2025

What was changed

This PR fixes a TypeError in temporalio/converter.py that occurs on Python 3.13.

The isinstance(key, key_type) check in the value_to_type function was modified to include a guard: not isinstance(key_type, type). This prevents the illegal isinstance() call from being used on typing generics like typing.Literal.

A new unit test is also added to reproduce this specific bug and verify the fix.

Why?

On Python 3.13+, isinstance() can no longer be used with subscripted generics (like typing.Literal), and doing so raises a TypeError. The value_to_type function was not handling this, causing data conversion to fail for dictionaries with Literal keys.

This fix short-circuits the logic to avoid the illegal call, allowing the function to fall through to the correct value_to_type call which already handles Literal types properly.

Checklist

  1. Closes [Bug] converter.py: TypeError on Python 3.13 when using isinstance with typing.Literal #1188

  2. How was this tested:
    A new unit test was added (test_value_to_type_literal_key_bug) that specifically reproduces this bug. This test fails before the fix and passes with it. The full test suite was also run successfully via poe test.

  3. Any docs updates needed?
    No. This is a minor internal bug fix.

@BrunodsLilly BrunodsLilly requested a review from a team as a code owner October 26, 2025 17:00
@CLAassistant
Copy link

CLAassistant commented Oct 26, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@tconley1428 tconley1428 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the one comment, and poe lint doesn't currently pass on the test.

@tconley1428 tconley1428 merged commit 35347b9 into temporalio:main Oct 30, 2025
25 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] converter.py: TypeError on Python 3.13 when using isinstance with typing.Literal

3 participants