Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions python/packages/ag-ui/tests/ag_ui/test_ag_ui_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import json
from collections.abc import AsyncGenerator, Awaitable, MutableSequence
from typing import Any
from typing import Any, cast

from ag_ui.core import Interrupt, ResumeEntry
from agent_framework import (
Expand Down Expand Up @@ -225,7 +225,7 @@ async def mock_post_run(*args: object, **kwargs: Any) -> AsyncGenerator[dict[str
stream = client.inner_get_response(messages=messages, stream=True, options=chat_options)
assert isinstance(stream, ResponseStream)
async for update in stream:
updates.append(update)
updates.append(cast(ChatResponseUpdate, update))

assert len(updates) == 4
assert updates[0].additional_properties is not None
Expand Down Expand Up @@ -468,7 +468,7 @@ async def mock_post_run(*args: object, **kwargs: Any) -> AsyncGenerator[dict[str
stream = client.inner_get_response(messages=messages, stream=True, options={"tools": [my_tool]})
assert isinstance(stream, ResponseStream)
async for update in stream:
updates.append(update)
updates.append(cast(ChatResponseUpdate, update))

# Find the function_call content - it should have agui_thread_id
found = False
Expand Down
4 changes: 2 additions & 2 deletions python/packages/azure-contentunderstanding/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ markers = [
extend = "../../pyproject.toml"

[tool.ruff.lint.per-file-ignores]
"**/tests/**" = ["D", "INP", "TD", "ERA001", "RUF", "S"]
"samples/**" = ["D", "INP", "ERA001", "RUF", "S", "T201", "CPY"]
"**/tests/**" = ["D", "INP", "TD", "commented-out-code", "RUF", "S"]
"samples/**" = ["D", "INP", "commented-out-code", "RUF", "S", "print", "CPY"]

[tool.coverage.run]
omit = ["**/__init__.py"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def _resolve_user_id(self, state: dict[str, Any], session: AgentSession) -> str:
# ``timeout`` is an intentional part of the public flush() API and is forwarded to
# ``asyncio.wait`` (which returns on expiry without raising), so the ASYNC109 suggestion to
# switch to ``asyncio.timeout`` does not apply here.
async def flush(self, timeout: float = 30.0) -> None: # noqa: ASYNC109
async def flush(self, timeout: float = 30.0) -> None: # ruff:ignore[async-function-with-timeout]
"""Wait for any pending background memory-extraction tasks to complete.

After each stored turn, the Agent Memory Toolkit schedules fact/summary
Expand Down
2 changes: 1 addition & 1 deletion python/packages/azure-cosmos-memory/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ extend = "../../pyproject.toml"
[tool.ruff.lint.extend-per-file-ignores]
# Samples are illustrative scripts: allow prints and a plain blocking input() loop, and
# skip docstring/namespace/copyright rules.
"samples/**" = ["D", "INP", "ERA001", "RUF", "S", "T201", "CPY", "ASYNC250"]
"samples/**" = ["D", "INP", "commented-out-code", "RUF", "S", "print", "CPY", "blocking-input-in-async-function"]

[tool.coverage.run]
omit = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def workflow_orchestrator(context: df.DurableOrchestrationContext) -> Any:

outputs = yield from run_workflow_orchestrator(context, captured_workflow, initial_message, shared_state)
# Durable Functions runtime extracts return value from StopIteration
return outputs # noqa: B901
return outputs # ruff:ignore[return-in-generator]

# Ensure the orchestrator function is registered (prevents garbage collection)
_ = workflow_orchestrator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

# Loopback hosts that resolve to ``http`` (not ``https``) when WEBSITE_HOSTNAME is
# host-only; covers the addresses ``func start`` can bind locally.
_LOOPBACK_HOSTS = frozenset({"localhost", "0.0.0.0", "::1"}) # noqa: S104 # nosec B104
_LOOPBACK_HOSTS = frozenset({"localhost", "0.0.0.0", "::1"}) # ruff:ignore[hardcoded-bind-all-interfaces] # nosec B104


def _is_loopback(host: str) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def route_prefix() -> str:
def _read_route_prefix() -> str:
# AzureWebJobsScriptRoot is the host-set path to the app root (mixed case is the real
# variable name and is case-sensitive on Linux, so it must not be upper-cased).
script_root = os.environ.get("AzureWebJobsScriptRoot") or os.getcwd() # noqa: SIM112
script_root = os.environ.get("AzureWebJobsScriptRoot") or os.getcwd() # ruff:ignore[uncapitalized-environment-variables]
host_json_path = os.path.join(script_root, "host.json")
try:
with open(host_json_path, encoding="utf-8") as f:
Expand Down
2 changes: 1 addition & 1 deletion python/packages/chatkit/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ markers = [
extend = "../../pyproject.toml"

[tool.ruff.lint]
ignore = ["RUF029"]
ignore = ["unused-async"]

[tool.coverage.run]
omit = [
Expand Down
2 changes: 1 addition & 1 deletion python/packages/core/agent_framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from __future__ import annotations

# pyright: reportUnsupportedDunderAll=false
# ruff: noqa: F822
# ruff:file-ignore[undefined-export]
import importlib
import importlib.metadata
from collections.abc import Mapping
Expand Down
2 changes: 1 addition & 1 deletion python/packages/core/agent_framework/_compaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
GROUP_KIND_KEY = "kind"
GROUP_INDEX_KEY = "index"
GROUP_HAS_REASONING_KEY = "has_reasoning"
GROUP_TOKEN_COUNT_KEY = "token_count" # noqa: S105 # nosec B105 - compaction metadata key, not a credential
GROUP_TOKEN_COUNT_KEY = "token_count" # ruff:ignore[hardcoded-password-string] # nosec B105 - compaction metadata key, not a credential
EXCLUDED_KEY = "_excluded"
EXCLUDE_REASON_KEY = "_exclude_reason"
SUMMARY_OF_MESSAGE_IDS_KEY = "_summary_of_message_ids"
Expand Down
2 changes: 1 addition & 1 deletion python/packages/core/agent_framework/_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,7 @@ async def evaluate_workflow(
overall_item.expected_output = expected_output[qi]
overall_items.append(overall_item)
else:
assert workflow_result is not None # noqa: S101 # nosec B101
assert workflow_result is not None # ruff:ignore[assert] # nosec B101
all_agent_data = _extract_agent_eval_data(workflow_result, workflow)
if include_overall:
original_query = _extract_overall_query(workflow_result)
Expand Down
10 changes: 5 additions & 5 deletions python/packages/core/agent_framework/_harness/_file_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ async def before_run(

@tool(name=FileAccessProvider.WRITE_TOOL_NAME, schema=_WriteFileInput, approval_mode=write_approval)
async def file_access_write(file_name: str, content: str, overwrite: bool = False) -> str:
"""Write a file with the given name and content. By default, does not overwrite an existing file unless overwrite is set to true.""" # noqa: E501
"""Write a file with the given name and content. By default, does not overwrite an existing file unless overwrite is set to true.""" # ruff:ignore[line-too-long]
try:
normalized = _normalize_relative_path(file_name)
async with self._write_lock:
Expand All @@ -1448,7 +1448,7 @@ async def file_access_write(file_name: str, content: str, overwrite: bool = Fals

@tool(name=FileAccessProvider.READ_TOOL_NAME, schema=_ReadFileInput, approval_mode=readonly_approval)
async def file_access_read(file_name: str) -> str:
"""Read the content of a file by name. Returns the file content or a message indicating the file could not be read.""" # noqa: E501
"""Read the content of a file by name. Returns the file content or a message indicating the file could not be read.""" # ruff:ignore[line-too-long]
try:
normalized = _normalize_relative_path(file_name)
content = await self.store.read(normalized)
Expand Down Expand Up @@ -1476,7 +1476,7 @@ async def file_access_ls(
directory: str | None = None,
glob_pattern: str | None = None,
) -> list[dict[str, str]] | str:
"""List the direct child files and subdirectories of a directory. Omit ``directory`` (or pass an empty string) to list the root. To enumerate a subdirectory, pass its relative path, for example ``"reports"`` or ``"reports/2024"``. Optionally filter entries with a ``glob_pattern`` (e.g. ``"*.md"``). Subdirectories are listed before files, and each entry is ``{"name": <name>, "type": "file"|"directory"}``.""" # noqa: E501
"""List the direct child files and subdirectories of a directory. Omit ``directory`` (or pass an empty string) to list the root. To enumerate a subdirectory, pass its relative path, for example ``"reports"`` or ``"reports/2024"``. Optionally filter entries with a ``glob_pattern`` (e.g. ``"*.md"``). Subdirectories are listed before files, and each entry is ``{"name": <name>, "type": "file"|"directory"}``.""" # ruff:ignore[line-too-long]
target = directory if directory and directory.strip() else ""
try:
listed = await self.store.list_children(target)
Expand All @@ -1495,7 +1495,7 @@ async def file_access_replace(
new_string: str,
replace_all: bool = False,
) -> str:
"""Replace occurrences of old_string with new_string in a file. Fails if old_string is not found, or if it occurs more than once and replace_all is false. Returns the number of occurrences replaced.""" # noqa: E501
"""Replace occurrences of old_string with new_string in a file. Fails if old_string is not found, or if it occurs more than once and replace_all is false. Returns the number of occurrences replaced.""" # ruff:ignore[line-too-long]
try:
normalized = _normalize_relative_path(file_name)
async with self._write_lock:
Expand All @@ -1516,7 +1516,7 @@ async def file_access_replace(
approval_mode=write_approval,
)
async def file_access_replace_lines(file_name: str, edits: list[_LineEdit]) -> str:
"""Replace lines in a file. Provide a list of edits, each with a 1-based line_number and a literal new_line (include your own trailing newline); an empty new_line deletes the line, including its line break. Fails on out-of-range or duplicate line numbers.""" # noqa: E501
"""Replace lines in a file. Provide a list of edits, each with a 1-based line_number and a literal new_line (include your own trailing newline); an empty new_line deletes the line, including its line break. Fails on out-of-range or duplicate line numbers.""" # ruff:ignore[line-too-long]
try:
normalized = _normalize_relative_path(file_name)
async with self._write_lock:
Expand Down
12 changes: 6 additions & 6 deletions python/packages/core/agent_framework/_harness/_file_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ async def before_run(

@tool(name="file_memory_write", schema=_WriteFileInput, approval_mode="never_require")
async def file_memory_write(file_name: str, content: str, description: str | None = None) -> str:
"""Write a memory file with the given name and content. Overwrites the file if it already exists. Include a description for large files to provide a summary that helps with future discovery.""" # noqa: E501
"""Write a memory file with the given name and content. Overwrites the file if it already exists. Include a description for large files to provide a summary that helps with future discovery.""" # ruff:ignore[line-too-long]
try:
normalized = _normalize_relative_path(file_name)
except ValueError as exc:
Expand Down Expand Up @@ -350,7 +350,7 @@ async def file_memory_write(file_name: str, content: str, description: str | Non

@tool(name="file_memory_read", schema=_ReadFileInput, approval_mode="never_require")
async def file_memory_read(file_name: str) -> str:
"""Read the content of a memory file by name. Returns the file content or a message indicating the file was not found.""" # noqa: E501
"""Read the content of a memory file by name. Returns the file content or a message indicating the file was not found.""" # ruff:ignore[line-too-long]
try:
normalized = _normalize_relative_path(file_name)
except ValueError as exc:
Expand Down Expand Up @@ -390,7 +390,7 @@ async def file_memory_delete(file_name: str) -> str:

@tool(name="file_memory_ls", schema=_ListInput, approval_mode="never_require")
async def file_memory_ls(glob_pattern: str | None = None) -> list[dict[str, Any]] | str:
"""List all memory files with their descriptions (if available). Optionally filter file names with a glob_pattern (e.g. "*.md"). Internal files (description sidecars and the memory index) are not shown. Each entry is {"name": <name>, "type": "file", "description": <desc-or-null>}.""" # noqa: E501
"""List all memory files with their descriptions (if available). Optionally filter file names with a glob_pattern (e.g. "*.md"). Internal files (description sidecars and the memory index) are not shown. Each entry is {"name": <name>, "type": "file", "description": <desc-or-null>}.""" # ruff:ignore[line-too-long]
try:
entries = await self.store.list_children(working_folder)
except OSError as exc:
Expand All @@ -415,7 +415,7 @@ async def file_memory_ls(glob_pattern: str | None = None) -> list[dict[str, Any]
async def file_memory_replace(
file_name: str, old_string: str, new_string: str, replace_all: bool = False
) -> str:
"""Replace occurrences of old_string with new_string in a memory file. Fails if old_string is not found, or if it occurs more than once and replace_all is false. Returns the number of occurrences replaced.""" # noqa: E501
"""Replace occurrences of old_string with new_string in a memory file. Fails if old_string is not found, or if it occurs more than once and replace_all is false. Returns the number of occurrences replaced.""" # ruff:ignore[line-too-long]
try:
normalized = _normalize_relative_path(file_name)
except ValueError as exc:
Expand Down Expand Up @@ -443,7 +443,7 @@ async def file_memory_replace(

@tool(name="file_memory_replace_lines", schema=_ReplaceLinesInput, approval_mode="never_require")
async def file_memory_replace_lines(file_name: str, edits: list[_LineEdit]) -> str:
"""Replace lines in a memory file. Provide a list of edits, each with a 1-based line_number and a literal new_line (include your own trailing newline); an empty new_line deletes the line, including its line break. Fails on out-of-range or duplicate line numbers.""" # noqa: E501
"""Replace lines in a memory file. Provide a list of edits, each with a 1-based line_number and a literal new_line (include your own trailing newline); an empty new_line deletes the line, including its line break. Fails on out-of-range or duplicate line numbers.""" # ruff:ignore[line-too-long]
try:
normalized = _normalize_relative_path(file_name)
except ValueError as exc:
Expand Down Expand Up @@ -474,7 +474,7 @@ async def file_memory_grep(
regex_pattern: str,
glob_pattern: str | None = None,
) -> list[dict[str, Any]] | str:
"""Search memory file contents using a case-insensitive regular expression. Optionally filter which files to search using a glob pattern (e.g., "*.md", "research*"). Returns matching file names, content snippets, and matching lines with line numbers. The regex_pattern must be 256 characters or fewer.""" # noqa: E501
"""Search memory file contents using a case-insensitive regular expression. Optionally filter which files to search using a glob pattern (e.g., "*.md", "research*"). Returns matching file names, content snippets, and matching lines with line numbers. The regex_pattern must be 256 characters or fewer.""" # ruff:ignore[line-too-long]
glob_filter = glob_pattern if glob_pattern and glob_pattern.strip() else None
try:
results = await self.store.search(working_folder, regex_pattern, glob_filter, recursive=False)
Expand Down
2 changes: 1 addition & 1 deletion python/packages/core/agent_framework/_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3068,7 +3068,7 @@ def get_mcp_client(self) -> _AsyncGeneratorContextManager[Any, None]:

if not hasattr(self, "_inject_headers_hook"):

async def _inject_headers(request: Request) -> None: # noqa: RUF029
async def _inject_headers(request: Request) -> None: # ruff:ignore[unused-async]
if _url_origin(request.url) != target_origin:
return
headers = _mcp_call_headers.get({})
Expand Down
10 changes: 5 additions & 5 deletions python/packages/core/agent_framework/_skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ async def run(self, skill: Skill, args: dict[str, Any] | list[str] | str | None
f"but received a list. Array-style arguments are only supported "
f"for file-based scripts."
)
if self._accepts_kwargs: # noqa: SIM108
if self._accepts_kwargs: # ruff:ignore[if-else-block-instead-of-if-exp]
result = self.function(**(args or {}), **kwargs)
else:
result = self.function(**(args or {}))
Expand Down Expand Up @@ -2319,13 +2319,13 @@ def _create_instructions(
except (KeyError, IndexError, ValueError) as exc:
raise ValueError(
"The provided instruction_template is not a valid format string. "
"It must contain a '{skills}' placeholder and escape any literal" # noqa: RUF027
"It must contain a '{skills}' placeholder and escape any literal" # ruff:ignore[missing-f-string-syntax]
" '{' or '}' "
"by doubling them ('{{' or '}}')."
) from exc
if "__PROBE__" not in result:
raise ValueError(
"The provided instruction_template must contain a '{skills}' placeholder." # noqa: RUF027
"The provided instruction_template must contain a '{skills}' placeholder." # ruff:ignore[missing-f-string-syntax]
)
template = prompt_template

Expand Down Expand Up @@ -2915,7 +2915,7 @@ async def get_skills(self, context: SkillsSourceContext) -> list[Skill]:
# Discover file-based scripts
scripts: list[SkillScript] = []
for sn in self._discover_script_files(skill_path, frontmatter.name):
script_full_path = os.path.normpath(os.path.join(skill_path, sn)) # noqa: ASYNC240
script_full_path = os.path.normpath(os.path.join(skill_path, sn)) # ruff:ignore[blocking-path-method-in-async-function]
scripts.append(FileSkillScript(name=sn, full_path=script_full_path, runner=self._script_runner))

file_skill = FileSkill(
Expand Down Expand Up @@ -3975,7 +3975,7 @@ def _mcp_join_text(result: ReadResourceResult) -> str:
return "\n".join(c.text for c in result.contents if isinstance(c, _TextResourceContents))


class _McpSkillIndexEntry: # noqa: B903
class _McpSkillIndexEntry: # ruff:ignore[class-as-data-structure]
"""A single entry in the ``skill://index.json`` discovery document.

All fields are optional to support lenient deserialization; callers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import base64
import io
import logging
import pickle # nosec # noqa: S403
import pickle # nosec # ruff:ignore[suspicious-pickle-import]
from typing import Any, cast

from ..exceptions import WorkflowCheckpointException
Expand Down Expand Up @@ -124,7 +124,7 @@
})


class _RestrictedUnpickler(pickle.Unpickler): # noqa: S301
class _RestrictedUnpickler(pickle.Unpickler): # ruff:ignore[suspicious-pickle-usage]
"""Unpickler that restricts which classes may be instantiated.

Only classes whose ``module:qualname`` key appears in the combined allow
Expand Down Expand Up @@ -330,7 +330,7 @@ def _base64_to_unpickle(encoded: str, *, allowed_types: frozenset[str] | None =
pickled = base64.b64decode(encoded.encode("ascii"))
if allowed_types is not None:
return _RestrictedUnpickler(pickled, allowed_types).load()
return pickle.loads(pickled) # nosec # noqa: S301
return pickle.loads(pickled) # nosec # ruff:ignore[suspicious-pickle-usage]
except Exception as exc:
raise WorkflowCheckpointException(f"Failed to decode pickled checkpoint data: {exc}") from exc

Expand Down
Loading
Loading