Skip to content

Commit 39bff6a

Browse files
committed
Introduce mypy utility
1 parent 9bc6f26 commit 39bff6a

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

demo/map/conditions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
from abc import ABC, abstractmethod
2-
from selenium.webdriver.support.expected_conditions import presence_of_element_located
2+
from selenium.webdriver.support.expected_conditions import presence_of_element_located as PresenceOfElement
33

44

55
class Condition(ABC):
66
"""Abstraction of web element condition."""
77

88
@abstractmethod
9-
def presence_of_element_located(self) -> presence_of_element_located:
9+
def presence_of_element_located(self) -> PresenceOfElement:
1010
pass
1111

1212

1313
class ExpectedCondition(Condition):
1414
"""Represent expected condition of a web element."""
1515

1616
def __init__(self, *locators: str) -> None:
17-
self._presence_of_element_located: presence_of_element_located = presence_of_element_located(locators)
17+
self._presence_of_element_located: PresenceOfElement = PresenceOfElement(locators)
1818

19-
def presence_of_element_located(self) -> presence_of_element_located:
19+
def presence_of_element_located(self) -> PresenceOfElement:
2020
return self._presence_of_element_located

demo/pages/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from functools import lru_cache
2-
from typing import Callable
2+
from typing import Callable, Optional
33
from demo.browsers import WebBrowser
44
from demo.driver.driver import Driver
55
from demo.pages import Page
@@ -24,9 +24,9 @@ def _driver() -> Driver:
2424
def driver(self) -> Driver:
2525
return self._driver()
2626

27-
def open(self, url: Url = None) -> None:
27+
def open(self, url: Optional[Url] = None) -> None:
2828
if not url:
29-
url: Url = self._url
29+
url = self._url
3030
self._driver().get(url.get())
3131

3232
def close(self) -> None:

mypy.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[mypy]
2+
python_version = 3.6
3+
ignore_missing_imports = True
4+
disallow_untyped_defs = False
5+
disallow_incomplete_defs = False
6+
disallow_any_generics = True
7+
warn_unused_ignores = True
8+
warn_unused_configs = True
9+
show_column_numbers = True

run-code-analysis.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ NONE_OUT="\033[0m"
99

1010
# specifies a set of variables to declare files to be used for code assessment
1111
PROJECT_FILES="./"
12+
LIB_FILES="demo"
1213

1314

1415
function store-failures {
@@ -54,12 +55,18 @@ function run-flake8-analysis {
5455
}
5556

5657

58+
function run-mypy-analysis() {
59+
echo "Running mypy analysis ..." && mypy --package "${LIB_FILES}"
60+
}
61+
62+
5763
function run-code-analysis {
5864
echo "Running code analysis ..."
5965
remove-pycache-trash
6066
run-unittests || store-failures "Unittests are failed!"
6167
run-black-analysis || store-failures "black analysis is failed!"
6268
run-flake8-analysis || store-failures "flake8 analysis is failed!"
69+
run-mypy-analysis || store-failures "mypy analysis is failed!"
6370

6471
if [[ ${#RESULT[@]} -ne 0 ]];
6572
then echo -e "${FAILED_OUT}Some errors occurred while analysing the code quality.${NONE_OUT}"

0 commit comments

Comments
 (0)