Skip to content

Commit d2d2027

Browse files
committed
chore: optimize chaining required and optional params
1 parent 03d573d commit d2d2027

File tree

1 file changed

+4
-3
lines changed
  • packages/toolbox-core/src/toolbox_core

1 file changed

+4
-3
lines changed

packages/toolbox-core/src/toolbox_core/tool.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import copy
16+
import itertools
1617
from inspect import Signature
1718
from types import MappingProxyType
1819
from typing import Any, Awaitable, Callable, Mapping, Optional, Sequence, Union
@@ -92,9 +93,9 @@ def __init__(
9293
# Separate parameters into required (no default) and optional (with
9394
# default) to prevent the "non-default argument follows default
9495
# argument" error when creating the function signature.
95-
required_params = [p for p in self.__params if p.required]
96-
optional_params = [p for p in self.__params if not p.required]
97-
ordered_params = required_params + optional_params
96+
required_params = (p for p in self.__params if p.required)
97+
optional_params = (p for p in self.__params if not p.required)
98+
ordered_params = itertools.chain(required_params, optional_params)
9899
inspect_type_params = [param.to_param() for param in ordered_params]
99100

100101
# the following properties are set to help anyone that might inspect it determine usage

0 commit comments

Comments
 (0)