Merge branch 'main' into fix218
This commit is contained in:
commit
0a27ae7b30
2 changed files with 16 additions and 4 deletions
4
.github/workflows/tests.yml
vendored
4
.github/workflows/tests.yml
vendored
|
|
@ -96,7 +96,7 @@ jobs:
|
||||||
args: "check"
|
args: "check"
|
||||||
|
|
||||||
- name: Check comments of changed Python files
|
- name: Check comments of changed Python files
|
||||||
if: ${{ !cancelled() && !failure() }}
|
if: ${{ false }}
|
||||||
run: |
|
run: |
|
||||||
if [[ ${{ github.event_name }} == 'pull_request_target' ]]; then
|
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 }} \
|
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
|
for file in "${files[@]}"; do
|
||||||
if [ -f "$file" ]; then
|
if [ -f "$file" ]; then
|
||||||
if python3 check_comment_ascii.py $file"; then
|
if python3 check_comment_ascii.py "$file"; then
|
||||||
echo "✅ $file"
|
echo "✅ $file"
|
||||||
else
|
else
|
||||||
echo "❌ $file"
|
echo "❌ $file"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,28 @@
|
||||||
#!/usr/bin/env python3
|
#!/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 sys
|
||||||
import tokenize
|
import tokenize
|
||||||
import ast
|
import ast
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
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:
|
def check(src: str, name: str) -> int:
|
||||||
"""
|
"""
|
||||||
I'm a docstring
|
docstring line 1
|
||||||
|
docstring line 2
|
||||||
"""
|
"""
|
||||||
ok = 1
|
ok = 1
|
||||||
# A common comment begins with `#`
|
# A common comment begins with `#`
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue