Skip to content

Commit

Permalink
Update pre-commit (microsoft#2067)
Browse files Browse the repository at this point in the history
* update pre-commit

* update pre-commit.ci

* lint fix
  • Loading branch information
davorrunje authored Mar 19, 2024
1 parent bf9f522 commit 93f9ebd
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 35 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
Expand All @@ -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
Expand Down
22 changes: 12 additions & 10 deletions autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,18 @@ class QueryResponse(BaseModel, extra="forbid"): # type: ignore
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 = {
Expand Down
6 changes: 3 additions & 3 deletions autogen/agentchat/user_proxy_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def __init__(
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():
Expand Down
4 changes: 1 addition & 3 deletions autogen/code_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions autogen/oai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ class Message(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
Expand All @@ -97,8 +96,7 @@ def message_retrieval(
"""
... # 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:
Expand Down
16 changes: 9 additions & 7 deletions autogen/oai/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ def yes_or_no_filter(context, config, response):
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."
)
Expand Down Expand Up @@ -866,12 +866,14 @@ def _construct_params(cls, context, config, prompt=None, messages=None, allow_fo
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
Expand Down
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions samples/apps/cap/py/autogencap/proto/Autogen_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
1 change: 1 addition & 0 deletions samples/apps/cap/py/demo/App.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Demo App
"""

import argparse
import _paths
from autogencap.Config import LOG_LEVEL, IGNORED_LOG_CONTEXTS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("."):
Expand Down
1 change: 1 addition & 0 deletions test/agentchat/extensions/tsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Triangular inequality is not required in this problem.
"""

import math
import pdb
import random
Expand Down

0 comments on commit 93f9ebd

Please sign in to comment.