Merge branch 'main' into fix218

This commit is contained in:
Zhichang Yu 2025-11-14 11:59:48 +08:00 committed by GitHub
commit 0a27ae7b30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

View file

@ -96,7 +96,7 @@ jobs:
args: "check"
- name: Check comments of changed Python files
if: ${{ !cancelled() && !failure() }}
if: ${{ false }}
run: |
if [[ ${{ github.event_name }} == 'pull_request_target' ]]; then
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} \
@ -110,7 +110,7 @@ jobs:
for file in "${files[@]}"; do
if [ -f "$file" ]; then
if python3 check_comment_ascii.py $file"; then
if python3 check_comment_ascii.py "$file"; then
echo "✅ $file"
else
echo "❌ $file"

View file

@ -1,16 +1,28 @@
#!/usr/bin/env python3
"""
Check whether given python files contain non-ASCII comments.
How to check the whole git repo:
```
$ git ls-files -z -- '*.py' | xargs -0 python3 check_comment_ascii.py
```
"""
import sys
import tokenize
import ast
import pathlib
import re
ASCII = re.compile(r"^[ -~]*\Z") # Only printable ASCII
ASCII = re.compile(r"^[\n -~]*\Z") # Printable ASCII + newline
def check(src: str, name: str) -> int:
"""
I'm a docstring
docstring line 1
docstring line 2
"""
ok = 1
# A common comment begins with `#`