Skip to content

Commit

Permalink
🔧⌨️ Made mypy optout instead of opt in and fixed some typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
s-weigand committed Nov 7, 2022
1 parent ece973f commit aeb4de0
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 40 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ repos:
rev: v0.982
hooks:
- id: mypy
files: "^glotaran/(plugin_system|utils|deprecation|testing|optimization|parameter|project|simulation|model|builtin/io/pandas)"
exclude: "docs"
additional_dependencies: [types-all, types-attrs]

Expand Down
7 changes: 6 additions & 1 deletion benchmark/benchmarks/unit/analysis/bench_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
from glotaran.simulation import simulate

try:
from glotaran.optimization.test.models import MultichannelMulticomponentDecay
# isort: off
from glotaran.optimization.test.models import ( # type: ignore[attr-defined]
MultichannelMulticomponentDecay,
)

# isort: on
except ImportError:
# 0.7.0
from glotaran.optimization.test.suites import MultichannelMulticomponentDecay
Expand Down
1 change: 1 addition & 0 deletions glotaran/builtin/io/yml/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def write_dict(
stream = StringIO()
yaml.dump(data, stream)
return stream.getvalue()
return None


def load_dict(source: str | Path, is_file: bool) -> dict[str, Any]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Any

import numpy as np
import pytest
import xarray as xr
Expand All @@ -18,7 +20,7 @@
("none", "dispersed", "shifted"),
)
def test_coherent_artifact(spectral_dependence: str):
model_dict = {
model_dict: dict[str, dict[str, Any]] = {
"initial_concentration": {
"j1": {"compartments": ["s1"], "parameters": ["irf_center"]},
},
Expand Down Expand Up @@ -80,7 +82,7 @@ def test_coherent_artifact(spectral_dependence: str):
**model_dict
)

parameters = Parameters.from_list(parameter_list)
parameters = Parameters.from_list(parameter_list) # type: ignore[arg-type]

time = np.arange(0, 50, 1.5)
spectral = np.asarray([200, 300, 400])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class ThreeComponentParallel:
["1", 501e-3],
["2", 202e-4],
["3", 105e-5],
{"non-negative": True},
{"non-negative": True}, # type: ignore[list-item]
],
"irf": [["center", 1.3], ["width", 7.8]],
}
Expand Down Expand Up @@ -223,7 +223,7 @@ class ThreeComponentSequential:
["1", 501e-3],
["2", 202e-4],
["3", 105e-5],
{"non-negative": True},
{"non-negative": True}, # type: ignore[list-item]
],
"irf": [["center", 1.3], ["width", 7.8]],
}
Expand Down
3 changes: 2 additions & 1 deletion glotaran/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from collections.abc import Callable
from collections.abc import Generator
from collections.abc import Iterable
from collections.abc import Mapping
from typing import Any
from typing import ClassVar
Expand Down Expand Up @@ -256,7 +257,7 @@ def create_class(cls, attributes: dict[str, Attribute]) -> type[Model]:

@classmethod
def create_class_from_megacomplexes(
cls, megacomplexes: list[type[Megacomplex]]
cls, megacomplexes: Iterable[type[Megacomplex]]
) -> type[Model]:
"""Create model class for megacomplexes.
Expand Down
4 changes: 2 additions & 2 deletions glotaran/testing/simulated_data/sequential_spectral_decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

SIMULATION_MODEL_YML = generate_model_yml(
generator_name="spectral_decay_sequential",
generator_arguments={"nr_compartments": 3, "irf": True}, # type:ignore[arg-type]
generator_arguments={"nr_compartments": 3, "irf": True},
)
SIMULATION_MODEL = load_model(SIMULATION_MODEL_YML, format_name="yml_str")

MODEL_YML = generate_model_yml(
generator_name="decay_sequential",
generator_arguments={"nr_compartments": 3, "irf": True}, # type:ignore[arg-type]
generator_arguments={"nr_compartments": 3, "irf": True},
)
MODEL = load_model(MODEL_YML, format_name="yml_str")

Expand Down
38 changes: 7 additions & 31 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -96,38 +96,14 @@ show_error_codes = True
warn_unused_configs = True
warn_unused_ignores = True

[mypy-glotaran.*]
[mypy-glotaran.builtin.megacomplexes.*]
ignore_errors = True

[mypy-glotaran.plugin_system.*]
ignore_errors = False

[mypy-glotaran.utils.*]
ignore_errors = False

[mypy-glotaran.deprecation.*]
ignore_errors = False

[mypy-glotaran.optimization.*]
ignore_errors = False

[mypy-glotaran.optimization.test.*]
ignore_errors = False

[mypy-glotaran.project.generators.test.*]
ignore_errors = False

[mypy-glotaran.parameter.*]
ignore_errors = False

[mypy-glotaran.project.*]
ignore_errors = False

[mypy-glotaran.simulation.*]
ignore_errors = False
[mypy-glotaran.builtin.io.ascii.*]
ignore_errors = True

[mypy-glotaran.model.*]
ignore_errors = False
[mypy-glotaran.cli.*]
ignore_errors = True

[mypy-glotaran.builtin.io.pandas.*]
ignore_errors = False
[mypy-benchmark.*]
ignore_errors = True

0 comments on commit aeb4de0

Please sign in to comment.