Skip to content

Commit f334b11

Browse files
AlexanderViand-IntelAlexanderViandjoserochh
authored
pre-commit improvements (#112)
* improve pre-commit setup * automatic changes * manual fixes * Update tests to work with newly cleaned up code * updated tests to expect new calls (w/o redundant default arguments passed in) * made pydantic happy by explicitly defaulting an int | None arg to None * Mocking for instruction in assembler tests is now done with `spec` instead of overwriting `isinstance` * Update graph.h * revert use of union type in isinstance * insert-license: warn if fuzzy match found * remove duplicate license headers * allow prior years in license headers * remove redundant pytest.ini files --------- Co-authored-by: Alexander Viand <alexander.viand@intel.com> Co-authored-by: Jose Rojas Chaves <jose.rojas.chaves@intel.com>
1 parent 8edca51 commit f334b11

File tree

210 files changed

+3175
-3821
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+3175
-3821
lines changed

.clang-format

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
---
32
Language: Cpp
43
BasedOnStyle: Microsoft
54
AccessModifierOffset: -4

.github/workflows/format.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,12 @@ jobs:
1313
runs-on: ubuntu-24.04
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1717

1818
- name: Set up Python
19-
uses: actions/setup-python@v5
19+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2020
with:
2121
python-version: '3.10'
2222

23-
- name: Install Development Dependencies
24-
run: pip install -r requirements-dev.txt
25-
26-
- name: Installing Component-specific Dependencies
27-
run: pip install -r assembler_tools/hec-assembler-tools/requirements.txt
28-
29-
- name: Install Apt Dependencies
30-
run: sudo apt install -y clang-format-14
31-
32-
- name: Fetch main branch for diff
33-
run: git fetch origin main
34-
35-
- name: Run pre-commit on changed files only
36-
run: pre-commit run --from-ref origin/main --to-ref HEAD
23+
- name: Run pre-commit
24+
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

.pre-commit-config.yaml

Lines changed: 29 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
default_language_version:
5-
# force all unspecified python hooks to run python3
5+
# force all unspecified python hooks to run python3.10
66
python: python3.10
77
repos:
88
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -15,6 +15,7 @@ repos:
1515
- id: check-yaml
1616
args:
1717
- --allow-multiple-documents
18+
- id: fix-byte-order-marker
1819
- repo: https://github.com/crate-ci/typos
1920
rev: v1.33.1 # Updated 2025/06
2021
hooks:
@@ -28,75 +29,45 @@ repos:
2829
name: insert-license-shell
2930
files: \.(sh|py)$
3031
args:
31-
- --license-filepath
32-
# defaults to: LICENSE.txt
33-
- HEADER
32+
- --license-filepath=HEADER
33+
- --use-current-year
34+
- --allow-past-years
35+
- --detect-license-in-X-top-lines=10
36+
- --fuzzy-ratio-cut-off=50
37+
- --remove-header
3438
- id: insert-license
3539
name: insert-license-cpp
3640
files: \.(c|cc|cxx|cpp|h|hpp|hxx|inl|h.in)$
3741
args:
38-
- --license-filepath
39-
# defaults to: LICENSE.txt
40-
- HEADER
41-
- --comment-style
42-
- // # defaults to: #
42+
- --license-filepath=HEADER
43+
- --comment-style=//
44+
- --use-current-year
45+
- --allow-past-years
46+
- --detect-license-in-X-top-lines=10
47+
- --fuzzy-ratio-cut-off=50
48+
- --remove-header
4349
- id: remove-tabs
4450
name: remove-tabs
4551
files: \.(py)$
4652
args: [--whitespaces-count, '4']
47-
- repo: https://github.com/psf/black-pre-commit-mirror
48-
rev: 25.1.0 # Updated 2025/06
53+
- repo: https://github.com/astral-sh/ruff-pre-commit
54+
rev: v0.8.4
4955
hooks:
50-
- id: black
51-
language_version: python3.10
56+
- id: ruff
57+
args: [--fix] # Automatically fix issues when possible
58+
- id: ruff-format # Replaces black
5259
- repo: https://github.com/pre-commit/mirrors-mypy
5360
rev: v1.16.0 # Last checked 2025/06
5461
hooks:
5562
- id: mypy
56-
language: system
57-
exclude: >-
58-
^(assembler_tools/hec-assembler-tools/assembler/common/run_config\.py|
59-
*assembler_tools/hec-assembler-tools/assembler/instructions/|
60-
*assembler_tools/hec-assembler-tools/assembler/memory_model/|
61-
*assembler_tools/hec-assembler-tools/assembler/stages/asm_scheduler\.py|
62-
*assembler_tools/hec-assembler-tools/assembler/stages/scheduler\.py|
63-
*assembler_tools/hec-assembler-tools/debug_tools/main\.py|
64-
*assembler_tools/hec-assembler-tools/debug_tools/xinst_timing_check/|
65-
*assembler_tools/hec-assembler-tools/he_as\.py|
66-
*assembler_tools/hec-assembler-tools/assembler/spec_config/isa_spec.py)
67-
args: ["--follow-imports=skip", "--install-types", "--non-interactive"]
68-
- repo: local
63+
pass_filenames: false
64+
- repo: https://github.com/pre-commit/mirrors-clang-format
65+
rev: "v18.1.2"
66+
hooks:
67+
- id: clang-format
68+
exclude_types: [json] # skip *.json and *.JSON
69+
args: ["--style=file"]
70+
- repo: https://github.com/cpplint/cpplint
71+
rev: "2.0.2"
6972
hooks:
70-
- id: pylint
71-
name: pylint
72-
entry: pylint
73-
language: system
74-
types: [python]
75-
exclude: >-
76-
^(assembler_tools/hec-assembler-tools/assembler/common/run_config\.py|
77-
*assembler_tools/hec-assembler-tools/assembler/instructions/|
78-
*assembler_tools/hec-assembler-tools/assembler/memory_model/|
79-
*assembler_tools/hec-assembler-tools/assembler/stages/asm_scheduler\.py|
80-
*assembler_tools/hec-assembler-tools/assembler/stages/scheduler\.py|
81-
*assembler_tools/hec-assembler-tools/debug_tools/main\.py|
82-
*assembler_tools/hec-assembler-tools/debug_tools/xinst_timing_check/|
83-
*assembler_tools/hec-assembler-tools/he_as\.py|
84-
*assembler_tools/hec-assembler-tools/assembler/spec_config/isa_spec.py)
85-
args:
86-
- -rn # Only display messages
87-
- -sn # Don't display the score
88-
- --source-roots=p-isa_tools/kerngen,assembler_tools/hec-assembler-tools
89-
- id: clang-format-14
90-
name: clang-format-14
91-
entry: clang-format-14
92-
language: system
93-
files: \.(c|cc|cxx|cpp|h|hpp|hxx|inl)$
94-
args: ["-i", "--style=file"]
9573
- id: cpplint
96-
name: cpplint
97-
entry: cpplint
98-
language: system
99-
files: \.(c|cc|cxx|cpp|h|hpp|hxx)$
100-
args:
101-
- --recursive
102-
- --filter=-build/c++17

.pylintrc

Lines changed: 0 additions & 27 deletions
This file was deleted.

.typos.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@
88
# variation of params
99
parms = "parms"
1010
bload = "bload"
11+
12+
[files]
13+
extend-exclude = [
14+
"requirements-dev.txt",
15+
]

HEADER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Copyright (C) 2025 Intel Corporation
1+
Copyright (C) {year} Intel Corporation
22
SPDX-License-Identifier: Apache-2.0

assembler_tools/hec-assembler-tools/assembler/common/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
14
import os
25

6+
37
def makeUniquePath(path: str) -> str:
48
"""
59
Returns a unique, normalized, and absolute version of the given file path.

0 commit comments

Comments
 (0)