<commit_before>import typing

from spyne import Address
from spyne.server.http import HttpTransportContext
from spyne.util.address import address_parser

if typing.TYPE_CHECKING:
    from aiohttp.web import Request  # noqa: F401

    from .aio_base import AioBase  # noqa: F401
    from .aio_method_ctx import AioMethodContext  # noqa: F401


class AioTransportContext(HttpTransportContext):
    def __init__(
        self,
        parent: "AioMethodContext",
        transport: "AioBase",
        req_env: "Request",
        content_type: str,
    ) -> None:
        super(AioTransportContext, self).__init__(
            parent, transport, req_env, content_type
        )
        self.req_env = req_env
        self.content_type = content_type

    def get_path(self) -> str:
        return self.req_env.path

    def get_path_and_qs(self) -> str:
        return self.req_env.path_qs

    def get_cookie(self, key) -> str:
        return self.req_env.cookies[key]

    def get_request_method(self) -> str:
        return self.req_env.method

    def get_request_content_type(self) -> str:
        return self.content_type

    def get_peer(self) -> typing.Optional[Address]:
        if not self.req_env.transport:
            return None

        peer = self.req_env.transport.get_extra_info("peername")
        if not peer:
            return None
        addr, port = peer

        if address_parser.is_valid_ipv4(addr):
            return Address(type=Address.TCP4, host=addr, port=port)

        if address_parser.is_valid_ipv6(addr):
            return Address(type=Address.TCP6, host=addr, port=port)

        return None<commit_msg>Rename addr -> host in get_peer()<commit_after>import typing

from spyne import Address
from spyne.server.http import HttpTransportContext
from spyne.util.address import address_parser

if typing.TYPE_CHECKING:
    from aiohttp.web import Request  # noqa: F401

    from .aio_base import AioBase  # noqa: F401
    from .aio_method_ctx import AioMethodContext  # noqa: F401


class AioTransportContext(HttpTransportContext):
    def __init__(
        self,
        parent: "AioMethodContext",
        transport: "AioBase",
        req_env: "Request",
        content_type: str,
    ) -> None:
        super(AioTransportContext, self).__init__(
            parent, transport, req_env, content_type
        )
        self.req_env = req_env
        self.content_type = content_type

    def get_path(self) -> str:
        return self.req_env.path

    def get_path_and_qs(self) -> str:
        return self.req_env.path_qs

    def get_cookie(self, key) -> str:
        return self.req_env.cookies[key]

    def get_request_method(self) -> str:
        return self.req_env.method

    def get_request_content_type(self) -> str:
        return self.content_type

    def get_peer(self) -> typing.Optional[Address]:
        if not self.req_env.transport:
            return None

        peer = self.req_env.transport.get_extra_info("peername")
        if not peer:
            return None
        host, port = peer

        if address_parser.is_valid_ipv4(host):
            return Address(type=Address.TCP4, host=host, port=port)

        if address_parser.is_valid_ipv6(host):
            return Address(type=Address.TCP6, host=host, port=port)

        return None
{'fraction_non_alphanumeric': 0.08419139915202907, 'fraction_numerical': 0.007874015748031496, 'mean_word_length': 2.5785482123510293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '503237', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1007, 'n_words': 235}