Skip to content

Commit 1f05ec0

Browse files
machshevhcallahan-lowrisc
authored andcommitted
linting: enforce space after license comment for python files
Signed-off-by: James McCorrie <[email protected]>
1 parent 8dad466 commit 1f05ec0

37 files changed

+68
-23
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright lowRISC contributors (OpenTitan project).
22
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
# SPDX-License-Identifier: Apache-2.0
4+
45
use flake
56

67
# create the venv if it doesn't yet exist

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright lowRISC contributors (OpenTitan project).
22
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
# SPDX-License-Identifier: Apache-2.0
4+
45
name: Python application
56

67
on:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright lowRISC contributors (OpenTitan project).
22
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
# SPDX-License-Identifier: Apache-2.0
4+
45
# Byte-compiled / optimized / DLL files
56
__pycache__/
67
*.py[cod]

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright lowRISC contributors (OpenTitan project).
22
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
# SPDX-License-Identifier: Apache-2.0
4+
45
[project]
56
name = "dvsim"
67
version = "0.1.0"

scripts/license_check.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Copyright lowRISC contributors (OpenTitan project).
33
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
44
# SPDX-License-Identifier: Apache-2.0
5+
56
"""Check all files for license header."""
67

78
import subprocess
@@ -25,8 +26,10 @@
2526

2627
IGNORE_SUFFIXES = [".lock"]
2728

29+
OPTIONAL_TRAILING_NEWLINE = [".nix", ".md"]
30+
2831

29-
def check_header(text: str) -> bool:
32+
def check_header(*, text: str, trailing_newline_optional: bool = False) -> bool:
3033
"""Check header complies with license requirmeents."""
3134
lines = text.splitlines()
3235

@@ -37,6 +40,7 @@ def check_header(text: str) -> bool:
3740
LICENSE[0] in lines[i],
3841
LICENSE[1] in lines[i + 1],
3942
LICENSE[2] in lines[i + 2],
43+
trailing_newline_optional or lines[i + 3] == "",
4044
]
4145
):
4246
return True
@@ -75,7 +79,10 @@ def check_header(text: str) -> bool:
7579

7680
logger.debug("Checking: %s", path)
7781

78-
if not check_header(text):
82+
if not check_header(
83+
text=text,
84+
trailing_newline_optional=path.suffix in OPTIONAL_TRAILING_NEWLINE,
85+
):
7986
failed.append(path)
8087

8188
for path in failed:

src/dvsim/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright lowRISC contributors (OpenTitan project).
22
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
# SPDX-License-Identifier: Apache-2.0
4+
45
"""DVSim."""

src/dvsim/cli.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Copyright lowRISC contributors (OpenTitan project).
22
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
# SPDX-License-Identifier: Apache-2.0
4-
"""dvsim is a command line tool to deploy ASIC tool flows such as regressions
5-
for design verification (DV), formal property verification (FPV), linting and
6-
synthesis.
4+
5+
"""dvsim is a command line tool to deploy ASIC tool flows.
6+
7+
Examples of a supported flow is regressions for design verification (DV),
8+
formal property verification (FPV), linting and synthesis.
79
810
It uses hjson as the format for specifying what to build and run. It is an
911
end-to-end regression manager that can deploy multiple builds (where some tests

src/dvsim/examples/testplanner/common_testplan.hjson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright lowRISC contributors (OpenTitan project).
22
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
// SPDX-License-Identifier: Apache-2.0
4+
45
{
56
testpoints: [
67
{

src/dvsim/examples/testplanner/foo_sim_results.hjson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright lowRISC contributors (OpenTitan project).
22
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
// SPDX-License-Identifier: Apache-2.0
4+
45
{
56
timestamp: 10/10/2019 1:55AM
67
test_results: [

src/dvsim/examples/testplanner/foo_testplan.hjson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright lowRISC contributors (OpenTitan project).
22
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
// SPDX-License-Identifier: Apache-2.0
4+
45
{
56
// 'name' is mandatory field
67
name: "foo"

0 commit comments

Comments
 (0)