-
-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow ${{}} exprs to call methods from external python modules #324
Conversation
Fix Publish to Test PyPI Action
Update poetry-publish version
--no-report flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for supporting ScanAPI, and congratulations on your first contribution! A project committer will shortly review your contribution.
In the mean time, if you haven't had a chance please skim over the First Pull Request Guide which all pull requests must adhere to.
We hope to see you around!
Weird, my local black setup gives a completely different result ...
|
Hey @camilamaia This month i will take a vacation, and after i can work at this PR if necessary. |
@hebertjulio perfect! It would help a lot. Have a great vacation! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jlugao I solved all conflicts 👌 It is still failing in some static analysis (https://github.com/scanapi/scanapi/pull/324/checks?check_run_id=3433068011 and https://github.com/scanapi/scanapi/pull/324/checks?check_run_id=3433067531) but we can tackle them later, before merging the PR. I believe it is all good now for you to test it. As a guide, I would suggest you:
Let me know how it goes! I can help with any blocker :) Also, feel free to join our discord server https://discord.scanapi.dev if you want some help via chat |
Sorry, closing this PR for now since there was no recent activity 🧹 If you want to update it, feel free to reopen it. |
#301
This PR adds the evaluator
RemoteMethodCallEvaluator
, It extendsCodeEvaluator
by allowing a RMC expression<module>:≤python function call>
to be inserted in${{}}
expressions, which so far only accepts pure Python code.RMC expression
A RMC expr allows you to invoke a method/function from a given python module:
The right member of the expression must either be a a raw name as above or a typical Python call:
std
In addition to any module name, the left member also accepts two values: the empty string and
std
. Those two values means the module to import from isscanapi/std.py
.std.py
is meant to be a standard library of methods shipped with scanapi.For now,
std
is only a module, but maybe it should become a package instead to avoid putting everything into a single file.How modules are imported
Modules are imported at evaluation time. Path resolution works the same as a regular import , i.e to import a local module you'll need to have it in your current working directory.
How functions are called
The function is imported from its module, then
functools.partial
;vars
to the function as efficiently as possible here, in the following order:vars
's keys, an exception is raised.vars
is fed as a single positional argument to the function.vars
argument,vars
is fed as a keyword argument under that name.#301 suggested that
vars
be fed implicitly to the function, but there may be a case for doing it explicitly instead; the right member is parsed using the ast module, and we could use it to parse name arguments as well; that wouldn't be too much of a stretch: