Skip to content

Commit 4b4caab

Browse files
committed
ENH: Use ClassVar for class variable type hinting
Use `ClassVar` for type hinting the `GaussianProcessRegressor` `_parameter_constraints` class variable in child class. Fixes: ``` src/nifreeze/model/gpr.py:156: error: Cannot override class variable (previously declared on base class "GaussianProcessRegressor") with instance variable [misc] ``` raised for example in: https://github.com/nipreps/nifreeze/actions/runs/12437972140/job/34728973936#step:8:71
1 parent ade884c commit 4b4caab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/nifreeze/model/gpr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from __future__ import annotations
2626

2727
from numbers import Integral, Real
28-
from typing import Callable, Mapping, Sequence
28+
from typing import Callable, ClassVar, Mapping, Sequence
2929

3030
import numpy as np
3131
from scipy import optimize
@@ -153,7 +153,7 @@ class DiffusionGPR(GaussianProcessRegressor):
153153
154154
"""
155155

156-
_parameter_constraints: dict = {
156+
_parameter_constraints: ClassVar[dict] = {
157157
"kernel": [None, Kernel],
158158
"alpha": [Interval(Real, 0, None, closed="left"), np.ndarray],
159159
"optimizer": [StrOptions(SUPPORTED_OPTIMIZERS), callable, None],

0 commit comments

Comments
 (0)