MCPcopy
hub / github.com/psf/black / detect_target_versions

Function detect_target_versions

src/black/__init__.py:1563–1570  ·  view source on GitHub ↗

Detect the version to target based on the nodes used.

(
    node: Node, *, future_imports: set[str] | None = None
)

Source from the content-addressed store, hash-verified

1561
1562
1563def detect_target_versions(
1564 node: Node, *, future_imports: set[str] | None = None
1565) -> set[TargetVersion]:
1566 """Detect the version to target based on the nodes used."""
1567 features = get_features_used(node, future_imports=future_imports)
1568 return {
1569 version for version in TargetVersion if features <= VERSION_TO_FEATURES[version]
1570 }
1571
1572
1573def get_future_imports(node: Node) -> set[str]:

Callers 1

_format_str_onceFunction · 0.85

Calls 1

get_features_usedFunction · 0.85

Tested by

no test coverage detected