why isn't functools.wraps preserving intellisense?

68 views Asked by At

python 3.12 pycharm pro 2023.2.2

i have this (stripped down) code where i check if an input is an id or serial, and then convert as necessary. with the decorator in place pycharm does not warn me that get_id fails to pass df to serial_to_id. i thought functools.wraps was supposed to solve this exact issue? if i comment out the decorator i get the desired squiggly red line

def a_decorator(func):
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        return func(*args, **kwargs)
    return wrapper

def an_id(id_or_serial):
    return len(id_or_serial) == 4

@a_decorator
def serial_to_id(serial, df):
    return convert(df=df, value=serial)

def get_id(id_or_serial):
    return id_or_serial if an_id(id_or_serial) else serial_to_id(id_or_serial)

0

There are 0 answers