🎨 Apply black formatting

This commit is contained in:
2024-12-14 01:15:29 +08:00
parent bf409f8564
commit 53d9cfb15a
58 changed files with 48 additions and 0 deletions
Regular → Executable
View File
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
+8
View File
@@ -1,5 +1,13 @@
fail_fast: true
repos:
- repo: local
hooks:
- id: check-filenames
name: Check Python Filenames
entry: python ./.pre-commit/check_filename.py
language: python
files: \.py$
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
import os
import re
import sys
def is_valid_filename(filename: str) -> bool:
"""文件名完整相对路径
Args:
filename (str): _description_
Returns:
bool: _description_
"""
# 检查文件名是否仅包含小写字母,数字,下划线
if not re.match(r"^[a-z0-9_]+\.py$", filename):
return False
else:
return True
def main():
invalid_files = []
for root, _, files in os.walk("nonebot_plugin_marshoai"):
for file in files:
if file.endswith(".py"):
if not is_valid_filename(file):
invalid_files.append(os.path.join(root, file))
if invalid_files:
print("以下文件名不符合命名规则:")
for file in invalid_files:
print(file)
sys.exit(1)
if __name__ == "__main__":
main()
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
View File
Regular → Executable
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
Regular → Executable
View File
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 121 KiB

Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 89 KiB

Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Regular → Executable
View File