-
Notifications
You must be signed in to change notification settings - Fork 0
intake(phenokit-config-kit): fold from phenotype-sdk decomp Phase 3 #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
179be8b
a66db4b
52375b2
e270d0a
90ad8d3
b1a093d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Origin - phenokit-config-kit | ||
|
|
||
| Folded from `KooshaPari/PhenoKits/libs/python/phenokit-config-kit` into `KooshaPari/phenotype-python-sdk/packages/phenokit-config-kit` on 2026-06-20. | ||
|
|
||
| This package is intentionally kept distinct from `packages/phenotype-config` because the source contains config-kit linting/pre-commit/pytest scaffolds that are not file-equivalent to the existing SDK config package. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,226 @@ | ||
| # PhenoKit Config Kit | ||
|
|
||
| A comprehensive configuration management package for Python projects providing pytest plugins, fixtures, linting configurations, and pre-commit hooks. | ||
|
|
||
| ## Features | ||
|
|
||
| - **Pre-commit Configuration**: Multiple pre-commit hook configurations (basic, comprehensive, security) | ||
| - **Pytest Configuration**: Standardized testing configurations for different scenarios | ||
| - **Pytest Plugins**: Architecture, performance, and security testing plugins | ||
| - **Pytest Fixtures**: Common, performance, and security fixtures for testing | ||
| - **Linting Configuration**: Code quality and style enforcement configs | ||
| - **Test Data Factory**: Generate consistent test data across projects | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| # Basic installation | ||
| pip install phenokit-config-kit | ||
|
|
||
| # With all dependencies | ||
| pip install phenokit-config-kit[all] | ||
|
|
||
| # With specific extras | ||
| pip install phenokit-config-kit[testing,linting] | ||
| ``` | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### Using Pre-commit Configurations | ||
|
|
||
| Copy the desired pre-commit configuration to your project: | ||
|
|
||
| ```bash | ||
| # Basic configuration | ||
| cp pre-commit/basic.yaml .pre-commit-config.yaml | ||
|
|
||
| # Comprehensive configuration | ||
| cp pre-commit/comprehensive.yaml .pre-commit-config.yaml | ||
|
|
||
| # Security-focused configuration | ||
| cp pre-commit/security.yaml .pre-commit-config.yaml | ||
| ``` | ||
|
|
||
| Install pre-commit hooks: | ||
| ```bash | ||
| pre-commit install | ||
| ``` | ||
|
|
||
| ### Using Pytest Configurations | ||
|
|
||
| ```bash | ||
| # Use basic configuration | ||
| pytest --ini=config-kit/pytest/basic.ini | ||
|
|
||
| # Use comprehensive configuration | ||
| pytest --ini=config-kit/pytest/comprehensive.ini | ||
|
|
||
| # Use CI configuration | ||
| pytest --ini=config-kit/pytest/ci.ini | ||
| ``` | ||
|
Comment on lines
+51
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Files and snippets:"
for f in packages/phenokit-config-kit/README.md packages/phenokit-config-kit/pytest/README.md; do
if [ -f "$f" ]; then
echo "--- $f"
wc -l "$f"
else
echo "missing $f"
fi
done
echo
echo "Occurrences of pytest --ini or pytest -c in markdown:"
rg -n "pytest\s+(--ini|-c)" packages/phenokit-config-kit/README.md packages/phenokit-config-kit/pytest/README.md || true
echo
echo "Current pytest config option help (if pytest is available):"
if command -v pytest >/dev/null 2>&1; then
pytest --help | awk '
/-c, \/\*config-file\//,/^$|^-[A-Za-z]/ {
if (index($0, "pytest") == 0) exit
print
}' || true
else
echo "pytest command not available"
fi
echo
echo "Installed pytest package option metadata (python, if available):"
python3 - <<'PY'
import subprocess, sys
try:
import pytest
print("pytest", getattr(pytest, "__version__", "<unknown>"))
except Exception as e:
print("pytest import failed:", type(e).__name__, e)
try:
result = subprocess.run([sys.executable, "-m", "pytest", "--help"], text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=30)
for line in result.stdout.splitlines():
if "Config-file" in line or "-c - file" in line or "-c file" in line or "-c file" in line:
print(line)
for i in range(1, 6):
print(result.stdout.splitlines()[result.stdout.splitlines().index(line)+i])
break
except Exception as e:
print("pytest help failed:", type(e).__name__, e)
PYRepository: KooshaPari/phenotype-python-sdk Length of output: 1840 🌐 Web query:
💡 Result: To manage command-line options and configuration files in pytest, you can use several configuration files to store default settings, which effectively act as persistent command-line arguments [1][2]. Configuration Files Pytest looks for configuration files in the root directory of your repository [1]. Supported files include: - pytest.ini: Takes high precedence [1]. - pyproject.toml: Uses a [tool.pytest.ini_options] table [1]. - tox.ini: Uses a [pytest] section [1]. - setup.cfg: Uses a [tool:pytest] section (though less recommended than other formats) [1][3]. Adding Default Options The addopts configuration option allows you to set default command-line arguments that will be applied every time you run pytest [2]. This is useful for avoiding repetitive flags [2]. Example (using pytest.ini): [pytest] addopts = -ra -q When you run pytest, these options are automatically included [2]. If you provide conflicting arguments on the actual command line, those will generally override the defaults in your configuration file [2]. Getting Help You can view a full list of available command-line and configuration file options by running the following command in your terminal [1][4]: pytest -h This command prints both standard command-line flags and the options that can be set via configuration files [1][4]. Additionally, you can use the @ prefix to read command-line arguments from a text file, for example: pytest Citations:
🌐 Web query:
💡 Result: There are no command-line options named --ini or --iniconfig in standard pytest [1][2]. It is likely these terms are being confused with one of the following concepts: 1. INI-style configuration files: Pytest supports configuration through files such as pytest.ini, tox.ini, and setup.cfg [1][3]. These are not invoked via a command-line flag but are automatically detected by pytest based on their filename and location in your project directory [1][4]. 2. The -c option: You can specify a custom configuration file path using the -c command-line option (e.g., pytest -c my_config.ini) [3][5]. 3. The -o/--override-ini option: If you want to override specific configuration settings from the command line without modifying your configuration file, you use the -o or --override-ini flag followed by option=value pairs (e.g., pytest -o cache_dir=my_cache) [2][6]. 4. The iniconfig library: This is a separate, small Python library used internally by pytest for parsing INI files [7][8]. It is not a user-facing command-line interface for pytest [8]. To see all available command-line options and supported configuration file settings, you can run: pytest -h This command displays both built-in command-line options and settings that can be defined in configuration files [1][9]. Citations:
Use
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
|
|
||
| ### Using Pytest Plugins | ||
|
|
||
| The pytest plugins are automatically registered when you install the package: | ||
|
|
||
| ```python | ||
| # Architecture testing (auto-added to test collection) | ||
| pytest --max-file-size=500 --max-complexity=10 | ||
|
|
||
| # Performance testing | ||
| pytest -m performance --benchmark-threshold=1.0 | ||
|
|
||
| # Security testing | ||
| pytest -m security | ||
| ``` | ||
|
|
||
| ### Using Fixtures | ||
|
|
||
| ```python | ||
| import pytest | ||
| from config_kit.pytest.fixtures.common import mock_client, test_data | ||
| from config_kit.pytest.fixtures.performance import performance_monitor | ||
| from config_kit.pytest.fixtures.security import security_context | ||
|
|
||
| def test_with_fixtures(mock_client, test_data): | ||
| result = mock_client.call_tool("test_tool", test_data["user"]) | ||
| assert result["success"] is True | ||
|
|
||
| @pytest.mark.performance | ||
| def test_performance(performance_monitor): | ||
| with performance_monitor["measure"]("test_operation"): | ||
| result = expensive_operation() | ||
| assert result is not None | ||
| ``` | ||
|
|
||
| ### Using Test Data Factory | ||
|
|
||
| ```python | ||
| from config_kit.pytest.data.factory import TestDataFactory | ||
|
|
||
| factory = TestDataFactory(seed=42) | ||
|
|
||
| # Generate user data | ||
| user_data = factory.user_data() | ||
|
|
||
| # Generate organization data | ||
| org_data = factory.organization_data() | ||
|
|
||
| # Generate project data | ||
| project_data = factory.project_data(organization_id="org-123") | ||
| ``` | ||
|
|
||
| ## Configuration Files | ||
|
|
||
| ### Pre-commit Configurations | ||
| - `pre-commit/basic.yaml` - Basic pre-commit hooks | ||
| - `pre-commit/comprehensive.yaml` - Full linting and security suite | ||
| - `pre-commit/security.yaml` - Security-focused configuration | ||
|
|
||
| ### Pytest Configurations | ||
| - `pytest/basic.ini` - Basic pytest configuration | ||
| - `pytest/comprehensive.ini` - Enterprise-grade configuration | ||
| - `pytest/ci.ini` - CI/CD optimized | ||
| - `pytest/parallel.ini` - Parallel execution optimized | ||
| - `pytest/performance.ini` - Performance testing | ||
| - `pytest/security.ini` - Security testing | ||
|
|
||
| ### Linting Configurations | ||
| - `linting/pyproject.toml` - Python linter configs (Ruff, Black, isort, mypy) | ||
| - `linting/.editorconfig` - Editor configuration | ||
| - `linting/.markdownlint.json` - Markdown linting rules | ||
| - `linting/linters.toml` - Centralized linter configuration | ||
| - `linting/ci-cd/gatekeeper.toml` - Quality gate definitions | ||
|
|
||
| ## Pytest Plugins | ||
|
|
||
| ### Architecture Plugin | ||
|
|
||
| Provides architecture fitness tests: | ||
| - File size validation | ||
| - Import boundary enforcement | ||
| - Dependency direction validation | ||
| - Cyclomatic complexity analysis | ||
|
|
||
| ### Performance Plugin | ||
|
|
||
| Provides performance testing capabilities: | ||
| - Benchmark testing | ||
| - Memory profiling | ||
| - Performance regression detection | ||
|
|
||
| ### Security Plugin | ||
|
|
||
| Provides security testing capabilities: | ||
| - Vulnerability scanning | ||
| - Forbidden imports check | ||
| - Hardcoded secrets detection | ||
|
|
||
| ## Git Hooks | ||
|
|
||
| The package includes useful git hooks: | ||
|
|
||
| ### Pre-commit Hook | ||
| Validates staged files with linters (Ruff, Black, isort, mypy, bandit, etc.) | ||
|
|
||
| ### Commit-msg Hook | ||
| Validates commit messages for: | ||
| - Conventional commits format | ||
| - Proper capitalization | ||
| - Proper punctuation | ||
| - Minimum length requirements | ||
|
|
||
| To use the git hooks: | ||
| ```bash | ||
| cp linting/git-hooks/pre-commit .git/hooks/pre-commit | ||
| chmod +x .git/hooks/pre-commit | ||
|
|
||
| cp linting/git-hooks/commit-msg .git/hooks/commit-msg | ||
| chmod +x .git/hooks/commit-msg | ||
| ``` | ||
|
|
||
| ## Quality Gate Script | ||
|
|
||
| Run comprehensive quality checks: | ||
|
|
||
| ```bash | ||
| bash linting/ci-cd/scripts/quality-gate.sh | ||
| ``` | ||
|
|
||
| This runs all configured linters and generates a `quality_gate_results.json` report. | ||
|
|
||
| ## Development | ||
|
|
||
| ### Project Structure | ||
|
|
||
| ``` | ||
| config-kit/ | ||
| ├── pyproject.toml # Package configuration | ||
| ├── README.md # This file | ||
| ├── pre-commit/ # Pre-commit configurations | ||
| ├── pytest/ # Pytest configurations, plugins, fixtures | ||
| │ ├── plugins/ # Pytest plugins | ||
| │ ├── fixtures/ # Pytest fixtures | ||
| │ └── data/ # Test data utilities | ||
| └── linting/ # Linting configurations and scripts | ||
| ├── ci-cd/ # CI/CD scripts | ||
| └── git-hooks/ # Git hooks | ||
| ``` | ||
|
|
||
| ### Running Tests | ||
|
|
||
| ```bash | ||
| pytest --ini=pytest/comprehensive.ini | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| MIT License - See LICENSE file for details. | ||
|
|
||
| ## Contributing | ||
|
|
||
| 1. Fork the repository | ||
| 2. Create a feature branch | ||
| 3. Make your changes | ||
| 4. Run the quality gate script | ||
| 5. Submit a pull request | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| """ | ||
| Config Kit - A comprehensive configuration management package for Python projects. | ||
|
|
||
| This package provides: | ||
| - Pre-commit hook configurations | ||
| - Pytest configurations, plugins, and fixtures | ||
| - Linting configurations | ||
| - Test data factory | ||
| """ | ||
|
|
||
| __version__ = "0.1.0" | ||
| __all__ = [ | ||
| "pytest", | ||
| "linting", | ||
|
Check failure on line 14 in packages/phenokit-config-kit/config_kit/__init__.py
|
||
| "pre_commit", | ||
|
Check failure on line 15 in packages/phenokit-config-kit/config_kit/__init__.py
|
||
| ] | ||
|
Comment on lines
+11
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files 'packages/phenokit-config-kit/**/__init__.py' | sort
echo "== outline root init =="
ast-grep outline packages/phenokit-config-kit/config_kit/__init__.py || true
echo "== root init =="
cat -n packages/phenokit-config-kit/config_kit/__init__.py
echo "== pytest data init =="
cat -n packages/phenokit-config-kit/config_kit/pytest/data/__init__.py
echo "== pytest fixtures init =="
cat -n packages/phenokit-config-kit/config_kit/pytest/fixtures/__init__.py
echo "== pytest plugins init =="
cat -n packages/phenokit-config-kit/config_kit/pytest/plugins/__init__.py
echo "== references to exported names in package =="
rg -n "TestDataFactory|TestDataGenerator|TestDataManager|TestDataValidator|cache_fixture|database_fixture|message_broker_fixture|mock_client|perform|security_context|temp_dir|test_data|ArchitecturePlugin|CoveragePlugin|PerformancePlugin|ReportingPlugin|SecurityPlugin|linting|pre_commit|pytest" packages/phenokit-config-kit/config_kit || trueRepository: KooshaPari/phenotype-python-sdk Length of output: 24006 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== all files under config_kit =="
git ls-files packages/phenokit-config-kit/config_kit | sort
echo "== fixtures __all__ candidates =="
rg -n "^def .*fixture|`@pytest.fixture`|^class .*Fixture|^cache_fixture|^database_fixture|^message_broker_fixture|^mock_client|^performance_monitor|^security_context|^temp_dir|^test_data" packages/phenokit-config-kit/config_kit/pytest/fixtures/config_kit || true
echo "== linting/pre_commit candidate submodules =="
fd -i '^(linting|pre_commit)(\.py|/)?' packages/phenokit-config-kit/config_kit || true
echo "== package init files =="
for f in packages/phenokit-config-kit/config_kit/__init__.py packages/phenokit-config-kit/config_kit/pytest/__init__.py packages/phenokit-config-kit/config_kit/pytest/data/__init__.py packages/phenokit-config-kit/config_kit/pytest/fixtures/__init__.py packages/phenokit-config-kit/config_kit/pytest/plugins/__init__.py; do
echo "-- $f"
cat -n "$f"
done
echo "== deterministic init symbol check =="
python3 - <<'PY'
import ast
from pathlib import Path
roots = [
Path("packages/phenokit-config-kit/config_kit/__init__.py"),
Path("packages/phenokit-config-kit/config_kit/pytest/data/__init__.py"),
Path("packages/phenokit-config-kit/config_kit/pytest/fixtures/__init__.py"),
Path("packages/phenokit-config-kit/config_kit/pytest/plugins/__init__.py"),
]
for init_path in roots:
tree = ast.parse(init_path.read_text())
module_aliases = set()
for node in ast.walk(tree):
if isinstance(node, ast.Assign):
for target in node.targets:
if isinstance(target, ast.Name) and target.id == "__all__":
module_aliases.add(target.id)
all_value = ast.literal_eval(node.value)
names = set(all_value)
defined = set(node.name for node in ast.walk(tree) if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef, ast.Assign, ast.AnnAssign)))
imported = set()
for item in ast.walk(tree):
if isinstance(item, ast.Import):
imported.update(alias.name.split(".")[0] for alias in item.names)
elif isinstance(item, ast.ImportFrom):
import_name = item.module.split(".")[0] if item.module else "."
imported.add(import_name)
print(f"{init_path}: __all__={all_value}")
print(" missing:", sorted(names - defined))
print(" imported_names:", sorted(set(imported)))
PYRepository: KooshaPari/phenotype-python-sdk Length of output: 3709 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== fixtures implementation files =="
cat -n packages/phenokit-config-kit/config_kit/pytest/fixtures/common.py | sed -n '1,120p'
cat -n packages/phenokit-config-kit/config_kit/pytest/fixtures/security.py | sed -n '1,120p'
cat -n packages/phenokit-config-kit/config_kit/pytest/fixtures/performance.py | sed -n '1,120p'
echo "== data implementation files =="
git ls-files packages/phenokit-config-kit/config_kit/pytest/data | sort
for f in packages/phenokit-config-kit/config_kit/pytest/data/factory.py packages/phenokit-config-kit/config_kit/pytest/data/factory.py; do
echo "-- $f"
rg -n "class TestData|TestDataFactory|TestDataGenerator|TestDataManager|TestDataValidator" "$f" || true
done
echo "== plugins implementation files =="
git ls-files packages/phenokit-config-kit/config_kit/pytest/plugins | sort
for f in packages/phenokit-config-kit/config_kit/pytest/plugins/architecture.py packages/phenokit-config-kit/config_kit/pytest/plugins/performance.py packages/phenokit-config-kit/config_kit/pytest/plugins/security.py; do
echo "-- $f"
rg -n "class .*Plugin" "$f" || true
doneRepository: KooshaPari/phenotype-python-sdk Length of output: 14154 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== fixtures names in implementation files =="
python3 - <<'PY'
from pathlib import Path
import ast
root = Path("packages/phenokit-config-kit/config_kit/pytest/fixtures")
all_path = root / "__init__.py"
tree = ast.parse(all_path.read_text())
all_value = next((node.value for node in tree.body if isinstance(node, ast.Assign) and any(isinstance(t, ast.Name) and t.id == "__all__" for t in node.targets)), None)
exported = ast.literal_eval(all_value) if all_value is not None else []
names = {name: [] for name in exported}
for py in sorted(root.glob("*.py")):
mod = ast.parse(py.read_text())
for node in mod.body:
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name in names:
names[node.name].append(str(py))
if isinstance(node, ast.ClassDef) and node.name in names:
names[node.name].append(str(py))
missing = [name for name, locs in names.items() if not locs]
print("__all__=", exported)
print("missing_names=", missing)
print("implemented_in=", {name: locs for name, locs in names.items() if locs})
print("\nsubmodules referenced in current init __all__:")
init_root = Path("packages/phenokit-config-kit/config_kit/__init__.py")
for node in ast.parse(init_root.read_text()).body:
if isinstance(node, ast.Assign) and any(isinstance(t, ast.Name) and t.id == "__all__" for t in node.targets):
symbols = ast.literal_eval(node.value)
print({sym: (root/sym).exists() or (root/sym/f"{sym}").exists() or (root/sym/f"{sym}.py").exists() for sym in symbols})
PYRepository: KooshaPari/phenotype-python-sdk Length of output: 1154 Bind every public symbol declared in
🧰 Tools🪛 GitHub Check: SonarCloud Code Analysis[failure] 15-15: Change or remove this string; "pre_commit" is not defined. [failure] 14-14: Change or remove this string; "linting" is not defined. 📍 Affects 4 files
🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| """ | ||
| Pytest module for config-kit. | ||
|
|
||
| This module provides pytest plugins, fixtures, and configurations. | ||
| """ | ||
|
|
||
| __version__ = "0.1.0" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """ | ||
| Test data management for config-kit package. | ||
|
|
||
| This module provides utilities for managing test data across different projects. | ||
| """ | ||
|
|
||
| __version__ = "0.1.0" | ||
| __all__ = [ | ||
| "TestDataFactory", | ||
|
Check failure on line 9 in packages/phenokit-config-kit/config_kit/pytest/data/__init__.py
|
||
| "TestDataGenerator", | ||
|
Check failure on line 10 in packages/phenokit-config-kit/config_kit/pytest/data/__init__.py
|
||
| "TestDataManager", | ||
|
Check failure on line 11 in packages/phenokit-config-kit/config_kit/pytest/data/__init__.py
|
||
| "TestDataValidator", | ||
|
Check failure on line 12 in packages/phenokit-config-kit/config_kit/pytest/data/__init__.py
|
||
| ] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Fix the reported Markdown lint violations.
Add blank lines around headings and fenced blocks. Add a language identifier to the project-structure fenced block.
Also applies to: 115-120, 163-174, 196-196
🧰 Tools
🪛 markdownlint-cli2 (0.23.2)
[warning] 45-45: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
🤖 Prompt for AI Agents
Source: Linters/SAST tools