diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a270cf8..edb7dc5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,7 +53,7 @@ repos: ## You can add flake8 plugins via `additional_dependencies`: # additional_dependencies: [flake8-bugbear] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.961 # Use the sha / tag you want to point at + rev: v1.9.0 # Use the sha / tag you want to point at hooks: - id: mypy additional_dependencies: ['types-PyYAML'] diff --git a/src/otoole/convert.py b/src/otoole/convert.py index 3cecd34..4267ac7 100644 --- a/src/otoole/convert.py +++ b/src/otoole/convert.py @@ -7,6 +7,7 @@ >>> convert('config.yaml', 'excel', 'datafile', 'input.xlsx', 'output.dat') """ + import logging import os from typing import Dict, Optional, Tuple, Union @@ -29,7 +30,7 @@ def read_results( from_path: str, input_format: str, input_path: str, - glpk_model: str = None, + glpk_model: Optional[str] = None, ) -> Tuple[Dict[str, pd.DataFrame], Dict[str, float]]: """Read OSeMOSYS results from CBC, GLPK, Gurobi, or CPLEX results files @@ -79,7 +80,7 @@ def convert_results( input_format: str, input_path: str, write_defaults: bool = False, - glpk_model: str = None, + glpk_model: Optional[str] = None, ) -> bool: """Post-process results from a CBC, CPLEX, Gurobi, or GLPK solution file into CSV format diff --git a/src/otoole/read_strategies.py b/src/otoole/read_strategies.py index 7f5805c..da362ce 100644 --- a/src/otoole/read_strategies.py +++ b/src/otoole/read_strategies.py @@ -33,7 +33,7 @@ def __init__( self._parameters = parameters def read( - self, filepath: Union[str, TextIO] = None, **kwargs + self, filepath: Union[str, TextIO, None] = None, **kwargs ) -> Tuple[Dict[str, pd.DataFrame], Dict[str, Any]]: config = self.user_config diff --git a/src/otoole/utils.py b/src/otoole/utils.py index d5308ca..fe989b7 100644 --- a/src/otoole/utils.py +++ b/src/otoole/utils.py @@ -2,7 +2,7 @@ import logging import os from importlib.resources import files -from typing import Any, Dict, List, Union +from typing import Any, Dict, List, Optional, Union import pandas as pd from pydantic import ValidationError @@ -29,7 +29,7 @@ def _read_file(open_file, ending): return contents -def read_packaged_file(filename: str, module_name: str = None): +def read_packaged_file(filename: str, module_name: Optional[str] = None): _, ending = os.path.splitext(filename) diff --git a/src/otoole/validate.py b/src/otoole/validate.py index f889bf7..3c39257 100644 --- a/src/otoole/validate.py +++ b/src/otoole/validate.py @@ -33,7 +33,7 @@ import logging import re from collections import defaultdict -from typing import Dict, List, Sequence +from typing import Dict, List, Optional, Sequence import networkx.algorithms.isolate as isolate import pandas as pd @@ -53,7 +53,7 @@ def check_for_duplicates(codes: Sequence) -> bool: return duplicate_values -def create_schema(config: Dict[str, Dict] = None) -> Dict: +def create_schema(config: Optional[Dict[str, Dict]] = None) -> Dict: """Populate the dict of schema with codes from the validation config Arguments