예제 #1
0
파일: rules.py 프로젝트: rahuliyer95/pants
async def fmt(formatter: IsortFormatter, isort: Isort) -> FmtResult:
    if isort.options.skip:
        return FmtResult.noop()
    setup = await Get[Setup](SetupRequest(formatter, check_only=False))
    result = await Get[ExecuteProcessResult](ExecuteProcessRequest,
                                             setup.process_request)
    return FmtResult.from_execute_process_result(result)
예제 #2
0
파일: rules.py 프로젝트: grimreaper/pants
async def fmt(wrapped_target: BlackTarget, black_setup: BlackSetup) -> FmtResult:
  if black_setup.skip:
    return FmtResult.noop()
  args = BlackArgs.create(black_setup=black_setup, wrapped_target=wrapped_target, check_only=False)
  request = await Get[ExecuteProcessRequest](BlackArgs, args)
  result = await Get[ExecuteProcessResult](ExecuteProcessRequest, request)
  return FmtResult.from_execute_process_result(result)
예제 #3
0
파일: rules.py 프로젝트: grimreaper/pants
async def fmt(wrapped_target: IsortTarget, isort_setup: IsortSetup) -> FmtResult:
  if isort_setup.skip:
    return FmtResult.noop()
  args = IsortArgs.create(wrapped_target=wrapped_target, isort_setup=isort_setup, check_only=False)
  request = await Get[ExecuteProcessRequest](IsortArgs, args)
  result = await Get[ExecuteProcessResult](ExecuteProcessRequest, request)
  return FmtResult.from_execute_process_result(result)
예제 #4
0
async def black_fmt(formatter: BlackFormatter, black: Black) -> FmtResult:
    if black.options.skip:
        return FmtResult.noop()
    setup = await Get[Setup](SetupRequest(formatter, check_only=False))
    result = await Get[ExecuteProcessResult](ExecuteProcessRequest,
                                             setup.process_request)
    return FmtResult.from_execute_process_result(result)
예제 #5
0
async def format_python_target(
        python_formatters: PythonFormatters,
        union_membership: UnionMembership) -> LanguageFmtResults:
    adaptors_with_origins = python_formatters.adaptors_with_origins
    original_sources = await Get[SourceFiles](AllSourceFilesRequest(
        adaptor_with_origin.adaptor
        for adaptor_with_origin in adaptors_with_origins))
    prior_formatter_result = original_sources.snapshot

    results: List[FmtResult] = []
    formatters: Iterable[
        Type[PythonFormatter]] = union_membership.union_rules[PythonFormatter]
    for formatter in formatters:
        result = await Get[FmtResult](
            PythonFormatter,
            formatter(adaptors_with_origins,
                      prior_formatter_result=prior_formatter_result),
        )
        if result != FmtResult.noop():
            results.append(result)
            prior_formatter_result = await Get[Snapshot](Digest, result.digest)
    return LanguageFmtResults(
        tuple(results),
        combined_digest=prior_formatter_result.directory_digest)
 def test_skip(self) -> None:
   lint_result, fmt_result = self.run_black([self.bad_source], skip=True)
   assert lint_result == LintResult.noop()
   assert fmt_result == FmtResult.noop()
예제 #7
0
 def test_skip(self) -> None:
     target = self.make_target_with_origin([self.bad_source])
     lint_result, fmt_result = self.run_isort([target], skip=True)
     assert lint_result == LintResult.noop()
     assert fmt_result == FmtResult.noop()