Skip to content

Commit ac6c44a

Browse files
authored
lint: update pre-commit and refomat (#11)
# Motivation - Testing github CI
1 parent 9a829f0 commit ac6c44a

File tree

30 files changed

+88
-101
lines changed

30 files changed

+88
-101
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repos:
77
hooks:
88
- id: taplo-format
99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.9.6
10+
rev: v0.11.7
1111
hooks:
1212
# Run the linter.
1313
- id: ruff
@@ -19,7 +19,7 @@ repos:
1919
types_or: [python, jupyter, pyi]
2020

2121
- repo: https://github.com/biomejs/pre-commit
22-
rev: "v0.6.1"
22+
rev: "v2.0.0-beta.1"
2323
hooks:
2424
- id: biome-check
2525
language: node
@@ -48,7 +48,7 @@ repos:
4848
- id: check-merge-conflict
4949

5050
- repo: https://github.com/python-jsonschema/check-jsonschema
51-
rev: 0.31.1
51+
rev: 0.33.0
5252
hooks:
5353
- id: check-github-workflows
5454
- id: check-github-actions
@@ -77,12 +77,12 @@ repos:
7777
entry: bash -c "uv run --frozen --all-extras --dev deptry src --ignore DEP001 --extend-exclude 'codegen-examples/.*'"
7878

7979
- repo: https://github.com/renovatebot/pre-commit-hooks
80-
rev: 39.169.3
80+
rev: 39.263.1
8181
hooks:
8282
- id: renovate-config-validator
8383

8484
- repo: https://github.com/astral-sh/uv-pre-commit
85-
rev: "0.5.31"
85+
rev: "0.6.17"
8686
hooks:
8787
- id: uv-sync
8888
args: ["--frozen", "--all-packages", "--all-extras"]

src/codegen/agents/agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from typing import Any, Optional
2+
from typing import Any
33

44
from codegen_api_client.api.agents_api import AgentsApi
55
from codegen_api_client.api_client import ApiClient
@@ -45,7 +45,7 @@ def refresh(self) -> None:
4545
class Agent:
4646
"""API client for interacting with Codegen AI agents."""
4747

48-
def __init__(self, token: str, org_id: Optional[int] = None, base_url: Optional[str] = CODEGEN_BASE_API_URL):
48+
def __init__(self, token: str, org_id: int | None = None, base_url: str | None = CODEGEN_BASE_API_URL):
4949
"""Initialize a new Agent client.
5050
5151
Args:
@@ -82,7 +82,7 @@ def run(self, prompt: str) -> AgentTask:
8282
self.current_job = job
8383
return job
8484

85-
def get_status(self) -> Optional[dict[str, Any]]:
85+
def get_status(self) -> dict[str, Any] | None:
8686
"""Get the status of the current job.
8787
8888
Returns:

src/codegen/cli/commands/serve/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import subprocess
55
import sys
66
from pathlib import Path
7-
from typing import Optional
87

98
import rich
109
import rich_click as click
@@ -89,7 +88,7 @@ def create_app_module(file_path: Path) -> str:
8988
return f"{module_name}:app"
9089

9190

92-
def start_ngrok(port: int) -> Optional[str]:
91+
def start_ngrok(port: int) -> str | None:
9392
"""Start ngrok and return the public URL"""
9493
try:
9594
import requests

src/codegen/extensions/attribution/git_history.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import time
22
from collections import defaultdict, deque
33
from datetime import datetime
4-
from typing import Optional
54

65
import pygit2
76
from intervaltree import IntervalTree
@@ -16,7 +15,7 @@
1615
class GitAttributionTracker:
1716
"""Tracks attribution information for code symbols based on git history."""
1817

19-
def __init__(self, codebase: Codebase, ai_authors: Optional[list[str]] = None):
18+
def __init__(self, codebase: Codebase, ai_authors: list[str] | None = None):
2019
"""Initialize the attribution tracker.
2120
2221
Args:
@@ -43,7 +42,7 @@ def __init__(self, codebase: Codebase, ai_authors: Optional[list[str]] = None):
4342

4443
self._commits: deque[Commit]
4544

46-
def build_history(self, max_commits: Optional[int] = None) -> None:
45+
def build_history(self, max_commits: int | None = None) -> None:
4746
"""Build the git history for the codebase.
4847
4948
Args:
@@ -206,7 +205,7 @@ def map_symbols_to_history(self, force=False) -> None:
206205
start_time = time.time()
207206

208207
print("Stashing any working directory changes...")
209-
stash_msg = f"Codegen Attribution Stash @ {datetime.now().timestamp()}"
208+
stash_msg = f"Codegen Attribution Stash @ {datetime.now().timestamp()}" # noqa: DTZ005
210209
stash_id = None
211210
try:
212211
stash_id = self.repo.stash(self.repo.default_signature, stash_msg, include_untracked=True)
@@ -325,7 +324,7 @@ def get_symbol_history(self, symbol: Symbol) -> list[dict]:
325324
symbol_id = f"{symbol.filepath}:{symbol.name}"
326325
return self._symbol_history.get(symbol_id, [])
327326

328-
def get_symbol_last_editor(self, symbol: Symbol) -> Optional[str]:
327+
def get_symbol_last_editor(self, symbol: Symbol) -> str | None:
329328
"""Get the last person who edited a symbol.
330329
331330
Args:
@@ -423,12 +422,12 @@ def get_ai_contribution_timeline(self) -> list[tuple[datetime, int]]:
423422
if any(name in author for name in self.ai_authors):
424423
for commit in commits:
425424
# Convert timestamp to year-month
426-
dt = datetime.fromtimestamp(commit["timestamp"])
425+
dt = datetime.fromtimestamp(commit["timestamp"]) # noqa: DTZ006
427426
month_key = f"{dt.year}-{dt.month:02d}"
428427
monthly_counts[month_key] += 1
429428

430429
# Sort by date
431430
timeline = sorted(monthly_counts.items())
432431

433432
# Convert to datetime objects
434-
return [(datetime.strptime(month, "%Y-%m"), count) for month, count in timeline]
433+
return [(datetime.strptime(month, "%Y-%m"), count) for month, count in timeline] # noqa: DTZ007

src/codegen/extensions/attribution/main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
from typing import Optional
2-
31
from codegen.extensions.attribution.git_history import GitAttributionTracker
42
from codegen.sdk.core.codebase import Codebase
53

64

7-
def analyze_ai_impact(codebase: Codebase, ai_authors: Optional[list[str]] = None, max_commits: Optional[int] = None) -> dict:
5+
def analyze_ai_impact(codebase: Codebase, ai_authors: list[str] | None = None, max_commits: int | None = None) -> dict:
86
"""Analyze the impact of AI on a codebase.
97
108
Args:
@@ -57,7 +55,7 @@ def analyze_ai_impact(codebase: Codebase, ai_authors: Optional[list[str]] = None
5755
}
5856

5957

60-
def add_attribution_to_symbols(codebase: Codebase, ai_authors: Optional[list[str]] = None) -> None:
58+
def add_attribution_to_symbols(codebase: Codebase, ai_authors: list[str] | None = None) -> None:
6159
"""Add attribution information to symbols in the codebase.
6260
6361
This adds the following attributes to each symbol:

src/codegen/extensions/events/codegen_app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from typing import Any, Optional
2+
from typing import Any
33

44
from fastapi import FastAPI, Request
55
from fastapi.responses import HTMLResponse
@@ -23,7 +23,7 @@ class CodegenApp:
2323
linear: Linear
2424
slack: Slack
2525

26-
def __init__(self, name: str, repo: Optional[str] = None, tmp_dir: str = "/tmp/codegen", commit: str | None = "latest"):
26+
def __init__(self, name: str, repo: str | None = None, tmp_dir: str = "/tmp/codegen", commit: str | None = "latest"):
2727
self.name = name
2828
self.tmp_dir = tmp_dir
2929

src/codegen/extensions/events/github.py

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

56
from fastapi import Request
67
from github import Github

src/codegen/extensions/events/github_types.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from datetime import datetime
2-
from typing import Optional
32

43

54
class GitHubRepository:
@@ -37,11 +36,11 @@ class GitHubInstallation:
3736
events: list[str]
3837
created_at: datetime
3938
updated_at: datetime
40-
single_file_name: Optional[str]
39+
single_file_name: str | None
4140
has_multiple_single_files: bool
4241
single_file_paths: list[str]
43-
suspended_by: Optional[str]
44-
suspended_at: Optional[datetime]
42+
suspended_by: str | None
43+
suspended_at: datetime | None
4544

4645

4746
class GitHubUser:
@@ -58,5 +57,5 @@ class GitHubInstallationEvent:
5857
action: str
5958
installation: GitHubInstallation
6059
repositories: list[GitHubRepository]
61-
requester: Optional[dict]
60+
requester: dict | None
6261
sender: GitHubUser

src/codegen/extensions/events/linear.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 Any, Callable, TypeVar
2+
from collections.abc import Callable
3+
from typing import Any, TypeVar
34

45
from pydantic import BaseModel
56

src/codegen/extensions/github/types/pull_request.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Literal, Optional
1+
from typing import Literal
22

33
from pydantic import BaseModel
44

@@ -47,30 +47,30 @@ class PullRequest(BaseModel):
4747
locked: bool
4848
title: str
4949
user: GitHubUser
50-
body: Optional[str]
50+
body: str | None
5151
created_at: str
5252
updated_at: str
53-
closed_at: Optional[str]
54-
merged_at: Optional[str]
55-
merge_commit_sha: Optional[str]
56-
assignee: Optional[GitHubUser]
53+
closed_at: str | None
54+
merged_at: str | None
55+
merge_commit_sha: str | None
56+
assignee: GitHubUser | None
5757
assignees: list[GitHubUser]
5858
requested_reviewers: list[GitHubUser]
5959
requested_teams: list[dict]
6060
labels: list[Label]
61-
milestone: Optional[dict]
61+
milestone: dict | None
6262
draft: bool
6363
head: PullRequestRef
6464
base: PullRequestRef
6565
_links: PullRequestLinks
6666
author_association: str
67-
auto_merge: Optional[dict]
68-
active_lock_reason: Optional[str]
67+
auto_merge: dict | None
68+
active_lock_reason: str | None
6969
merged: bool
70-
mergeable: Optional[bool]
71-
rebaseable: Optional[bool]
70+
mergeable: bool | None
71+
rebaseable: bool | None
7272
mergeable_state: str
73-
merged_by: Optional[GitHubUser]
73+
merged_by: GitHubUser | None
7474
comments: int
7575
review_comments: int
7676
maintainer_can_modify: bool

0 commit comments

Comments
 (0)