# Understanding Type Hinting with Python Arrays (Lists)

**URL:** https://forum.makecode.com/t/understanding-type-hinting-with-python-arrays-lists/43109
**Category:** Arcade
**Created:** [April 3, 2026, 6:03pm UTC](https://forum.makecode.com/t/understanding-type-hinting-with-python-arrays-lists/43109 "2026-04-03T18:03:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![michaelcaplan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/michaelcaplan/32/14780_2.png) [@michaelcaplan](https://forum.makecode.com/u/michaelcaplan)
#### Post date: [April 3, 2026, 6:03pm UTC](https://forum.makecode.com/t/understanding-type-hinting-with-python-arrays-lists/43109/1 "2026-04-03T18:03:06Z")

</div>

I believe I understand that when defining an empty array (list), you need to type hint it.

This does not work:

```auto
class test:
    def __init__ (self):
        self.a = randint(0, 10)

l = []

for i in range(4):
    l.append(test())
    pass

for value in l:
    print(value.a) #Line 12: unknown object type; cannot lookup attribute 'a'

```

This works:

```auto
class test:
    def __init__ (self):
        self.a = randint(0, 10)

l: List[test] = []

for i in range(4):
    l.append(test())
    pass

for value in l:
    print(value.a)

```

When introducing a typed list in a class, it throws a strange error:

```auto
class pest:
    def __init__ (self):
        self.l: List[test] = [] #Line 3: ';' expected.
        for i in range(4):
            self.l.append(test())
            pass

class test:
    def __init__ (self):
        self.a = randint(0, 10)

pest_obj = pest()

for value in pest_obj.l:
    print(value.a)

```

Why is that?

If I "seed’ the list with a value on definition, the compiler does not complain:

```auto
class pest:
    def __init__ (self):
        self.l = [test()]
        for i in range(4):
            self.l.append(test())
            pass

class test:
    def __init__ (self):
        self.a = randint(0, 10)

pest_obj = pest()

for value in pest_obj.l:
    print(value.a)

```

Thanks for the feedback,

Mike

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [April 3, 2026, 6:15pm UTC](https://forum.makecode.com/t/understanding-type-hinting-with-python-arrays-lists/43109/2 "2026-04-03T18:15:36Z")

</div>

ah, this is definitely a makecode bug (or i guess a python feature we never implemented). we don’t currently have support for annotated assignments on class properties

i’ll file an issue for this. unfortunately, i don’t have a workaround for you right now other than the seeding option you demonstrated

---

<div class="post-metadata">

### Author: ![michaelcaplan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/michaelcaplan/32/14780_2.png) [@michaelcaplan](https://forum.makecode.com/u/michaelcaplan)
#### Post date: [April 4, 2026, 1:14am UTC](https://forum.makecode.com/t/understanding-type-hinting-with-python-arrays-lists/43109/3 "2026-04-04T01:14:05Z")

</div>

Thanks Richard!
