src/upgrade_type_hints/definitions.py
def check_if_types_need_substitution(
    annotations: list[dict[str, str]], imports: list[dict]
) -> tuple[list, list]:
    """
    Checks whether the complete list of annotations contained in a file matches any of the pep-585-types
    we want to substitute.

    :return: We return a filtered list of dictionaries, where the dict has an
             extra attribute to indicate what it should be substituted with.
    """
    filtered_native_type_list = []
    filtered_import_list = []

    for item in annotations:
        stripped_annotation = item['annotation'].replace('typing.', '')
        if stripped_annotation in native_types:
            for _import in imports:
                if stripped_annotation in _import['names']:
                    item['new_annotation'] = native_types[stripped_annotation]
                    filtered_native_type_list.append(item)
                    break
        elif stripped_annotation in imported_types:
            for _import in imports:
                if stripped_annotation in _import['names']:
                    item['new_annotation'] = imported_types[stripped_annotation]['name']
                    item['import_from'] = imported_types[stripped_annotation]['from']
                    filtered_import_list.append(item)
                    break
    return filtered_native_type_list, filtered_import_list

    Checks whether the complete list of annotations contained in a file matches any of the pep-585-types
    we want to substitute.

    :return: We return a filtered list of dictionaries, where the dict has an
             extra attribute to indicate what it should be substituted with.
    
Checks whether the complete list of annotations contained in a file matches any of the pep-585-types
we want to substitute.
Checks whether the complete list of annotations contained in a file matches any of the pep - 585 - types we want to substitute .
def check_if_types_need_substitution(
    annotations: list[dict[str, str]], imports: list[dict]
) -> tuple[list, list]:
    filtered_native_type_list = []
    filtered_import_list = []
    for item in annotations:
        stripped_annotation = item['annotation'].replace('typing.', '')
        if stripped_annotation in native_types:
            for _import in imports:
                if stripped_annotation in _import['names']:
                    item['new_annotation'] = native_types[stripped_annotation]
                    filtered_native_type_list.append(item)
                    break
        elif stripped_annotation in imported_types:
            for _import in imports:
                if stripped_annotation in _import['names']:
                    item['new_annotation'] = imported_types[stripped_annotation]['name']
                    item['import_from'] = imported_types[stripped_annotation]['from']
                    filtered_import_list.append(item)
                    break
    return filtered_native_type_list, filtered_import_list
def check_if_types_need_substitution ( annotations : list [ dict [ str , str ] ] , imports : list [ dict ] ) -> tuple [ list , list ] : filtered_native_type_list = [ ] filtered_import_list = [ ] for item in annotations : stripped_annotation = item [ 'annotation' ] . replace ( 'typing.' , '' ) if stripped_annotation in native_types : for _import in imports : if stripped_annotation in _import [ 'names' ] : item [ 'new_annotation' ] = native_types [ stripped_annotation ] filtered_native_type_list . append ( item ) break elif stripped_annotation in imported_types : for _import in imports : if stripped_annotation in _import [ 'names' ] : item [ 'new_annotation' ] = imported_types [ stripped_annotation ] [ 'name' ] item [ 'import_from' ] = imported_types [ stripped_annotation ] [ 'from' ] filtered_import_list . append ( item ) break return filtered_native_type_list , filtered_import_list
Checks whether the complete list of annotations contained in a file matches any of the pep-585-types
we want to substitute.
Checks whether the complete list of annotations contained in a file matches any of the pep - 585 - types we want to substitute .
"""
    Checks whether the complete list of annotations contained in a file matches any of the pep-585-types
    we want to substitute.

    :return: We return a filtered list of dictionaries, where the dict has an
             extra attribute to indicate what it should be substituted with.
    """
We return a filtered list of dictionaries, where the dict has an
extra attribute to indicate what it should be substituted with.
We return a filtered list of dictionaries where the dict has an extra attribute to indicate what it should be substituted with .
annotations
list[dict[str, str]]
imports
list[dict]