pycheck-neuron 1.0.3__tar.gz → 1.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/PKG-INFO +36 -11
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/README.md +34 -9
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck/__init__.py +10 -10
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck/analyzer.py +244 -203
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck/audit.py +153 -153
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck/flow.py +39 -5
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck/rules.py +1397 -1110
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck_neuron.egg-info/PKG-INFO +36 -11
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pyproject.toml +66 -66
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/tests/test_cli.py +29 -1
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/tests/test_rules.py +958 -682
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/LICENSE +0 -0
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck/__main__.py +0 -0
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck/cli.py +0 -0
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck/server.py +0 -0
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck_neuron.egg-info/SOURCES.txt +0 -0
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck_neuron.egg-info/dependency_links.txt +0 -0
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck_neuron.egg-info/entry_points.txt +0 -0
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck_neuron.egg-info/requires.txt +0 -0
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/pycheck_neuron.egg-info/top_level.txt +0 -0
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/setup.cfg +0 -0
- {pycheck_neuron-1.0.3 → pycheck_neuron-1.0.5}/tests/test_audit.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pycheck-neuron
|
|
3
|
-
Version: 1.0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 1.0.5
|
|
4
|
+
Summary: 34-rule static AST analyzer catching temporal lookahead bias, causal confusion, and uncertainty bugs in Python ML code. Zero dependencies.
|
|
5
5
|
Author: NEURON Team
|
|
6
6
|
Author-email: Fayo Ibrahim <fayo@neuron-lab.org>
|
|
7
7
|
License-Expression: MIT
|
|
@@ -38,7 +38,7 @@ Dynamic: license-file
|
|
|
38
38
|
|
|
39
39
|
# PyCheck — ML Safety Analyzer
|
|
40
40
|
|
|
41
|
-
**
|
|
41
|
+
**34 rules. Zero dependencies. Catches the bugs that cost millions.**
|
|
42
42
|
|
|
43
43
|
PyCheck is a static AST analyzer that detects **temporal lookahead bias**, **causal confusion**, and **unguarded uncertainty** in Python ML and trading scripts — before you run a single line of code.
|
|
44
44
|
|
|
@@ -68,7 +68,7 @@ PyCheck catches all three before execution:
|
|
|
68
68
|
=================================================================
|
|
69
69
|
PyCheck — NEURON ML Safety Analyzer
|
|
70
70
|
Scanning: strategy.py
|
|
71
|
-
Rules:
|
|
71
|
+
Rules: 34 active + Data Flow & Provenance Engine
|
|
72
72
|
=================================================================
|
|
73
73
|
|
|
74
74
|
ERROR[T001]: .shift(-1) accesses data 1 rows INTO THE FUTURE
|
|
@@ -100,12 +100,12 @@ PyCheck catches all three before execution:
|
|
|
100
100
|
|
|
101
101
|
## What It Catches
|
|
102
102
|
|
|
103
|
-
### Temporal Leak Rules (
|
|
103
|
+
### Temporal Leak Rules (19 rules — `T001`–`T019`)
|
|
104
104
|
|
|
105
105
|
| Rule | What It Catches | Severity |
|
|
106
106
|
|------|----------------|----------|
|
|
107
|
-
| `T001` | `.shift(-1)` — accessing future data | **Error** |
|
|
108
|
-
| `T002` | `train_test_split()` on time-series data | **Error** |
|
|
107
|
+
| `T001` | `.shift(-1)` — accessing future data (including bound-method aliases like `sh = df.shift; sh(-1)`) | **Error** |
|
|
108
|
+
| `T002` | `train_test_split()` on time-series data without chronological ordering | **Error** |
|
|
109
109
|
| `T003` | `.rolling()` computed before the train/test split | Warning |
|
|
110
110
|
| `T004` | `.expanding()` computed before split | Warning |
|
|
111
111
|
| `T005` | `.pct_change(-1)` — future percent returns | **Error** |
|
|
@@ -121,7 +121,8 @@ PyCheck catches all three before execution:
|
|
|
121
121
|
| `T015` | Negative `.shift()` inside `groupby().transform()` | **Error** |
|
|
122
122
|
| `T016` | `pd.merge_asof()` with `direction='nearest'` or `'forward'` | **Error** |
|
|
123
123
|
| `T017` | Target laundering & un-split target encoding (`regime_success_rate`) | **Error** |
|
|
124
|
-
| `T018` | In-sample target encoding
|
|
124
|
+
| `T018` | In-sample target encoding via `.transform()` or un-split group means | **Error** |
|
|
125
|
+
| `T019` | `np.roll(arr, -k)` — negative shift rotates future data into present position | **Error** |
|
|
125
126
|
|
|
126
127
|
### Causal Confusion Rules (7 rules — `C001`–`C007`)
|
|
127
128
|
|
|
@@ -189,10 +190,34 @@ pycheck script.py # Errors + warnings (default)
|
|
|
189
190
|
pycheck script.py --info # Include info-level diagnostics
|
|
190
191
|
pycheck script.py --quiet # Errors only
|
|
191
192
|
pycheck script.py --json # JSON output — pipe into CI/CD
|
|
192
|
-
pycheck --list # List all
|
|
193
|
+
pycheck --list # List all 34 rules
|
|
193
194
|
pycheck --help
|
|
194
195
|
```
|
|
195
196
|
|
|
197
|
+
### Inline Rule Suppression
|
|
198
|
+
|
|
199
|
+
PyCheck supports standard inline suppression comments with audit reason annotations:
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
# Specific rule suppression
|
|
203
|
+
df['target'] = df['close'].shift(-1) # pycheck: ignore[T001]
|
|
204
|
+
|
|
205
|
+
# Multi-rule suppression with audit justification
|
|
206
|
+
signal = df[['close', 'target']].corr() # pycheck: ignore[C001, C002] reason: exploratory EDA baseline
|
|
207
|
+
|
|
208
|
+
# Blanket ignore or flake8-style noqa
|
|
209
|
+
cv = KFold(n_splits=5, shuffle=True) # pycheck: ignore
|
|
210
|
+
X_tr = scaler.fit_transform(X) # noqa: T010
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Both same-line trailing comments and line-above comments are supported.
|
|
214
|
+
|
|
215
|
+
### Sink-Gated Precision Engine
|
|
216
|
+
|
|
217
|
+
To prevent false alarms during research and exploratory data analysis (EDA), PyCheck uses **AST sink-gating**:
|
|
218
|
+
- Exploratory display calls like `df[['feature', 'target']].head()`, `.plot()`, `.describe()`, and `print(...)` are recognized as safe inspection and will **never** trigger feature leakage (`C002`).
|
|
219
|
+
- The rule strictly guards actual modeling sinks (`X = ...`, `model.fit(...)`, `cross_validate(...)`).
|
|
220
|
+
|
|
196
221
|
### JSON Output (CI/CD Integration)
|
|
197
222
|
|
|
198
223
|
```bash
|
|
@@ -285,9 +310,9 @@ The `pycheck-vscode` extension gives you **real-time red/yellow squiggles** as y
|
|
|
285
310
|
|
|
286
311
|
---
|
|
287
312
|
|
|
288
|
-
##
|
|
313
|
+
## PyCheck Cloud & Enterprise SaaS
|
|
289
314
|
|
|
290
|
-
For
|
|
315
|
+
For institutional hedge funds, algorithmic trading desks, and enterprise ML engineering teams, **PyCheck Cloud** provides continuous compliance and automated gatekeeping:
|
|
291
316
|
|
|
292
317
|
* **Automated PR / MR Gatekeeping**: GitHub App & GitLab integration that automatically blocks pull requests containing temporal leaks, lookahead joins, or cross-fold contamination before they reach production.
|
|
293
318
|
* **Proof-of-Causality Audit Certificates**: Cryptographically verifiable backtest audit reports (PDF & JSON) certifying that quantitative strategies and feature pipelines are provably free of temporal lookahead bias for LP allocators and risk committees.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# PyCheck — ML Safety Analyzer
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**34 rules. Zero dependencies. Catches the bugs that cost millions.**
|
|
4
4
|
|
|
5
5
|
PyCheck is a static AST analyzer that detects **temporal lookahead bias**, **causal confusion**, and **unguarded uncertainty** in Python ML and trading scripts — before you run a single line of code.
|
|
6
6
|
|
|
@@ -30,7 +30,7 @@ PyCheck catches all three before execution:
|
|
|
30
30
|
=================================================================
|
|
31
31
|
PyCheck — NEURON ML Safety Analyzer
|
|
32
32
|
Scanning: strategy.py
|
|
33
|
-
Rules:
|
|
33
|
+
Rules: 34 active + Data Flow & Provenance Engine
|
|
34
34
|
=================================================================
|
|
35
35
|
|
|
36
36
|
ERROR[T001]: .shift(-1) accesses data 1 rows INTO THE FUTURE
|
|
@@ -62,12 +62,12 @@ PyCheck catches all three before execution:
|
|
|
62
62
|
|
|
63
63
|
## What It Catches
|
|
64
64
|
|
|
65
|
-
### Temporal Leak Rules (
|
|
65
|
+
### Temporal Leak Rules (19 rules — `T001`–`T019`)
|
|
66
66
|
|
|
67
67
|
| Rule | What It Catches | Severity |
|
|
68
68
|
|------|----------------|----------|
|
|
69
|
-
| `T001` | `.shift(-1)` — accessing future data | **Error** |
|
|
70
|
-
| `T002` | `train_test_split()` on time-series data | **Error** |
|
|
69
|
+
| `T001` | `.shift(-1)` — accessing future data (including bound-method aliases like `sh = df.shift; sh(-1)`) | **Error** |
|
|
70
|
+
| `T002` | `train_test_split()` on time-series data without chronological ordering | **Error** |
|
|
71
71
|
| `T003` | `.rolling()` computed before the train/test split | Warning |
|
|
72
72
|
| `T004` | `.expanding()` computed before split | Warning |
|
|
73
73
|
| `T005` | `.pct_change(-1)` — future percent returns | **Error** |
|
|
@@ -83,7 +83,8 @@ PyCheck catches all three before execution:
|
|
|
83
83
|
| `T015` | Negative `.shift()` inside `groupby().transform()` | **Error** |
|
|
84
84
|
| `T016` | `pd.merge_asof()` with `direction='nearest'` or `'forward'` | **Error** |
|
|
85
85
|
| `T017` | Target laundering & un-split target encoding (`regime_success_rate`) | **Error** |
|
|
86
|
-
| `T018` | In-sample target encoding
|
|
86
|
+
| `T018` | In-sample target encoding via `.transform()` or un-split group means | **Error** |
|
|
87
|
+
| `T019` | `np.roll(arr, -k)` — negative shift rotates future data into present position | **Error** |
|
|
87
88
|
|
|
88
89
|
### Causal Confusion Rules (7 rules — `C001`–`C007`)
|
|
89
90
|
|
|
@@ -151,10 +152,34 @@ pycheck script.py # Errors + warnings (default)
|
|
|
151
152
|
pycheck script.py --info # Include info-level diagnostics
|
|
152
153
|
pycheck script.py --quiet # Errors only
|
|
153
154
|
pycheck script.py --json # JSON output — pipe into CI/CD
|
|
154
|
-
pycheck --list # List all
|
|
155
|
+
pycheck --list # List all 34 rules
|
|
155
156
|
pycheck --help
|
|
156
157
|
```
|
|
157
158
|
|
|
159
|
+
### Inline Rule Suppression
|
|
160
|
+
|
|
161
|
+
PyCheck supports standard inline suppression comments with audit reason annotations:
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
# Specific rule suppression
|
|
165
|
+
df['target'] = df['close'].shift(-1) # pycheck: ignore[T001]
|
|
166
|
+
|
|
167
|
+
# Multi-rule suppression with audit justification
|
|
168
|
+
signal = df[['close', 'target']].corr() # pycheck: ignore[C001, C002] reason: exploratory EDA baseline
|
|
169
|
+
|
|
170
|
+
# Blanket ignore or flake8-style noqa
|
|
171
|
+
cv = KFold(n_splits=5, shuffle=True) # pycheck: ignore
|
|
172
|
+
X_tr = scaler.fit_transform(X) # noqa: T010
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Both same-line trailing comments and line-above comments are supported.
|
|
176
|
+
|
|
177
|
+
### Sink-Gated Precision Engine
|
|
178
|
+
|
|
179
|
+
To prevent false alarms during research and exploratory data analysis (EDA), PyCheck uses **AST sink-gating**:
|
|
180
|
+
- Exploratory display calls like `df[['feature', 'target']].head()`, `.plot()`, `.describe()`, and `print(...)` are recognized as safe inspection and will **never** trigger feature leakage (`C002`).
|
|
181
|
+
- The rule strictly guards actual modeling sinks (`X = ...`, `model.fit(...)`, `cross_validate(...)`).
|
|
182
|
+
|
|
158
183
|
### JSON Output (CI/CD Integration)
|
|
159
184
|
|
|
160
185
|
```bash
|
|
@@ -247,9 +272,9 @@ The `pycheck-vscode` extension gives you **real-time red/yellow squiggles** as y
|
|
|
247
272
|
|
|
248
273
|
---
|
|
249
274
|
|
|
250
|
-
##
|
|
275
|
+
## PyCheck Cloud & Enterprise SaaS
|
|
251
276
|
|
|
252
|
-
For
|
|
277
|
+
For institutional hedge funds, algorithmic trading desks, and enterprise ML engineering teams, **PyCheck Cloud** provides continuous compliance and automated gatekeeping:
|
|
253
278
|
|
|
254
279
|
* **Automated PR / MR Gatekeeping**: GitHub App & GitLab integration that automatically blocks pull requests containing temporal leaks, lookahead joins, or cross-fold contamination before they reach production.
|
|
255
280
|
* **Proof-of-Causality Audit Certificates**: Cryptographically verifiable backtest audit reports (PDF & JSON) certifying that quantitative strategies and feature pipelines are provably free of temporal lookahead bias for LP allocators and risk committees.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"""
|
|
2
|
-
PyCheck — NEURON ML Safety Analyzer
|
|
3
|
-
Catches temporal leaks, causal confusion, and uncertainty bugs in Python ML scripts.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
__version__ = "1.0.
|
|
7
|
-
|
|
8
|
-
from pycheck.analyzer import analyze_file, format_output
|
|
9
|
-
from pycheck.rules import ALL_RULES, RULES_BY_CODE
|
|
10
|
-
from pycheck.flow import TaintTracker
|
|
1
|
+
"""
|
|
2
|
+
PyCheck — NEURON ML Safety Analyzer
|
|
3
|
+
Catches temporal leaks, causal confusion, and uncertainty bugs in Python ML scripts.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__ = "1.0.5"
|
|
7
|
+
|
|
8
|
+
from pycheck.analyzer import analyze_file, analyze_code, format_output
|
|
9
|
+
from pycheck.rules import ALL_RULES, RULES_BY_CODE
|
|
10
|
+
from pycheck.flow import TaintTracker
|