Skip to content

Commit

Permalink
Bump ruff from 0.5.2 to 0.6.5 (#331)
Browse files Browse the repository at this point in the history
* Bump ruff from 0.5.2 to 0.6.5

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.5.2 to 0.6.5.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@0.5.2...0.6.5)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Set ruff target-version to py310

* Use latest version of ruff

* ruff check --fix

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jack Collins <[email protected]>
  • Loading branch information
dependabot[bot] and jackmpcollins authored Sep 24, 2024
1 parent 3b40f1e commit b1805d1
Show file tree
Hide file tree
Showing 22 changed files with 81 additions and 74 deletions.
3 changes: 2 additions & 1 deletion docs/examples/registering_custom_type.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"# Create FunctionSchema for pd.DataFrame\n",
"\n",
"import json\n",
"from typing import Any, Iterable\n",
"from collections.abc import Iterable\n",
"from typing import Any\n",
"\n",
"import pandas as pd\n",
"\n",
Expand Down
51 changes: 20 additions & 31 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pytest-asyncio = "*"
pytest-clarity = "*"
pytest-cov = "*"
python-dotenv = "^1.0.1"
ruff = ">=0.3,<0.6"
ruff = "^0.6.7"

[tool.poetry.group.docs.dependencies]
mkdocs = "^1.5.3"
Expand All @@ -77,6 +77,7 @@ markers = [

[tool.ruff]
include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
target-version = "py310"
# Use `ruff linter` to list available linters
# https://beta.ruff.rs/docs/rules/

Expand Down
3 changes: 2 additions & 1 deletion src/magentic/_pydantic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Callable, TypeVar
from collections.abc import Callable
from typing import Any, TypeVar

import openai
from pydantic import BaseModel
Expand Down
5 changes: 3 additions & 2 deletions src/magentic/chat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import inspect
from typing import Any, Callable, Iterable, ParamSpec, TypeVar
from collections.abc import Callable, Iterable
from typing import Any, ParamSpec, TypeVar

from magentic.backend import get_chat_model
from magentic.chat_model.base import ChatModel
Expand Down Expand Up @@ -121,7 +122,7 @@ def exec_function_call(self: Self) -> Self:
parallel_function_call = self.last_message.content
chat = self
for result, function_call in zip(
parallel_function_call(), parallel_function_call
parallel_function_call(), parallel_function_call, strict=True
):
chat = chat.add_message(
FunctionResultMessage(content=result, function_call=function_call)
Expand Down
11 changes: 9 additions & 2 deletions src/magentic/chat_model/anthropic_chat_model.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import base64
import json
from collections.abc import AsyncIterator, Callable, Iterable, Iterator
from collections.abc import (
AsyncIterable,
AsyncIterator,
Callable,
Iterable,
Iterator,
Sequence,
)
from enum import Enum
from functools import singledispatch
from itertools import chain, groupby
from typing import Any, AsyncIterable, Generic, Sequence, TypeVar, cast, overload
from typing import Any, Generic, TypeVar, cast, overload

import filetype
from pydantic import ValidationError
Expand Down
4 changes: 2 additions & 2 deletions src/magentic/chat_model/litellm_chat_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Callable, Iterable
from collections.abc import Callable, Iterable, Sequence
from itertools import chain
from typing import Any, Sequence, TypeVar, cast, overload
from typing import Any, TypeVar, cast, overload

from openai.types.chat import ChatCompletionToolChoiceOptionParam

Expand Down
12 changes: 3 additions & 9 deletions src/magentic/chat_model/message.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from abc import ABC, abstractmethod
from collections.abc import Awaitable
from typing import (
Annotated,
Any,
Awaitable,
Generic,
Literal,
NamedTuple,
TypeVar,
Union,
cast,
get_origin,
overload,
Expand Down Expand Up @@ -210,13 +209,8 @@ def format(self, **kwargs: Any) -> "FunctionResultMessage[ContentT]":


AnyMessage = Annotated[
Union[
SystemMessage,
UserMessage,
AssistantMessage[Any],
ToolResultMessage[Any],
# Do not include FunctionResultMessage which also uses "tool" role
],
# Do not include FunctionResultMessage which also uses "tool" role
SystemMessage | UserMessage | AssistantMessage[Any] | ToolResultMessage[Any],
Field(discriminator="role"),
]
"""Union of all message types."""
3 changes: 2 additions & 1 deletion src/magentic/chat_model/mistral_chat_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from collections.abc import Callable, Iterable, Sequence
from enum import Enum
from typing import Any, Callable, Iterable, Sequence, TypeVar, overload
from typing import Any, TypeVar, overload

import openai
from openai.types.chat import ChatCompletionStreamOptionsParam
Expand Down
11 changes: 9 additions & 2 deletions src/magentic/chat_model/openai_chat_model.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import base64
from collections.abc import AsyncIterable, AsyncIterator, Callable, Iterable, Iterator
from collections.abc import (
AsyncIterable,
AsyncIterator,
Callable,
Iterable,
Iterator,
Sequence,
)
from enum import Enum
from functools import singledispatch, wraps
from itertools import chain, groupby
from typing import Any, Generic, Literal, ParamSpec, Sequence, TypeVar, cast, overload
from typing import Any, Generic, Literal, ParamSpec, TypeVar, cast, overload

import filetype
import openai
Expand Down
4 changes: 1 addition & 3 deletions src/magentic/chatprompt.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import inspect
from collections.abc import Awaitable, Callable, Sequence
from functools import update_wrapper
from typing import (
Any,
Awaitable,
Callable,
Generic,
ParamSpec,
Protocol,
Sequence,
TypeVar,
cast,
overload,
Expand Down
11 changes: 6 additions & 5 deletions src/magentic/function_call.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import asyncio
import inspect
from typing import (
Any,
from collections.abc import (
AsyncIterable,
AsyncIterator,
Awaitable,
Callable,
Generic,
Iterable,
Iterator,
)
from typing import (
Any,
Generic,
ParamSpec,
Tuple,
TypeVar,
cast,
)
Expand Down Expand Up @@ -99,7 +100,7 @@ class AsyncParallelFunctionCall(Generic[T]):
def __init__(self, function_calls: AsyncIterable[FunctionCall[Awaitable[T] | T]]):
self._function_calls = CachedAsyncIterable(function_calls)

async def __call__(self) -> Tuple[T, ...]:
async def __call__(self) -> tuple[T, ...]:
with logfire.span("Executing async parallel function call"):
tasks_and_results: list[asyncio.Task[T] | T] = []
async for function_call in self._function_calls:
Expand Down
2 changes: 1 addition & 1 deletion src/magentic/prompt_chain.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import inspect
from collections.abc import Callable
from functools import wraps
from typing import (
Any,
Callable,
ParamSpec,
TypeVar,
cast,
Expand Down
4 changes: 1 addition & 3 deletions src/magentic/prompt_function.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import copy
import inspect
from collections.abc import Awaitable, Callable, Sequence
from functools import update_wrapper
from typing import (
Any,
Awaitable,
Callable,
Generic,
ParamSpec,
Protocol,
Sequence,
TypeVar,
cast,
overload,
Expand Down
4 changes: 2 additions & 2 deletions src/magentic/streaming.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import asyncio
import textwrap
from collections.abc import AsyncIterable, Iterable
from collections.abc import AsyncIterable, AsyncIterator, Callable, Iterable, Iterator
from dataclasses import dataclass
from itertools import chain, dropwhile
from typing import Any, AsyncIterator, Callable, Iterator, TypeVar
from typing import Any, TypeVar

T = TypeVar("T")

Expand Down
3 changes: 1 addition & 2 deletions src/magentic/typing.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import inspect
import types
from collections.abc import Mapping, Sequence
from collections.abc import Iterable, Mapping, Sequence
from typing import (
Any,
Iterable,
TypeGuard,
TypeVar,
Union,
Expand Down
3 changes: 2 additions & 1 deletion tests/chat_model/test_litellm_chat_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Annotated, Any, Iterator
from collections.abc import Iterator
from typing import Annotated, Any

import litellm
import pytest
Expand Down
5 changes: 4 additions & 1 deletion tests/test_chat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Awaitable
from typing import TYPE_CHECKING

import pytest

Expand All @@ -16,6 +16,9 @@
from magentic.prompt_function import prompt
from magentic.streaming import async_iter

if TYPE_CHECKING:
from collections.abc import Awaitable


def test_chat_from_prompt():
"""Test creating a chat from a prompt function."""
Expand Down
5 changes: 4 additions & 1 deletion tests/test_function_call.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import inspect
from typing import Awaitable
from typing import TYPE_CHECKING

import pytest
from typing_extensions import assert_type
Expand All @@ -11,6 +11,9 @@
)
from magentic.streaming import async_iter

if TYPE_CHECKING:
from collections.abc import Awaitable


def plus(a: int, b: int) -> int:
return a + b
Expand Down
3 changes: 2 additions & 1 deletion tests/test_prompt_function.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Tests for PromptFunction."""

from collections.abc import Awaitable
from inspect import getdoc
from typing import Annotated, Awaitable
from typing import Annotated
from unittest.mock import AsyncMock, Mock

import pytest
Expand Down
2 changes: 1 addition & 1 deletion tests/test_streaming.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import AsyncIterator
from collections.abc import AsyncIterator

import pytest

Expand Down
3 changes: 2 additions & 1 deletion tests/test_typing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import typing
from collections.abc import Iterable
from types import NoneType
from typing import Any, Generic, Iterable, TypeVar
from typing import Any, Generic, TypeVar

import pytest
from pydantic import BaseModel
Expand Down

0 comments on commit b1805d1

Please sign in to comment.