Skip to content

Conversation

@panzi
Copy link
Contributor

@panzi panzi commented Nov 19, 2025

I've also added __slots__ less so to improve efficiency and more to be sure there are no typos on assignments.

There remain a few untyped parts where I could not find documentation of the types. These things are in particular:

  • Agent.Dsl
  • Agent.create_session()
  • DataSet.ParserConfig - I'm not sure if the documented parameters are complete.
  • Session.ask() - kwargs specific to agent/chat

What problem does this PR solve?

Type annotations are really handy for library consumers. They give you handy hints in your IDE and prevent typo bugs. The Python SDK is lacking type annotations, which is annoying at times.

Type of change

  • Other (please describe):

Added type annotations.

I've also added __slots__ less so to improve efficiency and more to be sure
there are no typos on assignments.

There remain a few untyped parts where I could not find documentation of the
types. These things are in particular:

- Agent.Dsl
- Agent.create_session()
- DataSet.ParserConfig - I'm not sure if the documented parameters are complete.
- Session.ask() - kwargs specific to agent/chat
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. 🌈 python Pull requests that update Python code labels Nov 19, 2025
actual_keys = set(response.keys())
if actual_keys == error_keys:
raise Exception(res.get("message"))
raise Exception(response.get("message"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed a bug here and fixed it while I was at it. Mentioned the bug here:
f007c1c#r170921731

answer = json_data["answer"]
reference = json_data.get("reference", {})
else:
raise Exception(f"Unknown session type: {self.__session_type}")
Copy link
Contributor Author

@panzi panzi Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed a missing else branch and fixed it while I was at it. I mentioned that here:
95fad5d#r170922254

reference = json_data.get("reference", {})
else:
raise Exception(f"Unknown session type: {self.__session_type}")
reference = json_data.get("reference")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I removed the default parameter to the get() method here. Creating an empty dict in any case here is useless overhead, especially since below there is an if reference ... anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌈 python Pull requests that update Python code size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant