From 5c812a029a36aa92e7a8716a5dd1dbb2ffb331dc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 23:42:52 +0000 Subject: [PATCH 1/5] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.6.0...v5.0.0) - [github.com/astral-sh/ruff-pre-commit: v0.6.3 → v0.6.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.3...v0.6.9) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1fdef3c43..2e66f74db 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: @@ -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.6.9 hooks: # Run the linter. - id: ruff From 5aede2586f4ceeec27aac924a661b0c2efc83bdc Mon Sep 17 00:00:00 2001 From: Tim Mensinger Date: Wed, 23 Oct 2024 12:50:11 +0200 Subject: [PATCH 2/5] Autoupdate pre-commit hooks --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e66f74db..9cf7fe710 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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.9 + rev: v0.7.0 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 From ed136a3b3d9f1dec072546d6c6dbac87d0912758 Mon Sep 17 00:00:00 2001 From: Tim Mensinger Date: Wed, 23 Oct 2024 16:12:24 +0200 Subject: [PATCH 3/5] Add quick fixes to errors from new mypy version --- .tools/envs/testenv-linux.yml | 2 +- .tools/envs/testenv-others.yml | 2 +- .tools/envs/testenv-pandas.yml | 2 +- environment.yml | 2 +- src/optimagic/algorithms.py | 6 ++++-- src/optimagic/optimization/algorithm.py | 2 +- src/optimagic/optimization/create_optimization_problem.py | 4 ++-- 7 files changed, 11 insertions(+), 9 deletions(-) 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..c66775df4 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 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 From b8f2c63b636124320f567ab6ff72c5cf3f58e2cc Mon Sep 17 00:00:00 2001 From: Tim Mensinger Date: Mon, 28 Oct 2024 09:26:13 +0100 Subject: [PATCH 4/5] Run pre-commit autoupdate and use docformatter fix commit --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9cf7fe710..b00b2f9a7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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.7.0 + rev: v0.7.1 hooks: # Run the linter. - id: ruff From 999f042db6b3c47b819a25f12f5ec07593e564b5 Mon Sep 17 00:00:00 2001 From: Tim Mensinger Date: Mon, 28 Oct 2024 09:41:02 +0100 Subject: [PATCH 5/5] Restrict pre-commit>=4 --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index c66775df4..34dd22f05 100644 --- a/environment.yml +++ b/environment.yml @@ -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