# IntEnum as optional argument

Hey Numba team,

I’m encountering an issue while trying to use an IntEnum as an optional argument in a jitted function. Whenever I attempt to pass an IntEnum member as an optional argument, I get a `TypeError: '>' not supported between instances of 'Conversion' and 'NoneType'`. Explicit casting into an integer doesn’t seem to be supported.

``````from enum import IntEnum
import numba as nb

class Number(IntEnum):
ONE = 1
TWO = 2
THREE = 3

@nb.njit(['i8(i8, i8)', 'i8(i8, Omitted(None))'])
b = b or Number.ONE
return a+b

# TypeError: '>' not supported between instances of 'Conversion' and 'NoneType'
``````

Surprisingly, if you’ve previously called a function that uses IntEnum as an ordinary argument, you can then use the IntEnum as an optional argument, too.

``````from enum import IntEnum
import numba as nb

class Number(IntEnum):
ONE = 1
TWO = 2
THREE = 3

@nb.njit(['i8(i8, i8)'])
return a+b

@nb.njit(['i8(i8, i8)', 'i8(i8, Omitted(None))'])
b = b or Number.ONE
return a+b

``````

Is there a way to provide sufficient type hints and prevent the TypeError?

Here is a version with type inference:

``````from enum import IntEnum
import numba as nb

class Number(IntEnum):
ONE = 1
TWO = 2
THREE = 3

@nb.njit
if b is None:
bint = Number.ONE
else:
bint = b
return a + bint

# [(int64, int64), (int64, omitted(default=None)), (int64, IntEnum<int64>(Number))]
``````

Here is a version with explicit signatures:

``````from enum import IntEnum
import numba as nb
import numba.types as nbt

class Number(IntEnum):
ONE = 1
TWO = 2
THREE = 3

# Register the IntEnum with Numba.
NumberType = nb.typeof(Number.ONE)

@nb.njit(['i8(i8, i8)', 'i8(i8, Omitted(None))', nbt.i8(nbt.i8, NumberType)])
if b is None:
bint = Number.ONE
else:
bint = b
return a + bint

``````

Unfortunately, these implementations result in an additional function signature which might be avoidable.

This seems to work as intended.

``````from enum import IntEnum
import numba as nb

class Number(IntEnum):
ONE = 1
TWO = 2
THREE = 3

# Register Numba type for your IntEnum class
@nb.extending.typeof_impl.register(Number)
def typeof_number(obj, c):
return nb.types.int64

@nb.njit
b = b or Number.ONE
return a + b