Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to mypy 1.9.0 #223

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading