Skip to content

Commit ffee216

Browse files
committed
codex: advance quality tool adoption
1 parent 89a5d8d commit ffee216

56 files changed

Lines changed: 10186 additions & 582 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/quality.yml‎

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ jobs:
3939
run: pip-audit . --cache-dir /tmp/pip-audit-cache
4040
- name: Vulture dead-code scan
4141
run: vulture
42+
- name: Radon complexity policy
43+
env:
44+
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
45+
PUSH_BEFORE_SHA: ${{ github.event.before }}
46+
run: python tools/check_radon_policy.py --base-ref auto
4247
- name: Radon complexity report
4348
continue-on-error: true
4449
run: radon cc c_parser fortran_parser semantics x2py -n C -s --total-average
@@ -112,31 +117,33 @@ jobs:
112117
- name: Run tests with a changing random seed
113118
env:
114119
PYTHONPATH: .
115-
run: python -m pytest -q -n auto --randomly-seed=${{ github.run_id }} --benchmark-disable
120+
run: python -m pytest -q -n auto --randomly-seed=${{ github.run_id }}
116121

117-
benchmark:
118-
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
119-
runs-on: ubuntu-latest
120-
timeout-minutes: 15
121-
permissions:
122-
contents: read
123-
steps:
124-
- name: Checkout repository
125-
uses: actions/checkout@v4
126-
- name: Set up Python
127-
uses: actions/setup-python@v5
128-
with:
129-
python-version: "3.12"
130-
- name: Install QA dependencies
131-
run: |
132-
python -m pip install --upgrade pip
133-
python -m pip install -e ".[qa]"
134-
- name: Run parser benchmarks
135-
env:
136-
PYTHONPATH: .
137-
run: python -m pytest -q tests/benchmarks -m benchmark --benchmark-only --benchmark-json=benchmark.json
138-
- name: Upload benchmark report
139-
uses: actions/upload-artifact@v4
140-
with:
141-
name: parser-benchmark-${{ github.run_id }}
142-
path: benchmark.json
122+
# Benchmark workflow is intentionally parked for later activation.
123+
# benchmark:
124+
# if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
125+
# runs-on: ubuntu-latest
126+
# timeout-minutes: 15
127+
# permissions:
128+
# contents: read
129+
# steps:
130+
# - name: Checkout repository
131+
# uses: actions/checkout@v4
132+
# - name: Set up Python
133+
# uses: actions/setup-python@v5
134+
# with:
135+
# python-version: "3.12"
136+
# - name: Install QA dependencies
137+
# run: |
138+
# python -m pip install --upgrade pip
139+
# python -m pip install -e ".[qa]"
140+
# - name: Run parser benchmarks
141+
# env:
142+
# PYTHONPATH: .
143+
# run: python -m pytest -q tests/benchmarks -m benchmark --benchmark-only --benchmark-json=benchmark.json
144+
# - name: Upload benchmark report
145+
# uses: actions/upload-artifact@v4
146+
# with:
147+
# name: parser-benchmark-${{ github.run_id }}
148+
# path: benchmark.json
149+
# retention-days: 90

‎.github/workflows/tests.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
PYTHONPATH: .
3737
COVERAGE_PROCESS_START: ${{ github.workspace }}/pyproject.toml
3838
HYPOTHESIS_PROFILE: ci
39-
run: python -m coverage run -m pytest -q -n auto --randomly-seed=1 --benchmark-disable
39+
run: python -m coverage run -m pytest -q -n auto --randomly-seed=1
4040
- name: Combine coverage data
4141
run: python -m coverage combine
4242
- name: Report coverage

‎.pre-commit-config.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ repos:
2929
pass_filenames: false
3030
files: \.py$
3131

32+
- id: radon-policy
33+
name: radon complexity policy
34+
entry: python3 tools/check_radon_policy.py
35+
language: system
36+
pass_filenames: false
37+
files: \.py$
38+
3239
- id: vulture
3340
name: vulture dead-code scan
3441
entry: vulture

‎c_parser/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
"CChar",
6060
"CComposedType",
6161
"CConst",
62+
"CDiagnostic",
6263
"CDouble",
6364
"CDoubleComplex",
64-
"CDiagnostic",
6565
"CEnum",
6666
"CEnumerator",
6767
"CFile",
@@ -80,8 +80,8 @@
8080
"CMacroDependency",
8181
"CParameter",
8282
"CParseError",
83-
"CPointer",
8483
"CParser",
84+
"CPointer",
8585
"CProject",
8686
"CQualifier",
8787
"CRawDirective",

‎c_parser/lexer.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,13 +786,13 @@ def lex_c_source(source: str, filename: str | None = None) -> list[CToken]:
786786

787787

788788
__all__ = (
789-
"CLogicalRecord",
790789
"CLineMapping",
790+
"CLogicalRecord",
791791
"CToken",
792792
"CTopLevelSegment",
793793
"NormalizedCSource",
794-
"line_mappings_for_source",
795794
"lex_c_source",
795+
"line_mappings_for_source",
796796
"normalize_c_source",
797797
"split_top_level_c_source",
798798
"strip_c_comments",

‎c_parser/models.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ def c_model_to_dict(obj: Any, _seen: set[int] | None = None) -> Any:
5252
if isinstance(obj, CQualifier):
5353
return obj.spelling
5454
if isinstance(obj, CType):
55-
if isinstance(obj, (CStruct, CUnion, CEnum, CTypedef)) and id(obj) in _seen:
55+
if isinstance(obj, CStruct | CUnion | CEnum | CTypedef) and id(obj) in _seen:
5656
return {"reference": obj.reference_name}
57-
if isinstance(obj, (CStruct, CUnion, CEnum, CTypedef)):
57+
if isinstance(obj, CStruct | CUnion | CEnum | CTypedef):
5858
_seen.add(id(obj))
5959
payload = {"model": type(obj).__name__}
6060
payload.update(
@@ -87,7 +87,7 @@ def c_model_to_dict(obj: Any, _seen: set[int] | None = None) -> Any:
8787
return [c_model_to_dict(v, _seen) for v in obj]
8888
if isinstance(obj, dict):
8989
return {k: c_model_to_dict(v, _seen) for k, v in obj.items()}
90-
if isinstance(obj, (set, frozenset)):
90+
if isinstance(obj, set | frozenset):
9191
return sorted(c_model_to_dict(v, _seen) for v in obj)
9292
return obj
9393

@@ -406,7 +406,7 @@ def type(self) -> CFunctionType:
406406
@dataclass
407407
class CStruct(CType):
408408
name: str | None = None
409-
members: list["CVariable"] = field(default_factory=list)
409+
members: list[CVariable] = field(default_factory=list)
410410
anonymous_id: str | None = None
411411
is_incomplete: bool = False
412412
source_location: CSourceLocation | None = None
@@ -420,7 +420,7 @@ def reference_name(self) -> str:
420420
@dataclass
421421
class CUnion(CType):
422422
name: str | None = None
423-
members: list["CVariable"] = field(default_factory=list)
423+
members: list[CVariable] = field(default_factory=list)
424424
anonymous_id: str | None = None
425425
is_incomplete: bool = False
426426
source_location: CSourceLocation | None = None

0 commit comments

Comments
 (0)