src/upgrade_type_hints/update.py
def replace_type(old_annotation: str, new_annotation: str, line) -> tuple[bytes, dict]:
    """
    Perform type replacement on a string (line).
    """
    new_annotation = bytes(new_annotation, encoding='utf-8')
    pattern = b'[^a-zA-Z](' + old_annotation.encode(encoding='utf-8') + b')(?:[^a-zA-Z]|$)'
    match = re.search(pattern, line)
    line = line[: match.start(1)] + line[match.end(1) :]
    line = line[: match.start(1)] + new_annotation + line[match.start(1) :]
    return line

    Perform type replacement on a string (line).
    
Perform type replacement on a string (line).
Perform type replacement on a string ( line ) .
def replace_type(old_annotation: str, new_annotation: str, line) -> tuple[bytes, dict]:
    new_annotation = bytes(new_annotation, encoding='utf-8')
    pattern = b'[^a-zA-Z](' + old_annotation.encode(encoding='utf-8') + b')(?:[^a-zA-Z]|$)'
    match = re.search(pattern, line)
    line = line[: match.start(1)] + line[match.end(1) :]
    line = line[: match.start(1)] + new_annotation + line[match.start(1) :]
    return line
def replace_type ( old_annotation : str , new_annotation : str , line ) -> tuple [ bytes , dict ] : new_annotation = bytes ( new_annotation , encoding = 'utf-8' ) pattern = b'[^a-zA-Z](' + old_annotation . encode ( encoding = 'utf-8' ) + b')(?:[^a-zA-Z]|$)' match = re . search ( pattern , line ) line = line [ : match . start ( 1 ) ] + line [ match . end ( 1 ) : ] line = line [ : match . start ( 1 ) ] + new_annotation + line [ match . start ( 1 ) : ] return line
Perform type replacement on a string (line).
Perform type replacement on a string ( line ) .
"""
    Perform type replacement on a string (line).
    """
old_annotation
str
new_annotation
str
line