Skip to content
Open
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: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Install poetry
run: pip install poetry
- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
cache: 'poetry'
cache-dependency-path: "tests/pyproject.toml"
Expand All @@ -77,7 +77,7 @@ jobs:
- name: Install poetry
run: pip install poetry
- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: '3.12'
cache: 'poetry'
Expand Down
21 changes: 12 additions & 9 deletions scripts/checkstyle.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env python3
import re
import os
import argparse
import os
import re
import sys
from collections.abc import Callable # Compatibility.
from pathlib import Path
from typing import Callable, List, Dict, Any # compat
from typing import Any

# This file checks Bash and Shell scripts for violations not found with
# shellcheck or existing methods. You can use it in several ways:
Expand All @@ -21,7 +23,7 @@
# Check to ensure all regular expressions are working as intended:
# $ ./scripts/checkstyle.py --internal-test-regex

Rule = Dict[str, Any]
Rule = dict[str, Any]

class c:
RED = '\033[91m'
Expand Down Expand Up @@ -91,7 +93,7 @@ def noVerboseRedirectionFixer(line: str, m: Any) -> str:

return f'{prestr}&>/dev/null{poststr}'

def lintfile(file: Path, rules: List[Rule], options: Dict[str, Any]):
def lintfile(file: Path, rules: list[Rule], options: dict[str, Any]):
content_arr = file.read_text().split('\n')

for line_i, line in enumerate(content_arr):
Expand All @@ -100,6 +102,7 @@ def lintfile(file: Path, rules: List[Rule], options: Dict[str, Any]):

for rule in rules:
should_run = False
# ruff: noqa: SIM102
if 'sh' in rule['fileTypes']:
if file.name.endswith('.sh'):
should_run = True
Expand All @@ -108,7 +111,7 @@ def lintfile(file: Path, rules: List[Rule], options: Dict[str, Any]):
should_run = True

if options['verbose']:
print(f'{str(file)}: {should_run}')
print(f'{file!s}: {should_run}')

if not should_run:
continue
Expand All @@ -134,7 +137,7 @@ def lintfile(file: Path, rules: List[Rule], options: Dict[str, Any]):
file.write_text('\n'.join(content_arr))

def main():
rules: List[Rule] = [
rules: list[Rule] = [
{
'name': 'no-pwd-capture',
'regex': '(?P<match>\\$\\(pwd\\))',
Expand Down Expand Up @@ -255,8 +258,8 @@ def main():

# exit
if grand_total == 0:
exit(0)
sys.exit(0)
else:
exit(2)
sys.exit(2)

main()
Loading