Skip to content

Commit e7cf740

Browse files
committed
Add ruff output for code quality checks and address identified issues
- Created a new file `ruff_output.txt` to capture the output from the ruff linter. - Identified and documented multiple issues including: - Unsorted or unformatted import blocks in `__init__.py` and `backend_simulator.py`. - Magic values used in comparisons, suggesting replacement with constant variables. - Lines exceeding the maximum length in several files, including `backend_simulator.py` and `main.py`. - Highlighted the need for organizing imports and reducing line lengths to improve code readability and maintainability.
1 parent 96b3e0e commit e7cf740

7 files changed

Lines changed: 184 additions & 14 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ license = "MIT"
1111
license-files = ["LICEN[CS]E*"]
1212
dependencies = [
1313
"psutil>=7.1.3",
14+
"pydantic>=2.12.5",
1415
"pyyaml>=6.0.3",
1516
"rich>=14.2.0",
1617
]

ruff_output.txt

9.92 KB
Binary file not shown.

src/fortscript/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .main import FortScript, RamConfig, Callbacks
21
from .games import GAMES
2+
from .main import Callbacks, FortScript, RamConfig
33

44
__all__ = ['FortScript', 'RamConfig', 'GAMES', 'Callbacks']

src/fortscript/cookbook/project_with_games_list/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from fortscript import GAMES, Callbacks, FortScript, RamConfig
21
import logging
32
import os
43
import sys
54

5+
from fortscript import GAMES, Callbacks, FortScript, RamConfig
6+
67
# Ensure we can import fortscript from source
78
current_dir = os.path.dirname(os.path.abspath(__file__))
89
src_path = os.path.abspath(os.path.join(current_dir, '../../../'))

src/fortscript/games.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
Pre-defined list of popular games and heavy applications with their process names.
33
"""
44

5-
GAMES = [
5+
from .main import HeavyProcessConfig
6+
7+
GAMES: list[HeavyProcessConfig] = [
68
# Battle Royale / Shooter
79
{'name': 'Fortnite', 'process': 'fortnite'},
810
{'name': 'Fortnite', 'process': 'fortniteclient-win64-shipping'},

src/fortscript/main.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55
import time
66
from dataclasses import dataclass
7-
from typing import Any, Callable, TypedDict
7+
from typing import Any, Callable, Mapping, Sequence, TypedDict, cast
88

99
import psutil
1010
import yaml
@@ -81,21 +81,28 @@ class Callbacks:
8181
on_resume: Callable | None = None
8282

8383

84+
@dataclass
85+
class Functions:
86+
...
87+
88+
8489
class FortScript:
8590
"""Main class to manage scripts and monitor application status."""
8691

8792
def __init__(
8893
self,
8994
config_path: str = 'fortscript.yaml',
90-
projects: list[ProjectConfig] | None = None,
91-
heavy_process: list[HeavyProcessConfig] | None = None,
95+
projects: Sequence[Mapping[str, Any]] | None = None,
96+
functions: Functions | None = None,
97+
heavy_process: Sequence[Mapping[str, Any]] | None = None,
9298
ram_config: RamConfig | None = None,
9399
callbacks: Callbacks | None = None,
94100
log_level: str | int | None = None,
95101
new_console: bool = True,
96102
):
97103
"""
98-
Initializes FortScript with the configuration file and monitoring parameters.
104+
Initializes FortScript with the configuration file and monitoring
105+
parameters.
99106
100107
Args:
101108
config_path (str): The path to the YAML configuration file.
@@ -106,22 +113,25 @@ def __init__(
106113
ram_config (RamConfig, optional): RAM usage configuration.
107114
callbacks (Callbacks, optional): Callback functions for events.
108115
log_level (str | int, optional): Severity level for logging.
109-
new_console (bool): If True, launches scripts in a separate console.
116+
new_console (bool): If True, launches scripts in a separate
117+
console.
110118
"""
111119
self.new_console = new_console
112120
self.file_config = self.load_config(config_path)
113121

114122
self.active_processes: list[subprocess.Popen] = []
115123

116-
self.projects: list[ProjectConfig] = (
124+
self.projects: list[ProjectConfig] = cast(
125+
list[ProjectConfig],
117126
projects
118127
if projects is not None
119-
else self.file_config.get('projects', [])
128+
else self.file_config.get('projects', []),
120129
)
121-
self.heavy_processes: list[HeavyProcessConfig] = (
130+
self.heavy_processes: list[HeavyProcessConfig] = cast(
131+
list[HeavyProcessConfig],
122132
heavy_process
123133
if heavy_process is not None
124-
else (self.file_config.get('heavy_processes') or [])
134+
else (self.file_config.get('heavy_processes') or []),
125135
)
126136
if ram_config is None:
127137
self.ram_config = RamConfig(
@@ -147,7 +157,7 @@ def __init__(
147157
self.ram_monitoring = RamMonitoring()
148158

149159
def load_config(self, path: str) -> dict[str, Any]:
150-
"""Loads the configuration from a YAML file. Returns empty dict if file fails."""
160+
"""Loads the configuration from a YAML file."""
151161
try:
152162
if os.path.exists(path):
153163
with open(path, 'r') as file:

0 commit comments

Comments
 (0)