saurabh0719 / constable Goto Github PK
View Code? Open in Web Editor NEWConstable lets you be lazy by inserting prints directly into your AST for stateful debugging :man_juggling:
Home Page: https://pypi.org/project/constable
License: MIT License
Constable lets you be lazy by inserting prints directly into your AST for stateful debugging :man_juggling:
Home Page: https://pypi.org/project/constable
License: MIT License
Started using constable
and loving it so far.
I have however noticed that constable
seems to have issues with static methods. The following sample code produces an exception:
import constable
class Test:
@staticmethod
@constable.trace("a", "b", "c")
def add(a: int, b: int) -> int:
c = a + b
return c
d = Test.add(a=1, b=2)
print(f"{d=}")
Following is the traceback when running the above code:
/home/mark/wip/feed2fedi/.venv/bin/python /home/mark/.config/JetBrains/PyCharmCE2024.1/scratches/constable_scratch.py
Traceback (most recent call last):
File "/home/mark/.config/JetBrains/PyCharmCE2024.1/scratches/constable_scratch.py", line 11, in <module>
d = Test.add(a=1, b=2)
^^^^^^^^^^^^^^^^^^
File "/home/mark/wip/feed2fedi/.venv/lib/python3.12/site-packages/constable/__init__.py", line 228, in wrapper
ret = executor.execute()
^^^^^^^^^^^^^^^^^^
File "/home/mark/wip/feed2fedi/.venv/lib/python3.12/site-packages/constable/__init__.py", line 190, in execute
result = fn(*self.fn_wrapper.args, **self.fn_wrapper.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mark/wip/feed2fedi/.venv/lib/python3.12/site-packages/constable/__init__.py", line 225, in wrapper
fn_wrapper = FunctionWrapper(func, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mark/wip/feed2fedi/.venv/lib/python3.12/site-packages/constable/__init__.py", line 43, in __init__
self.source_code_lines = inspect.getsource(func).splitlines()
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mark/.rye/py/[email protected]/install/lib/python3.12/inspect.py", line 1282, in getsource
lines, lnum = getsourcelines(object)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/mark/.rye/py/[email protected]/install/lib/python3.12/inspect.py", line 1264, in getsourcelines
lines, lnum = findsource(object)
^^^^^^^^^^^^^^^^^^
File "/home/mark/.rye/py/[email protected]/install/lib/python3.12/inspect.py", line 1093, in findsource
raise OSError('could not get source code')
OSError: could not get source code
Process finished with exit code 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.