# development


12/12/2019, 2:30 AM
Copy code
class FormattablePythonType:

class BlackTarget:
	target: HydratedTarget

class IsortTarget:
	target: HydratedTarget

def rules():
	return [
	  UnionRule(FormattablePythonType, BlackTarget),
	  UnionRule(FormattablePythonType, IsortTarget),

def my_python_formatting_rule(...) -> FormatResult:
	"""This is an aggregator that allows multiple python formatters to coexist.

	TODO: It's not common to need to do this for sideeffects, but it will be common for linting.

	"linters for type" feels like a thing that can be accomplished with (possibly nested) unions?
	  # ... need to filter by relevant to this target type
	await MultiGet[LintResult](LintableType, linter.cls(target) for target in targets for linters in union_membership.members(LintableType))

	sources = my_python_target...sources
	for member in union_membership.members(FormattablePythonTypes):
	  result = await Get[FormatResult](FormattablePythonTypes, member.cls(sources))
	  sources = result.directory_digest
	  stdout_so_far = result.stdout

	return FormatResult(sources)