diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml new file mode 100644 index 0000000..81a9adf --- /dev/null +++ b/.github/workflows/codestyle.yml @@ -0,0 +1,23 @@ +name: Code Style Check + +on: + pull_request: + push: + branches: ['main', 'release/*'] + +jobs: + check-code-style: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + # Install Dependencies for Python + - name: Install Dependencies for Python + run: | + python -m pip install --upgrade pip + pip install "clang-format==13.0.0" + - uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a94ef86 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,50 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: a11d9314b22d8f8c7556443875b731ef05965464 + hooks: + - id: check-merge-conflict + - id: check-symlinks + - id: detect-private-key + files: (?!.*paddle)^.*$ + - id: end-of-file-fixer + files: \.md$ + - id: trailing-whitespace + files: \.md$ +- repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.0.1 + hooks: + - id: forbid-crlf + files: \.md$ + - id: remove-crlf + files: \.md$ + - id: forbid-tabs + files: \.md$ + - id: remove-tabs + files: \.md$ +- repo: local + hooks: + - id: clang-format + name: clang-format + description: Format files with ClangFormat + entry: bash .clang_format.hook -i + language: system + files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$ +# For Python files +- repo: https://github.com/psf/black.git + rev: 23.3.0 + hooks: + - id: black + files: (.*\.(py|pyi|bzl)|BUILD|.*\.BUILD|WORKSPACE)$ + +# Flake8 +- repo: https://github.com/pycqa/flake8 + rev: 7.0.0 + hooks: + - id: flake8 + args: + - --count + - --select=E9,F63,F7,F82 + - --show-source + - --statistics + exclude: ^benchmark/|^test_tipc/ + diff --git a/libs/ustr.py b/libs/ustr.py index 51d8ce4..01dfce3 100644 --- a/libs/ustr.py +++ b/libs/ustr.py @@ -25,7 +25,7 @@ def ustr(x): if type(x) == QString: # https://blog.csdn.net/friendan/article/details/51088476 # https://blog.csdn.net/xxm524/article/details/74937308 - return unicode(x.toUtf8(), DEFAULT_ENCODING, "ignore") + return unicode(x.toUtf8(), DEFAULT_ENCODING, "ignore") # noqa return x else: return x