Skip to content

Errors with type annotation handling in 1.7.0 #796

@RussEaton

Description

@RussEaton

Hi,

Ver 1.7.0 seems to have introduced issues with the runtime handling of certain type annotations. The cases I have found so far are demonstrated by the following contrived minimal examples:

def foo[K](arg: K) -> K:
    ret: K = arg
    return ret

foo(1)

causes exception NameError: name 'K' is not defined

def bar(x) -> None:
    y: Any[int] = None

bar(1)

gives exception TypeError: type 'Any' is not subscriptable

Both work properly in ver 1.6.4 and are OK with Pylance.

Note that these problems arise with the declaration of the annotated variables above. Other uses of similar constructs seem to work OK, e.g:

def baz(x: Any[int] = None) -> None:
    pass

baz()

works fine.

Any thoughts?

pyscript 1.6.4 / 1.7.0
HA OS core 2025.12.1 on RPi4 & RPi3

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