diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1fdef3c43..b00b2f9a7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: always_run: true require_serial: true - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files args: @@ -56,7 +56,7 @@ repos: - id: yamllint exclude: tests/optimagic/optimizers/_pounders/fixtures - repo: https://github.com/PyCQA/docformatter - rev: v1.7.5 + rev: eb1df34 hooks: - id: docformatter args: @@ -68,7 +68,7 @@ repos: - --blank exclude: src/optimagic/optimization/algo_options.py - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.3 + rev: v0.7.1 hooks: # Run the linter. - id: ruff @@ -85,7 +85,7 @@ repos: - pyi - jupyter - repo: https://github.com/executablebooks/mdformat - rev: 0.7.17 + rev: 0.7.18 hooks: - id: mdformat additional_dependencies: @@ -97,7 +97,7 @@ repos: - '88' files: (README\.md) - repo: https://github.com/executablebooks/mdformat - rev: 0.7.17 + rev: 0.7.18 hooks: - id: mdformat additional_dependencies: @@ -119,7 +119,7 @@ repos: args: - --drop-empty-cells - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.2 + rev: v1.13.0 hooks: - id: mypy files: src|tests diff --git a/.tools/envs/testenv-linux.yml b/.tools/envs/testenv-linux.yml index fa5ece402..a0284a6f6 100644 --- a/.tools/envs/testenv-linux.yml +++ b/.tools/envs/testenv-linux.yml @@ -23,7 +23,7 @@ dependencies: - scipy>=1.2.1 # run, tests - sqlalchemy # run, tests - seaborn # dev, tests - - mypy>=1.11 # dev, tests + - mypy>=1.13 # dev, tests - pyyaml # dev, tests - jinja2 # dev, tests - annotated-types # dev, tests diff --git a/.tools/envs/testenv-others.yml b/.tools/envs/testenv-others.yml index 4467a19b0..dde468ff9 100644 --- a/.tools/envs/testenv-others.yml +++ b/.tools/envs/testenv-others.yml @@ -21,7 +21,7 @@ dependencies: - scipy>=1.2.1 # run, tests - sqlalchemy # run, tests - seaborn # dev, tests - - mypy>=1.11 # dev, tests + - mypy>=1.13 # dev, tests - pyyaml # dev, tests - jinja2 # dev, tests - annotated-types # dev, tests diff --git a/.tools/envs/testenv-pandas.yml b/.tools/envs/testenv-pandas.yml index 757d5f39a..112d42512 100644 --- a/.tools/envs/testenv-pandas.yml +++ b/.tools/envs/testenv-pandas.yml @@ -21,7 +21,7 @@ dependencies: - scipy>=1.2.1 # run, tests - sqlalchemy # run, tests - seaborn # dev, tests - - mypy>=1.11 # dev, tests + - mypy>=1.13 # dev, tests - pyyaml # dev, tests - jinja2 # dev, tests - annotated-types # dev, tests diff --git a/environment.yml b/environment.yml index d321d992e..34dd22f05 100644 --- a/environment.yml +++ b/environment.yml @@ -32,7 +32,7 @@ dependencies: - sphinx-panels # docs - sphinxcontrib-bibtex # docs - seaborn # dev, tests - - mypy>=1.11 # dev, tests + - mypy>=1.13 # dev, tests - pyyaml # dev, tests - jinja2 # dev, tests - furo # dev, docs @@ -42,7 +42,7 @@ dependencies: - Py-BOBYQA # dev, tests - fides==0.7.4 # dev, tests - kaleido # dev, tests - - pre-commit # dev + - pre-commit>=4 # dev - -e . # dev # type stubs - pandas-stubs # dev, tests diff --git a/src/optimagic/algorithms.py b/src/optimagic/algorithms.py index 242a5538b..9e42ea828 100644 --- a/src/optimagic/algorithms.py +++ b/src/optimagic/algorithms.py @@ -40,10 +40,12 @@ name = candidate.__algo_info__.name if issubclass(candidate, Algorithm) and candidate is not Algorithm: ALL_ALGORITHMS[name] = candidate - if candidate.__algo_info__.is_available: + if candidate.__algo_info__.is_available: # type: ignore[attr-defined] AVAILABLE_ALGORITHMS[name] = candidate GLOBAL_ALGORITHMS = [ - name for name, algo in ALL_ALGORITHMS.items() if algo.__algo_info__.is_global + name + for name, algo in ALL_ALGORITHMS.items() + if algo.__algo_info__.is_global # type: ignore[attr-defined] ] diff --git a/src/optimagic/optimization/algorithm.py b/src/optimagic/optimization/algorithm.py index add879d28..3bef1d09f 100644 --- a/src/optimagic/optimization/algorithm.py +++ b/src/optimagic/optimization/algorithm.py @@ -154,7 +154,7 @@ def _solve_internal_problem( def __post_init__(self) -> None: for field in self.__dataclass_fields__: raw_value = getattr(self, field) - target_type = self.__dataclass_fields__[field].type + target_type = typing.cast(type, self.__dataclass_fields__[field].type) if target_type in TYPE_CONVERTERS: try: value = TYPE_CONVERTERS[target_type](raw_value) diff --git a/src/optimagic/optimization/create_optimization_problem.py b/src/optimagic/optimization/create_optimization_problem.py index d11a9bcb3..1403427d0 100644 --- a/src/optimagic/optimization/create_optimization_problem.py +++ b/src/optimagic/optimization/create_optimization_problem.py @@ -1,7 +1,7 @@ import warnings from dataclasses import dataclass from pathlib import Path -from typing import Any, Callable, Type, cast +from typing import Any, Callable, Type from optimagic import deprecations from optimagic.algorithms import ALL_ALGORITHMS @@ -591,4 +591,4 @@ def pre_process_user_algorithm( elif isinstance(algorithm, type) and issubclass(algorithm, Algorithm): algorithm = algorithm() - return cast(Algorithm, algorithm) + return algorithm