Coverage for src / ezcompiler / types.py: 100.00%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-27 06:49 +0000

1# /////////////////////////////////////////////////////////////// 

2# TYPES - Type Aliases Module 

3# Project: ezcompiler 

4# /////////////////////////////////////////////////////////////// 

5 

6""" 

7Type aliases module for ezcompiler. 

8 

9This module centralizes common type aliases used throughout the library 

10to improve code readability, maintainability, and type safety. 

11 

12Example: 

13 >>> from ezcompiler.types import IncludeFiles, CompilerName 

14 >>> 

15 >>> def build(compiler: CompilerName, files: IncludeFiles) -> None: 

16 ... pass 

17""" 

18 

19from __future__ import annotations 

20 

21# /////////////////////////////////////////////////////////////// 

22# IMPORTS 

23# /////////////////////////////////////////////////////////////// 

24# Standard library imports 

25from pathlib import Path 

26from typing import TypeAlias 

27 

28# /////////////////////////////////////////////////////////////// 

29# TYPE ALIASES 

30# /////////////////////////////////////////////////////////////// 

31 

32# ------------------------------------------------ 

33# Path Types 

34# ------------------------------------------------ 

35 

36FilePath: TypeAlias = str | Path 

37"""Type alias for file path inputs. 

38 

39Accepts: 

40 - str: String file path 

41 - Path: pathlib.Path object 

42 

43Used by: CompilerConfig, template loaders, file utilities. 

44""" 

45 

46# ------------------------------------------------ 

47# Compiler Types 

48# ------------------------------------------------ 

49 

50CompilerName: TypeAlias = str 

51"""Type alias for compiler name selection. 

52 

53Valid values: "auto", "Cx_Freeze", "PyInstaller", "Nuitka" 

54 

55Used by: CompilerConfig.compiler, EzCompiler.compile_project(). 

56""" 

57 

58UploadTarget: TypeAlias = str 

59"""Type alias for upload destination selection. 

60 

61Valid values: "disk", "server" 

62 

63Used by: CompilerConfig.upload_structure, EzCompiler.upload_to_repo(). 

64""" 

65 

66# ------------------------------------------------ 

67# Configuration Types 

68# ------------------------------------------------ 

69 

70IncludeFiles: TypeAlias = dict[str, list[str]] 

71"""Type alias for the include_files configuration structure. 

72 

73Expected shape:: 

74 

75 { 

76 "files": ["path/to/file1.txt", "path/to/file2.dll"], 

77 "folders": ["path/to/assets/", "path/to/data/"], 

78 } 

79 

80Used by: CompilerConfig.include_files. 

81""" 

82 

83JsonMap: TypeAlias = dict[str, object] 

84"""Type alias for a generic JSON-serializable mapping. 

85 

86Used by: configuration parsers, template renderers, YAML/JSON loaders. 

87""" 

88 

89# /////////////////////////////////////////////////////////////// 

90# PUBLIC API 

91# /////////////////////////////////////////////////////////////// 

92 

93__all__ = [ 

94 "FilePath", 

95 "CompilerName", 

96 "UploadTarget", 

97 "IncludeFiles", 

98 "JsonMap", 

99]