Skip to content

Commit 57cb0de

Browse files
authored
Enable python linters and formatters (#5)
1 parent 0a7ae5b commit 57cb0de

File tree

7 files changed

+69
-5
lines changed

7 files changed

+69
-5
lines changed

.bazelrc

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,34 @@ build --incompatible_autoload_externally=
3737
build:verilator_lint --aspects=//verilator:verilator_lint_aspect.bzl%verilator_lint_aspect
3838
build:verilator_lint --output_groups=+verilator_lint_checks
3939

40-
test --config=verilator_lint
40+
# Enable black for all targets in the workspace
41+
build:black --aspects=@rules_venv//python/black:defs.bzl%py_black_aspect
42+
build:black --output_groups=+py_black_checks
43+
44+
# Enable isort for all targets in the workspace
45+
build:isort --aspects=@rules_venv//python/isort:defs.bzl%py_isort_aspect
46+
build:isort --output_groups=+py_isort_checks
47+
build --@rules_venv//python/isort:config=//:.isort.cfg
48+
49+
# Enable mypy for all targets in the workspace
50+
build:mypy --aspects=@rules_venv//python/mypy:defs.bzl%py_mypy_aspect
51+
build:mypy --output_groups=+py_mypy_checks
52+
build --@rules_venv//python/mypy:config=//:.mypy.ini
53+
54+
# Enable pylint for all targets in the workspace
55+
build:pylint --aspects=@rules_venv//python/pylint:defs.bzl%py_pylint_aspect
56+
build:pylint --output_groups=+py_pylint_checks
57+
build --@rules_venv//python/pylint:config=//:.pylintrc.toml
58+
59+
# Define a config that enables all linter aspects.
60+
build:strict --config=verilator_lint
61+
build:strict --config=black
62+
build:strict --config=isort
63+
build:strict --config=pylint
64+
build:strict --config=mypy
65+
66+
67+
test --config=strict
4168

4269
###############################################################################
4370
## Custom user flags

.isort.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[settings]
2+
profile = black

.mypy.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# https://mypy.readthedocs.io/en/stable/config_file.html
2+
[mypy]
3+
4+
# Improve strictness of checks
5+
strict = True
6+
7+
# Improve logging
8+
pretty = True
9+
10+
# Improve behavior in actions.
11+
explicit_package_bases = True

.pylintrc.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[tool.pylint.main]
2+
3+
# Allow loading of arbitrary C extensions. Extensions are imported into the
4+
# active Python interpreter and may run arbitrary code.
5+
unsafe-load-any-extension = true
6+
7+
# Limit actions to using 1 core per action.
8+
jobs = 1
9+
10+
disable = [
11+
"fixme", # Developers should be allowed to leave TODO comments.
12+
"wrong-import-position", # isort is in charge of import ordering.
13+
"wrong-import-order", # isort is in charge of import ordering.
14+
"line-too-long", # Black is responsible for shortening where possible.
15+
]

BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
exports_files([
2+
".isort.cfg",
3+
".mypy.ini",
4+
".pylintrc.toml",
5+
"LICENSE",
26
"MODULE.bazel",
37
"version.bzl",
4-
"LICENSE",
58
])

system_rdl/private/BUILD.bazel

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ current_system_rdl_peakrdl_toolchain(
66
name = "current_system_rdl_peakrdl_toolchain",
77
)
88

9-
py_binary(
9+
alias(
1010
name = "peakrdl",
11+
actual = "peakrdl_wrapper",
12+
visibility = ["//visibility:public"],
13+
)
14+
15+
py_binary(
16+
name = "peakrdl_wrapper",
1117
srcs = [
12-
"peakrdl.py",
18+
"peakrdl_wrapper.py",
1319
],
14-
main = "peakrdl.py",
20+
main = "peakrdl_wrapper.py",
1521
deps = [
1622
":current_system_rdl_peakrdl_toolchain",
1723
],

0 commit comments

Comments
 (0)