-
Notifications
You must be signed in to change notification settings - Fork 3k
refactor: flatten the methods in Client
#1914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| self, | ||
| params: types.PaginatedRequestParams | None = None, | ||
| ) -> types.ListResourcesResult: | ||
| async def list_resources(self, *, cursor: str | None = None) -> types.ListResourcesResult: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR started from this. I understand that in the typescript world this is the best practice, but it's not in Python.
| # TODO(Marcelo): When do `raise_exceptions=True` actually raises? | ||
| raise_exceptions: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't test this. What it is supposed to raise?
| timeout = request_read_timeout_seconds | ||
| elif self._session_read_timeout_seconds is not None: # pragma: no cover | ||
| timeout = self._session_read_timeout_seconds | ||
| timeout = request_read_timeout_seconds or self._session_read_timeout_seconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've simplified this.
| addopts = """ | ||
| --color=yes | ||
| --capture=fd | ||
| --numprocesses auto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually forgot to remove this when I added the scripts/test script.
You need to be able to run pytest without -n auto, because you may want to run a single test, and you don't need multiple cores for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maxisbey @felixweinberger please check the changes in this file.
ClientClient
| self, | ||
| params: types.PaginatedRequestParams | None = None, | ||
| ) -> types.ListResourcesResult: | ||
| async def list_resources(self, *, cursor: str | None = None) -> types.ListResourcesResult: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will need to update migration docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Client is a new class, it doesn't need any migration docs.
| caps = client.server_capabilities | ||
| assert caps is not None | ||
| assert caps.tools is not None | ||
| assert client.server_capabilities == snapshot( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never seen this before, that's cool
| """Send a notification that the roots list has changed.""" | ||
| await self.session.send_roots_list_changed() | ||
| # TODO(Marcelo): Currently, there is no way for the server to handle this. We should add support. | ||
| await self.session.send_roots_list_changed() # pragma: no cover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is there a new pragma?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the test was not testing anything, and the server actually doesn't do anything with this notification. We need to solve the TODO, which will result in dropping the pragma.
| async def __aexit__(self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: Any) -> None: | ||
| """Exit the async context manager.""" | ||
| if self._exit_stack: | ||
| if self._exit_stack: # pragma: no branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why a new pragma?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I don't think it's necessary to test this. If you can suggest a cute test, please push it.
No description provided.