Option C Tools
Loading...
Searching...
No Matches
exclusions.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# oct/core/exclusions.py
4
5"""
6Purpose
7-------
8Provide shared default directory exclusion lists for linter and exporter.
9
10Responsibilities
11----------------
12- Define common exclusion directories used by both the linter and the source exporter.
13- Provide tool-specific supersets for each consumer.
14- Centralise wildcard (substring) exclusion patterns.
15
16Diagnostics
17-----------
18Domain: OCT-CORE
19Levels:
20 L2 — lifecycle
21 L3 — semantic details
22 L4 — deep tracing
23
24Contracts
25---------
26- All sets are frozen at module level; consumers copy before mutating.
27- Linter and exporter import from here instead of defining their own constants.
28"""
29
30# Directories excluded by exact name match — shared between linter and exporter.
31COMMON_EXCLUDE_DIRS = {
32 ".git",
33 "__pycache__",
34 "Old",
35 "old",
36 ".linter_archive",
37 "copied_python_files",
38 "data",
39 "data_raw",
40 "raw_data",
41 "data.bk",
42 "flow_charts",
43 "dot_files",
44 "dev-tools",
45 # Virtual environment directories — must be excluded to avoid scanning
46 # thousands of third-party library files on every lint or export run.
47 ".venv",
48 "venv",
49 "env",
50}
51
52# Linter-specific exclusions (adds Code Reviews and fixtures to the common set).
53# "fixtures" is excluded globally because test fixtures are intentionally
54# non-compliant (missing headers, broken docstrings, etc.) — they exist to
55# exercise the linter itself (OI-420).
56LINTER_EXCLUDE_DIRS = COMMON_EXCLUDE_DIRS | {
57 "Code Reviews",
58 "fixtures",
59}
60
61# Exporter-specific exclusions (adds dataset, doxygen, backup dirs to the common set).
62EXPORTER_EXCLUDE_DIRS = COMMON_EXCLUDE_DIRS | {
63 "Code Reviews",
64 "dataset_library",
65 "doxygen_work_dir",
66 "doxygen_output",
67 "logs",
68 "cache",
69 "_backup",
70 "old_backup",
71}
72
73# Wildcard (substring) patterns — shared between linter and exporter.
74# The venv/ suffix entries here act as a belt-and-suspenders guard for
75# non-standard venv names (e.g. .venv-dev, venv38) that might not match
76# the exact-name set above.
77WILDCARD_EXCLUDE_DIRS = ["cache", "_source", "_skeleton", "logs", "_exports", "_build", ".venv", "venv"]
78
79# File patterns excluded from export and documentation output.
80# These files contain environment-specific runtime configuration
81# and must never appear in exported source or generated docs.
82# See §6b Secret Hygiene in the Master Coding Style Specification.
83NEVER_EXPORT_FILE_PATTERNS = [
84 ".env", ".env.*", # Environment variable files
85 "*.pem", "*.key", # Private key files
86 "credentials.json", # Service account credentials
87 "secrets.json", # Application secrets
88 "secrets.yaml", # Application secrets (YAML)
89 "secrets.yml", # Application secrets (YAML)
90]
91
92# Default .gitignore entries written by ``oct git init`` (Phase 4C).
93# Phase 4A defines this constant only — no code reads it yet. The
94# format is a tuple of strings, one per .gitignore line, with blank
95# strings representing literal blank separators between sections. The
96# patterns intentionally cover:
97#
98# - Python bytecode, caches, and build artefacts
99# - Virtualenv conventions (.venv, venv, env)
100# - Distribution / packaging output
101# - OCT's own internal backup and archive directories
102# - Sphinx / docs build output
103# - Test / coverage artefacts
104# - Common IDE and OS metadata files
105# - Secrets (.env, *.pem, *.key) — mirrors NEVER_EXPORT_FILE_PATTERNS
106GIT_IGNORE_DEFAULTS: tuple[str, ...] = (
107 "# Python",
108 "__pycache__/",
109 "*.py[cod]",
110 "*$py.class",
111 "*.so",
112 ".Python",
113 "",
114 "# Virtualenvs",
115 ".venv/",
116 "venv/",
117 "env/",
118 "",
119 "# Distribution / packaging",
120 "build/",
121 "dist/",
122 "*.egg-info/",
123 "",
124 "# OCT internal",
125 ".formatter_archive/",
126 ".linter_archive/",
127 ".octrc.json.bak",
128 "",
129 "# Sphinx / docs build",
130 "docs/_build/",
131 "docs/_api/",
132 "docs/_autosummary/",
133 "docs/doctrees/",
134 "",
135 "# Testing / coverage",
136 ".pytest_cache/",
137 ".coverage",
138 "htmlcov/",
139 ".tox/",
140 "",
141 "# IDE",
142 ".vscode/",
143 ".idea/",
144 "*.swp",
145 "",
146 "# OS",
147 ".DS_Store",
148 "Thumbs.db",
149 "",
150 "# Secrets",
151 ".env",
152 ".env.*",
153 "*.pem",
154 "*.key",
155)