Skip to content
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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ insert_final_newline = unset
[*.sh]
indent_size = 2

# JSON
[*.json]
indent_style = tab

# YAML
[*.{yml,yaml}]
indent_size = 2
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
# Shell
*.sh text diff=bash

# JSON
*.json text

# YAML
*.yml text
*.yaml text
Expand Down
17 changes: 7 additions & 10 deletions .github/scripts/resolve_competitive_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import sys
import tomllib
from pathlib import Path
from typing import Any, cast
from typing import Any, Never, cast

EXPECTED_GIT_URL = "https://github.com/NotLeonian/competitive-verifier"
SHA_RE = re.compile(r"^[0-9a-fA-F]{40}$")


def error(message: str) -> None:
def error(message: str) -> Never:
print(f"::error::{message}", file=sys.stderr)
raise SystemExit(1)

Expand Down Expand Up @@ -44,9 +44,7 @@ def normalize_git_url(source: dict[str, Any]) -> str:

url_without_suffix = git_url[:-4] if git_url.endswith(".git") else git_url
if url_without_suffix != EXPECTED_GIT_URL:
error(
f"competitive-verifier URL does not match the expected URL: {git_url!r}"
)
error(f"competitive-verifier URL does not match the expected URL: {git_url!r}")

return EXPECTED_GIT_URL + ".git"

Expand All @@ -61,9 +59,7 @@ def read_source_ref(source: dict[str, Any]) -> tuple[str, str]:
has_tag = "tag" in source

if has_rev == has_tag:
error(
"competitive-verifier must be pinned by exactly one of rev or tag."
)
error("competitive-verifier must be pinned by exactly one of rev or tag.")

if has_rev:
rev = source["rev"]
Expand Down Expand Up @@ -115,8 +111,9 @@ def resolve_tag_to_commit(git_url: str, tag: str) -> str:

resolved = peeled_sha or direct_sha
if resolved is None or not SHA_RE.fullmatch(resolved):
error(f"Could not resolve the competitive-verifier tag to a commit SHA: {tag!r}")
assert False # 上の error で落ちる、型注釈のエラーを防ぐため
error(
f"Could not resolve the competitive-verifier tag to a commit SHA: {tag!r}"
)

return resolved.lower()

Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ bash .github/scripts/local_verify.sh "$@"
' _ --no-prev-result
```

## Python checks

Python ソースコードのフォーマットと静的検査には以下のコマンドを使用できます。

```sh
uv run ruff format .
uv run ruff check .
git ls-files -z --cached --others --exclude-standard -- '*.py' |
xargs -0 -r uv run pyright --project pyright-checks.json
git ls-files -z --cached --others --exclude-standard -- '*.py' |
xargs -0 -r uv run mypy
```

## Contributing

不具合の指摘または修正の Issue, Pull Request は歓迎します。
Expand Down
4 changes: 4 additions & 0 deletions STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
- `main` 関数内の全ての `return 0;` の前の行には、空行を 1 行入れる。
- `main` 関数の最後の行にも `return 0;` を記述する。

## Python ソースコード
- Ruff によるフォーマットおよび、Mypy, Pyright, Ruff による静的検査でエラーが検出されないようにする。
- なお、フォーマットや静的検査に用いる具体的なコマンドは [README.md](README.md) の「Python checks」の節に記述してある。

## ドキュメント(共通)
- TeX 数式の囲みは `$ $` とする(`\( \)` などでない)。
- TeX 数式の前後は、必ず空白または改行とする(たとえ前後が句読点や括弧であっても、`$` との間に空白を入れる)。
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ dependencies = []
[dependency-groups]
dev = [
"competitive-verifier",
"mypy>=2.3.0",
"pyright>=1.1.411",
"ruff>=0.15.12",
]

[tool.mypy]
python_version = "3.13"

[tool.pyright]
pythonVersion = "3.13"

[tool.ruff.format]
quote-style = "preserve"

Expand Down
17 changes: 17 additions & 0 deletions pyright-checks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "./pyproject.toml",
"exclude": [
"**/node_modules",
"**/__pycache__",
"**/.git",
"**/.env",
"**/.venv",
Comment thread
NotLeonian marked this conversation as resolved.
"**/env",
"**/venv",
"**/ENV",
"**/env.bak",
"**/venv.bak",
".competitive-verifier/cache"
],
"include": ["**/*.py"]
}
176 changes: 176 additions & 0 deletions uv.lock

Large diffs are not rendered by default.

Loading