Skip to content

Commit 7bf48b1

Browse files
committed
lint
1 parent 0213180 commit 7bf48b1

File tree

1 file changed

+46
-49
lines changed

1 file changed

+46
-49
lines changed

toolchain/mfc/gen_case_constraints_docs.py

Lines changed: 46 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,25 @@ def _analyze_method(self, func: ast.FunctionDef):
8383
self.local_param_stack.pop()
8484
self.current_method = None
8585

86-
def _build_local_param_map(self, func: ast.FunctionDef) -> Dict[str, str]:
86+
def _build_local_param_map(self, func: ast.FunctionDef) -> Dict[str, str]: # pylint: disable=too-many-nested-blocks
8787
"""
8888
Look for assignments like:
8989
igr = self.get('igr', 'F') == 'T'
9090
model_eqns = self.get('model_eqns')
9191
and record local_name -> 'param_name'.
9292
"""
9393
m: Dict[str, str] = {}
94-
for stmt in func.body:
94+
for stmt in func.body: # pylint: disable=too-many-nested-blocks
9595
if isinstance(stmt, ast.Assign):
9696
# Handle both direct calls and comparisons
9797
value = stmt.value
9898
# Unwrap comparisons like "self.get('igr', 'F') == 'T'"
9999
if isinstance(value, ast.Compare):
100100
value = value.left
101-
101+
102102
if isinstance(value, ast.Call):
103103
call = value
104-
if (
104+
if ( # pylint: disable=too-many-boolean-expressions
105105
isinstance(call.func, ast.Attribute)
106106
and isinstance(call.func.value, ast.Name)
107107
and call.func.value.id == "self"
@@ -168,7 +168,7 @@ def _extract_params(self, condition: ast.AST) -> Set[str]:
168168

169169
# direct self.get('param_name')
170170
if isinstance(node, ast.Call):
171-
if (
171+
if ( # pylint: disable=too-many-boolean-expressions
172172
isinstance(node.func, ast.Attribute)
173173
and isinstance(node.func.value, ast.Name)
174174
and node.func.value.id == "self"
@@ -233,7 +233,7 @@ def classify_message(msg: str) -> str:
233233
"""
234234
text = msg.lower()
235235

236-
if (
236+
if ( # pylint: disable=too-many-boolean-expressions
237237
"not compatible" in text
238238
or "does not support" in text
239239
or "cannot be used" in text
@@ -244,7 +244,7 @@ def classify_message(msg: str) -> str:
244244
):
245245
return "incompatibility"
246246

247-
if (
247+
if ( # pylint: disable=too-many-boolean-expressions
248248
"requires" in text
249249
or "must be set if" in text
250250
or "must be specified" in text
@@ -254,7 +254,7 @@ def classify_message(msg: str) -> str:
254254
):
255255
return "requirement"
256256

257-
if (
257+
if ( # pylint: disable=too-many-boolean-expressions
258258
"must be between" in text
259259
or "must be positive" in text
260260
or "must be non-negative" in text
@@ -307,7 +307,7 @@ def feature_title(param: str) -> str:
307307
# Markdown rendering
308308
# ---------------------------------------------------------------------------
309309

310-
def render_markdown(rules: Iterable[Rule]) -> str:
310+
def render_markdown(rules: Iterable[Rule]) -> str: # pylint: disable=too-many-locals,too-many-branches,too-many-statements
311311
"""
312312
Render user-friendly compatibility tables and summaries.
313313
"""
@@ -352,7 +352,7 @@ def render_markdown(rules: Iterable[Rule]) -> str:
352352
lines.append("'avg_state': 2, # Arithmetic average")
353353
lines.append("```")
354354
lines.append("</details>\n")
355-
355+
356356
lines.append("<details>")
357357
lines.append("<summary><b>⚡ Magnetohydrodynamics (MHD)</b></summary>\n")
358358
lines.append("```python")
@@ -362,7 +362,7 @@ def render_markdown(rules: Iterable[Rule]) -> str:
362362
lines.append("'riemann_solver': 1, # HLL (or 4 for HLLD)")
363363
lines.append("```")
364364
lines.append("</details>\n")
365-
365+
366366
lines.append("<details>")
367367
lines.append("<summary><b>🌡️ Phase Change</b></summary>\n")
368368
lines.append("```python")
@@ -372,7 +372,7 @@ def render_markdown(rules: Iterable[Rule]) -> str:
372372
lines.append("'riemann_solver': 2, # HLLC")
373373
lines.append("```")
374374
lines.append("</details>\n")
375-
375+
376376
lines.append("<details>")
377377
lines.append("<summary><b>💎 Elastic Materials</b></summary>\n")
378378
lines.append("```python")
@@ -385,26 +385,26 @@ def render_markdown(rules: Iterable[Rule]) -> str:
385385
# 2. Feature Compatibility Matrix (simplified, no IGR column)
386386
lines.append("## 📊 Feature Compatibility\n")
387387
lines.append("What works together:\n")
388-
389-
for category, features in major_features.items():
388+
389+
for category, features in major_features.items(): # pylint: disable=too-many-nested-blocks
390390
lines.append(f"\n### {category}\n")
391-
391+
392392
# Build compatibility info (exclude IGR from incompatibilities)
393393
compat_info = {}
394394
for feat in features:
395395
if feat not in by_param:
396396
continue
397-
397+
398398
incomp = []
399399
req = []
400400
for rule in by_param[feat]:
401401
kind = classify_message(rule.message)
402402
msg = rule.message
403-
403+
404404
# Skip IGR-related incompatibilities
405405
if "IGR" in msg:
406406
continue
407-
407+
408408
if kind == "incompatibility":
409409
for other_feat in features:
410410
if other_feat != feat and other_feat in rule.params:
@@ -413,19 +413,19 @@ def render_markdown(rules: Iterable[Rule]) -> str:
413413
for other_feat in features:
414414
if other_feat != feat and other_feat in rule.params:
415415
req.append(feature_title(other_feat))
416-
416+
417417
compat_info[feat] = {"incomp": list(set(incomp)), "req": list(set(req))}
418-
418+
419419
# Render as compact table
420420
lines.append("| Feature | Requirements | Notes |")
421421
lines.append("|---------|-------------|-------|")
422-
422+
423423
for feat in features:
424424
if feat not in by_param:
425425
continue
426426
title = feature_title(feat)
427427
info = compat_info.get(feat, {"incomp": [], "req": []})
428-
428+
429429
# Get key requirement
430430
reqs = []
431431
for rule in by_param[feat]:
@@ -434,48 +434,48 @@ def render_markdown(rules: Iterable[Rule]) -> str:
434434
if "model_eqns" in msg:
435435
reqs.append("Specific model")
436436
break
437-
437+
438438
req_str = reqs[0] if reqs else "—"
439-
439+
440440
# Get short note
441441
incomp_with = [i for i in info["incomp"] if i not in ["IGR"]][:2]
442442
if incomp_with:
443443
note = f"⚠️ Not with: {', '.join(incomp_with)}"
444444
else:
445445
note = "✓ General use"
446-
446+
447447
lines.append(f"| {title} | {req_str} | {note} |")
448-
448+
449449
lines.append("")
450450

451-
# 3. Model Equations
451+
# 3. Model Equations
452452
lines.append("## 🔢 Model Equations\n")
453453
lines.append("Choose your governing equations:\n")
454454
lines.append("")
455-
455+
456456
lines.append("<details>")
457457
lines.append("<summary><b>Model 1: π-γ (Compressible Euler)</b></summary>\n")
458458
lines.append("- **Use for:** Single-fluid compressible flow")
459459
lines.append("- **Value:** `model_eqns = 1`")
460460
lines.append("- **Note:** Cannot use `num_fluids`, bubbles, or certain WENO variants")
461461
lines.append("</details>\n")
462-
462+
463463
lines.append("<details>")
464464
lines.append("<summary><b>Model 2: 5-Equation (Most versatile)</b></summary>\n")
465465
lines.append("- **Use for:** Multiphase, bubbles, elastic materials, MHD")
466466
lines.append("- **Value:** `model_eqns = 2`")
467467
lines.append("- **Requirements:** Set `num_fluids`")
468468
lines.append("- **Compatible with:** Most physics models")
469469
lines.append("</details>\n")
470-
470+
471471
lines.append("<details>")
472472
lines.append("<summary><b>Model 3: 6-Equation (Phase change)</b></summary>\n")
473473
lines.append("- **Use for:** Phase change, cavitation")
474474
lines.append("- **Value:** `model_eqns = 3`")
475475
lines.append("- **Requirements:** `riemann_solver = 2` (HLLC), `avg_state = 2`, `wave_speeds = 1`")
476476
lines.append("- **Note:** Not compatible with bubbles or 3D cylindrical")
477477
lines.append("</details>\n")
478-
478+
479479
lines.append("<details>")
480480
lines.append("<summary><b>Model 4: 4-Equation (Single component)</b></summary>\n")
481481
lines.append("- **Use for:** Single-component flows with bubbles")
@@ -498,7 +498,7 @@ def render_markdown(rules: Iterable[Rule]) -> str:
498498
if "bubbles_euler" in by_param or "bubbles_lagrange" in by_param:
499499
lines.append("## 💧 Bubble Models\n")
500500
lines.append("")
501-
501+
502502
lines.append("<details>")
503503
lines.append("<summary><b>Euler-Euler (`bubbles_euler`)</b></summary>\n")
504504
lines.append("**Requirements:**")
@@ -511,7 +511,7 @@ def render_markdown(rules: Iterable[Rule]) -> str:
511511
lines.append("- `qbmm = T`: Quadrature method (requires `nnode = 4`)")
512512
lines.append("- `adv_n = T`: Number density advection (requires `num_fluids = 1`)")
513513
lines.append("</details>\n")
514-
514+
515515
lines.append("<details>")
516516
lines.append("<summary><b>Euler-Lagrange (`bubbles_lagrange`)</b></summary>\n")
517517
lines.append("**Requirements:**")
@@ -524,66 +524,66 @@ def render_markdown(rules: Iterable[Rule]) -> str:
524524
# 6. Condensed Parameter Reference
525525
lines.append("## 📖 Quick Parameter Reference\n")
526526
lines.append("Key parameters and their constraints:\n")
527-
527+
528528
# Highlight only the most important parameters in collapsible sections
529529
important_params = {
530530
"MHD": "mhd",
531-
"Surface Tension": "surface_tension",
531+
"Surface Tension": "surface_tension",
532532
"Viscosity": "viscous",
533533
"Number of Fluids": "num_fluids",
534534
"Cylindrical Coordinates": "cyl_coord",
535535
"Immersed Boundaries": "ib",
536536
}
537-
537+
538538
for title, param in important_params.items():
539539
if param not in by_param:
540540
continue
541-
541+
542542
rules_for_param = by_param[param]
543-
543+
544544
# Get key info
545545
requirements = []
546546
incompatibilities = []
547547
ranges = []
548-
548+
549549
for rule in rules_for_param:
550550
msg = rule.message
551551
# Skip IGR-related messages
552552
if "IGR" in msg:
553553
continue
554-
554+
555555
kind = classify_message(msg)
556556
if kind == "requirement":
557557
requirements.append(msg)
558558
elif kind == "incompatibility":
559559
incompatibilities.append(msg)
560560
elif kind == "range":
561561
ranges.append(msg)
562-
562+
563563
if not (requirements or incompatibilities or ranges):
564564
continue
565-
565+
566566
lines.append(f"\n<details>")
567567
lines.append(f"<summary><b>{title}</b> (`{param}`)</summary>\n")
568-
568+
569569
if requirements:
570570
lines.append("**Requirements:**")
571571
for req in requirements[:3]:
572572
lines.append(f"- {req}")
573573
lines.append("")
574-
574+
575575
if incompatibilities:
576576
lines.append("**Incompatibilities:**")
577577
for inc in incompatibilities[:3]:
578578
lines.append(f"- {inc}")
579579
lines.append("")
580-
580+
581581
if ranges:
582582
lines.append("**Valid values:**")
583583
for rng in ranges[:2]:
584584
lines.append(f"- {rng}")
585585
lines.append("")
586-
586+
587587
lines.append("</details>\n")
588588

589589
# Add a footer with link to full validator
@@ -618,6 +618,3 @@ def main() -> None:
618618

619619
if __name__ == "__main__":
620620
main()
621-
622-
623-

0 commit comments

Comments
 (0)