Broken ability to annotate with type information (8.2)

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
jeffster
Veteran
Posts: 409
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Broken ability to annotate with type information (8.2)

#1 Post by jeffster »

PS. OK, I guess it's not a bug but an intentional change. For type hint annotations using particular classes like Optional, Union etc. we'll need to have imports like

Code: Select all

init python:
    from typing import Optional, Union
---- The original post: ----

This isn't completely functional in 8.2:
Python 3 Support (Ren'Py 8.0)
...
The ability to annotate functions arguments and return values with type information. (This is only supported in Python.)
https://renpy.org/doc/html/changelog.ht ... ren-py-8-0

Both in the last stable release and "+ Nightly Fix":
8.2.1.24030407
8.2.2.24032701+nightly

you get errors with some type hint annotations like

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/inventory.rpy", line 676, in script
    init python:
  File "game/inventory.rpy", line 676, in script
    init python:
  File "game/inventory.rpy", line 684, in <module>
    def findLast(l: list, val) -> Optional[int]:
NameError: name 'Optional' is not defined
Names like 'Optional' and the like are not defined. (They should).

A program to test the bug:
download/file.php?id=64314
posted in
viewtopic.php?t=66699

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]