# Buggy code
def _build_import_removals() -> Dict[MinVersion, Dict[str, Tuple[str, ...]]]:
    ret = {}
    future: Tuple[Tuple[MinVersion, Tuple[str, ...]], ...] = (
        ((2, 7), ("nested_scopes", "generators", "with_statement")),
        (
            (3,),
            (
                "absolute_import",
                "division",
                "print_function",
                "unicode_literals",
            ),
        ),
        ((3, 6), ()),
        ((3, 7), ("generator_stop",)),
        ((3, 8), ()),
    )

    prev: Tuple[str, ...] = ()
    for min_version, names in future:
        prev += names
        ret[min_version] = {"__future__": prev}
    # see reorder_python_imports
    for k, v in ret.items():
        if k >= (3,):
            v.update(
                {
                    "builtins": (
                        "ascii",
                        "bytes",
                        "chr",
                        "dict",
                        "filter",
                        "hex",
                        "input",
                        "int",
                        "list",
                        "map",
                        "max",
                        "min",
                        "next",
                        "object",
                        "oct",
                        "open",
                        "pow",
                        "range",
                        "round",
                        "str",
                        "super",
                        "zip",
                        "*",
                    ),
                    "io": ("open",),
                    "six": ("callable", "next"),
                    "six.moves": ("filter", "input", "map", "range", "zip"),
                }
            )
    return ret


# Traceback (KeyError)
venv/bin/pyupgrade --py39-plus src/**.py
Traceback (most recent call last):
File "/Users/bgabor8/git/a/venv/bin/pyupgrade", line 8, in <module>
sys.exit(main())
File "/Users/bgabor8/git/a/venv/lib/python3.9/site-packages/pyupgrade.py", line 2823, in main
ret |= _fix_file(filename, args)
File "/Users/bgabor8/git/a/venv/lib/python3.9/site-packages/pyupgrade.py", line 2770, in _fix_file
contents_text = _fix_tokens(contents_text, min_version=args.min_version)
File "/Users/bgabor8/git/a/venv/lib/python3.9/site-packages/pyupgrade.py", line 808, in _fix_tokens
_fix_import_removals(tokens, i, min_version)
File "/Users/bgabor8/git/a/venv/lib/python3.9/site-packages/pyupgrade.py", line 732, in _fix_import_removals
if modname not in IMPORT_REMOVALS[min_version]:
KeyError: (3, 9)

# Fixed code
def _build_import_removals() -> Dict[MinVersion, Dict[str, Tuple[str, ...]]]:
    ret = {}
    future: Tuple[Tuple[MinVersion, Tuple[str, ...]], ...] = (
        ((2, 7), ("nested_scopes", "generators", "with_statement")),
        (
            (3,),
            (
                "absolute_import",
                "division",
                "print_function",
                "unicode_literals",
            ),
        ),
        ((3, 6), ()),
        ((3, 7), ("generator_stop",)),
        ((3, 8), ()),
        ((3, 9), ()),
    )

    prev: Tuple[str, ...] = ()
    for min_version, names in future:
        prev += names
        ret[min_version] = {"__future__": prev}
    # see reorder_python_imports
    for k, v in ret.items():
        if k >= (3,):
            v.update(
                {
                    "builtins": (
                        "ascii",
                        "bytes",
                        "chr",
                        "dict",
                        "filter",
                        "hex",
                        "input",
                        "int",
                        "list",
                        "map",
                        "max",
                        "min",
                        "next",
                        "object",
                        "oct",
                        "open",
                        "pow",
                        "range",
                        "round",
                        "str",
                        "super",
                        "zip",
                        "*",
                    ),
                    "io": ("open",),
                    "six": ("callable", "next"),
                    "six.moves": ("filter", "input", "map", "range", "zip"),
                }
            )
    return ret