Skip to content

Commit 07e6057

Browse files
committed
Add pyupgrade as a pre-commit hook; commit the changes
1 parent a0b2155 commit 07e6057

35 files changed

+68
-48
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,10 @@ repos:
2626
args: ["--maxkb=1024"]
2727
- id: check-merge-conflict
2828
- id: debug-statements
29+
30+
- repo: https://github.com/asottile/pyupgrade
31+
rev: v3.20.0
32+
hooks:
33+
- id: pyupgrade
34+
name: Enforce Python 3.10+ idioms
35+
args: ["--py310-plus"]

docs/scripts/generate_api_summary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def format_nav_section(nav_dict, indent_level=2):
6060

6161
def read_mkdocs_sections(filename: str = "mkdocs.yml"):
6262
"""Read and parse the mkdocs.yml file into sections."""
63-
with open(filename, "r") as f:
63+
with open(filename) as f:
6464
lines = f.readlines()
6565

6666
nav_start = -1

dspy/adapters/types/tool.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import inspect
3-
from typing import TYPE_CHECKING, Any, Callable, get_origin, get_type_hints
3+
from collections.abc import Callable
4+
from typing import TYPE_CHECKING, Any, get_origin, get_type_hints
45

56
import pydantic
67
from jsonschema import ValidationError, validate

dspy/clients/embedding.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Callable
1+
from collections.abc import Callable
2+
from typing import Any
23

34
import litellm
45
import numpy as np

dspy/dsp/utils/dpr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def __init__(self, **kwargs):
158158
annotators: None or empty set (only tokenizes).
159159
"""
160160
self._regexp = regex.compile(
161-
"(%s)|(%s)" % (self.ALPHA_NUM, self.NON_WS),
161+
f"({self.ALPHA_NUM})|({self.NON_WS})",
162162
flags=regex.IGNORECASE + regex.UNICODE + regex.MULTILINE,
163163
)
164164
if len(kwargs.get("annotators", {})) > 0:

dspy/evaluate/evaluate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import json
44
import logging
55
import types
6-
from typing import TYPE_CHECKING, Any, Callable
6+
from collections.abc import Callable
7+
from typing import TYPE_CHECKING, Any
78

89
if TYPE_CHECKING:
910
import pandas as pd

dspy/predict/best_of_n.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Callable
1+
from collections.abc import Callable
22

33
import dspy
44
from dspy.predict.predict import Module, Prediction

dspy/predict/code_act.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import inspect
22
import logging
3-
from typing import Callable
3+
from collections.abc import Callable
44

55
import dspy
66
from dspy.adapters.types.tool import Tool

dspy/predict/react.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
2-
from typing import TYPE_CHECKING, Any, Callable, Literal
2+
from collections.abc import Callable
3+
from typing import TYPE_CHECKING, Any, Literal
34

45
from litellm import ContextWindowExceededError
56

dspy/predict/refine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import inspect
22
import textwrap
3-
from typing import Callable
3+
from collections.abc import Callable
44

55
import orjson
66

0 commit comments

Comments
 (0)