Commit cb8bcfb
fix(scripts): make cocotb_ref_model importable again (#1589)
* fix(scripts): make cocotb_ref_model importable again
The module fails at import:
NameError: name 'EvalContext' is not defined
EvalContext is annotated on function parameters at lines 174 and 215 but the class
is defined at line 402. Python evaluates annotations at function-definition time
unless the module opts out, so the forward reference raises before argparse is
reached and the tool cannot run at all.
Adding `from __future__ import annotations` defers annotation evaluation and the
module loads. Afterwards it reaches its own argument parser and reports what it
needs:
usage: cocotb_ref_model.py [-h] --ast-json AST_JSON --verilog VERILOG
--top-module TOP_MODULE [--use-cocotb] [--verbose]
Placement matters and is easy to get wrong: a __future__ import may be preceded
only by the module docstring, comments and blank lines. Inserting it between the
shebang and the docstring also makes the module load, but silently demotes the
docstring to an ordinary string expression and leaves __doc__ as None. It is
inserted after the docstring here, and ast.get_docstring confirms the docstring
survives.
Found by extending the pass-57/58 side-effect sweep to the EXEC bucket -- the last
12 scripts in the repository that had never been executed. No workflow references
this file, which is why the breakage went unnoticed.
* docs(now): record #1589 in the coordination anchor
now-sync-gate requires every PR to master to update docs/NOW.md.
This PR predates my knowing that; the entry describes what it
lands and states its honesty limits, in the file's existing shape.
---------
Co-authored-by: gHashTag <admin@t27.ai>1 parent 7a71742 commit cb8bcfb
2 files changed
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
1 | 20 | | |
2 | 21 | | |
3 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
0 commit comments