Skip to content

Commit

Permalink
[py]: document mypy config; add additional types and types dependen…
Browse files Browse the repository at this point in the history
…cies
  • Loading branch information
symonk committed Oct 5, 2022
1 parent 3918220 commit a793b3a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
22 changes: 21 additions & 1 deletion py/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
[mypy]
files = selenium
ignore_missing_imports = False
; warn about per-module sections in the config file that do not match any files processed.
warn_unused_configs = True
; disallows subclassing of typing.Any.
disallow_subclassing_any = True
; disallow usage of generic types that do not specify explicit type parameters.
disallow_any_generics = True
; disallow calling functions without type annotations from functions that have type annotations.
disallow_untyped_calls = True
; disallow defining functions without type annotations or with incomplete annotations.
disallow_untyped_defs = True
; disallow defining functions with incomplete type annotations.
disallow_incomplete_defs = True
; type-checks the interior of functions without type annotations.
check_untyped_defs = True
; reports an error whenever a function with type annotations is decorated with a decorator without annotations.
disallow_untyped_decorators = True
; changes the treatment of arguments with a default value of None by not implicitly making their type `typing.Optional`.
no_implicit_optional = True
; warns about casting an expression to it's inferred type.
warn_redundant_casts = True
; warns about unneeded `# type: ignore` comments.
warn_unused_ignores = True
; warns when returning a value with typing.Any from a function with a non typing.Any return type.
warn_return_any = True
; Shows a warning when encountering any code inferred to be unreachable after performing type analysis.
warn_unreachable = True

[mypy-trio_websocket]
; suppress error messages about imports that cannot be resolved.
ignore_missing_imports = True

[mypy-_winreg]
; suppress error messages about imports that cannot be resolved.
ignore_missing_imports = True
8 changes: 4 additions & 4 deletions py/selenium/webdriver/ie/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import typing
from typing import List

from selenium.webdriver.common import service
Expand All @@ -31,9 +31,9 @@ def __init__(
self,
executable_path: str = DEFAULT_EXECUTABLE_PATH,
port: int = 0,
host: str = None,
log_level: str = None,
log_file: str = None,
host: typing.Optional[str] = None,
log_level: typing.Optional[str] = None,
log_file: typing.Optional[str] = None,
):
"""
Creates a new instance of the Service
Expand Down
12 changes: 6 additions & 6 deletions py/selenium/webdriver/support/expected_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"""


def title_is(title):
def title_is(title: str):
"""An expectation for checking the title of a page.
title is the expected title, which must be an exact match
returns True if the title matches, false otherwise."""
Expand All @@ -41,7 +41,7 @@ def _predicate(driver):
return _predicate


def title_contains(title):
def title_contains(title: str):
"""An expectation for checking that the title contains a case-sensitive
substring. title is the fragment of title expected
returns True when the title matches, False otherwise
Expand All @@ -66,7 +66,7 @@ def _predicate(driver):
return _predicate


def url_contains(url):
def url_contains(url: str):
"""An expectation for checking that the current url contains a
case-sensitive substring.
url is the fragment of url expected,
Expand All @@ -79,7 +79,7 @@ def _predicate(driver):
return _predicate


def url_matches(pattern):
def url_matches(pattern: str):
"""An expectation for checking the current url.
pattern is the expected pattern, which must be an exact match
returns True if the url matches, false otherwise."""
Expand All @@ -90,7 +90,7 @@ def _predicate(driver):
return _predicate


def url_to_be(url):
def url_to_be(url: str):
"""An expectation for checking the current url.
url is the expected url, which must be an exact match
returns True if the url matches, false otherwise."""
Expand All @@ -101,7 +101,7 @@ def _predicate(driver):
return _predicate


def url_changes(url):
def url_changes(url: str):
"""An expectation for checking the current url.
url is the expected url, which must not be an exact match
returns True if the url is different, false otherwise."""
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/support/wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(
exceptions.append(ignored_exceptions)
self._ignored_exceptions = tuple(exceptions)

def __repr__(self):
def __repr__(self) -> str:
return '<{0.__module__}.{0.__name__} (session="{1}")>'.format(type(self), self._driver.session_id)

def until(self, method, message: str = ""):
Expand Down
9 changes: 6 additions & 3 deletions py/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ commands = sphinx-build -b html -d ../build/doctrees docs/source ../build/docs/a
[testenv:mypy]
skip_install = true
deps =
mypy
lxml
commands = mypy {posargs}
mypy==0.982
lxml==4.9.1
types-urllib3==1.26.25
types-certifi==2021.10.8.3
trio-typing==0.7.0
commands = mypy --install-types {posargs}


[isort]
Expand Down

0 comments on commit a793b3a

Please sign in to comment.