Skip to content

Fix mypy error with mypy v0.812#590

Merged
ki4070ma merged 3 commits intoappium:dependabot/pip/mypy-approx-eq-0.812from
ki4070ma:fix-mypy
Feb 24, 2021
Merged

Fix mypy error with mypy v0.812#590
ki4070ma merged 3 commits intoappium:dependabot/pip/mypy-approx-eq-0.812from
ki4070ma:fix-mypy

Conversation

@ki4070ma
Copy link
Copy Markdown
Collaborator

@ki4070ma ki4070ma commented Feb 23, 2021

Background

Root cause is that MobileSwitchTo is unreachable when driver.switch_to is called from checking current behavior by mypy/on IDE.
(Also context@MobileSwithTo doesn't show at IDE(PyCharm) as auto completion)

Notes

mypy errors

************* Module test.functional.android.context_switching_tests
test/functional/android/context_switching_tests.py:49:8: E1101: Instance of 'SwitchTo' has no 'context' member (no-member)
test/functional/android/context_switching_tests.py:54:12: E1101: Instance of 'SwitchTo' has no 'context' member (no-member)
test/functional/android/context_switching_tests.py:59:8: E1101: Instance of 'SwitchTo' has no 'context' member (no-member)

dependabot bot and others added 2 commits February 22, 2021 11:07
Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](python/mypy@v0.800...v0.812)

Signed-off-by: dependabot[bot] <support@github.com>
@ki4070ma ki4070ma changed the title Fix mypy error Fix mypy error with mypy v0.812 Feb 23, 2021

class MobileSwitchTo(SwitchTo):
def context(self, context_name: str) -> T:
def context(self, context_name: Optional[str]) -> T:
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.

why context name is optional?

Copy link
Copy Markdown
Collaborator Author

@ki4070ma ki4070ma Feb 23, 2021

Choose a reason for hiding this comment

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

It comes from here

self.driver.switch_to.context(None)

Copy link
Copy Markdown
Contributor

@mykola-mokhnach mykola-mokhnach Feb 23, 2021

Choose a reason for hiding this comment

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

it makes sense to mention that in the docstring (e.g. passing None is equal to switching to native context)

self._addCommands()

self.error_handler = MobileErrorHandler()
self._switch_to = MobileSwitchTo(self)
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.

do we use _switch_to property anywhere else?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for your pointing out, I've checked it again, but it isn't used anywhere else.

@ki4070ma ki4070ma marked this pull request as ready for review February 24, 2021 14:09
@ki4070ma ki4070ma merged commit e7264c5 into appium:dependabot/pip/mypy-approx-eq-0.812 Feb 24, 2021
@ki4070ma ki4070ma deleted the fix-mypy branch February 24, 2021 14:10
ki4070ma added a commit that referenced this pull request Feb 24, 2021
* chore(deps): update mypy requirement from ~=0.800 to ~=0.812

Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](python/mypy@v0.800...v0.812)

Signed-off-by: dependabot[bot] <support@github.com>

* Fix mypy error with mypy v0.812 (#590)

* chore(deps): update mypy requirement from ~=0.800 to ~=0.812

Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](python/mypy@v0.800...v0.812)

Signed-off-by: dependabot[bot] <support@github.com>

* fix mypy error

* review comment

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mori Atsushi <ki4070ma@gmail.com>
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.

2 participants