def detect_target_versions(
    node: Node, *, future_imports: Optional[set[str]] = None
) -> set[TargetVersion]:
    """Detect the version to target based on the nodes used."""
    features = get_features_used(node, future_imports=future_imports)
    return {
        version for version in TargetVersion if features <= VERSION_TO_FEATURES[version]
    }
Detect the version to target based on the nodes used.
src/black/__init__.py