Skip to content

A programming framework for agentic AI

Update pre-commit (#2067)

Davor Runjeb1839c3845f2
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index b2751f167..6b27154f9 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -4,11 +4,11 @@ exclude: 'dotnet'
ci:
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
- autoupdate_schedule: 'quarterly'
+ autoupdate_schedule: 'monthly'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.4.0
+ rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
@@ -23,11 +23,11 @@ repos:
- id: end-of-file-fixer
- id: no-commit-to-branch
- repo: https://github.com/psf/black
- rev: 23.3.0
+ rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
- rev: v0.0.261
+ rev: v0.3.3
hooks:
- id: ruff
args: ["--fix"]
@@ -45,7 +45,7 @@ repos:
notebook/.*
)$
- repo: https://github.com/nbQA-dev/nbQA
- rev: 1.7.1
+ rev: 1.8.4
hooks:
- id: nbqa-ruff
# Don't require notebooks to have all imports at the top
diff --git a/autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py b/autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py
index 01b513623..c539c716a 100644
--- a/autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py
+++ b/autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py
@@ -281,16 +281,18 @@ def query_qdrant(
collection_name,
query_texts,
limit=n_results,
- query_filter=models.Filter(
- must=[
- models.FieldCondition(
- key="document",
- match=models.MatchText(text=search_string),
- )
- ]
- )
- if search_string
- else None,
+ query_filter=(
+ models.Filter(
+ must=[
+ models.FieldCondition(
+ key="document",
+ match=models.MatchText(text=search_string),
+ )
+ ]
+ )
+ if search_string
+ else None
+ ),
)
data = {
diff --git a/autogen/agentchat/user_proxy_agent.py b/autogen/agentchat/user_proxy_agent.py
index 980ca12c6..d1d7f89ab 100644
--- a/autogen/agentchat/user_proxy_agent.py
+++ b/autogen/agentchat/user_proxy_agent.py
@@ -90,9 +90,9 @@ class UserProxyAgent(ConversableAgent):
code_execution_config=code_execution_config,
llm_config=llm_config,
default_auto_reply=default_auto_reply,
- description=description
- if description is not None
- else self.DEFAULT_USER_PROXY_AGENT_DESCRIPTIONS[human_input_mode],
+ description=(
+ description if description is not None else self.DEFAULT_USER_PROXY_AGENT_DESCRIPTIONS[human_input_mode]
+ ),
)
if logging_enabled():
diff --git a/autogen/code_utils.py b/autogen/code_utils.py
index b18b6588e..710af02fa 100644
--- a/autogen/code_utils.py
+++ b/autogen/code_utils.py
@@ -458,9 +458,7 @@ def execute_code(
image_list = (
["python:3-slim", "python:3", "python:3-windowsservercore"]
if use_docker is True
- else [use_docker]
- if isinstance(use_docker, str)
- else use_docker
+ else [use_docker] if isinstance(use_docker, str) else use_docker
)
for image in image_list:
# check if the image exists
diff --git a/autogen/oai/client.py b/autogen/oai/client.py
index 1d70b8531..0ecc050fa 100644
--- a/autogen/oai/client.py
+++ b/autogen/oai/client.py
@@ -83,8 +83,7 @@ class ModelClient(Protocol):
choices: List[Choice]
model: str
- def create(self, params: Dict[str, Any]) -> ModelClientResponseProtocol:
- ... # pragma: no cover
+ def create(self, params: Dict[str, Any]) -> ModelClientResponseProtocol: ... # pragma: no cover
def message_retrieval(
self, response: ModelClientResponseProtocol
@@ -97,8 +96,7 @@ class ModelClient(Protocol):
"""
... # pragma: no cover
- def cost(self, response: ModelClientResponseProtocol) -> float:
- ... # pragma: no cover
+ def cost(self, response: ModelClientResponseProtocol) -> float: ... # pragma: no cover
@staticmethod
def get_usage(response: ModelClientResponseProtocol) -> Dict:
diff --git a/autogen/oai/completion.py b/autogen/oai/completion.py
index 7029e6d10..43ccd0b3b 100644
--- a/autogen/oai/completion.py
+++ b/autogen/oai/completion.py
@@ -792,7 +792,7 @@ class Completion(openai_Completion):
raise ERROR
# Warn if a config list was provided but was empty
- if type(config_list) is list and len(config_list) == 0:
+ if isinstance(config_list, list) and len(config_list) == 0:
logger.warning(
"Completion was provided with a config_list, but the list was empty. Adopting default OpenAI behavior, which reads from the 'model' parameter instead."
)
@@ -866,12 +866,14 @@ class Completion(openai_Completion):
if prompt is None:
params["messages"] = (
[
- {
- **m,
- "content": cls.instantiate(m["content"], context, allow_format_str_template),
- }
- if m.get("content")
- else m
+ (
+ {
+ **m,
+ "content": cls.instantiate(m["content"], context, allow_format_str_template),
+ }
+ if m.get("content")
+ else m
+ )
for m in messages
]
if context
diff --git a/pyproject.toml b/pyproject.toml
index f1763fba3..570799849 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -16,7 +16,12 @@ exclude = "(.eggs|.git|.hg|.mypy_cache|.venv|_build|buck-out|build|dist)"
[tool.ruff]
+
line-length = 120
+
+[tool.ruff.lint]
+
+
# Enable Pyflakes `E` and `F` codes by default.
select = [
"E", "W", # see: https://pypi.org/project/pycodestyle
@@ -25,12 +30,14 @@ select = [
# "N", # see: https://pypi.org/project/pep8-naming
# "S", # see: https://pypi.org/project/flake8-bandit
]
+
ignore = [
"E501",
"F401",
"F403",
"C901",
]
+
# Exclude a variety of commonly ignored directories.
exclude = [
".eggs",
@@ -49,7 +56,7 @@ exclude = [
ignore-init-module-imports = true
unfixable = ["F401"]
-[tool.ruff.mccabe]
+[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10
diff --git a/samples/apps/cap/py/autogencap/proto/Autogen_pb2.pyi b/samples/apps/cap/py/autogencap/proto/Autogen_pb2.pyi
index e73da3735..9c3cda6a4 100644
--- a/samples/apps/cap/py/autogencap/proto/Autogen_pb2.pyi
+++ b/samples/apps/cap/py/autogencap/proto/Autogen_pb2.pyi
@@ -15,6 +15,7 @@ class DataMap(_message.Message):
key: str
value: str
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
+
DATA_FIELD_NUMBER: _ClassVar[int]
data: _containers.ScalarMap[str, str]
def __init__(self, data: _Optional[_Mapping[str, str]] = ...) -> None: ...
diff --git a/samples/apps/cap/py/demo/App.py b/samples/apps/cap/py/demo/App.py
index 45dbeb224..e9a49ba4a 100644
--- a/samples/apps/cap/py/demo/App.py
+++ b/samples/apps/cap/py/demo/App.py
@@ -1,6 +1,7 @@
"""
Demo App
"""
+
import argparse
import _paths
from autogencap.Config import LOG_LEVEL, IGNORED_LOG_CONTEXTS
diff --git a/samples/tools/autogenbench/scenarios/AutoGPT/Templates/TwoAgents/check.py b/samples/tools/autogenbench/scenarios/AutoGPT/Templates/TwoAgents/check.py
index da7ea832a..c9b4c0e0f 100644
--- a/samples/tools/autogenbench/scenarios/AutoGPT/Templates/TwoAgents/check.py
+++ b/samples/tools/autogenbench/scenarios/AutoGPT/Templates/TwoAgents/check.py
@@ -41,11 +41,11 @@ def check():
with open("../should_contain.json.txt", "r") as f:
should_contain = json.loads(f.read())
- assert type(should_contain) == list, "TERMINATE\n"
+ assert isinstance(should_contain, list), "TERMINATE\n"
with open("../should_not_contain.json.txt", "r") as f:
should_not_contain = json.loads(f.read())
- assert type(should_not_contain) == list, "TERMINATE\n"
+ assert isinstance(should_not_contain, list), "TERMINATE\n"
# Check if file pattern is a file extension
if file_pattern.startswith("."):
diff --git a/test/agentchat/extensions/tsp.py b/test/agentchat/extensions/tsp.py
index b979d407e..82cc98c0c 100644
--- a/test/agentchat/extensions/tsp.py
+++ b/test/agentchat/extensions/tsp.py
@@ -2,6 +2,7 @@
Triangular inequality is not required in this problem.
"""
+
import math
import pdb
import random