• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

psf / black / 7692220850

29 Jan 2024 06:46AM UTC coverage: 96.45%. Remained the same
7692220850

Pull #4192

github

web-flow
Bump peter-evans/create-or-update-comment from 3.1.0 to 4.0.0

Bumps [peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment) from 3.1.0 to 4.0.0.
- [Release notes](https://github.com/peter-evans/create-or-update-comment/releases)
- [Commits](https://github.com/peter-evans/create-or-update-comment/compare/23ff15729...71345be02)

---
updated-dependencies:
- dependency-name: peter-evans/create-or-update-comment
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #4192: Bump peter-evans/create-or-update-comment from 3.1.0 to 4.0.0

3021 of 3232 branches covered (0.0%)

7145 of 7408 relevant lines covered (96.45%)

4.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.67
/src/blackd/middlewares.py
1
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Iterable, TypeVar
5✔
2

3
from aiohttp.web_request import Request
5✔
4
from aiohttp.web_response import StreamResponse
5✔
5

6
if TYPE_CHECKING:
5!
7
    F = TypeVar("F", bound=Callable[..., Any])
×
8
    middleware: Callable[[F], F]
×
9
else:
10
    try:
5✔
11
        from aiohttp.web_middlewares import middleware
5✔
12
    except ImportError:
×
13
        # @middleware is deprecated and its behaviour is the default since aiohttp 4.0
14
        # so if it doesn't exist anymore, define a no-op for forward compatibility.
15
        middleware = lambda x: x  # noqa: E731
×
16

17
Handler = Callable[[Request], Awaitable[StreamResponse]]
5✔
18
Middleware = Callable[[Request, Handler], Awaitable[StreamResponse]]
5✔
19

20

21
def cors(allow_headers: Iterable[str]) -> Middleware:
5✔
22
    @middleware
5✔
23
    async def impl(request: Request, handler: Handler) -> StreamResponse:
5✔
24
        is_options = request.method == "OPTIONS"
5✔
25
        is_preflight = is_options and "Access-Control-Request-Method" in request.headers
5✔
26
        if is_preflight:
5✔
27
            resp = StreamResponse()
5✔
28
        else:
29
            resp = await handler(request)
5✔
30

31
        origin = request.headers.get("Origin")
5✔
32
        if not origin:
5✔
33
            return resp
5✔
34

35
        resp.headers["Access-Control-Allow-Origin"] = "*"
5✔
36
        resp.headers["Access-Control-Expose-Headers"] = "*"
5✔
37
        if is_options:
5✔
38
            resp.headers["Access-Control-Allow-Headers"] = ", ".join(allow_headers)
5✔
39
            resp.headers["Access-Control-Allow-Methods"] = ", ".join(
5✔
40
                ("OPTIONS", "POST")
41
            )
42

43
        return resp
5✔
44

45
    return impl
5✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc