Skip to content

Commit 36f240c

Browse files
authored
Replace kwargs:dict with kwargs:any (#697)
* Replace `kwargs:dict` with `kwargs:any` * Args: Tuple[str] -> str
1 parent dc03503 commit 36f240c

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

pymoo/core/individual.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
]
1313

1414
import copy
15+
from typing import Any
1516
from typing import Optional
1617
from typing import Tuple
1718
from typing import Union
@@ -48,7 +49,7 @@ class Individual:
4849
def __init__(
4950
self,
5051
config: Optional[dict] = None,
51-
**kwargs: dict,
52+
**kwargs: Any,
5253
) -> None:
5354
"""
5455
Constructor for the ``Invididual`` class.
@@ -58,7 +59,7 @@ def __init__(
5859
config : dict, None
5960
A dictionary of configuration metadata.
6061
If ``None``, use a class-dependent default configuration.
61-
kwargs : dict
62+
kwargs : Any
6263
Additional keyword arguments containing data which is to be stored
6364
in the ``Individual``.
6465
"""
@@ -553,14 +554,14 @@ def feasible(self) -> np.ndarray:
553554

554555
def set_by_dict(
555556
self,
556-
**kwargs: dict
557+
**kwargs: Any
557558
) -> None:
558559
"""
559560
Set an individual's data or metadata using values in a dictionary.
560561
561562
Parameters
562563
----------
563-
kwargs : dict
564+
kwargs : Any
564565
Keyword arguments defining the data to set.
565566
"""
566567
for k, v in kwargs.items():
@@ -594,15 +595,15 @@ def set(
594595

595596
def get(
596597
self,
597-
*keys: Tuple[str,...],
598+
*keys: str,
598599
) -> Union[tuple,object]:
599600
"""
600601
Get the values for one or more keys for an individual.
601602
602603
Parameters
603604
----------
604-
keys : tuple
605-
A tuple of keys for which to get values.
605+
keys : str
606+
Keys for which to get values.
606607
607608
Returns
608609
-------

pymoo/core/variable.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"get",
1414
]
1515

16-
from typing import Optional, Tuple
16+
from typing import Any, Optional, Tuple
1717
from typing import Union
1818
import numpy as np
1919
from numpy.typing import ArrayLike
@@ -111,14 +111,14 @@ def set(
111111

112112
def get(
113113
self,
114-
**kwargs: dict
114+
**kwargs: Any
115115
) -> object:
116116
"""
117117
Get the value of a decision variable.
118118
119119
Parameters
120120
----------
121-
kwargs : dict
121+
kwargs : Any
122122
Additional keyword arguments.
123123
124124
Returns
@@ -139,7 +139,7 @@ def __init__(
139139
value: Optional[object] = None,
140140
bounds: Tuple[Optional[object],Optional[object]] = (None, None),
141141
strict: Optional[Tuple[Optional[object],Optional[object]]] = None,
142-
**kwargs: dict,
142+
**kwargs: Any,
143143
) -> None:
144144
"""
145145
Constructor for the ``BoundedVariable`` class.
@@ -154,7 +154,7 @@ def __init__(
154154
strict : tuple, None
155155
Strict boundaries for the decision variable.
156156
If ``None``, the value of ``bounds`` is copied to ``strict``.
157-
kwargs : dict
157+
kwargs : Any
158158
Additional keyword arguments for ``active`` and ``flag``.
159159
"""
160160
# call the Variable constructor
@@ -302,7 +302,7 @@ def __init__(
302302
value: Optional[object] = None,
303303
options: Optional[ArrayLike] = None,
304304
all: Optional[ArrayLike] = None,
305-
**kwargs: dict,
305+
**kwargs: Any,
306306
) -> None:
307307
"""
308308
Constructor for the ``Choice`` class.
@@ -316,7 +316,7 @@ def __init__(
316316
all : ArrayLike, None
317317
A strict list of decision variable options from which to choose.
318318
If ``None``, the value of ``options`` is copied to ``all``.
319-
kwargs : dict
319+
kwargs : Any
320320
Additional keyword arguments for ``active`` and ``flag``.
321321
"""
322322
# all super constructor
@@ -357,7 +357,7 @@ def _sample(
357357
def get(
358358
*args: Tuple[Union[Variable,object],...],
359359
size: Optional[Union[tuple,int]] = None,
360-
**kwargs: dict
360+
**kwargs: Any
361361
) -> Union[tuple,object,None]:
362362
"""
363363
Get decision variable values from a tuple of ``Variable`` objects.
@@ -368,7 +368,7 @@ def get(
368368
A tuple of ``Variable`` or ``object``s.
369369
size : tuple, int, None
370370
Size to reshape decision variables.
371-
kwargs : dict
371+
kwargs : Any
372372
Additional keyword arguments to pass to the ``get`` method of the
373373
``Variable`` class when getting decision variable values.
374374

0 commit comments

Comments
 (0)