def _update_code_co_name(self, code):
    "Python 3.10 changed the behaviour so that whenever a code object\n        is assembled in the compile(ast) the co_firstlineno would be == 1.\n\n        This makes pydevd/debugpy think that all cells invoked are the same\n        since it caches information based on (co_firstlineno, co_name, co_filename).\n\n        Given that, this function changes the code 'co_name' to be unique\n        based on the first real lineno of the code (which also has a nice\n        side effect of customizing the name so that it's not always <module>).\n\n        See: https://github.com/ipython/ipykernel/issues/841\n        "
    if (not hasattr(code, 'replace')):
        return code
    try:
        first_real_line = next(dis.findlinestarts(code))[1]
    except StopIteration:
        return code
    return code.replace(co_name=('<cell line: %s>' % (first_real_line,)))
Python 3.10 changed the behaviour so that whenever a code object
is assembled in the compile(ast) the co_firstlineno would be == 1.

This makes pydevd/debugpy think that all cells invoked are the same
since it caches information based on (co_firstlineno, co_name, co_filename).

Given that, this function changes the code 'co_name' to be unique
based on the first real lineno of the code (which also has a nice
side effect of customizing the name so that it's not always <module>).

See: https://github.com/ipython/ipykernel/issues/841
def _update_code_co_name(self, code):
    "Python 3.10 changed the behaviour so that whenever a code object\n        is assembled in the compile(ast) the co_firstlineno would be == 1.\n\n        This makes pydevd/debugpy think that all cells invoked are the same\n        since it caches information based on (co_firstlineno, co_name, co_filename).\n\n        Given that, this function changes the code 'co_name' to be unique\n        based on the first real lineno of the code (which also has a nice\n        side effect of customizing the name so that it's not always <module>).\n\n        See: https://github.com/ipython/ipykernel/issues/841\n        "
    if (not hasattr(code, 'replace')):
        return code
    try:
        first_real_line = next(dis.findlinestarts(code))[1]
    except StopIteration:
        return code
    return code.replace(co_name=('<cell line: %s>' % (first_real_line,)))