Network property should cause a recursion error
ross-spencer opened this issue · 1 comments
Describe the bug
A clear and concise description of what the bug is.
In the Ogmios context the network property returns self.nework. This shouldn't be possible, and when calling users are likely to see:
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/ross-spencer/git/orcfax/cnt/src/cnt/main.py", line 227, in <module>
main()
File "/home/ross-spencer/git/orcfax/cnt/src/cnt/main.py", line 223, in main
cnt_collect()
File "/home/ross-spencer/git/orcfax/cnt/src/cnt/main.py", line 188, in cnt_collect
print("network:", context.network)
File "/home/ross-spencer/git/orcfax/cnt/venv/lib/python3.10/site-packages/pycardano/backend/ogmios.py", line 247, in network
return self.network
File "/home/ross-spencer/git/orcfax/cnt/venv/lib/python3.10/site-packages/pycardano/backend/ogmios.py", line 247, in network
return self.network
File "/home/ross-spencer/git/orcfax/cnt/venv/lib/python3.10/site-packages/pycardano/backend/ogmios.py", line 247, in network
return self.network
[Previous line repeated 991 more times]
RecursionError: maximum recursion depth exceeded
Ref:
pycardano/pycardano/backend/ogmios.py
Lines 244 to 247 in 9b5d367
Snippet:
@property
def network(self) -> Network:
"""Get current network"""
return self.networkTo Reproduce
Steps to reproduce the behavior. e.g. A python script.
Create an Ogmios Pycardano conext:
context: OgmiosChainContext = OgmiosChainContext(
ws_url=OGMIOS_URL, network=Network.MAINNET
)
And try and return its network propery:
print("network:", context.network)
Logs
If applicable, add logs to help explain your problem.
Error trace as per above.
Expected behavior
A clear and concise description of what you expected to happen.
When calling the network property it returns the network that the context is associated with and doesn't cause a recursion error.
Environment and software version (please complete the following information):
- OS: [e.g. Ubuntu 20.04.3 LTS, Mac OS 12.1]
- PyCardano Version [e.g. 0.1.1]
pycardano==0.10.0
Python 3.10.12.
Additional context
Add any other context about the problem here.
N/A.