Skip to content

Commit ed8ecdc

Browse files
committed
fix(lint): resolve ruff formatting issues
- Sort imports alphabetically - Fix line length violation in _attach_child_switcher - Add noqa: E402 for late imports (necessary to avoid circular imports) - All ruff checks now passing
1 parent c6aeb65 commit ed8ecdc

5 files changed

Lines changed: 16 additions & 13 deletions

File tree

src/smartswitch/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
- DbOpPlugin
99
"""
1010

11-
from .core import Switcher, BasePlugin, MethodEntry
12-
from .plugins import SmartAsyncPlugin, DbOpPlugin, LoggingPlugin
11+
from .core import BasePlugin, MethodEntry, Switcher
12+
from .plugins import DbOpPlugin, LoggingPlugin, SmartAsyncPlugin
1313

1414
# PydanticPlugin is conditionally imported in plugins/__init__.py
1515
# Only available if pydantic is installed

src/smartswitch/core.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
import contextvars
2424
from dataclasses import dataclass, field
25-
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Type, Tuple
26-
25+
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type
2726

2827
# ============================================================
2928
# THREAD-LOCAL CONTEXT
@@ -297,7 +296,9 @@ def get_child(self, name: str) -> "Switcher":
297296
except KeyError:
298297
raise KeyError(f"No child switch named {name!r} in {self!r}")
299298

300-
def _attach_child_switcher(self, child: "Switcher", explicit_name: Optional[str] = None) -> None:
299+
def _attach_child_switcher(
300+
self, child: "Switcher", explicit_name: Optional[str] = None
301+
) -> None:
301302
"""Attach an actual Switcher instance as a child."""
302303
if child is self:
303304
raise ValueError("Cannot attach a switch to itself")

src/smartswitch/plugins/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import inspect
66
from typing import Optional
77

8-
from ..core import MethodEntry, BasePlugin, Switcher
8+
from ..core import BasePlugin, MethodEntry, Switcher
99

1010

1111
class SmartAsyncPlugin(BasePlugin):
@@ -76,11 +76,11 @@ def wrapper(*args, **kwargs):
7676
Switcher.register_plugin("dbop", DbOpPlugin)
7777

7878
# Import logging plugin (always available)
79-
from .logging import LoggingPlugin
79+
from .logging import LoggingPlugin # noqa: E402
8080

8181
# Import pydantic plugin only if pydantic is installed
8282
try:
83-
from .pydantic import PydanticPlugin
83+
from .pydantic import PydanticPlugin # noqa: E402
8484
__all__ = ["SmartAsyncPlugin", "DbOpPlugin", "LoggingPlugin", "PydanticPlugin"]
8585
except ImportError:
8686
# Pydantic not installed - plugin not available

src/smartswitch/plugins/logging.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import TYPE_CHECKING, Any, Callable, Optional
1111

1212
if TYPE_CHECKING:
13-
from ..core import Switcher, MethodEntry
13+
from ..core import MethodEntry, Switcher
1414

1515
from ..core import BasePlugin
1616

@@ -379,5 +379,6 @@ def set_mode(self, mode: str):
379379

380380

381381
# Register plugin globally
382-
from ..core import Switcher
382+
from ..core import Switcher # noqa: E402
383+
383384
Switcher.register_plugin("logging", LoggingPlugin)

src/smartswitch/plugins/pydantic.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
)
2323

2424
if TYPE_CHECKING:
25-
from ..core import Switcher, MethodEntry
25+
from ..core import MethodEntry, Switcher
2626

2727
from ..core import BasePlugin
2828

@@ -149,7 +149,7 @@ def wrapper(*args, **kwargs):
149149
try:
150150
bound = sig.bind(*args, **kwargs)
151151
bound.apply_defaults()
152-
except TypeError as e:
152+
except TypeError:
153153
# Signature binding failed - let it propagate
154154
raise
155155

@@ -187,5 +187,6 @@ def wrapper(*args, **kwargs):
187187

188188

189189
# Register plugin globally
190-
from ..core import Switcher
190+
from ..core import Switcher # noqa: E402
191+
191192
Switcher.register_plugin("pydantic", PydanticPlugin)

0 commit comments

Comments
 (0)