Skip to content

Commit 8a2a697

Browse files
Merge pull request #94 from jupyter-server/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2 parents 6480db6 + 660d814 commit 8a2a697

File tree

10 files changed

+8
-31
lines changed

10 files changed

+8
-31
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repos:
44
hooks:
55
- id: isort
66
- repo: https://github.com/psf/black
7-
rev: 22.12.0
7+
rev: 23.1.0
88
hooks:
99
- id: black
1010
- repo: https://github.com/PyCQA/flake8

fps/app.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def _get_pluggin_manager(hook_type: HookType) -> PluginManager:
3131
def _grouped_hookimpls_results(
3232
hook: pluggy._hooks._HookCaller,
3333
) -> Dict[ModuleType, List[Callable]]:
34-
3534
plugins = [impl.plugin for impl in hook.get_hookimpls()]
3635
result = hook()
3736
assert len(plugins) == len(result)
@@ -45,15 +44,13 @@ def _grouped_hookimpls_results(
4544

4645

4746
def _load_exceptions_handlers(app: FastAPI) -> None:
48-
4947
pm = _get_pluggin_manager(HookType.EXCEPTION)
5048

5149
grouped_exceptions_handlers = _grouped_hookimpls_results(pm.hook.exception_handler)
5250

5351
app.add_exception_handler(RedirectException, _redirect_exception_handler)
5452

5553
if grouped_exceptions_handlers:
56-
5754
pkg_names = {
5855
get_pkg_name(p, strip_fps=False) for p in grouped_exceptions_handlers
5956
}
@@ -62,7 +59,7 @@ def _load_exceptions_handlers(app: FastAPI) -> None:
6259
for p, exceptions in grouped_exceptions_handlers.items():
6360
p_name = Config.plugin_name(p)
6461

65-
for (exc_class, exc_handler) in exceptions:
62+
for exc_class, exc_handler in exceptions:
6663
if exc_class in app.exception_handlers:
6764
logger.error(
6865
f"Redefinition of handler for '{exc_class}' exception is not allowed."
@@ -80,7 +77,6 @@ def _load_exceptions_handlers(app: FastAPI) -> None:
8077

8178

8279
def _load_configurations() -> None:
83-
8480
Config.clear_names()
8581
Config.clear_models()
8682

@@ -97,12 +93,10 @@ def _load_configurations() -> None:
9793
grouped_plugin_names = _grouped_hookimpls_results(pm.hook.plugin_name)
9894

9995
if plugin_name_impls:
100-
10196
pkg_names = {get_pkg_name(p, strip_fps=False) for p in grouped_plugin_names}
10297
logger.info(f"Loading names from plugin package(s) {pkg_names}")
10398

10499
for p, plugin_names in grouped_plugin_names.items():
105-
106100
if not plugin_names:
107101
name = Config.register_plugin_name(p)
108102
elif len(plugin_names) > 1:
@@ -131,7 +125,6 @@ def _load_configurations() -> None:
131125
# config values, and load them from files
132126
config_impls = pm.hook.config.get_hookimpls()
133127
if config_impls:
134-
135128
grouped_configs = _grouped_hookimpls_results(pm.hook.config)
136129
pkg_names = {get_pkg_name(p, strip_fps=False) for p in grouped_plugin_names}
137130
logger.info(f"Loading configurations from plugin package(s) {pkg_names}")
@@ -156,7 +149,6 @@ def _load_configurations() -> None:
156149

157150

158151
def _load_routers(app: FastAPI) -> None:
159-
160152
pm = _get_pluggin_manager(HookType.ROUTER)
161153

162154
# Ensure any plugins package has a name registered
@@ -306,7 +298,6 @@ async def __call__(
306298

307299

308300
def create_app():
309-
310301
logging.getLogger("fps")
311302
configure_loggers(logging.root.manager.loggerDict.keys())
312303

fps/config.py

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class Config:
5151

5252

5353
class Config:
54-
5554
_models: Dict[Type[PluginModel], Tuple[str, PluginModel]] = {}
5655
_based_on: Dict[Type[PluginModel], List[str]] = {}
5756
_files: Dict[str, dict] = {}

fps/hooks.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ def router_callback() -> Tuple[APIRouter, Dict[str, Any]]:
3131

3232

3333
@pluggy.HookspecMarker(HookType.EXCEPTION.value)
34-
def exception_handler() -> Tuple[
35-
typing.Union[int, typing.Type[Exception]], typing.Callable
36-
]:
34+
def exception_handler() -> (
35+
Tuple[typing.Union[int, typing.Type[Exception]], typing.Callable]
36+
):
3737
pass
3838

3939

4040
def register_exception_handler(
4141
exc_class_or_status_code: typing.Union[int, typing.Type[Exception]],
4242
handler: typing.Callable,
4343
):
44-
def exception_handler_callback() -> Tuple[
45-
typing.Union[int, typing.Type[Exception]], typing.Callable
46-
]:
44+
def exception_handler_callback() -> (
45+
Tuple[typing.Union[int, typing.Type[Exception]], typing.Callable]
46+
):
4747
return exc_class_or_status_code, handler
4848

4949
return pluggy.HookimplMarker(HookType.EXCEPTION.value)(

fps/logging.py

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818

1919
class ColouredPercentStyle(PercentStyle):
20-
2120
validation_pattern = re.compile(
2221
r"%\(\w+\)[#0+ -]*(\*|\d+)?(\.(\*|\d+))?[diouxefgcrsa]|", re.I
2322
)
@@ -146,7 +145,6 @@ def colourized_formatter(
146145

147146

148147
def _set_loggers_config(loggers=(), level="info"):
149-
150148
filename = None
151149
log_level = level.upper()
152150

fps/utils.py

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111

1212
def get_caller_module_name(stack_level: int = 1) -> str:
13-
1413
frm = inspect.stack()[stack_level]
1514
mod = inspect.getmodule(frm[0])
1615
return mod.__name__
@@ -40,7 +39,6 @@ def get_pkg_name(plugin: Union[str, ModuleType], strip_fps: bool = True) -> str:
4039

4140

4241
def get_all_plugins_pkgs_names() -> Set[str]:
43-
4442
names = []
4543
for dist in list(importlib_metadata.distributions()):
4644
for ep in dist.entry_points:

plugins/helloworld/fps_helloworld/routes.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
@r.get("/hello")
1414
async def root(name: str = "world", config=Depends(get_config)):
15-
1615
if config.random:
1716
name = " ".join((name, str(random.randint(0, 250))))
1817
else:

plugins/uvicorn/fps_uvicorn/cli.py

-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def unnested_option(key: str, val: str, root: bool = True) -> Dict[str, Any]:
8383

8484

8585
def store_extra_options(options: List[str]):
86-
8786
if options:
8887
opts = parse_extra_options(options)
8988
f_name = "fps_cli_args.toml"

tests/conftest.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
@pytest.fixture
1313
def config_content():
14-
1514
yield ""
1615

1716

tests/test_config.py

-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def hookimpl_config(func):
1717

1818

1919
def test_forbid_extras(config_file, plugin_manager):
20-
2120
with open(config_file, "w") as f:
2221
f.write("[fps]\nsome_extra = 'extra'")
2322

@@ -57,7 +56,6 @@ def plugin_name():
5756
),
5857
)
5958
def test_plugin_names(app, plugins):
60-
6159
assert len(Config._plugin2name) == len(plugins)
6260
assert Config._plugin2name == {plugins[0]: "some-plugin"}
6361

@@ -106,7 +104,6 @@ class Plugin3Config(PluginModel):
106104
@classmethod
107105
@hookimpl_config
108106
def plugin_config(cls):
109-
110107
return cls.Plugin3Config
111108

112109
@staticmethod
@@ -128,7 +125,6 @@ def plugin_config():
128125
),
129126
)
130127
def test_no_file(self, app, config_file, plugins):
131-
132128
assert self.Plugin3.Plugin3Config in Config._models
133129
assert Config._models[self.Plugin3.Plugin3Config] == (
134130
"tests",
@@ -153,7 +149,6 @@ def test_no_file(self, app, config_file, plugins):
153149
"config_content", (pytest.lazy_fixture(("fps_only_config",)))
154150
)
155151
def test_fps_config(self, app, plugins, config_file, config_content):
156-
157152
assert self.Plugin3.Plugin3Config in Config._models
158153
assert Config._models[self.Plugin3.Plugin3Config] == (
159154
"tests",
@@ -181,7 +176,6 @@ def test_fps_config(self, app, plugins, config_file, config_content):
181176
"config_content", (pytest.lazy_fixture(("plugin_config",)))
182177
)
183178
def test_plugin_config(self, app, plugins, config_file, config_content):
184-
185179
assert self.Plugin3.Plugin3Config in Config._models
186180
assert Config._models[self.Plugin3.Plugin3Config] == (
187181
"tests",

0 commit comments

Comments
 (0)