chore: use primitives instead of typing imports and fixes completion …#149
Conversation
…signature This migrates from typing imports to primitives per the following feedback from @lamchau: > :nit: i think our patterns here don't realize as of python 3.9+ we generally don't need `Dict`, `List`, and `Tuple` anymore we can use the primitives (`dict`, `list`, and `tuple` respectively) This also fixes inconsistency in our provider completion signature with regards to: * tools: more precisely allow any amount of tools as often there are none ```diff - tools: Tuple[Tool] = field(factory=tuple, converter=tuple) + tools: tuple[Tool, ...] = field(factory=tuple, converter=tuple) ``` * kwargs: providers were inconsistent on accepting this, which could lead to small bugs ```diff - messages: List[Message], - tools: Tuple[Tool], - ) -> Tuple[Message, Usage]: + messages: list[Message], + tools: tuple[Tool, ...], + **kwargs: dict[str, any], + ) -> tuple[Message, Usage]: ``` Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
| @pytest.mark.parametrize( | ||
| "env_var_name", | ||
| [ | ||
| ("AZURE_CHAT_COMPLETIONS_HOST_NAME"), |
There was a problem hiding this comment.
static analysis found this an unnecessary coersion
| @@ -1,5 +1,5 @@ | |||
| import re | |||
| from typing import Callable, List, Tuple | |||
| from typing import Callable | |||
There was a problem hiding this comment.
in cases like this, I couldn't use the primitive as it wasn't subscriptable
There was a problem hiding this comment.
fwiw this Callable was deprecated which kind of solves the subscriptable problem. we'd probably always need to keep one of those since i don't recall it's hinting can be expressed otherwise
https://docs.python.org/3/library/typing.html#typing.Callable
Deprecated since version 3.9: collections.abc.Callable now supports subscripting ([]). See PEP 585 and Generic Alias Type.
edit: i stand corrected there is a callable primitive for hinting but not sure what's going on here
There was a problem hiding this comment.
me neither.. if you figure it out, ping me!
|
lgtm! |
* origin/main: docs: add subheaders to the 'Other ways to run Goose' section (#155) fix: Remove tools from exchange when summarizing files (#157) chore: use primitives instead of typing imports and fixes completion … (#149) chore: make vcr tests pretty-print JSON (#146) chore(release): goose 0.9.5 (#159) chore(release): exchange 0.9.5 (#158)
* main: (23 commits) feat: Run with resume session (#153) refactor: move langfuse wrapper to a module in exchange instead of a package (#138) docs: add subheaders to the 'Other ways to run Goose' section (#155) fix: Remove tools from exchange when summarizing files (#157) chore: use primitives instead of typing imports and fixes completion … (#149) chore: make vcr tests pretty-print JSON (#146) chore(release): goose 0.9.5 (#159) chore(release): exchange 0.9.5 (#158) chore: updates ollama default model from mistral-nemo to qwen2.5 (#150) feat: add vision support for Google (#141) fix: session resume with arg handled incorrectly (#145) docs: add release instructions to CONTRIBUTING.md (#143) docs: add link to action, IDE words (#140) docs: goosehints doc fix only (#142) chore(release): release 0.9.4 (#136) revert: "feat: add local langfuse tracing option (#106)" (#137) feat: add local langfuse tracing option (#106) feat: add groq provider (#134) feat: add a deep thinking reasoner model (o1-preview/mini) (#68) fix: use concrete SessionNotifier (#135) ...
#149) Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
block#149) Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
…signature
This migrates from typing imports to primitives per the following feedback from @lamchau:
This also fixes inconsistency in our provider completion signature with regards to: