list type annotation support #47

Closed
opened 2021-10-03 17:17:03 +08:00 by sb10q · 5 comments
Owner
@kernel
class Foo:
    x: List[int32]

def run() -> int32:
    x = Foo()
    return 0

fails with

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "unknown class name"', nac3standalone/src/main.rs:65:35
```python @kernel class Foo: x: List[int32] def run() -> int32: x = Foo() return 0 ``` fails with ``` thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "unknown class name"', nac3standalone/src/main.rs:65:35 ```
Author
Owner

Outside classes the error is different:

def run() -> int32:
    x: List[int32] = [1, 2]
    return 0
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Unknown type annotation List"', nac3standalone/src/main.rs:65:35
Outside classes the error is different: ```python def run() -> int32: x: List[int32] = [1, 2] return 0 ``` ``` thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Unknown type annotation List"', nac3standalone/src/main.rs:65:35 ```
sb10q changed title from list type annotation support in classes to list type annotation support 2021-10-03 17:18:26 +08:00
Author
Owner

list works. Do we want to support List? It's in the typing module...

If not we should specify Python 3.9+ (which is fine for me):

Python 3.8.11 (default, Jun 28 2021, 10:57:31) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> list[int]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'type' object is not subscriptable


Python 3.9.6 (default, Jun 28 2021, 08:57:49) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> list[int]
list[int]
``list`` works. Do we want to support ``List``? It's in the ``typing`` module... If not we should specify Python 3.9+ (which is fine for me): ``` Python 3.8.11 (default, Jun 28 2021, 10:57:31) [GCC 10.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> list[int] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'type' object is not subscriptable Python 3.9.6 (default, Jun 28 2021, 08:57:49) [GCC 10.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> list[int] list[int] ```
Author
Owner

How about we only support list? List is deprecated in Python 3.9.

I'm still a bit worried about the first error message, why does it print "unknown class name"?

How about we only support ``list``? ``List`` is deprecated in Python 3.9. I'm still a bit worried about the first error message, why does it print "unknown class name"?
Collaborator

How about we only support list? List is deprecated in Python 3.9.

I'm still a bit worried about the first error message, why does it print "unknown class name"?

It prints this for now:

NameError: name 'List' is not defined

We support list already.

> How about we only support ``list``? ``List`` is deprecated in Python 3.9. > > I'm still a bit worried about the first error message, why does it print "unknown class name"? It prints this for now: ``` NameError: name 'List' is not defined ``` We support list already.
Collaborator

can we close this?

can we close this?
sb10q closed this issue 2021-11-05 23:36:32 +08:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#47
No description provided.