Skip to content

Commit

Permalink
chore: upgrade black for newer code style
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Jan 26, 2024
1 parent c382789 commit 878a062
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 47 deletions.
33 changes: 11 additions & 22 deletions python/promplate/chain/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@

class ChainContext(SafeChainMapContext):
@overload
def __init__(self):
...
def __init__(self): ...

@overload
def __init__(self, least: MutableMapping | None = None):
...
def __init__(self, least: MutableMapping | None = None): ...

@overload
def __init__(self, least: MutableMapping | None = None, *maps: Mapping):
...
def __init__(self, least: MutableMapping | None = None, *maps: Mapping): ...

def __init__(self, least: MutableMapping | None = None, *maps: Mapping):
super().__init__({} if least is None else least, *maps) # type: ignore
Expand Down Expand Up @@ -56,35 +53,31 @@ def invoke(
/,
complete: Complete | None = None,
**config,
) -> ChainContext:
...
) -> ChainContext: ...

async def ainvoke(
self,
context: Context | None = None,
/,
complete: Complete | AsyncComplete | None = None,
**config,
) -> ChainContext:
...
) -> ChainContext: ...

def stream(
self,
context: Context | None = None,
/,
generate: Generate | None = None,
**config,
) -> Iterable[ChainContext]:
...
) -> Iterable[ChainContext]: ...

def astream(
self,
context: Context | None = None,
/,
generate: Generate | AsyncGenerate | None = None,
**config,
) -> AsyncIterable[ChainContext]:
...
) -> AsyncIterable[ChainContext]: ...

@classmethod
def _get_chain_type(cls):
Expand All @@ -108,8 +101,7 @@ def _invoke(
complete: Complete | None,
callbacks: list[BaseCallback],
**config,
):
...
): ...

async def _ainvoke(
self,
Expand All @@ -118,8 +110,7 @@ async def _ainvoke(
complete: Complete | AsyncComplete | None,
callbacks: list[BaseCallback],
**config,
):
...
): ...

def _stream(
self,
Expand All @@ -128,8 +119,7 @@ def _stream(
generate: Generate | None,
callbacks: list[BaseCallback],
**config,
) -> Iterable:
...
) -> Iterable: ...

def _astream(
self,
Expand All @@ -138,8 +128,7 @@ def _astream(
generate: Generate | AsyncGenerate | None,
callbacks: list[BaseCallback],
**config,
) -> AsyncIterable:
...
) -> AsyncIterable: ...

callbacks: list[BaseCallback | type[BaseCallback]]

Expand Down
18 changes: 6 additions & 12 deletions python/promplate/llm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,24 @@ def _config(self):


class Complete(Protocol):
def __call__(self, prompt, /, **config) -> str:
...
def __call__(self, prompt, /, **config) -> str: ...


class Generate(Protocol):
def __call__(self, prompt, /, **config) -> Iterable[str]:
...
def __call__(self, prompt, /, **config) -> Iterable[str]: ...


class AsyncComplete(Protocol):
def __call__(self, prompt, /, **config) -> Awaitable[str]:
...
def __call__(self, prompt, /, **config) -> Awaitable[str]: ...


class AsyncGenerate(Protocol):
def __call__(self, prompt, /, **config) -> AsyncIterable[str]:
...
def __call__(self, prompt, /, **config) -> AsyncIterable[str]: ...


class LLM(Protocol):
@partial(cast, Complete | AsyncComplete)
def complete(self, prompt, /, **config) -> str | Awaitable[str]:
...
def complete(self, prompt, /, **config) -> str | Awaitable[str]: ...

@partial(cast, Generate | AsyncGenerate)
def generate(self, prompt, /, **config) -> Iterable[str] | AsyncIterable[str]:
...
def generate(self, prompt, /, **config) -> Iterable[str] | AsyncIterable[str]: ...
6 changes: 2 additions & 4 deletions python/promplate/llm/openai/v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ def __init__(
for key, val in other_config.items():
setattr(self, key, val)

def __setattr__(self, *_):
...
def __setattr__(self, *_): ...

def __getattr__(self, _):
...
def __getattr__(self, _): ...

else:
Config = Configurable
Expand Down
6 changes: 2 additions & 4 deletions python/promplate/llm/openai/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ def _aclient(self):

class ClientConfig(Config):
@same_params_as(Client)
def __init__(self, **config):
...
def __init__(self, **config): ...

class AsyncClientConfig(Config):
@same_params_as(AsyncClient)
def __init__(self, **config):
...
def __init__(self, **config): ...

else:
ClientConfig = AsyncClientConfig = Config
Expand Down
6 changes: 2 additions & 4 deletions python/promplate/prompt/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@


class Component(Protocol):
def render(self, context: Context) -> str:
...
def render(self, context: Context) -> str: ...

async def arender(self, context: Context) -> str:
...
async def arender(self, context: Context) -> str: ...


class TemplateCore(AutoNaming):
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ all = ["aiofiles", "httpx", "openai"]

[tool.poetry.group.dev.dependencies]
isort = "^5"
black = "^23"
black = "^24"
pytest = "^7"
coverage = "^7"
pytest-asyncio = "^0.23"
Expand Down

0 comments on commit 878a062

Please sign in to comment.