Skip to content

Conversation

mykola-mokhnach
Copy link
Contributor

This should improve auto-complete suggestions in the IDE and address type warnings in PyCharm.

It would be necessary to use protocols if we want to give mypy a hint about access to other mixin classes. For example:

class CanValidateCoordinates(Protocol):
    def validate(x, y): ...

......

Here we have some other mixin class, which implements the `CanValidateCoordinates` protocol
......
T = TypeVar('T', bound=Union['MixinClass', CanValidateCoordinates])
....
def mixin_method(self: T):
   self.validate(x, y)  # <--- mypy appreciates

@mykola-mokhnach mykola-mokhnach changed the title fix: Tune mixin types, so linterscould recognize them better fix: Tune mixin types, so linters could recognize them better May 8, 2020
Copy link
Member

@KazuCocoa KazuCocoa left a comment

Choose a reason for hiding this comment

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

👀

from ..mobilecommand import MobileCommand as Command

if TYPE_CHECKING:
# noinspection PyUnresolvedReferences
Copy link
Collaborator

Choose a reason for hiding this comment

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

[Question] Is this for Pycharm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exactly. Pycharm has its own linter, which shows warnings

@mykola-mokhnach mykola-mokhnach merged commit e911457 into appium:master May 9, 2020
@mykola-mokhnach mykola-mokhnach deleted the ext_types branch May 9, 2020 10:28
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