# Problem with Typed List function argument

**URL:** <https://numba.discourse.group/t/problem-with-typed-list-function-argument/2199>\
**Category:** Community Support\
**Created:** [October 12, 2023, 7:00am UTC](https://numba.discourse.group/t/problem-with-typed-list-function-argument/2199 "2023-10-12T07:00:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![edfink234](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/edfink234/32/914_2.png) [@edfink234](https://numba.discourse.group/u/edfink234)\
**Post date:** [October 12, 2023, 7:00am UTC](https://numba.discourse.group/t/problem-with-typed-list-function-argument/2199/1 "2023-10-12T07:00:02Z")

</div>

Hello,

I have a simple function that I would like to njit in numba that takes a list of strings as the argument and returns a tuple of int and bool. The problem is with the function argument. When I do the following:

```python
@njit(types.Tuple((types.int32, types.boolean))(types.List(types.unicode_type,True)))
def func(items: list[str]) -> tuple[int, bool]:
    return len(items), 'apple' in items

print(func(["apple", "orange", "banana"])) #(3, True)

```

I get the warning:

```auto
NumbaPendingDeprecationWarning: 
Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'lst' of function 'in_seq.<locals>.seq_contains_impl'.

For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

def in_seq(context, builder, sig, args):
    def seq_contains_impl(lst, value):
    ^

  warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))

```

However when I change it to use `typed.List` below:

```python
from numba import njit, types, typed

@njit(types.Tuple((types.int32, types.boolean))(typed.List(types.unicode_type)))
def func(items: list[str]) -> tuple[int, bool]:
    return len(items), 'apple' in items

print(func(["apple", "orange", "banana"]))

```

I get:

`KeyError: 'Can only index numba types with slices with no start or stop, got 0.'`

What should I do in this situation?

My numba version is 0.58.0 and the Python version is Python 3.9.17 and am using a Mac Book Pro with an M1 chip

---

<div class="post-metadata">

**Author:** ![Oyibo](https://avatars.discourse-cdn.com/v4/letter/o/4af34b/32.png) [@Oyibo](https://numba.discourse.group/u/Oyibo)\
**Post date:** [October 12, 2023, 9:31am UTC](https://numba.discourse.group/t/problem-with-typed-list-function-argument/2199/2 "2023-10-12T09:31:37Z")

</div>

Hey @edfink234 ,  
Numba allows reflected and typed lists as arguments.  
Using reflected lists you will receive a DeprecationWarning.  
You can switch off the warning when you generate the jitted function if you need to use reflected lists.  
If you want to use typed list the correct definition would be ListType(unicode\_type).

```auto
import warnings
import numba as nb
import numba.types as nbt
from numba.core.errors import NumbaDeprecationWarning, NumbaPendingDeprecationWarning

def pyfunc(items: list[str]) -> tuple[int, bool]:
    return len(items), 'apple' in items

typeReflectedList = nbt.List(nbt.unicode_type, True)
typeTypedList = nbt.ListType(nbt.unicode_type)
signature = [nbt.Tuple((nbt.int32, nbt.boolean))(typeReflectedList),
             nbt.Tuple((nbt.int32, nbt.boolean))(typeTypedList)]

with warnings.catch_warnings():
    warnings.simplefilter('ignore', category=NumbaDeprecationWarning)
    warnings.simplefilter('ignore', category=NumbaPendingDeprecationWarning)
    jitfunc = nb.njit(signature)(pyfunc)

myReflectedList = ["apple", "orange", "banana"]
myTypedList = nb.typed.List(myReflectedList)
print(jitfunc(myReflectedList))
print(jitfunc(myTypedList))
# (3, True)
# (3, True)

```
