Skip to content

feat: Add command with setattr#615

Merged
KazuCocoa merged 12 commits intoappium:masterfrom
KazuCocoa:add-command-as-arguments
Jul 14, 2021
Merged

feat: Add command with setattr#615
KazuCocoa merged 12 commits intoappium:masterfrom
KazuCocoa:add-command-as-arguments

Conversation

@KazuCocoa
Copy link
Copy Markdown
Member

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 as driver.new_command. It should be better than call a method as string as the previous one.

I haven't updated docstring.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we actually invoke command_wrapper here? I'm not sure about what this method is supposed to return

Copy link
Copy Markdown
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀


httpretty = "~=1.0"
python-dateutil = "~=2.8"
types-python-dateutil = "~=0.1"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure failure pointed to this necessity.

@KazuCocoa KazuCocoa marked this pull request as ready for review July 13, 2021 07:16
Copy link
Copy Markdown
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!

def __init__(self, execute: Callable[[str, Dict], Dict[str, Any]]):
self._execute = execute

def execute(self, parameters: Any = {}) -> Any:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we use *args, **kwargs notation instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KazuCocoa KazuCocoa merged commit e48085d into appium:master Jul 14, 2021
@KazuCocoa KazuCocoa deleted the add-command-as-arguments branch July 14, 2021 07:35
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants