Commit 59824519 authored by Gabriel Couture's avatar Gabriel Couture

Adding mypy linter, fix errors found by mypy

parent 4911d782
Pipeline #185 failed with stage
in 5 seconds
......@@ -4,7 +4,7 @@ setup(
name='howtotest',
version='0.1.0',
packages=find_packages(),
url='https://gitlab.physmed.chudequebec.ca//gacou54/howtotestbasic',
url='https://gitlab.physmed.chudequebec.ca//gacou54/howtotest',
license='MIT',
author='Gabriel Couture',
author_email='gabriel.couture.4@ulaval.ca',
......
......@@ -19,7 +19,7 @@ def is_dvh_has_a_prescription_dose(dvh: DVH) -> bool:
Returns:
True if dvh has a prescription dose, else False.
"""
return False if dvh.get_prescription_dose() is None else True
return False if dvh.get_prescription_dose() == -1 else True
def convert_absolute_doses_to_relative(absolute_doses: List[float], prescription_dose: float) -> List[float]:
......
......@@ -15,8 +15,8 @@ class DVH:
volumes: List[float],
dose_unit: str,
volume_unit: str,
structure_name: str = None,
prescription_dose: float = None):
structure_name: str = '',
prescription_dose: float = -1):
"""Constructor of a DVH object.
Args:
......
......@@ -3,7 +3,8 @@ import subprocess
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
LINT_COMMAND = ['./venv/bin/flake8', '--ignore=E501', 'dvh', 'tests']
FLAKE8_COMMAND = ['./venv/bin/flake8', '--ignore=E501', 'dvh', 'tests']
MYPY_COMMAND = ['./venv/bin/mypy', 'dvh']
UNIT_TESTS_COMMAND = ['./venv/bin/python', '-m', 'unittest', 'discover', '-s', './tests/unit/']
INTEGRATION_TESTS_COMMAND = ['./venv/bin/python', '-m', 'unittest', 'discover', '-s', './tests/integration']
......@@ -38,7 +39,8 @@ class LintTests(TestCommand):
user_options = []
def run_tests(self):
_run_command(LINT_COMMAND)
_run_command(FLAKE8_COMMAND)
_run_command(MYPY_COMMAND)
class AllTests(TestCommand):
......@@ -48,14 +50,15 @@ class AllTests(TestCommand):
def run_tests(self):
_run_command(UNIT_TESTS_COMMAND)
_run_command(INTEGRATION_TESTS_COMMAND)
_run_command(LINT_COMMAND)
_run_command(FLAKE8_COMMAND)
_run_command(MYPY_COMMAND)
setup(
name='howtotest',
version='0.1.0',
packages=find_packages(),
url='https://gitlab.physmed.chudequebec.ca//gacou54/howtotestbasic',
url='https://gitlab.physmed.chudequebec.ca//gacou54/howtotest',
license='MIT',
author='Gabriel Couture',
author_email='gabriel.couture.4@ulaval.ca',
......
......@@ -95,7 +95,7 @@ class TestConversion(unittest.TestCase):
dvh.doses = AN_ABSOLUTE_DOSE_LIST
dvh.dose_unit = ABSOLUTE_DOSE_UNIT
dvh.get_prescription_dose.return_value = None
dvh.get_prescription_dose.return_value = -1
dvh.get_dose_unit.return_value = ABSOLUTE_DOSE_UNIT
dvh.get_doses.return_value = AN_ABSOLUTE_DOSE_LIST
......@@ -107,7 +107,7 @@ class TestConversion(unittest.TestCase):
dvh.doses = A_RELATIVE_DOSE_LIST
dvh.dose_unit = RELATIVE_DOSE_UNIT
dvh.get_prescription_dose.return_value = None
dvh.get_prescription_dose.return_value = -1
dvh.get_dose_unit.return_value = RELATIVE_DOSE_UNIT
dvh.get_doses.return_value = A_RELATIVE_DOSE_LIST
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment