Skip to content

Commit ef3d718

Browse files
committed
pre-commit reformatting
1 parent 4f9da3e commit ef3d718

File tree

8 files changed

+32
-14
lines changed

8 files changed

+32
-14
lines changed

.github/workflows/code_quality_checks.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ permissions:
66

77
on: [pull_request]
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
pre-commit:
1114
runs-on: [ self-hosted ]
1215
container: python:3.10
1316

1417
steps:
1518
- uses: actions/checkout@v3
16-
- uses: pre-commit/action@v3.0.1
17-
19+
- name: setup environment
20+
run: |
21+
./dev-setup.sh
22+
- name: run pre-commit hooks
23+
run: |
24+
pre-commit run --all-files --show-diff-on-failure --color=always
1825
- name: Print message on failure
1926
if: failure()
2027
run: |

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ repos:
1515
rev: 25.1.0
1616
hooks:
1717
- id: black
18+
- repo: https://github.com/pre-commit/mirrors-mypy
19+
rev: v1.15.0
20+
hooks:
21+
- id: mypy
22+
args: [--install-types, --non-interactive, --explicit-package-bases, --allow-redefinition]
23+
language: system

nodescraper/interfaces/dataanalyzertask.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ def __init_subclass__(cls, **kwargs: dict[str, Any]) -> None:
125125
def analyze_data(
126126
self,
127127
data: TDataModel,
128-
args: Optional[TAnalyzeArg | dict],
128+
args: Optional[TAnalyzeArg],
129129
) -> TaskResult:
130130
"""Analyze the provided data and return a TaskResult
131131
132132
Args:
133133
data (TDataModel): data to analyze
134-
args (Optional[TAnalyzeArg | dict]): Optional arguments for analysis, can be a model or dict
134+
args (Optional[TAnalyzeArg]): Optional arguments for analysis. Dicts will be handled in the decorator"
135135
136136
Returns:
137137
TaskResult: Task result containing the analysis outcome

nodescraper/interfaces/task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def max_event_priority_level(self, input_value: str | EventPriority):
8181
if isinstance(input_value, str):
8282
value: EventPriority = getattr(EventPriority, input_value)
8383
elif isinstance(input_value, EventPriority):
84-
value: EventPriority = input_value
84+
value: EventPriority = input_value # type:ignore
8585
else:
8686
raise ValueError(f"Invalid type for max_event_priority_level: {type(input_value)}")
8787

nodescraper/models/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Event(BaseModel):
5151
default_factory=lambda: datetime.datetime.now(datetime.timezone.utc)
5252
)
5353
reporter: str = "ERROR_SCRAPER"
54-
category: str
54+
category: str | Enum
5555
description: str
5656
data: dict = Field(default_factory=dict)
5757
priority: EventPriority

nodescraper/plugins/inband/cmdline/cmdline_analyzer.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# SOFTWARE.
2424
#
2525
###############################################################################
26-
from typing import Optional
26+
from typing import Any, Optional
2727

2828
from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus
2929
from nodescraper.interfaces import DataAnalyzer
@@ -38,13 +38,15 @@ class CmdlineAnalyzer(DataAnalyzer[CmdlineDataModel, CmdlineAnalyzerArgs]):
3838

3939
DATA_MODEL = CmdlineDataModel
4040

41-
def _compare_cmdline(self, cmdline: str, required_cmdline: list, banned_cmdline: list) -> bool:
41+
def _compare_cmdline(
42+
self, cmdline: str, required_cmdline: str | list[Any], banned_cmdline: str | list[Any]
43+
) -> bool:
4244
"""Compare the kernel cmdline against required and banned cmdline arguments.
4345
4446
Args:
4547
cmdline (str): Kernel command line arguments as a string.
46-
required_cmdline (list): required kernel cmdline arguments that must be present.
47-
banned_cmdline (list): banned kernel cmdline arguments that must not be present.
48+
required_cmdline (str) | (list): required kernel cmdline arguments that must be present.
49+
banned_cmdline (str) | (list): banned kernel cmdline arguments that must not be present.
4850
4951
Returns:
5052
bool: True if the cmdline matches the required arguments and does not contain banned arguments,

nodescraper/resultcollators/tablesummary.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def collate_results(
4040
connection_results (list[TaskResult]): list of connection results to collate
4141
"""
4242

43-
def gen_str_table(headers: list[str], rows: list[str]):
43+
def gen_str_table(headers: list[str], rows: list[list[str | None]]):
4444
column_widths = [len(header) for header in headers]
4545
for row in rows:
4646
for i, cell in enumerate(row):
@@ -67,8 +67,10 @@ def gen_row(row):
6767

6868
if plugin_results:
6969
rows = []
70-
for result in plugin_results:
71-
rows.append([result.source, result.status.name, result.message])
70+
for plugin_result in plugin_results:
71+
rows.append(
72+
[plugin_result.source, plugin_result.status.name, plugin_result.message]
73+
)
7274

7375
table = gen_str_table(["Plugin", "Status", "Message"], rows)
7476
tables += f"\n\n{table}"

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ dev = [
2828
"ruff",
2929
"pre-commit",
3030
"pytest",
31-
"pytest-cov"
31+
"pytest-cov",
32+
"mypy"
3233
]
3334

3435
[project.urls]

0 commit comments

Comments
 (0)