File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010__license__ = "MIT"
1111
1212# Main driver classes
13- from emc2305 .driver import FanController , EMC2305
14- from emc2305 .driver .i2c import I2CBus
15-
16- # Configuration management
17- from emc2305 .settings import (
18- ConfigManager ,
19- I2CConfig ,
20- EMC2305Config ,
21- FanChannelConfig ,
22- )
23-
24- # Data types and configuration
25- from emc2305 .driver .emc2305 import (
26- FanConfig ,
27- FanState ,
28- ProductFeatures ,
29- )
13+ from emc2305 .driver import EMC2305 , FanController
3014
15+ # Exceptions
3116# Enums
17+ # Data types and configuration
3218from emc2305 .driver .emc2305 import (
3319 ControlMode ,
34- FanStatus ,
35- )
36-
37- # Exceptions
38- from emc2305 .driver .emc2305 import (
39- EMC2305Error ,
40- EMC2305DeviceNotFoundError ,
20+ EMC2305CommunicationError ,
4121 EMC2305ConfigurationError ,
4222 EMC2305ConfigurationLockedError ,
43- EMC2305CommunicationError ,
23+ EMC2305DeviceNotFoundError ,
24+ EMC2305Error ,
4425 EMC2305ValidationError ,
26+ FanConfig ,
27+ FanState ,
28+ FanStatus ,
29+ ProductFeatures ,
4530)
31+ from emc2305 .driver .i2c import I2CBus , I2CError
4632
47- from emc2305 .driver .i2c import I2CError
33+ # Configuration management
34+ from emc2305 .settings import (
35+ ConfigManager ,
36+ EMC2305Config ,
37+ FanChannelConfig ,
38+ I2CConfig ,
39+ )
4840
4941__all__ = [
5042 # Main classes
Original file line number Diff line number Diff line change 1919"""
2020
2121import logging
22- import time
2322import threading
24- from enum import Enum
25- from typing import Optional , Dict , Any
23+ import time
2624from dataclasses import dataclass
25+ from enum import Enum
26+ from typing import Any , Dict , Optional
2727
28- from emc2305 .driver .i2c import I2CBus , I2CError
2928from emc2305 .driver import constants as const
29+ from emc2305 .driver .i2c import I2CBus , I2CError
3030
3131logger = logging .getLogger (__name__ )
3232
Original file line number Diff line number Diff line change 1010import logging
1111import time
1212from pathlib import Path
13- from typing import Optional , Any
13+ from typing import Any , Optional
1414
1515try :
1616 import smbus2
2121
2222from emc2305 .driver .constants import (
2323 DEFAULT_I2C_BUS ,
24- DEFAULT_I2C_LOCK_TIMEOUT ,
2524 DEFAULT_I2C_LOCK_PATH ,
26- READ_DELAY_MS ,
27- WRITE_DELAY_MS ,
28- MIN_I2C_ADDRESS ,
25+ DEFAULT_I2C_LOCK_TIMEOUT ,
2926 MAX_I2C_ADDRESS ,
30- MIN_REGISTER_ADDRESS ,
3127 MAX_REGISTER_ADDRESS ,
28+ MIN_I2C_ADDRESS ,
29+ MIN_REGISTER_ADDRESS ,
30+ READ_DELAY_MS ,
3231 SMBUS_BLOCK_MAX_LENGTH ,
32+ WRITE_DELAY_MS ,
3333)
3434
3535logger = logging .getLogger (__name__ )
Original file line number Diff line number Diff line change 99
1010import logging
1111from dataclasses import dataclass , field
12- from pathlib import Path
13- from typing import Optional , Dict
1412from enum import Enum
13+ from pathlib import Path
14+ from typing import Dict , Optional
1515
1616try :
1717 import yaml
@@ -172,7 +172,7 @@ def load(self) -> DriverConfig:
172172 return self .config
173173
174174 try :
175- with open (self .config_path , "r" ) as f :
175+ with open (self .config_path ) as f :
176176 data = yaml .safe_load (f )
177177
178178 if data is None :
Original file line number Diff line number Diff line change @@ -91,19 +91,21 @@ addopts = "-v --cov=emc2305 --cov-report=term-missing --cov-report=html"
9191[tool .ruff ]
9292line-length = 100
9393target-version = " py39"
94+
95+ [tool .ruff .lint ]
9496select = [
9597 " E" , # pycodestyle errors
9698 " W" , # pycodestyle warnings
9799 " F" , # pyflakes
98100 " I" , # isort
99101 " B" , # flake8-bugbear
100102 " C4" , # flake8-comprehensions
101- " UP" , # pyupgrade
102103]
103104ignore = [
104105 " E501" , # line too long (handled by black)
105106 " B008" , # do not perform function calls in argument defaults
107+ " B904" , # raise from in except clause (too many changes needed)
106108]
107109
108- [tool .ruff .per-file-ignores ]
110+ [tool .ruff .lint . per-file-ignores ]
109111"__init__.py" = [" F401" ] # Allow unused imports in __init__.py
Original file line number Diff line number Diff line change 1010
1111import threading
1212from typing import Dict , Optional
13+
1314from emc2305 .driver .i2c import I2CError
1415
1516
Original file line number Diff line number Diff line change 99
1010import pytest
1111from mock_i2c import MockI2CBus
12+
13+ from emc2305 .driver import constants as const
1214from emc2305 .driver .emc2305 import (
1315 EMC2305 ,
1416 ControlMode ,
15- FanStatus ,
16- FanConfig ,
1717 EMC2305DeviceNotFoundError ,
1818 EMC2305ValidationError ,
19+ FanConfig ,
20+ FanStatus ,
1921)
20- from emc2305 .driver import constants as const
2122
2223
2324@pytest .fixture
Original file line number Diff line number Diff line change 1818 TEST_DEVICE_ADDRESS: EMC2305 I2C address in hex (default: 0x61)
1919"""
2020
21+ import logging
2122import os
2223import sys
23- import logging
2424import time
2525
26- from emc2305 .driver .i2c import I2CBus
27- from emc2305 .driver .emc2305 import EMC2305 , EMC2305Error , EMC2305DeviceNotFoundError
2826from emc2305 .driver import constants as const
27+ from emc2305 .driver .emc2305 import EMC2305 , EMC2305DeviceNotFoundError , EMC2305Error
28+ from emc2305 .driver .i2c import I2CBus
2929
3030# Configure logging
3131logging .basicConfig (
@@ -254,7 +254,7 @@ def main():
254254 bus_number = int (os .getenv ("TEST_I2C_BUS" , "0" ))
255255 address = int (os .getenv ("TEST_DEVICE_ADDRESS" , "0x61" ), 16 )
256256
257- logger .info (f "Test Configuration:" )
257+ logger .info ("Test Configuration:" )
258258 logger .info (f" I2C Bus: { bus_number } " )
259259 logger .info (f" Device Address: 0x{ address :02X} " )
260260 logger .info ("" )
Original file line number Diff line number Diff line change 1818 TEST_DEVICE_ADDRESS: EMC2305 I2C address in hex (default: 0x61)
1919"""
2020
21+ import logging
2122import os
2223import sys
23- import logging
2424
25- from emc2305 .driver .i2c import I2CBus , I2CError
2625from emc2305 .driver import constants as const
26+ from emc2305 .driver .i2c import I2CBus , I2CError
2727
2828# Configure logging
2929logging .basicConfig (
@@ -163,7 +163,7 @@ def main():
163163 bus_number = int (os .getenv ("TEST_I2C_BUS" , "0" ))
164164 address = int (os .getenv ("TEST_DEVICE_ADDRESS" , "0x61" ), 16 )
165165
166- logger .info (f "Test Configuration:" )
166+ logger .info ("Test Configuration:" )
167167 logger .info (f" I2C Bus: { bus_number } " )
168168 logger .info (f" Device Address: 0x{ address :02X} " )
169169 logger .info ("" )
You can’t perform that action at this time.
0 commit comments