diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 8ca6378a151..211ad869473 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -21,3 +21,5 @@ jobs: run: pip install tox - name: run tests run: tox -e lint + - name: run mypy checks + run: tox -e mypy diff --git a/lib/galaxy_test/api/_framework.py b/lib/galaxy_test/api/_framework.py index aeda014fdf1..f76fee71ead 100644 --- a/lib/galaxy_test/api/_framework.py +++ b/lib/galaxy_test/api/_framework.py @@ -7,7 +7,7 @@ try: except ImportError: # Galaxy libraries and galaxy test driver not available, just assume we're # targetting a remote Galaxy. - GalaxyTestDriver = None + GalaxyTestDriver = None # type: ignore class ApiTestCase(FunctionalTestCase, UsesApiTestCaseMixin, TestCase): diff --git a/setup.cfg b/setup.cfg index a21920be2b8..29200c5b5bb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,3 +16,6 @@ exclude = lib/galaxy/util/jstree.py # https://github.com/PyCQA/flake8-import-order/blob/master/tests/test_cases/complete_smarkets.py import-order-style = smarkets application-import-names = galaxy,galaxy_test,tool_shed + +[mypy] +ignore_missing_imports = True diff --git a/test/integration/objectstore/test_objectstore_datatype_upload.py b/test/integration/objectstore/test_objectstore_datatype_upload.py index 095fd779722..52178898be8 100644 --- a/test/integration/objectstore/test_objectstore_datatype_upload.py +++ b/test/integration/objectstore/test_objectstore_datatype_upload.py @@ -3,6 +3,7 @@ import os import string import subprocess import time +from typing import Optional import pytest @@ -106,7 +107,7 @@ def stop_irods(container_name): class BaseObjectstoreUploadTest(UploadTestDatatypeDataTestCase): - object_store_template = None + object_store_template: Optional[string.Template] = None @classmethod def handle_galaxy_config_kwds(cls, config): diff --git a/test/integration/resubmission_runners.py b/test/integration/resubmission_runners.py index 7787cbef4ae..ece06942a44 100644 --- a/test/integration/resubmission_runners.py +++ b/test/integration/resubmission_runners.py @@ -1,4 +1,5 @@ import time +from typing import List from galaxy import model from galaxy.jobs.runners import ( @@ -66,7 +67,7 @@ class AssertionJobRunner(LocalJobRunner): class FailOnlyFirstJobRunner(LocalJobRunner): """Job runner that knows about test cases and checks final state assumptions.""" - tests_seen = [] + tests_seen: List[str] = [] def queue_job(self, job_wrapper): resource_parameters = job_wrapper.get_resource_parameters() diff --git a/test/integration/test_repository_operations.py b/test/integration/test_repository_operations.py index 73c5476c18b..de17c8a9b56 100644 --- a/test/integration/test_repository_operations.py +++ b/test/integration/test_repository_operations.py @@ -6,7 +6,8 @@ from galaxy_test.driver import integration_util from tool_shed.util import hg_util from .uses_shed import UsesShed -REPO = namedtuple('Repository', 'name owner changeset')( +REPO_TYPE = namedtuple('Repository', 'name owner changeset') +REPO = REPO_TYPE( 'collection_column_join', 'iuc', 'dfde09461b1e', # revision 2, a known installable revision diff --git a/test/unit/tools/test_toolbox.py b/test/unit/tools/test_toolbox.py index 5a664b53e6b..f3185da9d81 100644 --- a/test/unit/tools/test_toolbox.py +++ b/test/unit/tools/test_toolbox.py @@ -35,10 +35,11 @@ CONFIG_TEST_TOOL_VERSION_TEMPLATE = string.Template( CONFIG_TEST_TOOL_VERSION_1 = CONFIG_TEST_TOOL_VERSION_TEMPLATE.safe_substitute(dict(version="1")) CONFIG_TEST_TOOL_VERSION_2 = CONFIG_TEST_TOOL_VERSION_TEMPLATE.safe_substitute(dict(version="2")) -DEFAULT_TEST_REPO = collections.namedtuple( +REPO_TYPE = collections.namedtuple( 'DEFAULT_TEST_REPO', 'tool_shed owner name changeset_revision installed_changeset_revision description status', -)('github.com', 'galaxyproject', 'example', '1', '1', 'description', 'OK') +) +DEFAULT_TEST_REPO = REPO_TYPE('github.com', 'galaxyproject', 'example', '1', '1', 'description', 'OK') class BaseToolBoxTestCase(unittest.TestCase, UsesApp, UsesTools): diff --git a/tox.ini b/tox.ini index de8922ed99b..29a1a772291 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,8 @@ commands = lint_docstring_include_list: bash .ci/flake8_wrapper_docstrings.sh --include unit: bash run_tests.sh -u + # start with test here but obviously someday all of it... + mypy: mypy test whitelist_externals = bash passenv = CI CONDA_EXE @@ -28,6 +30,7 @@ setenv = deps = lint,lint_docstring,lint_docstring_include_list: -rlib/galaxy/dependencies/pipfiles/flake8/pinned-requirements.txt unit: mock-ssh-server + mypy: mypy [testenv:mulled] commands = bash run_tests.sh --skip-venv -u test/unit/tool_util/mulled