[tool.hatch.version]
path = "starlette/__init__.py"
-[tool.ruff]
+[tool.ruff.lint]
select = ["E", "F", "I"]
-[tool.ruff.isort]
+[tool.ruff.lint.isort]
combine-as-imports = true
[tool.mypy]
-e .[full]
# Testing
-black==23.10.1
coverage==7.3.1
importlib-metadata==6.8.0
mypy==1.5.1
-ruff==0.1.3
+ruff==0.1.4
typing_extensions==4.8.0
types-contextvars==2.4.7.3
types-PyYAML==6.0.12.12
set -x
./scripts/sync-version
-${PREFIX}black --check --diff $SOURCE_FILES
+${PREFIX}ruff format --check --diff $SOURCE_FILES
# TODO: Use `[[tool.mypy.overrides]]` on the `pyproject.toml` when the mypy issue is solved:
# github.com/python/mypy/issues/10045. Check github.com/encode/starlette/pull/2180 for more info.
${PREFIX}mypy starlette
set -x
-${PREFIX}black $SOURCE_FILES
+${PREFIX}ruff format $SOURCE_FILES
${PREFIX}ruff --fix $SOURCE_FILES
self.exception_handlers[exc_class_or_status_code] = handler
def add_event_handler(
- self, event_type: str, func: typing.Callable # type: ignore[type-arg]
+ self,
+ event_type: str,
+ func: typing.Callable, # type: ignore[type-arg]
) -> None: # pragma: no cover
self.router.add_event_handler(event_type, func)
return decorator
- def websocket_route(
- self, path: str, name: str | None = None
- ) -> typing.Callable: # type: ignore[type-arg]
+ def websocket_route(self, path: str, name: str | None = None) -> typing.Callable: # type: ignore[type-arg]
"""
We no longer document this decorator style API, and its usage is discouraged.
Instead you should use the following approach:
self.backend = backend
self.on_error: typing.Callable[
[HTTPConnection, AuthenticationError], Response
- ] = (on_error if on_error is not None else self.default_on_error)
+ ] = on_error if on_error is not None else self.default_on_error
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
if scope["type"] not in ["http", "websocket"]:
def generate_frame_html(self, frame: inspect.FrameInfo, is_collapsed: bool) -> str:
code_context = "".join(
self.format_line(
- index, line, frame.lineno, frame.index # type: ignore[arg-type]
+ index,
+ line,
+ frame.lineno,
+ frame.index, # type: ignore[arg-type]
)
for index, line in enumerate(frame.code_context or [])
)
def _wrap_gen_lifespan_context(
lifespan_context: typing.Callable[
[typing.Any], typing.Generator[typing.Any, typing.Any, typing.Any]
- ]
+ ],
) -> typing.Callable[[typing.Any], typing.AsyncContextManager[typing.Any]]:
cmgr = contextlib.contextmanager(lifespan_context)