Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-commitでformat, lintを自動実行 #15

Merged
merged 6 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
47 changes: 47 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ref: https://github.com/osushinekotan/uv-template/blob/main/%7B%7Bcookiecutter.project_slug%7D%7D/.pre-commit-config.yaml
repos:
# python linter and formatter
- repo: local # use local ruff
hooks:
# Run the linter.
- id: ruff
name: ruff-lint
types_or: [python, jupyter]
entry: uv run ruff check . --fix
language: python

# Run the formatter.
- id: ruff-format
name: ruff-format
entry: uv run ruff format .
language: python
types_or: [python, jupyter]

# yaml, json formatting
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types: [yaml, json]

# md formatting
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
args: ["--number"] # ファイル内の見出しに番号を自動的に付ける
additional_dependencies:
- mdformat-gfm
- mdformat-tables
- mdformat_frontmatter

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
# list of supported hooks: https://pre-commit.com/hooks.html
- id: trailing-whitespace # 行末の不要な空白を削除
- id: end-of-file-fixer # ファイルの末尾に改行を保証
- id: detect-private-key # プライベートキーがコミットされていないかをチェック
- id: check-toml # TOMLファイルの構文エラーをチェック
- id: check-case-conflict # ファイル名の大文字小文字の競合を検出
- id: check-added-large-files # 特定のサイズを超える大きなファイルが追加された場合に警告
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ $ pip install uv

```
uv sync
```
```

3. activate pre-commit

```
uv run pre-commit install
```
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ index-url = "https://download.pytorch.org/whl/cu121"

[tool.uv]
managed = true
dev-dependencies = ["jupyter>=1.1.1", "mypy==1.11.2", "ruff>=0.6.6"]
dev-dependencies = [
"jupyter>=1.1.1",
"mypy==1.11.2",
"pre-commit>=3.8.0",
"ruff>=0.6.9",
]

[tool.mypy]
allow_redefinition = true
Expand Down
Loading