Coverage for src/pylint_sort_functions/privacy_types.py: 100%

1"""Common types and data structures for privacy fixing functionality.

2

3 This module contains the shared types used across the privacy fixing system,

4 extracted to avoid circular imports between modules.

5

6 Part of the refactoring described in GitHub Issue #32.

7"""

8

9 from pathlib import Path

10 from typing import List, NamedTuple

11

12 from astroid import nodes # type: ignore[import-untyped]

13

14

15 class FunctionReference(NamedTuple):

16 """Represents a reference to a function within a module."""

17

18 node: nodes.NodeNG

19 line: int

20 col: int

21 context: str # "call", "decorator", "assignment", etc.

22

23

24 class FunctionTestReference(NamedTuple):

25 """Represents a reference to a function within a test file."""

26

27 file_path: Path

28 line: int

29 col: int

30 context: str # "import", "mock_patch", "call", etc.

31 reference_text: str # The actual text that needs to be replaced

32

33

34 class RenameCandidate(NamedTuple):

35 """Represents a function that is a candidate for renaming to private."""

36

37 function_node: nodes.FunctionDef

38 old_name: str

39 new_name: str

40 references: List[FunctionReference]

41 test_references: List[FunctionTestReference]

42 is_safe: bool

43 safety_issues: List[str]