Skip to content

Commit 1f5f4a7

Browse files
committed
pre-commit reformatting
1 parent 798d8d2 commit 1f5f4a7

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
@@ -3,15 +3,22 @@ name: Code Quality Check
33

44
on: [pull_request]
55

6+
permissions:
7+
contents: read
8+
69
jobs:
710
pre-commit:
811
runs-on: [ self-hosted ]
912
container: python:3.10
1013

1114
steps:
1215
- uses: actions/checkout@v3
13-
- uses: pre-commit/[email protected]
14-
16+
- name: setup environment
17+
run: |
18+
./dev-setup.sh
19+
- name: run pre-commit hooks
20+
run: |
21+
pre-commit run --all-files --show-diff-on-failure --color=always
1522
- name: Print message on failure
1623
if: failure()
1724
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
@@ -126,13 +126,13 @@ def __init_subclass__(cls, **kwargs: dict[str, Any]) -> None:
126126
def analyze_data(
127127
self,
128128
data: TDataModel,
129-
args: Optional[TAnalyzeArg | dict],
129+
args: Optional[TAnalyzeArg],
130130
) -> TaskResult:
131131
"""Analyze the provided data and return a TaskResult
132132
133133
Args:
134134
data (TDataModel): data to analyze
135-
args (Optional[TAnalyzeArg | dict]): Optional arguments for analysis, can be a model or dict
135+
args (Optional[TAnalyzeArg]): Optional arguments for analysis. Dicts will be handled in the decorator"
136136
137137
Returns:
138138
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)