• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 19015773527

02 Nov 2025 05:33PM UTC coverage: 17.872% (-62.4%) from 80.3%
19015773527

Pull #22816

github

web-flow
Merge a12d75757 into 6c024e162
Pull Request #22816: Update Pants internal Python to 3.14

4 of 5 new or added lines in 3 files covered. (80.0%)

28452 existing lines in 683 files now uncovered.

9831 of 55007 relevant lines covered (17.87%)

0.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/python/pants/backend/python/lint/autoflake/rules.py
1
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

UNCOV
4
from dataclasses import dataclass
×
5

UNCOV
6
from pants.backend.python.lint.autoflake.skip_field import SkipAutoflakeField
×
UNCOV
7
from pants.backend.python.lint.autoflake.subsystem import Autoflake
×
UNCOV
8
from pants.backend.python.target_types import PythonSourceField
×
UNCOV
9
from pants.backend.python.util_rules import pex
×
UNCOV
10
from pants.backend.python.util_rules.pex import VenvPexProcess, create_venv_pex
×
UNCOV
11
from pants.core.goals.fix import FixResult, FixTargetsRequest
×
UNCOV
12
from pants.core.util_rules.partitions import PartitionerType
×
UNCOV
13
from pants.engine.process import execute_process_or_raise
×
UNCOV
14
from pants.engine.rules import collect_rules, implicitly, rule
×
UNCOV
15
from pants.engine.target import FieldSet, Target
×
UNCOV
16
from pants.util.logging import LogLevel
×
UNCOV
17
from pants.util.strutil import pluralize
×
18

19

UNCOV
20
@dataclass(frozen=True)
×
UNCOV
21
class AutoflakeFieldSet(FieldSet):
×
UNCOV
22
    required_fields = (PythonSourceField,)
×
23

24
    source: PythonSourceField
25

UNCOV
26
    @classmethod
×
UNCOV
27
    def opt_out(cls, tgt: Target) -> bool:
×
28
        return tgt.get(SkipAutoflakeField).value
×
29

30

UNCOV
31
class AutoflakeRequest(FixTargetsRequest):
×
UNCOV
32
    field_set_type = AutoflakeFieldSet
×
UNCOV
33
    tool_subsystem = Autoflake  # type: ignore[assignment]
×
UNCOV
34
    partitioner_type = PartitionerType.DEFAULT_SINGLE_PARTITION
×
35

36

UNCOV
37
@rule(desc="Fix with Autoflake", level=LogLevel.DEBUG)
×
UNCOV
38
async def autoflake_fix(request: AutoflakeRequest.Batch, autoflake: Autoflake) -> FixResult:
×
39
    autoflake_pex = await create_venv_pex(**implicitly(autoflake.to_pex_request()))
×
40
    result = await execute_process_or_raise(
×
41
        **implicitly(
42
            VenvPexProcess(
43
                autoflake_pex,
44
                argv=(
45
                    "--in-place",
46
                    *autoflake.args,
47
                    *request.files,
48
                ),
49
                input_digest=request.snapshot.digest,
50
                output_files=request.files,
51
                description=f"Run Autoflake on {pluralize(len(request.files), 'file')}.",
52
                level=LogLevel.DEBUG,
53
            )
54
        )
55
    )
56
    return await FixResult.create(request, result)
×
57

58

UNCOV
59
def rules():
×
UNCOV
60
    return (
×
61
        *collect_rules(),
62
        *AutoflakeRequest.rules(),
63
        *pex.rules(),
64
    )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc