Skip to content

Commit

Permalink
Merge pull request #223 from OSeMOSYS/issue-222
Browse files Browse the repository at this point in the history
Upgrade to mypy 1.9.0
  • Loading branch information
trevorb1 authored Mar 31, 2024
2 parents 15bdc0b + cfc0ccc commit 8e103ed
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
5 changes: 3 additions & 2 deletions src/otoole/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
>>> convert('config.yaml', 'excel', 'datafile', 'input.xlsx', 'output.dat')
"""

import logging
import os
from typing import Dict, Optional, Tuple, Union
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/otoole/read_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/otoole/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions src/otoole/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8e103ed

Please sign in to comment.