Coverage for metrics/duplication/config.py: 100%

1"""Per-language configuration for AST-based duplication detection."""

2

3 from __future__ import annotations

4

5 from dataclasses import dataclass

6

7

8@dataclass(frozen=True)

9 class LanguageConfig:

10 comment_types: frozenset[str]

11 identifier_types: frozenset[str]

12 literal_types: frozenset[str]

13

14

15 PYTHON_CONFIG = LanguageConfig(

16 comment_types=frozenset({"comment"}),

17 identifier_types=frozenset({"identifier"}),

18 literal_types=frozenset({

19 "integer", "float", "string", "concatenated_string",

20 "true", "false", "none",

21 }),

22)

23

24 TYPESCRIPT_CONFIG = LanguageConfig(

25 comment_types=frozenset({"comment"}),

26 identifier_types=frozenset({

27 "identifier", "property_identifier", "shorthand_property_identifier",

28 "type_identifier",

29 }),

30 literal_types=frozenset({

31 "number", "string", "template_string", "regex",

32 "true", "false", "null", "undefined",

33 }),

34)

35

36 GO_CONFIG = LanguageConfig(

37 comment_types=frozenset({"comment"}),

38 identifier_types=frozenset({

39 "identifier", "type_identifier", "field_identifier", "package_identifier",

40 }),

41 literal_types=frozenset({

42 "int_literal", "float_literal", "imaginary_literal",

43 "rune_literal", "raw_string_literal", "interpreted_string_literal",

44 "true", "false", "nil", "iota",

45 }),

46)