mirror of
https://github.com/AtsushiSakai/PythonRobotics.git
synced 2026-04-22 03:00:22 -04:00
add mypy unit test (#621)
* add mypy unit test * add mypy unit test * add mypy unit test
This commit is contained in:
15
.github/workflows/Linux_CI.yml
vendored
15
.github/workflows/Linux_CI.yml
vendored
@@ -28,21 +28,6 @@ jobs:
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install -r requirements.txt
|
||||
- name: install coverage
|
||||
run: pip install coverage
|
||||
- name: install mypy
|
||||
run: pip install mypy
|
||||
- name: mypy check
|
||||
run: |
|
||||
mypy -p AerialNavigation
|
||||
mypy -p ArmNavigation
|
||||
mypy -p Bipedal
|
||||
mypy -p Control
|
||||
mypy -p Localization
|
||||
mypy -p Mapping
|
||||
mypy -p PathPlanning
|
||||
mypy -p PathTracking
|
||||
mypy -p SLAM
|
||||
- name: do all unit tests
|
||||
run: bash runtests.sh
|
||||
|
||||
|
||||
15
.github/workflows/MacOS_CI.yml
vendored
15
.github/workflows/MacOS_CI.yml
vendored
@@ -35,20 +35,5 @@ jobs:
|
||||
python -m pip install --upgrade pip
|
||||
pip install numpy # cvxpy install workaround
|
||||
pip install -r requirements.txt
|
||||
- name: install coverage
|
||||
run: pip install coverage
|
||||
- name: install mypy
|
||||
run: pip install mypy
|
||||
- name: mypy check
|
||||
run: |
|
||||
mypy -p AerialNavigation
|
||||
mypy -p ArmNavigation
|
||||
mypy -p Bipedal
|
||||
mypy -p Control
|
||||
mypy -p Localization
|
||||
mypy -p Mapping
|
||||
mypy -p PathPlanning
|
||||
mypy -p PathTracking
|
||||
mypy -p SLAM
|
||||
- name: do all unit tests
|
||||
run: bash runtests.sh
|
||||
@@ -64,15 +64,15 @@ class DStarLite:
|
||||
for x, y in zip(ox, oy)]
|
||||
self.start = Node(0, 0)
|
||||
self.goal = Node(0, 0)
|
||||
self.U = list()
|
||||
self.U = list() # type: ignore
|
||||
self.km = 0.0
|
||||
self.kold = 0.0
|
||||
self.rhs = list()
|
||||
self.g = list()
|
||||
self.detected_obstacles = list()
|
||||
self.rhs = list() # type: ignore
|
||||
self.g = list() # type: ignore
|
||||
self.detected_obstacles = list() # type: ignore
|
||||
if show_animation:
|
||||
self.detected_obstacles_for_plotting_x = list()
|
||||
self.detected_obstacles_for_plotting_y = list()
|
||||
self.detected_obstacles_for_plotting_x = list() # type: ignore
|
||||
self.detected_obstacles_for_plotting_y = list() # type: ignore
|
||||
|
||||
def create_grid(self, val: float):
|
||||
grid = list()
|
||||
@@ -248,7 +248,7 @@ class DStarLite:
|
||||
return False
|
||||
return True
|
||||
|
||||
def display_path(self, path: list, colour: str, alpha: int = 1):
|
||||
def display_path(self, path: list, colour: str, alpha: float = 1.0):
|
||||
px = [(node.x + self.x_min_world) for node in path]
|
||||
py = [(node.y + self.y_min_world) for node in path]
|
||||
drawing = plt.plot(px, py, colour, alpha=alpha)
|
||||
|
||||
@@ -5,6 +5,7 @@ matplotlib == 3.5.1
|
||||
cvxpy == 1.1.18
|
||||
pytest == 6.2.5 # For unit test
|
||||
pytest-xdist == 2.5.0 # For unit test
|
||||
mypy == 0.931 # For unit test
|
||||
flake8 == 4.0.1 # For unit test
|
||||
sphinx == 4.3.2 # For sphinx documentation
|
||||
sphinx_rtd_theme == 1.0.0
|
||||
|
||||
50
tests/test_mypy_type_check.py
Normal file
50
tests/test_mypy_type_check.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import conftest
|
||||
|
||||
SUBPACKAGE_LIST = [
|
||||
"AerialNavigation",
|
||||
"ArmNavigation",
|
||||
"Bipedal",
|
||||
"Control",
|
||||
"Localization",
|
||||
"Mapping",
|
||||
"PathPlanning",
|
||||
"PathTracking",
|
||||
"SLAM",
|
||||
]
|
||||
|
||||
|
||||
def run_mypy(dir_name, project_path, config_path):
|
||||
res = subprocess.run(
|
||||
['mypy',
|
||||
'--config-file',
|
||||
config_path,
|
||||
'-p',
|
||||
dir_name],
|
||||
cwd=project_path,
|
||||
stdout=subprocess.PIPE,
|
||||
encoding='utf-8')
|
||||
return res.returncode, res.stdout
|
||||
|
||||
|
||||
def test():
|
||||
project_dir_path = os.path.dirname(
|
||||
os.path.dirname(os.path.abspath(__file__)))
|
||||
print(f"{project_dir_path=}")
|
||||
|
||||
config_path = os.path.join(project_dir_path, "mypy.ini")
|
||||
print(f"{config_path=}")
|
||||
|
||||
for sub_package_name in SUBPACKAGE_LIST:
|
||||
rc, errors = run_mypy(sub_package_name, project_dir_path, config_path)
|
||||
if errors:
|
||||
print(errors)
|
||||
else:
|
||||
print("No lint errors found.")
|
||||
assert rc == 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
conftest.run_this_test(__file__)
|
||||
Reference in New Issue
Block a user