Skip to content

Commit dd4be3e

Browse files
committed
style: Apply black formatting to source files
Fix black formatting issues preventing CI/CD from passing. Files reformatted: - src/smartswitch/plugin.py - src/smartswitch/plugins/pydantic.py - src/smartswitch/plugins/logging.py - src/smartswitch/plugins/typerule.py - src/smartswitch/core.py All 197 tests still pass after formatting.
1 parent 0c1d9d0 commit dd4be3e

5 files changed

Lines changed: 19 additions & 22 deletions

File tree

src/smartswitch/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def plug(self, plugin, name=None, **kwargs):
232232
if name:
233233
# Use custom name
234234
self._plugin_registry[name] = plugin
235-
elif hasattr(plugin, 'plugin_name'):
235+
elif hasattr(plugin, "plugin_name"):
236236
# Use plugin's default name
237237
self._plugin_registry[plugin.plugin_name] = plugin
238238
elif plugin_name:

src/smartswitch/plugin.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,7 @@ def config_aware_wrapper(*args, **kwargs):
271271

272272
return config_aware_wrapper
273273

274-
def _wrap_handler(
275-
self, func: Callable, switcher: "Switcher"
276-
) -> Callable:
274+
def _wrap_handler(self, func: Callable, switcher: "Switcher") -> Callable:
277275
"""
278276
Wrap handler with plugin-specific logic.
279277
@@ -301,6 +299,4 @@ def _wrap_handler(
301299
... return func(*args, **kwargs)
302300
... return wrapper
303301
"""
304-
raise NotImplementedError(
305-
f"{self.__class__.__name__} must implement _wrap_handler()"
306-
)
302+
raise NotImplementedError(f"{self.__class__.__name__} must implement _wrap_handler()")

src/smartswitch/plugins/logging.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,7 @@ def logged_wrapper(*args, **kwargs):
163163

164164
# Log before if enabled
165165
if self.mode in ("log", "both"):
166-
self._logger.info(
167-
f"Calling {handler_name} with args={args}, kwargs={kwargs}"
168-
)
166+
self._logger.info(f"Calling {handler_name} with args={args}, kwargs={kwargs}")
169167

170168
# Execute handler and measure time
171169
start_time = time.time() if self.track_time else None

src/smartswitch/plugins/pydantic.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
from pydantic import BaseModel, ValidationError, create_model
1919
except ImportError:
2020
raise ImportError(
21-
"Pydantic plugin requires pydantic. "
22-
"Install with: pip install smartswitch[pydantic]"
21+
"Pydantic plugin requires pydantic. " "Install with: pip install smartswitch[pydantic]"
2322
)
2423

2524
from ..plugin import BasePlugin
@@ -136,9 +135,7 @@ def wrapper(*args, **kwargs):
136135

137136
# Split arguments into those with hints and those without
138137
args_to_validate = {k: v for k, v in bound.arguments.items() if k in hints}
139-
args_without_hints = {
140-
k: v for k, v in bound.arguments.items() if k not in hints
141-
}
138+
args_without_hints = {k: v for k, v in bound.arguments.items() if k not in hints}
142139

143140
# Validate using Pydantic
144141
try:

src/smartswitch/plugins/typerule.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,15 @@ def wrap(self, func: Callable, switcher: "Switcher") -> Callable:
123123
type_checks = self._compile_type_checks(typerule, param_names)
124124

125125
# Register the rule
126-
self._type_rules.append({
127-
"func": func,
128-
"typerule": typerule,
129-
"signature": sig,
130-
"param_names": param_names,
131-
"type_checks": type_checks,
132-
})
126+
self._type_rules.append(
127+
{
128+
"func": func,
129+
"typerule": typerule,
130+
"signature": sig,
131+
"param_names": param_names,
132+
"type_checks": type_checks,
133+
}
134+
)
133135

134136
return func
135137

@@ -141,20 +143,24 @@ def _inject_dispatch(self, switcher: "Switcher"):
141143
def enhanced_call(arg=None, /, *, typerule=None, valrule=None):
142144
# If typerule specified, attach metadata to function for later registration
143145
if typerule is not None:
146+
144147
def decorator(func):
145148
func._smartswitch_typerule = typerule
146149
return original_call(func)
150+
147151
return decorator
148152

149153
# Dispatch mode: switch()(*args, **kwargs)
150154
if arg is None and typerule is None and valrule is None:
155+
151156
def invoker(*args, **kwargs):
152157
# Try type rules
153158
for rule in self._type_rules:
154159
if self._matches_typerule(rule, args, kwargs):
155160
return rule["func"](*args, **kwargs)
156161
# Fall back to original dispatch
157162
raise ValueError(f"No type rule matched for {args}, {kwargs}")
163+
158164
return invoker
159165

160166
# Otherwise use original behavior

0 commit comments

Comments
 (0)