Cannot call super() inside method with graph/node decorator
Open
Nobody has claimed this yet.
type: bug
- Dominant language
- Python
- Stars
- 441
- Forks
- 90
- Avg merge
- 1d 12m
- Merged PRs (30d)
- 5
Description
import csp
from datetime import datetime
class MyClass:
@csp.graph
def my_graph(self, x: int):
csp.print("x", csp.const(x))
class MySubClass(MyClass):
@csp.graph
def my_graph(self):
super().my_graph(x=5)
msc = MySubClass()
csp.run(msc.my_graph, realtime=True, starttime=datetime.now())
Traceback (most recent call last):
File "tmp2.py", line 18, in <module>
csp.run(msc.my_graph, realtime=True, starttime=datetime.now())
File "csp/impl/wiring/runtime.py", line 214, in run
return run(graph, starttime=starttime, endtime=endtime, **engine_settings)
File "csp/impl/error_handling.py", line 37, in __exit__
raise exc_val.with_traceback(new_tb)
File "tmp2.py", line 14, in my_graph
super().my_graph(x=5)
RuntimeError: super(): __class__ cell not found
Note that this works ok (no decorator):
class MySubClass(MyClass):
def my_graph(self):
super().my_graph(x=5)
Note that old style does also not work:
class MySubClass(MyClass):
@csp.graph
def my_graph(self):
super(MySubClass, self).my_graph(x=5)
name 'MySubClass' is not defined. Did you mean: `MyClass`?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproducer from the issue and inspect csp/impl/wiring/runtime.py, with csp/impl/error_handling.py for the reported traceback handling. Trace how the graph decorator transforms methods and verify that a decorated subclass method can call super(); done means both super() forms execute without the reported errors and existing behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- stream-processing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100