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

22 statements  

« prev     ^ index     » next       coverage.py v7.10.1, created at 2025-08-12 16:06 +0200

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

2 

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

4extracted to avoid circular imports between modules. 

5 

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

7""" 

8 

9from pathlib import Path 

10from typing import List, NamedTuple 

11 

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

13 

14 

15class 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 

24class 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 

34class 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]