Skip to content

Commit 1271c97

Browse files
davorrunjesuchaudn
authored and
suchaudn
committed
Update pre-commit (microsoft#2067)
* update pre-commit * update pre-commit.ci * lint fix
1 parent c6a6d5f commit 1271c97

File tree

11 files changed

+45
-35
lines changed

11 files changed

+45
-35
lines changed

.pre-commit-config.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ exclude: 'dotnet'
44
ci:
55
autofix_prs: true
66
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
7-
autoupdate_schedule: 'quarterly'
7+
autoupdate_schedule: 'monthly'
88

99
repos:
1010
- repo: https://github.com/pre-commit/pre-commit-hooks
11-
rev: v4.4.0
11+
rev: v4.5.0
1212
hooks:
1313
- id: check-added-large-files
1414
- id: check-ast
@@ -23,11 +23,11 @@ repos:
2323
- id: end-of-file-fixer
2424
- id: no-commit-to-branch
2525
- repo: https://github.com/psf/black
26-
rev: 23.3.0
26+
rev: 24.3.0
2727
hooks:
2828
- id: black
2929
- repo: https://github.com/charliermarsh/ruff-pre-commit
30-
rev: v0.0.261
30+
rev: v0.3.3
3131
hooks:
3232
- id: ruff
3333
args: ["--fix"]
@@ -45,7 +45,7 @@ repos:
4545
notebook/.*
4646
)$
4747
- repo: https://github.com/nbQA-dev/nbQA
48-
rev: 1.7.1
48+
rev: 1.8.4
4949
hooks:
5050
- id: nbqa-ruff
5151
# Don't require notebooks to have all imports at the top

autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,18 @@ class QueryResponse(BaseModel, extra="forbid"): # type: ignore
281281
collection_name,
282282
query_texts,
283283
limit=n_results,
284-
query_filter=models.Filter(
285-
must=[
286-
models.FieldCondition(
287-
key="document",
288-
match=models.MatchText(text=search_string),
289-
)
290-
]
291-
)
292-
if search_string
293-
else None,
284+
query_filter=(
285+
models.Filter(
286+
must=[
287+
models.FieldCondition(
288+
key="document",
289+
match=models.MatchText(text=search_string),
290+
)
291+
]
292+
)
293+
if search_string
294+
else None
295+
),
294296
)
295297

