chore: import upstream snapshot with attribution
CI / Test (ubuntu-latest, Node 18.x, bun) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, npm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, pnpm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, yarn) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 20.x, bun) (push) Failing after 17m13s
CI / Test (ubuntu-latest, Node 20.x, npm) (push) Failing after 18m42s
CI / Test (ubuntu-latest, Node 20.x, pnpm) (push) Failing after 15m0s
CI / Test (ubuntu-latest, Node 20.x, yarn) (push) Failing after 49m44s
CI / Test (ubuntu-latest, Node 22.x, bun) (push) Failing after 51m55s
CI / Test (ubuntu-latest, Node 22.x, pnpm) (push) Failing after 21m57s
CI / Test (ubuntu-latest, Node 22.x, npm) (push) Failing after 37m39s
CI / Test (ubuntu-latest, Node 22.x, yarn) (push) Failing after 34m7s
CI / Validate Components (push) Failing after 37m15s
CI / Python Tests (push) Failing after 10m1s
CI / Security Scan (push) Failing after 10m1s
CI / Lint (push) Failing after 17m12s
CI / Coverage (push) Failing after 20m19s
CI / Test (macos-latest, Node 18.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (ubuntu-latest, Node 18.x, bun) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, npm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, pnpm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, yarn) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 20.x, bun) (push) Failing after 17m13s
CI / Test (ubuntu-latest, Node 20.x, npm) (push) Failing after 18m42s
CI / Test (ubuntu-latest, Node 20.x, pnpm) (push) Failing after 15m0s
CI / Test (ubuntu-latest, Node 20.x, yarn) (push) Failing after 49m44s
CI / Test (ubuntu-latest, Node 22.x, bun) (push) Failing after 51m55s
CI / Test (ubuntu-latest, Node 22.x, pnpm) (push) Failing after 21m57s
CI / Test (ubuntu-latest, Node 22.x, npm) (push) Failing after 37m39s
CI / Test (ubuntu-latest, Node 22.x, yarn) (push) Failing after 34m7s
CI / Validate Components (push) Failing after 37m15s
CI / Python Tests (push) Failing after 10m1s
CI / Security Scan (push) Failing after 10m1s
CI / Lint (push) Failing after 17m12s
CI / Coverage (push) Failing after 20m19s
CI / Test (macos-latest, Node 18.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, yarn) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
---
|
||||
paths:
|
||||
- "**/*.py"
|
||||
- "**/*.pyi"
|
||||
---
|
||||
# Python コーディングスタイル
|
||||
|
||||
> このファイルは [common/coding-style.md](../common/coding-style.md) を Python 固有のコンテンツで拡張します。
|
||||
|
||||
## 標準
|
||||
|
||||
- **PEP 8** 規約に従う
|
||||
- すべての関数シグネチャに**型アノテーション**を使用する
|
||||
|
||||
## 不変性
|
||||
|
||||
不変データ構造を優先する:
|
||||
|
||||
```python
|
||||
from dataclasses import dataclass
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class User:
|
||||
name: str
|
||||
email: str
|
||||
|
||||
from typing import NamedTuple
|
||||
|
||||
class Point(NamedTuple):
|
||||
x: float
|
||||
y: float
|
||||
```
|
||||
|
||||
## フォーマット
|
||||
|
||||
- **black** — コードフォーマット
|
||||
- **isort** — インポートの並べ替え
|
||||
- **ruff** — リンティング
|
||||
|
||||
## リファレンス
|
||||
|
||||
スキル: `python-patterns` で包括的な Python のイディオムとパターンを参照してください。
|
||||
@@ -0,0 +1,58 @@
|
||||
---
|
||||
paths:
|
||||
- "**/app/**/*.py"
|
||||
- "**/fastapi/**/*.py"
|
||||
- "**/*_api.py"
|
||||
---
|
||||
# FastAPI ルール
|
||||
|
||||
FastAPI プロジェクトでは、一般的な Python ルールと併せてこれらのルールを使用してください。
|
||||
|
||||
## 構造
|
||||
|
||||
- アプリの構築は `create_app()` に配置する。
|
||||
- ルーターは薄く保つ; 永続化とビジネスロジックはサービスまたは CRUD ヘルパーに移動する。
|
||||
- リクエストスキーマ、更新スキーマ、レスポンススキーマは分離する。
|
||||
- データベースセッションと認証は依存関係に配置する。
|
||||
|
||||
## 非同期
|
||||
|
||||
- I/O を実行するエンドポイントには `async def` を使用する。
|
||||
- 非同期エンドポイントからは非同期データベースクライアントと HTTP クライアントを使用する。
|
||||
- 非同期ルートから `requests`、同期 SQLAlchemy セッション、またはブロッキングファイル/ネットワーク操作を呼び出さない。
|
||||
|
||||
## 依存性注入
|
||||
|
||||
```python
|
||||
@router.get("/users/{user_id}")
|
||||
async def get_user(
|
||||
user_id: str,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
...
|
||||
```
|
||||
|
||||
ルートハンドラ内で `SessionLocal()` や長寿命クライアントを作成しない。
|
||||
|
||||
## スキーマ
|
||||
|
||||
- レスポンスモデルにパスワード、パスワードハッシュ、アクセストークン、リフレッシュトークン、内部認証状態を含めない。
|
||||
- アプリケーションデータを返すエンドポイントには `response_model` を使用する。
|
||||
- 手書きのバリデーションの代わりに、Pydantic でルールを表現できる場合はフィールド制約を使用する。
|
||||
|
||||
## セキュリティ
|
||||
|
||||
- CORS オリジンは環境固有にする。
|
||||
- ワイルドカードオリジンと認証情報付き CORS を組み合わせない。
|
||||
- JWT の有効期限、発行者、オーディエンス、アルゴリズムを検証する。
|
||||
- 認証および書き込み負荷の高いエンドポイントにレート制限を適用する。
|
||||
- ログから認証情報、Cookie、Authorization ヘッダー、トークンを除去する。
|
||||
|
||||
## テスト
|
||||
|
||||
- `Depends` で使用される正確な依存関係をオーバーライドする。
|
||||
- テスト後に `app.dependency_overrides` をクリアする。
|
||||
- 非同期アプリケーションには非同期テストクライアントを優先する。
|
||||
|
||||
スキル: `fastapi-patterns` を参照してください。
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
paths:
|
||||
- "**/*.py"
|
||||
- "**/*.pyi"
|
||||
---
|
||||
# Python フック
|
||||
|
||||
> このファイルは [common/hooks.md](../common/hooks.md) を Python 固有のコンテンツで拡張します。
|
||||
|
||||
## PostToolUse フック
|
||||
|
||||
`~/.claude/settings.json` で設定:
|
||||
|
||||
- **black/ruff**: 編集後に `.py` ファイルを自動フォーマット
|
||||
- **mypy/pyright**: `.py` ファイル編集後に型チェックを実行
|
||||
|
||||
## 警告
|
||||
|
||||
- 編集されたファイル内の `print()` 文について警告する(代わりに `logging` モジュールを使用)
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
paths:
|
||||
- "**/*.py"
|
||||
- "**/*.pyi"
|
||||
---
|
||||
# Python パターン
|
||||
|
||||
> このファイルは [common/patterns.md](../common/patterns.md) を Python 固有のコンテンツで拡張します。
|
||||
|
||||
## Protocol(ダックタイピング)
|
||||
|
||||
```python
|
||||
from typing import Protocol
|
||||
|
||||
class Repository(Protocol):
|
||||
def find_by_id(self, id: str) -> dict | None: ...
|
||||
def save(self, entity: dict) -> dict: ...
|
||||
```
|
||||
|
||||
## DTO としての Dataclass
|
||||
|
||||
```python
|
||||
from dataclasses import dataclass
|
||||
|
||||
@dataclass
|
||||
class CreateUserRequest:
|
||||
name: str
|
||||
email: str
|
||||
age: int | None = None
|
||||
```
|
||||
|
||||
## コンテキストマネージャとジェネレータ
|
||||
|
||||
- リソース管理にはコンテキストマネージャ(`with` 文)を使用する
|
||||
- 遅延評価とメモリ効率の良いイテレーションにはジェネレータを使用する
|
||||
|
||||
## リファレンス
|
||||
|
||||
スキル: `python-patterns` でデコレータ、並行処理、パッケージ構成を含む包括的なパターンを参照してください。
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
paths:
|
||||
- "**/*.py"
|
||||
- "**/*.pyi"
|
||||
---
|
||||
# Python セキュリティ
|
||||
|
||||
> このファイルは [common/security.md](../common/security.md) を Python 固有のコンテンツで拡張します。
|
||||
|
||||
## シークレット管理
|
||||
|
||||
```python
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
api_key = os.environ["OPENAI_API_KEY"] # 未設定の場合 KeyError を発生
|
||||
```
|
||||
|
||||
## セキュリティスキャン
|
||||
|
||||
- **bandit** を使用して静的セキュリティ解析を実行:
|
||||
```bash
|
||||
bandit -r src/
|
||||
```
|
||||
|
||||
## リファレンス
|
||||
|
||||
スキル: `django-security` で Django 固有のセキュリティガイドラインを参照してください(該当する場合)。
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
paths:
|
||||
- "**/*.py"
|
||||
- "**/*.pyi"
|
||||
---
|
||||
# Python テスト
|
||||
|
||||
> このファイルは [common/testing.md](../common/testing.md) を Python 固有のコンテンツで拡張します。
|
||||
|
||||
## フレームワーク
|
||||
|
||||
テストフレームワークとして **pytest** を使用する。
|
||||
|
||||
## カバレッジ
|
||||
|
||||
```bash
|
||||
pytest --cov=src --cov-report=term-missing
|
||||
```
|
||||
|
||||
## テストの構成
|
||||
|
||||
テスト分類には `pytest.mark` を使用する:
|
||||
|
||||
```python
|
||||
import pytest
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_calculate_total():
|
||||
...
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_database_connection():
|
||||
...
|
||||
```
|
||||
|
||||
## リファレンス
|
||||
|
||||
スキル: `python-testing` で詳細な pytest パターンとフィクスチャを参照してください。
|
||||
Reference in New Issue
Block a user