Skip to content
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

Fixes gather_with_concurrency typing #714

Merged
merged 16 commits into from
Nov 26, 2024
Merged

Fixes gather_with_concurrency typing #714

merged 16 commits into from
Nov 26, 2024

Conversation

maykcaldas
Copy link
Collaborator

@maykcaldas maykcaldas commented Nov 20, 2024

Changes the type hint of gather_with_concurrency from

gather_with_concurrency(n: int, coros: list[Coroutine]) -> list[Any]:

to

T = TypeVar("T")
async def gather_with_concurrency(n: int, coros: Iterable[Awaitable[T]]) -> list[T]:

Also pinned pydantic version to <2.10 until they release the v2.10 bugfix.

@@ -650,7 +650,7 @@ async def aget_evidence(
for _, llm_result in results:
session.add_tokens(llm_result)

session.contexts += [r for r, _ in results if r is not None]
session.contexts += [r for r, _ in results]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is being discussed in #687. However, the typing change didn't fix the mypy error saying that r is not None is a always True statement

Copy link
Collaborator

Choose a reason for hiding this comment

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

Cannot do this I think. You can get a None back I believe

paperqa/agents/models.py Outdated Show resolved Hide resolved
@maykcaldas maykcaldas changed the title [WIP] Fixes gather_with_concurrency typing Fixes gather_with_concurrency typing Nov 21, 2024
@maykcaldas maykcaldas marked this pull request as ready for review November 21, 2024 21:45
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Nov 21, 2024
Copy link
Collaborator

@jamesbraza jamesbraza left a comment

Choose a reason for hiding this comment

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

@maykcaldas looks like pydantic==2.10.1 is out, can you rebase or merge main for the updated uv.lock

.pre-commit-config.yaml Outdated Show resolved Hide resolved
paperqa/types.py Show resolved Hide resolved
Copy link
Collaborator

@jamesbraza jamesbraza left a comment

Choose a reason for hiding this comment

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

LGTM from my side. Looks like Andrew has an outstanding comment

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 26, 2024
@maykcaldas maykcaldas merged commit 87f4e1e into main Nov 26, 2024
5 checks passed
@maykcaldas maykcaldas deleted the fix_gwc_typing branch November 26, 2024 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants