Skip to content

Commit

Permalink
Added skip_strip_code argument
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Apr 15, 2024
1 parent 975c5c4 commit b2ef6d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ Client().query(
code: str,
scope: Optional[str] = None,
timeout: Optional[int] = None,
skip_strip_code: bool = False,
**kwargs: Any
) -> asyncio.Future
```
Expand All @@ -335,6 +336,10 @@ Use this method to run `code` in a scope.
Raise a time-out exception if no response is received within X
seconds. If no time-out is given, the client will wait forever.
Defaults to `None`.
- *skip_strip_code (bool, optional)*:
This can be set to `True` which can be helpful when line numbers
in syntax errors need to match. When `False`, the code will be
stripped from white-space and comments to reduce the code size.
- *\*\*kwargs (any, optional)*:
Can be used to inject variable into the ThingsDB code.

Expand Down
9 changes: 8 additions & 1 deletion thingsdb/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def query(
code: str,
scope: Optional[str] = None,
timeout: Optional[int] = None,
skip_strip_code: bool = False,
**kwargs: Any
) -> asyncio.Future:
"""Query ThingsDB.
Expand All @@ -311,6 +312,10 @@ def query(
Raise a time-out exception if no response is received within X
seconds. If no time-out is given, the client will wait forever.
Defaults to `None`.
skip_strip_code (bool, optional):
This can be set to True which can be helpful when line numbers
in syntax errors need to match. When False, the code will be
stripped from white-space and comments to reduce the code size.
**kwargs (any, optional):
Can be used to inject variable into the ThingsDB code.
Expand All @@ -337,7 +342,9 @@ def query(
if scope is None:
scope = self._scope

code = strip_code(code)
if skip_strip_code is False:
code = strip_code(code)

data = [scope, code]
if kwargs:
data.append(kwargs)
Expand Down
2 changes: 1 addition & 1 deletion thingsdb/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.1.0'
__version__ = '1.1.1'

0 comments on commit b2ef6d9

Please sign in to comment.