feat: Add command with setattr#615
Merged
KazuCocoa merged 12 commits intoappium:masterfrom Jul 14, 2021
Merged
Conversation
appium/webdriver/webdriver.py
Outdated
| logger.warn( | ||
| '{} is alreadt defined. The new one is overriding the old one.'.format(instance.method_name()) | ||
| ) | ||
| setattr(WebDriver, instance.method_name(), instance.command_wrapper) |
Contributor
There was a problem hiding this comment.
should we actually invoke command_wrapper here? I'm not sure about what this method is supposed to return
KazuCocoa
commented
Jul 12, 2021
|
|
||
| httpretty = "~=1.0" | ||
| python-dateutil = "~=2.8" | ||
| types-python-dateutil = "~=0.1" |
Member
Author
There was a problem hiding this comment.
Azure failure pointed to this necessity.
appium/webdriver/webdriver.py
Outdated
| def __init__(self, execute: Callable[[str, Dict], Dict[str, Any]]): | ||
| self._execute = execute | ||
|
|
||
| def execute(self, parameters: Any = {}) -> Any: |
Contributor
There was a problem hiding this comment.
Please do not set mutable objects as defaults: https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html
Contributor
There was a problem hiding this comment.
shall we use *args, **kwargs notation instead?
Member
Author
There was a problem hiding this comment.
Changed here as Dict explicitly to match with original execute: https://github.com/SeleniumHQ/selenium/blob/e46dba531896f67bdb93ba8d9e1d64f8b6b75b6f/py/selenium/webdriver/remote/webdriver.py#L380
KazuCocoa
added a commit
that referenced
this pull request
Aug 29, 2021
* chore: add placeholder * move to extention way * revert pytest * add todo * call method_name instead of wrapper * remove types * rename a method * add examples * add types-python-dateutil as error message * add example more * tweak naming * Explicit Dict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As #608 (comment) and after I considered better way, I think we can add a new method dynamically with
setattr. Then, the new command can call asdriver.new_command. It should be better than call a method as string as the previous one.I haven't updated docstring.