Skip to content

Commit

Permalink
Add type annotations to builtin_funcs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
angelcaru committed May 2, 2024
1 parent fc16027 commit ea3ce4f
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 154 deletions.
10 changes: 5 additions & 5 deletions core/builtin_classes/requests_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RequestsObject(BuiltInObject):
def constructor(self):
return RTResult().success(None)

@args(["url", "headers"], [String, HashMap({})])
@args(["url", "headers"], [None, HashMap({})])
@method
def get(ctx):
res = RTResult()
Expand All @@ -30,7 +30,7 @@ def get(ctx):
except Exception as e:
return res.failure(RTError(url.pos_start, url.pos_end, f"Error sending GET request: {str(e)}", ctx))

@args(["url", "data", "headers"], [String, HashMap({}), HashMap({})])
@args(["url", "data", "headers"], [None, HashMap({}), HashMap({})])
@method
def post(ctx):
res = RTResult()
Expand All @@ -47,7 +47,7 @@ def post(ctx):
except Exception as e:
return res.failure(RTError(url.pos_start, url.pos_end, f"Error sending POST request: {str(e)}", ctx))

@args(["url", "data", "headers"], [String, HashMap({}), HashMap({})])
@args(["url", "data", "headers"], [None, HashMap({}), HashMap({})])
@method
def put(ctx):
res = RTResult()
Expand All @@ -64,7 +64,7 @@ def put(ctx):
except Exception as e:
return res.failure(RTError(url.pos_start, url.pos_end, f"Error sending PUT request: {str(e)}", ctx))

@args(["url", "headers"], [String, HashMap({})])
@args(["url", "headers"], [None, HashMap({})])
@method
def delete(ctx):
res = RTResult()
Expand All @@ -78,7 +78,7 @@ def delete(ctx):
except Exception as e:
return res.failure(RTError(url.pos_start, url.pos_end, f"Error sending DELETE request: {str(e)}", ctx))

@args(["url", "data", "headers"], [String, HashMap({}), HashMap({})])
@args(["url", "data", "headers"], [None, HashMap({}), HashMap({})])
@method
def patch(ctx):
res = RTResult()
Expand Down
Loading

0 comments on commit ea3ce4f

Please sign in to comment.