Skip to content

Commit

Permalink
style: Integrate no-optional pre-commit hook (#133)
Browse files Browse the repository at this point in the history
[no-optional](https://github.com/Kludex/no-optional) pre-commit hook
allows to ensure that all `Optional[T]` type annotations will be
replaced to `Union[T, None]` as they are similar to `T | None` from
Python 3.10.
  • Loading branch information
playpauseandstop authored Oct 23, 2022
1 parent 865d135 commit 8c2a904
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,16 @@ repos:
- repo: "https://github.com/asottile/yesqa"
rev: "v1.4.0"
hooks:
- id: yesqa
- id: "yesqa"
name: "Lint code (yesqa)"
additional_dependencies: *flake8_additional_dependencies
exclude: ^docs/.*$

- repo: "https://github.com/Kludex/no-optional"
rev: "0.4.0"
hooks:
- id: "no_optional"

- repo: "local"
hooks:
- id: "mypy"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pytest-aiohttp = "^1.0.4"
pytest-cov = "^3.0.0"

[tool.pytest.ini_options]
minversion = "7.1.2"
minversion = "7.1.3"
addopts = "--cov --no-cov-on-fail"
testpaths = ["./tests/"]
log_level = "info"
Expand Down
6 changes: 3 additions & 3 deletions src/aiohttp_middlewares/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async def api_error(request: web.Request) -> web.Response:
import logging
from contextlib import contextmanager
from functools import partial
from typing import Dict, Iterator, Optional, Tuple, Union
from typing import Dict, Iterator, Tuple, Union

import attr
from aiohttp import web
Expand Down Expand Up @@ -223,8 +223,8 @@ def get_error_from_request(request: web.Request) -> Exception:


def get_error_handler(
request: web.Request, config: Optional[Config]
) -> Optional[Handler]:
request: web.Request, config: Union[Config, None]
) -> Union[Handler, None]:
"""Find error handler matching current request path if any."""
if not config:
return None
Expand Down

0 comments on commit 8c2a904

Please sign in to comment.