296298
data = {

autogen/agentchat/user_proxy_agent.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ def __init__(
9090
code_execution_config=code_execution_config,
9191
llm_config=llm_config,
9292
default_auto_reply=default_auto_reply,
93-
description=description
94-
if description is not None
95-
else self.DEFAULT_USER_PROXY_AGENT_DESCRIPTIONS[human_input_mode],
93+
description=(
94+
description if description is not None else self.DEFAULT_USER_PROXY_AGENT_DESCRIPTIONS[human_input_mode]
95+
),
9696
)
9797

9898
if logging_enabled():

autogen/code_utils.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,7 @@ def execute_code(
458458
image_list = (
459459
["python:3-slim", "python:3", "python:3-windowsservercore"]
460460
if use_docker is True
461-
else [use_docker]
462-
if isinstance(use_docker, str)
463-
else use_docker
461+
else [use_docker] if isinstance(use_docker, str) else use_docker
464462
)
465463
for image in image_list:
466464
# check if the image exists

autogen/oai/client.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ class Message(Protocol):
8383
choices: List[Choice]
8484
model: str
8585

86-
def create(self, params: Dict[str, Any]) -> ModelClientResponseProtocol:
87-
... # pragma: no cover
86+
def create(self, params: Dict[str, Any]) -> ModelClientResponseProtocol: ... # pragma: no cover
8887

8988
def message_retrieval(
9089
self, response: ModelClientResponseProtocol
@@ -97,8 +96,7 @@ def message_retrieval(
9796
"""
9897
... # pragma: no cover
9998

100-
def cost(self, response: ModelClientResponseProtocol) -> float:
101-
... # pragma: no cover
99+
def cost(self, response: ModelClientResponseProtocol) -> float: ... # pragma: no cover
102100

103101
@staticmethod
104102
def get_usage(response: ModelClientResponseProtocol) -> Dict:

autogen/oai/completion.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ def yes_or_no_filter(context, config, response):
792792
raise ERROR
793793

794794
# Warn if a config list was provided but was empty
795-
if type(config_list) is list and len(config_list) == 0:
795+
if isinstance(config_list, list) and len(config_list) == 0:
796796
logger.warning(
797797
"Completion was provided with a config_list, but the list was empty. Adopting default OpenAI behavior, which reads from the 'model' parameter instead."
798798
)
@@ -866,12 +866,14 @@ def _construct_params(cls, context, config, prompt=None, messages=None, allow_fo
866866
if prompt is None:
867867
params["messages"] = (
868868
[
869-
{
870-
**m,
871-
"content": cls.instantiate(m["content"], context, allow_format_str_template),
872-
}
873-
if m.get("content")
874-
else m
869+
(
870+
{
871+
**m,
872+
"content": cls.instantiate(m["content"], context, allow_format_str_template),
873+
}
874+
if m.get("content")
875+
else m
876+
)
875877
for m in messages
876878
]
877879
if context

pyproject.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ exclude = "(.eggs|.git|.hg|.mypy_cache|.venv|_build|buck-out|build|dist)"
1616

1717

1818
[tool.ruff]
19+
1920
line-length = 120
21+
22+
[tool.ruff.lint]
23+
24+
2025
# Enable Pyflakes `E` and `F` codes by default.
2126
select = [
2227
"E", "W", # see: https://pypi.org/project/pycodestyle
@@ -25,12 +30,14 @@ select = [
2530
# "N", # see: https://pypi.org/project/pep8-naming
2631
# "S", # see: https://pypi.org/project/flake8-bandit
2732
]
33+
2834
ignore = [
2935
"E501",
3036
"F401",
3137
"F403",
3238
"C901",
3339
]
40+
3441
# Exclude a variety of commonly ignored directories.
3542
exclude = [
3643
".eggs",
@@ -49,7 +56,7 @@ exclude = [
4956
ignore-init-module-imports = true
5057
unfixable = ["F401"]
5158

52-
[tool.ruff.mccabe]
59+
[tool.ruff.lint.mccabe]
5360
# Unlike Flake8, default to a complexity level of 10.
5461
max-complexity = 10
5562

samples/apps/cap/py/autogencap/proto/Autogen_pb2.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class DataMap(_message.Message):
1515
key: str
1616
value: str
1717
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
18+
1819
DATA_FIELD_NUMBER: _ClassVar[int]
1920
data: _containers.ScalarMap[str, str]
2021
def __init__(self, data: _Optional[_Mapping[str, str]] = ...) -> None: ...

samples/apps/cap/py/demo/App.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Demo App
33
"""
4+
45
import argparse
56
import _paths
67
from autogencap.Config import LOG_LEVEL, IGNORED_LOG_CONTEXTS

samples/tools/autogenbench/scenarios/AutoGPT/Templates/TwoAgents/check.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ def check():
4141

4242
with open("../should_contain.json.txt", "r") as f:
4343
should_contain = json.loads(f.read())
44-
assert type(should_contain) == list, "TERMINATE\n"
44+
assert isinstance(should_contain, list), "TERMINATE\n"
4545

4646
with open("../should_not_contain.json.txt", "r") as f:
4747
should_not_contain = json.loads(f.read())
48-
assert type(should_not_contain) == list, "TERMINATE\n"
48+
assert isinstance(should_not_contain, list), "TERMINATE\n"
4949

5050
# Check if file pattern is a file extension
5151
if file_pattern.startswith("."):

test/agentchat/extensions/tsp.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
Triangular inequality is not required in this problem.
44
"""
5+
56
import math
67
import pdb
78
import random

0 commit comments

Comments
 (0)