diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index f9e9bb338..1e7a2df32 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -63,6 +63,12 @@ jobs: pip install -e . flake8 libensemble + - name: Install mypy + run: pip install mypy + + - name: Run mypy (limited scope) + run: mypy + - name: Remove various tests on newer pythons if: matrix.python-version == 'py311' || matrix.python-version == 'py312' || matrix.python-version == 'py313' || matrix.python-version == 'py314' run: | diff --git a/libensemble/utils/misc.py b/libensemble/utils/misc.py index cfb4f4df2..aa1c3105d 100644 --- a/libensemble/utils/misc.py +++ b/libensemble/utils/misc.py @@ -14,8 +14,8 @@ def extract_H_ranges(Work: dict) -> str: else: # From https://stackoverflow.com/a/30336492 ranges = [] - for diff, group in groupby(enumerate(work_H_rows.tolist()), lambda x: x[0] - x[1]): - group = list(map(itemgetter(1), group)) + for diff, group_iter in groupby(enumerate(work_H_rows.tolist()), lambda x: x[0] - x[1]): + group = list(map(itemgetter(1), group_iter)) if len(group) > 1: ranges.append(str(group[0]) + "-" + str(group[-1])) else: diff --git a/libensemble/utils/output_directory.py b/libensemble/utils/output_directory.py index b43ee3491..b5e202bad 100644 --- a/libensemble/utils/output_directory.py +++ b/libensemble/utils/output_directory.py @@ -110,6 +110,7 @@ def _make_calc_dir(self, workerID, H_rows, calc_str: str, locs: LocationStack): # If using input_dir, set of files to copy is contents of provided dir if input_dir: + assert isinstance(input_dir, Path) copy_files = set(copy_files + [i for i in input_dir.iterdir()]) # If identical paths to copy and symlink, remove those paths from symlink_files @@ -124,7 +125,7 @@ def _make_calc_dir(self, workerID, H_rows, calc_str: str, locs: LocationStack): prefix = self.ensemble_dir else: # Each worker does work in prefix (ensemble_dir) key = self.ensemble_dir - dirname = self.ensemble_dir + dirname = str(self.ensemble_dir) prefix = None locs.register_loc( diff --git a/pyproject.toml b/pyproject.toml index 271c171b4..647b0b215 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -244,4 +244,15 @@ inpt = "inpt" extend-exclude = ["*.bib", "*.xml", "docs/nitpicky"] [tool.mypy] +# Initial, permissive mypy configuration for libensemble. +# Allows incremental adoption. To be tightened in future releases. +packages = ["libensemble.utils"] +exclude = ''' +libensemble/utils/(launcher|loc_stack|runners|pydantic|output_directory)\.py +''' disable_error_code = ["import-not-found", "import-untyped"] +ignore_missing_imports = true +follow_imports = "skip" +check_untyped_defs = false +disallow_untyped_defs = false +warn_unused_ignores = false