mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-09 12:54:17 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
5802220a75
commit
3693804f64
1 changed files with 7 additions and 4 deletions
|
|
@ -1,10 +1,13 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
|
|
||||||
def check_naming_convention(files):
|
def check_naming_convention(files):
|
||||||
for file_path in files:
|
for file_path in files:
|
||||||
with open(file_path, 'r') as file:
|
with open(file_path) as file:
|
||||||
lines = file.readlines()
|
lines = file.readlines()
|
||||||
for line_num, line in enumerate(lines, start=1):
|
for line_num, line in enumerate(lines, start=1):
|
||||||
words = re.findall(r'\b[a-zA-Z0-9_]+\b', line)
|
words = re.findall(r'\b[a-zA-Z0-9_]+\b', line)
|
||||||
|
|
@ -13,8 +16,8 @@ def check_naming_convention(files):
|
||||||
continue # Valid snake_case
|
continue # Valid snake_case
|
||||||
elif re.match(r'^[A-Z][a-zA-Z0-9]*$', word):
|
elif re.match(r'^[A-Z][a-zA-Z0-9]*$', word):
|
||||||
if '_' in word:
|
if '_' in word:
|
||||||
print(f"WARNING: CamelCase with underscores found in {os.path.basename(file_path)}:{line_num}: {word}")
|
print(f'WARNING: CamelCase with underscores found in {os.path.basename(file_path)}:{line_num}: {word}')
|
||||||
continue # Valid CamelCase
|
continue # Valid CamelCase
|
||||||
else:
|
else:
|
||||||
print(f"ERROR: Invalid naming convention in {os.path.basename(file_path)}:{line_num}: {word}")
|
print(f'ERROR: Invalid naming convention in {os.path.basename(file_path)}:{line_num}: {word}')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue