oct
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
29Dependencies
30------------
31- oct.core.diagnostics (_dbg structured logger; imported but never called, the module holds constants only)
32"""
33
34# OCT-LINT: disable-file=dbg_usage reason="Plan 263: a constants-only module with no function or method, so there is no seam to observe; a module-level call would emit before init() on every import"
35
36from oct.core.diagnostics import _dbg
37
38# Directories excluded by exact name match - shared between linter and exporter.
39COMMON_EXCLUDE_DIRS = {
40 ".git",
41 "__pycache__",
42 "Old",
43 "old",
44 ".linter_archive",
45 "copied_python_files",
46 "data",
47 "data_raw",
48 "raw_data",
49 "data.bk",
50 "flow_charts",
51 "dot_files",
52 "dev-tools",
53 # Virtual environment directories - must be excluded to avoid scanning
54 # thousands of third-party library files on every lint or export run.
55 ".venv",
56 "venv",
57 "env",
58}
59
60# Linter-specific exclusions (adds Code Reviews and fixtures to the common set).
61# "fixtures" is excluded globally because test fixtures are intentionally
62# non-compliant (missing headers, broken docstrings, etc.) - they exist to
63# exercise the linter itself (OI-420).
64LINTER_EXCLUDE_DIRS = COMMON_EXCLUDE_DIRS | {
65 "Code Reviews",
66 "fixtures",
67}
68
69# Exporter-specific exclusions (adds dataset, doxygen, backup dirs to the common set).
70EXPORTER_EXCLUDE_DIRS = COMMON_EXCLUDE_DIRS | {
71 "Code Reviews",
72 "dataset_library",
73 "doxygen_work_dir",
74 "doxygen_output",
75 "logs",
76 "cache",
77 "_backup",
78 "old_backup",
79}
80
81# Wildcard (substring) patterns - shared between linter and exporter.
82# The venv/ suffix entries here act as a belt-and-suspenders guard for
83# non-standard venv names (e.g. .venv-dev, venv38) that might not match
84# the exact-name set above.
85WILDCARD_EXCLUDE_DIRS = ["cache", "_source", "_skeleton", "logs", "_exports", "_build", ".venv", "venv"]
86
87# File patterns excluded from export and documentation output.
88# These files contain environment-specific runtime configuration
89# and must never appear in exported source or generated docs.
90# See ยง6b Secret Hygiene in the Master Coding Style Specification.
91NEVER_EXPORT_FILE_PATTERNS = [
92 ".env", ".env.*", # Environment variable files
93 "*.pem", "*.key", # Private key files
94 "credentials.json", # Service account credentials
95 "secrets.json", # Application secrets
96 "secrets.yaml", # Application secrets (YAML)
97 "secrets.yml", # Application secrets (YAML)
98]
99
100# Default .gitignore entries written by ``oct git init`` (Phase 4C).
101# Phase 4A defines this constant only - no code reads it yet. The
102# format is a tuple of strings, one per .gitignore line, with blank
103# strings representing literal blank separators between sections. The
104# patterns intentionally cover:
105#
106# - Python bytecode, caches, and build artefacts
107# - Virtualenv conventions (.venv, venv, env)
108# - Distribution / packaging output
109# - OCT's own internal backup and archive directories
110# - Sphinx / docs build output
111# - Test / coverage artefacts
112# - Common IDE and OS metadata files
113# - Secrets (.env, *.pem, *.key) - mirrors NEVER_EXPORT_FILE_PATTERNS
114GIT_IGNORE_DEFAULTS: tuple[str, ...] = (
115 "# Python",
116 "__pycache__/",
117 "*.py[cod]",
118 "*$py.class",
119 "*.so",
120 ".Python",
121 "",
122 "# Virtualenvs",
123 ".venv/",
124 "venv/",
125 "env/",
126 "",
127 "# Distribution / packaging",
128 "build/",
129 "dist/",
130 "*.egg-info/",
131 "",
132 "# OCT internal",
133 ".formatter_archive/",
134 ".linter_archive/",
135 ".octrc.json.bak",
136 "",
137 "# Sphinx / docs build",
138 "docs/_build/",
139 "docs/_api/",
140 "docs/_autosummary/",
141 "docs/doctrees/",
142 "",
143 "# Testing / coverage",
144 ".pytest_cache/",
145 ".coverage",
146 "htmlcov/",
147 ".tox/",
148 "",
149 "# IDE",
150 ".vscode/",
151 ".idea/",
152 "*.swp",
153 "",
154 "# OS",
155 ".DS_Store",
156 "Thumbs.db",
157 "",
158 "# Secrets",
159 ".env",
160 ".env.*",
161 "*.pem",
162 "*.key",
163)