{
    "file_diffs": [
        {
            "old_file_content": "- Contributors -\n----------------\nA. Jesse Jiryu Davis\nAdam Bannister\nAdam Cooper\nAdam Horacek\nAdam Mills\nAdrian Krupa\nAdrián Chaves\nAhmed Tahri\nAlan Tse\nAlec Hanefeld\nAlejandro Gómez\nAleksandr Danshyn\nAleksey Kutepov\nAlex Hayes\nAlex Key\nAlex Khomchenko\nAlex Kuzmenko\nAlex Lisovoy\nAlexander Bayandin\nAlexander Karpinsky\nAlexander Koshevoy\nAlexander Malev\nAlexander Mohr\nAlexander Shorin\nAlexander Travov\nAlexandru Mihai\nAlexey Firsov\nAlexey Popravka\nAlexey Stepanov\nAlmaz Salakhov\nAmin Etesamian\nAmit Tulshyan\nAmy Boyle\nAnas El Amraoui\nAnders Melchiorsen\nAndrei Ursulenko\nAndrej Antonov\nAndrew Leech\nAndrew Lytvyn\nAndrew Svetlov\nAndrew Zhou\nAndrii Soldatenko\nAnes Abismail\nAntoine Pietri\nAnton Kasyanov\nAnton Zhdan-Pushkin\nArie Bovenberg\nArseny Timoniq\nArtem Yushkovskiy\nArthur Darcet\nAustin Scola\nBen Bader\nBen Greiner\nBen Timby\nBenedikt Reinartz\nBob Haddleton\nBoris Feld\nBorys Vorona\nBoyi Chen\nBrett Cannon\nBrian Bouterse\nBrian C. Lane\nBrian Muller\nBruce Merry\nBruno Souza Cabral\nBryan Kok\nBryce Drennan\nCarl George\nCecile Tonglet\nChien-Wei Huang\nChih-Yuan Chen\nChris AtLee\nChris Laws\nChris Moore\nChristopher Schmitt\nClaudiu Popa\nColin Dunklau\nCong Xu\nDamien Nadé\nDan King\nDan Xu\nDaniel García\nDaniel Grossmann-Kavanagh\nDaniel Nelson\nDaniele Trifirò\nDanny Song\nDavid Bibb\nDavid Michael Brown\nDenilson Amorim\nDenis Matiychuk\nDenis Moshensky\nDennis Kliban\nDima Veselov\nDimitar Dimitrov\nDiogo Dutra da Mata\nDmitriy Safonov\nDmitry Doroshev\nDmitry Erlikh\nDmitry Lukashin\nDmitry Marakasov\nDmitry Shamov\nDmitry Trofimov\nDmytro Bohomiakov\nDmytro Kuznetsov\nDustin J. Mitchell\nEduard Iskandarov\nEli Ribble\nElizabeth Leddy\nEmil Melnikov\nEnrique Saez\nEric Sheng\nErich Healy\nErik Peterson\nEugene Chernyshov\nEugene Ershov\nEugene Naydenov\nEugene Nikolaiev\nEugene Tolmachev\nEvan Kepner\nEvert Lammerts\nFelix Yan\nFernanda Guimarães\nFichteFoll\nFlorian Scheffler\nFranek Magiera\nFrederik Gladhorn\nFrederik Peter Aalund\nGabriel Tremblay\nGary Wilson Jr.\nGennady Andreyev\nGeorges Dubus\nGreg Holt\nGregory Haynes\nGus Goulart\nGustavo Carneiro\nGünther Jena\nHans Adema\nHarmon Y.\nHarry Liu\nHiroshi Ogawa\nHrishikesh Paranjape\nHu Bo\nHugh Young\nHugo Herter\nHugo van Kemenade\nHynek Schlawack\nIgor Alexandrov\nIgor Davydenko\nIgor Mozharovsky\nIgor Pavlov\nIllia Volochii\nIlya Chichak\nIlya Gruzinov\nIngmar Steen\nIvan Lakovic\nIvan Larin\nJ. Nick Koston\nJacob Champion\nJaesung Lee\nJake Davis\nJakob Ackermann\nJakub Wilk\nJan Buchar\nJan Gosmann\nJarno Elonen\nJashandeep Sohi\nJean-Baptiste Estival\nJens Steinhauser\nJeonghun Lee\nJeongkyu Shin\nJeroen van der Heijden\nJesus Cea\nJian Zeng\nJinkyu Yi\nJoel Watts\nJon Nabozny\nJonas Krüger Svensson\nJonas Obrist\nJonathan Wright\nJonny Tan\nJoongi Kim\nJordan Borean\nJosep Cugat\nJosh Junon\nJoshu Coats\nJulia Tsemusheva\nJulien Duponchelle\nJungkook Park\nJunjie Tao\nJunyeong Jeong\nJustas Trimailovas\nJustin Foo\nJustin Turner Arthur\nKay Zheng\nKevin Samuel\nKimmo Parviainen-Jalanko\nKirill Klenov\nKirill Malovitsa\nKonstantin Valetov\nKrzysztof Blazewicz\nKyrylo Perevozchikov\nKyungmin Lee\nLars P. Søndergaard\nLee LieWhite\nLiu Hua\nLouis-Philippe Huberdeau\nLoïc Lajeanne\nLu Gong\nLubomir Gelo\nLudovic Gasc\nLuis Pedrosa\nLukasz Marcin Dobrzanski\nMakc Belousow\nManuel Miranda\nMarat Sharafutdinov\nMarco Paolini\nMariano Anaya\nMariusz Masztalerczuk\nMarko Kohtala\nMartijn Pieters\nMartin Melka\nMartin Richard\nMathias Fröjdman\nMathieu Dugré\nMatt VanEseltine\nMatthieu Hauglustaine\nMatthieu Rigal\nMatvey Tingaev\nMeet Mangukiya\nMichael Ihnatenko\nMichał Górny\nMikhail Burshteyn\nMikhail Kashkin\nMikhail Lukyanchenko\nMikhail Nacharov\nMisha Behersky\nMitchell Ferree\nMorgan Delahaye-Prat\nMoss Collum\nMun Gwan-gyeong\nNavid Sheikhol\nNicolas Braem\nNikolay Kim\nNikolay Novik\nNikolay Tiunov\nNándor Mátravölgyi\nOisin Aylward\nOlaf Conradi\nOleg Höfling\nPahaz Blinov\nPanagiotis Kolokotronis\nPankaj Pandey\nPau Freixes\nPaul Colomiets\nPaulius Šileikis\nPaulus Schoutsen\nPavel Kamaev\nPavel Polyakov\nPavel Sapezhko\nPavol Vargovčík\nPawel Kowalski\nPawel Miech\nPepe Osca\nPhilipp A.\nPieter van Beek\nQiao Han\nRafael Viotti\nRaphael Bialon\nRaúl Cumplido\nRequired Field\nRobert Lu\nRobert Nikolich\nRoman Markeloff\nRoman Podoliaka\nSamir Akarioh\nSamuel Colvin\nSean Hunt\nSebastian Acuna\nSebastian Hanula\nSebastian Hüther\nSebastien Geffroy\nSeongSoo Cho\nSergey Ninua\nSergey Skripnick\nSerhii Charykov\nSerhii Kostel\nSerhiy Storchaka\nSimon Kennedy\nSin-Woo Bang\nStanislas Plum\nStanislav Prokop\nStefan Tjarks\nStepan Pletnev\nStephan Jaensch\nStephen Cirelli\nStephen Granade\nSteven Seguin\nSunghyun Hwang\nSunit Deshpande\nSviatoslav Bulbakha\nSviatoslav Sydorenko\nTaha Jahangir\nTaras Voinarovskyi\nTerence Honles\nThanos Lefteris\nThijs Vermeir\nThomas Forbes\nThomas Grainger\nTolga Tezel\nTomasz Trebski\nToshiaki Tanaka\nTrinh Hoang Nhu\nVadim Suharnikov\nVaibhav Sagar\nVamsi Krishna Avula\nVasiliy Faronov\nVasyl Baran\nViacheslav Greshilov\nVictor Collod\nVictor Kovtun\nVictor Makarov\nVikas Kawadia\nViktor Danyliuk\nVille Skyttä\nVincent Maillol\nVitalik Verhovodov\nVitaly Haritonsky\nVitaly Magerya\nVladimir Kamarzin\nVladimir Kozlovski\nVladimir Rutsky\nVladimir Shulyak\nVladimir Zakharov\nVladyslav Bohaichuk\nVladyslav Bondar\nW. Trevor King\nWei Lin\nWeiwei Wang\nWill Fatherley\nWill McGugan\nWillem de Groot\nWilliam Grzybowski\nWilliam S.\nWilson Ong\nwouter bolsterlee\nYang Zhou\nYannick Koechlin\nYannick Péroux\nYe Cao\nYegor Roganov\nYifei Kong\nYoung-Ho Cha\nYuriy Shatrov\nYury Pliner\nYury Selivanov\nYusuke Tsutsumi\nYuval Ofir\nYuvi Panda\nZainab Lawal\nZeal Wierslee\nZlatan Sičanica\nМарк Коренберг\nСемён Марьясин\n",
            "new_file_content": "- Contributors -\n----------------\nA. Jesse Jiryu Davis\nAdam Bannister\nAdam Cooper\nAdam Horacek\nAdam Mills\nAdrian Krupa\nAdrián Chaves\nAhmed Tahri\nAlan Tse\nAlec Hanefeld\nAlejandro Gómez\nAleksandr Danshyn\nAleksey Kutepov\nAlex Hayes\nAlex Key\nAlex Khomchenko\nAlex Kuzmenko\nAlex Lisovoy\nAlexander Bayandin\nAlexander Karpinsky\nAlexander Koshevoy\nAlexander Malev\nAlexander Mohr\nAlexander Shorin\nAlexander Travov\nAlexandru Mihai\nAlexey Firsov\nAlexey Popravka\nAlexey Stepanov\nAlmaz Salakhov\nAmin Etesamian\nAmit Tulshyan\nAmy Boyle\nAnas El Amraoui\nAnders Melchiorsen\nAndrei Ursulenko\nAndrej Antonov\nAndrew Leech\nAndrew Lytvyn\nAndrew Svetlov\nAndrew Zhou\nAndrii Soldatenko\nAnes Abismail\nAntoine Pietri\nAnton Kasyanov\nAnton Zhdan-Pushkin\nArie Bovenberg\nArseny Timoniq\nArtem Yushkovskiy\nArthur Darcet\nAustin Scola\nBen Bader\nBen Greiner\nBen Timby\nBenedikt Reinartz\nBob Haddleton\nBoris Feld\nBorys Vorona\nBoyi Chen\nBrett Cannon\nBrian Bouterse\nBrian C. Lane\nBrian Muller\nBruce Merry\nBruno Souza Cabral\nBryan Kok\nBryce Drennan\nCarl George\nCecile Tonglet\nChien-Wei Huang\nChih-Yuan Chen\nChris AtLee\nChris Laws\nChris Moore\nChristopher Schmitt\nClaudiu Popa\nColin Dunklau\nCong Xu\nDamien Nadé\nDan King\nDan Xu\nDaniel García\nDaniel Grossmann-Kavanagh\nDaniel Nelson\nDaniele Trifirò\nDanny Song\nDavid Bibb\nDavid Michael Brown\nDenilson Amorim\nDenis Matiychuk\nDenis Moshensky\nDennis Kliban\nDima Veselov\nDimitar Dimitrov\nDiogo Dutra da Mata\nDmitriy Safonov\nDmitry Doroshev\nDmitry Erlikh\nDmitry Lukashin\nDmitry Marakasov\nDmitry Shamov\nDmitry Trofimov\nDmytro Bohomiakov\nDmytro Kuznetsov\nDustin J. Mitchell\nEduard Iskandarov\nEli Ribble\nElizabeth Leddy\nEmil Melnikov\nEnrique Saez\nEric Sheng\nErich Healy\nErik Peterson\nEugene Chernyshov\nEugene Ershov\nEugene Naydenov\nEugene Nikolaiev\nEugene Tolmachev\nEvan Kepner\nEvert Lammerts\nFelix Yan\nFernanda Guimarães\nFichteFoll\nFlorian Scheffler\nFranek Magiera\nFrederik Gladhorn\nFrederik Peter Aalund\nGabriel Tremblay\nGary Wilson Jr.\nGennady Andreyev\nGeorges Dubus\nGreg Holt\nGregory Haynes\nGus Goulart\nGustavo Carneiro\nGünther Jena\nHans Adema\nHarmon Y.\nHarry Liu\nHiroshi Ogawa\nHrishikesh Paranjape\nHu Bo\nHugh Young\nHugo Herter\nHugo van Kemenade\nHynek Schlawack\nIgor Alexandrov\nIgor Davydenko\nIgor Mozharovsky\nIgor Pavlov\nIllia Volochii\nIlya Chichak\nIlya Gruzinov\nIngmar Steen\nIvan Lakovic\nIvan Larin\nJ. Nick Koston\nJacob Champion\nJaesung Lee\nJake Davis\nJakob Ackermann\nJakub Wilk\nJan Buchar\nJan Gosmann\nJarno Elonen\nJashandeep Sohi\nJean-Baptiste Estival\nJens Steinhauser\nJeonghun Lee\nJeongkyu Shin\nJeroen van der Heijden\nJesus Cea\nJian Zeng\nJinkyu Yi\nJoel Watts\nJon Nabozny\nJonas Krüger Svensson\nJonas Obrist\nJonathan Wright\nJonny Tan\nJoongi Kim\nJordan Borean\nJosep Cugat\nJosh Junon\nJoshu Coats\nJulia Tsemusheva\nJulien Duponchelle\nJungkook Park\nJunjie Tao\nJunyeong Jeong\nJustas Trimailovas\nJustin Foo\nJustin Turner Arthur\nKay Zheng\nKevin Samuel\nKimmo Parviainen-Jalanko\nKirill Klenov\nKirill Malovitsa\nKonstantin Valetov\nKrzysztof Blazewicz\nKyrylo Perevozchikov\nKyungmin Lee\nLars P. Søndergaard\nLee LieWhite\nLiu Hua\nLouis-Philippe Huberdeau\nLoïc Lajeanne\nLu Gong\nLubomir Gelo\nLudovic Gasc\nLuis Pedrosa\nLukasz Marcin Dobrzanski\nMakc Belousow\nManuel Miranda\nMarat Sharafutdinov\nMarc Mueller\nMarco Paolini\nMariano Anaya\nMariusz Masztalerczuk\nMarko Kohtala\nMartijn Pieters\nMartin Melka\nMartin Richard\nMathias Fröjdman\nMathieu Dugré\nMatt VanEseltine\nMatthieu Hauglustaine\nMatthieu Rigal\nMatvey Tingaev\nMeet Mangukiya\nMichael Ihnatenko\nMichał Górny\nMikhail Burshteyn\nMikhail Kashkin\nMikhail Lukyanchenko\nMikhail Nacharov\nMisha Behersky\nMitchell Ferree\nMorgan Delahaye-Prat\nMoss Collum\nMun Gwan-gyeong\nNavid Sheikhol\nNicolas Braem\nNikolay Kim\nNikolay Novik\nNikolay Tiunov\nNándor Mátravölgyi\nOisin Aylward\nOlaf Conradi\nOleg Höfling\nPahaz Blinov\nPanagiotis Kolokotronis\nPankaj Pandey\nPau Freixes\nPaul Colomiets\nPaulius Šileikis\nPaulus Schoutsen\nPavel Kamaev\nPavel Polyakov\nPavel Sapezhko\nPavol Vargovčík\nPawel Kowalski\nPawel Miech\nPepe Osca\nPhilipp A.\nPieter van Beek\nQiao Han\nRafael Viotti\nRaphael Bialon\nRaúl Cumplido\nRequired Field\nRobert Lu\nRobert Nikolich\nRoman Markeloff\nRoman Podoliaka\nSamir Akarioh\nSamuel Colvin\nSean Hunt\nSebastian Acuna\nSebastian Hanula\nSebastian Hüther\nSebastien Geffroy\nSeongSoo Cho\nSergey Ninua\nSergey Skripnick\nSerhii Charykov\nSerhii Kostel\nSerhiy Storchaka\nSimon Kennedy\nSin-Woo Bang\nStanislas Plum\nStanislav Prokop\nStefan Tjarks\nStepan Pletnev\nStephan Jaensch\nStephen Cirelli\nStephen Granade\nSteven Seguin\nSunghyun Hwang\nSunit Deshpande\nSviatoslav Bulbakha\nSviatoslav Sydorenko\nTaha Jahangir\nTaras Voinarovskyi\nTerence Honles\nThanos Lefteris\nThijs Vermeir\nThomas Forbes\nThomas Grainger\nTolga Tezel\nTomasz Trebski\nToshiaki Tanaka\nTrinh Hoang Nhu\nVadim Suharnikov\nVaibhav Sagar\nVamsi Krishna Avula\nVasiliy Faronov\nVasyl Baran\nViacheslav Greshilov\nVictor Collod\nVictor Kovtun\nVictor Makarov\nVikas Kawadia\nViktor Danyliuk\nVille Skyttä\nVincent Maillol\nVitalik Verhovodov\nVitaly Haritonsky\nVitaly Magerya\nVladimir Kamarzin\nVladimir Kozlovski\nVladimir Rutsky\nVladimir Shulyak\nVladimir Zakharov\nVladyslav Bohaichuk\nVladyslav Bondar\nW. Trevor King\nWei Lin\nWeiwei Wang\nWill Fatherley\nWill McGugan\nWillem de Groot\nWilliam Grzybowski\nWilliam S.\nWilson Ong\nwouter bolsterlee\nYang Zhou\nYannick Koechlin\nYannick Péroux\nYe Cao\nYegor Roganov\nYifei Kong\nYoung-Ho Cha\nYuriy Shatrov\nYury Pliner\nYury Selivanov\nYusuke Tsutsumi\nYuval Ofir\nYuvi Panda\nZainab Lawal\nZeal Wierslee\nZlatan Sičanica\nМарк Коренберг\nСемён Марьясин\n",
            "header": {
                "file": {
                    "path": "CONTRIBUTORS.txt"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "c7e6b951",
                "new_commit_hash": "8a91cb49",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/CONTRIBUTORS.txt"
            },
            "plus_file": {
                "path": "b/CONTRIBUTORS.txt"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 215,
                            "length": 6
                        },
                        "new_range": {
                            "start": 215,
                            "length": 7
                        },
                        "section": "Lukasz Marcin Dobrzanski"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "Makc Belousow",
                                "type": "context"
                            },
                            {
                                "content": "Manuel Miranda",
                                "type": "context"
                            },
                            {
                                "content": "Marat Sharafutdinov",
                                "type": "context"
                            },
                            {
                                "content": "Marc Mueller",
                                "type": "added"
                            },
                            {
                                "content": "Marco Paolini",
                                "type": "context"
                            },
                            {
                                "content": "Mariano Anaya",
                                "type": "context"
                            },
                            {
                                "content": "Mariusz Masztalerczuk",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "import asyncio\nimport logging\nimport warnings\nfrom functools import partial, update_wrapper\nfrom typing import (  # noqa\n    TYPE_CHECKING,\n    Any,\n    AsyncIterator,\n    Awaitable,\n    Callable,\n    Dict,\n    Iterable,\n    Iterator,\n    List,\n    Mapping,\n    MutableMapping,\n    Optional,\n    Sequence,\n    Tuple,\n    Type,\n    TypeVar,\n    Union,\n    cast,\n    overload,\n)\n\nfrom aiosignal import Signal\nfrom frozenlist import FrozenList\nfrom typing_extensions import final\n\nfrom . import hdrs\nfrom .helpers import AppKey\nfrom .log import web_logger\nfrom .typedefs import Middleware\nfrom .web_middlewares import _fix_request_current_app\nfrom .web_request import Request\nfrom .web_response import StreamResponse\nfrom .web_routedef import AbstractRouteDef\nfrom .web_urldispatcher import (\n    AbstractResource,\n    AbstractRoute,\n    Domain,\n    MaskDomain,\n    MatchedSubAppResource,\n    PrefixedSubAppResource,\n    UrlDispatcher,\n)\n\n__all__ = (\"Application\", \"CleanupError\")\n\n\nif TYPE_CHECKING:  # pragma: no cover\n    _AppSignal = Signal[Callable[[\"Application\"], Awaitable[None]]]\n    _RespPrepareSignal = Signal[Callable[[Request, StreamResponse], Awaitable[None]]]\n    _Middlewares = FrozenList[Middleware]\n    _MiddlewaresHandlers = Sequence[Middleware]\n    _Subapps = List[\"Application\"]\nelse:\n    # No type checker mode, skip types\n    _AppSignal = Signal\n    _RespPrepareSignal = Signal\n    _Handler = Callable\n    _Middlewares = FrozenList\n    _MiddlewaresHandlers = Sequence\n    _Subapps = List\n\n_T = TypeVar(\"_T\")\n_U = TypeVar(\"_U\")\n\n\n@final\nclass Application(MutableMapping[Union[str, AppKey[Any]], Any]):\n    __slots__ = (\n        \"logger\",\n        \"_debug\",\n        \"_router\",\n        \"_loop\",\n        \"_handler_args\",\n        \"_middlewares\",\n        \"_middlewares_handlers\",\n        \"_run_middlewares\",\n        \"_state\",\n        \"_frozen\",\n        \"_pre_frozen\",\n        \"_subapps\",\n        \"_on_response_prepare\",\n        \"_on_startup\",\n        \"_on_shutdown\",\n        \"_on_cleanup\",\n        \"_client_max_size\",\n        \"_cleanup_ctx\",\n    )\n\n    def __init__(\n        self,\n        *,\n        logger: logging.Logger = web_logger,\n        middlewares: Iterable[Middleware] = (),\n        handler_args: Optional[Mapping[str, Any]] = None,\n        client_max_size: int = 1024**2,\n        debug: Any = ...,  # mypy doesn't support ellipsis\n    ) -> None:\n        if debug is not ...:\n            warnings.warn(\n                \"debug argument is no-op since 4.0 \" \"and scheduled for removal in 5.0\",\n                DeprecationWarning,\n                stacklevel=2,\n            )\n        self._router = UrlDispatcher()\n        self._handler_args = handler_args\n        self.logger = logger\n\n        self._middlewares: _Middlewares = FrozenList(middlewares)\n\n        # initialized on freezing\n        self._middlewares_handlers: _MiddlewaresHandlers = tuple()\n        # initialized on freezing\n        self._run_middlewares: Optional[bool] = None\n\n        self._state: Dict[Union[AppKey[Any], str], object] = {}\n        self._frozen = False\n        self._pre_frozen = False\n        self._subapps: _Subapps = []\n\n        self._on_response_prepare: _RespPrepareSignal = Signal(self)\n        self._on_startup: _AppSignal = Signal(self)\n        self._on_shutdown: _AppSignal = Signal(self)\n        self._on_cleanup: _AppSignal = Signal(self)\n        self._cleanup_ctx = CleanupContext()\n        self._on_startup.append(self._cleanup_ctx._on_startup)\n        self._on_cleanup.append(self._cleanup_ctx._on_cleanup)\n        self._client_max_size = client_max_size\n\n    def __init_subclass__(cls: Type[\"Application\"]) -> None:\n        raise TypeError(\n            \"Inheritance class {} from web.Application \"\n            \"is forbidden\".format(cls.__name__)\n        )\n\n    # MutableMapping API\n\n    def __eq__(self, other: object) -> bool:\n        return self is other\n\n    @overload  # type: ignore[override]\n    def __getitem__(self, key: AppKey[_T]) -> _T:\n        ...\n\n    @overload\n    def __getitem__(self, key: str) -> Any:\n        ...\n\n    def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:\n        return self._state[key]\n\n    def _check_frozen(self) -> None:\n        if self._frozen:\n            raise RuntimeError(\n                \"Changing state of started or joined \" \"application is forbidden\"\n            )\n\n    @overload  # type: ignore[override]\n    def __setitem__(self, key: AppKey[_T], value: _T) -> None:\n        ...\n\n    @overload\n    def __setitem__(self, key: str, value: Any) -> None:\n        ...\n\n    def __setitem__(self, key: Union[str, AppKey[_T]], value: Any) -> None:\n        self._check_frozen()\n        if not isinstance(key, AppKey):\n            warnings.warn(\n                \"It is recommended to use web.AppKey instances for keys.\\n\"\n                + \"https://docs.aiohttp.org/en/stable/web_advanced.html\"\n                + \"#application-s-config\"\n            )\n        self._state[key] = value\n\n    def __delitem__(self, key: Union[str, AppKey[_T]]) -> None:\n        self._check_frozen()\n        del self._state[key]\n\n    def __len__(self) -> int:\n        return len(self._state)\n\n    def __iter__(self) -> Iterator[Union[str, AppKey[Any]]]:\n        return iter(self._state)\n\n    @overload  # type: ignore[override]\n    def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]:\n        ...\n\n    @overload\n    def get(self, key: AppKey[_T], default: _U) -> Union[_T, _U]:\n        ...\n\n    @overload\n    def get(self, key: str, default: Any = ...) -> Any:\n        ...\n\n    def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:\n        return self._state.get(key, default)\n\n    ########\n    def _set_loop(self, loop: Optional[asyncio.AbstractEventLoop]) -> None:\n        warnings.warn(\n            \"_set_loop() is no-op since 4.0 \" \"and scheduled for removal in 5.0\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n\n    @property\n    def pre_frozen(self) -> bool:\n        return self._pre_frozen\n\n    def pre_freeze(self) -> None:\n        if self._pre_frozen:\n            return\n\n        self._pre_frozen = True\n        self._middlewares.freeze()\n        self._router.freeze()\n        self._on_response_prepare.freeze()\n        self._cleanup_ctx.freeze()\n        self._on_startup.freeze()\n        self._on_shutdown.freeze()\n        self._on_cleanup.freeze()\n        self._middlewares_handlers = tuple(self._prepare_middleware())\n\n        # If current app and any subapp do not have middlewares avoid run all\n        # of the code footprint that it implies, which have a middleware\n        # hardcoded per app that sets up the current_app attribute. If no\n        # middlewares are configured the handler will receive the proper\n        # current_app without needing all of this code.\n        self._run_middlewares = True if self.middlewares else False\n\n        for subapp in self._subapps:\n            subapp.pre_freeze()\n            self._run_middlewares = self._run_middlewares or subapp._run_middlewares\n\n    @property\n    def frozen(self) -> bool:\n        return self._frozen\n\n    def freeze(self) -> None:\n        if self._frozen:\n            return\n\n        self.pre_freeze()\n        self._frozen = True\n        for subapp in self._subapps:\n            subapp.freeze()\n\n    @property\n    def debug(self) -> bool:\n        warnings.warn(\n            \"debug property is deprecated since 4.0\" \"and scheduled for removal in 5.0\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n        return asyncio.get_event_loop().get_debug()\n\n    def _reg_subapp_signals(self, subapp: \"Application\") -> None:\n        def reg_handler(signame: str) -> None:\n            subsig = getattr(subapp, signame)\n\n            async def handler(app: \"Application\") -> None:\n                await subsig.send(subapp)\n\n            appsig = getattr(self, signame)\n            appsig.append(handler)\n\n        reg_handler(\"on_startup\")\n        reg_handler(\"on_shutdown\")\n        reg_handler(\"on_cleanup\")\n\n    def add_subapp(self, prefix: str, subapp: \"Application\") -> AbstractResource:\n        if not isinstance(prefix, str):\n            raise TypeError(\"Prefix must be str\")\n        prefix = prefix.rstrip(\"/\")\n        if not prefix:\n            raise ValueError(\"Prefix cannot be empty\")\n        factory = partial(PrefixedSubAppResource, prefix, subapp)\n        return self._add_subapp(factory, subapp)\n\n    def _add_subapp(\n        self, resource_factory: Callable[[], AbstractResource], subapp: \"Application\"\n    ) -> AbstractResource:\n        if self.frozen:\n            raise RuntimeError(\"Cannot add sub application to frozen application\")\n        if subapp.frozen:\n            raise RuntimeError(\"Cannot add frozen application\")\n        resource = resource_factory()\n        self.router.register_resource(resource)\n        self._reg_subapp_signals(subapp)\n        self._subapps.append(subapp)\n        subapp.pre_freeze()\n        return resource\n\n    def add_domain(self, domain: str, subapp: \"Application\") -> AbstractResource:\n        if not isinstance(domain, str):\n            raise TypeError(\"Domain must be str\")\n        elif \"*\" in domain:\n            rule: Domain = MaskDomain(domain)\n        else:\n            rule = Domain(domain)\n        factory = partial(MatchedSubAppResource, rule, subapp)\n        return self._add_subapp(factory, subapp)\n\n    def add_routes(self, routes: Iterable[AbstractRouteDef]) -> List[AbstractRoute]:\n        return self.router.add_routes(routes)\n\n    @property\n    def on_response_prepare(self) -> _RespPrepareSignal:\n        return self._on_response_prepare\n\n    @property\n    def on_startup(self) -> _AppSignal:\n        return self._on_startup\n\n    @property\n    def on_shutdown(self) -> _AppSignal:\n        return self._on_shutdown\n\n    @property\n    def on_cleanup(self) -> _AppSignal:\n        return self._on_cleanup\n\n    @property\n    def cleanup_ctx(self) -> \"CleanupContext\":\n        return self._cleanup_ctx\n\n    @property\n    def router(self) -> UrlDispatcher:\n        return self._router\n\n    @property\n    def middlewares(self) -> _Middlewares:\n        return self._middlewares\n\n    async def startup(self) -> None:\n        \"\"\"Causes on_startup signal\n\n        Should be called in the event loop along with the request handler.\n        \"\"\"\n        await self.on_startup.send(self)\n\n    async def shutdown(self) -> None:\n        \"\"\"Causes on_shutdown signal\n\n        Should be called before cleanup()\n        \"\"\"\n        await self.on_shutdown.send(self)\n\n    async def cleanup(self) -> None:\n        \"\"\"Causes on_cleanup signal\n\n        Should be called after shutdown()\n        \"\"\"\n        if self.on_cleanup.frozen:\n            await self.on_cleanup.send(self)\n        else:\n            # If an exception occurs in startup, ensure cleanup contexts are completed.\n            await self._cleanup_ctx._on_cleanup(self)\n\n    def _prepare_middleware(self) -> Iterator[Middleware]:\n        yield from reversed(self._middlewares)\n        yield _fix_request_current_app(self)\n\n    async def _handle(self, request: Request) -> StreamResponse:\n        match_info = await self._router.resolve(request)\n        match_info.add_app(self)\n        match_info.freeze()\n\n        resp = None\n        request._match_info = match_info\n        expect = request.headers.get(hdrs.EXPECT)\n        if expect:\n            resp = await match_info.expect_handler(request)\n            await request.writer.drain()\n\n        if resp is None:\n            handler = match_info.handler\n\n            if self._run_middlewares:\n                for app in match_info.apps[::-1]:\n                    assert app.pre_frozen, \"middleware handlers are not ready\"\n                    for m in app._middlewares_handlers:\n                        handler = update_wrapper(partial(m, handler=handler), handler)\n\n            resp = await handler(request)\n\n        return resp\n\n    def __call__(self) -> \"Application\":\n        \"\"\"gunicorn compatibility\"\"\"\n        return self\n\n    def __repr__(self) -> str:\n        return f\"<Application 0x{id(self):x}>\"\n\n    def __bool__(self) -> bool:\n        return True\n\n\nclass CleanupError(RuntimeError):\n    @property\n    def exceptions(self) -> List[BaseException]:\n        return cast(List[BaseException], self.args[1])\n\n\nif TYPE_CHECKING:  # pragma: no cover\n    _CleanupContextBase = FrozenList[Callable[[Application], AsyncIterator[None]]]\nelse:\n    _CleanupContextBase = FrozenList\n\n\nclass CleanupContext(_CleanupContextBase):\n    def __init__(self) -> None:\n        super().__init__()\n        self._exits: List[AsyncIterator[None]] = []\n\n    async def _on_startup(self, app: Application) -> None:\n        for cb in self:\n            it = cb(app).__aiter__()\n            await it.__anext__()\n            self._exits.append(it)\n\n    async def _on_cleanup(self, app: Application) -> None:\n        errors = []\n        for it in reversed(self._exits):\n            try:\n                await it.__anext__()\n            except StopAsyncIteration:\n                pass\n            except Exception as exc:\n                errors.append(exc)\n            else:\n                errors.append(RuntimeError(f\"{it!r} has more than one 'yield'\"))\n        if errors:\n            if len(errors) == 1:\n                raise errors[0]\n            else:\n                raise CleanupError(\"Multiple errors on cleanup stage\", errors)\n",
            "new_file_content": "import asyncio\nimport logging\nimport warnings\nfrom functools import partial, update_wrapper\nfrom typing import (  # noqa\n    TYPE_CHECKING,\n    Any,\n    AsyncIterator,\n    Awaitable,\n    Callable,\n    Dict,\n    Iterable,\n    Iterator,\n    List,\n    Mapping,\n    MutableMapping,\n    Optional,\n    Sequence,\n    Tuple,\n    Type,\n    TypeVar,\n    Union,\n    cast,\n    overload,\n)\n\nfrom aiosignal import Signal\nfrom frozenlist import FrozenList\nfrom typing_extensions import final\n\nfrom . import hdrs\nfrom .helpers import AppKey\nfrom .log import web_logger\nfrom .typedefs import Middleware\nfrom .web_middlewares import _fix_request_current_app\nfrom .web_request import Request\nfrom .web_response import StreamResponse\nfrom .web_routedef import AbstractRouteDef\nfrom .web_urldispatcher import (\n    AbstractResource,\n    AbstractRoute,\n    Domain,\n    MaskDomain,\n    MatchedSubAppResource,\n    PrefixedSubAppResource,\n    UrlDispatcher,\n)\n\n__all__ = (\"Application\", \"CleanupError\")\n\n\nif TYPE_CHECKING:  # pragma: no cover\n    _AppSignal = Signal[Callable[[\"Application\"], Awaitable[None]]]\n    _RespPrepareSignal = Signal[Callable[[Request, StreamResponse], Awaitable[None]]]\n    _Middlewares = FrozenList[Middleware]\n    _MiddlewaresHandlers = Sequence[Middleware]\n    _Subapps = List[\"Application\"]\nelse:\n    # No type checker mode, skip types\n    _AppSignal = Signal\n    _RespPrepareSignal = Signal\n    _Handler = Callable\n    _Middlewares = FrozenList\n    _MiddlewaresHandlers = Sequence\n    _Subapps = List\n\n_T = TypeVar(\"_T\")\n_U = TypeVar(\"_U\")\n\n\n@final\nclass Application(MutableMapping[Union[str, AppKey[Any]], Any]):\n    __slots__ = (\n        \"logger\",\n        \"_debug\",\n        \"_router\",\n        \"_loop\",\n        \"_handler_args\",\n        \"_middlewares\",\n        \"_middlewares_handlers\",\n        \"_run_middlewares\",\n        \"_state\",\n        \"_frozen\",\n        \"_pre_frozen\",\n        \"_subapps\",\n        \"_on_response_prepare\",\n        \"_on_startup\",\n        \"_on_shutdown\",\n        \"_on_cleanup\",\n        \"_client_max_size\",\n        \"_cleanup_ctx\",\n    )\n\n    def __init__(\n        self,\n        *,\n        logger: logging.Logger = web_logger,\n        middlewares: Iterable[Middleware] = (),\n        handler_args: Optional[Mapping[str, Any]] = None,\n        client_max_size: int = 1024**2,\n        debug: Any = ...,  # mypy doesn't support ellipsis\n    ) -> None:\n        if debug is not ...:\n            warnings.warn(\n                \"debug argument is no-op since 4.0 \" \"and scheduled for removal in 5.0\",\n                DeprecationWarning,\n                stacklevel=2,\n            )\n        self._router = UrlDispatcher()\n        self._handler_args = handler_args\n        self.logger = logger\n\n        self._middlewares: _Middlewares = FrozenList(middlewares)\n\n        # initialized on freezing\n        self._middlewares_handlers: _MiddlewaresHandlers = tuple()\n        # initialized on freezing\n        self._run_middlewares: Optional[bool] = None\n\n        self._state: Dict[Union[AppKey[Any], str], object] = {}\n        self._frozen = False\n        self._pre_frozen = False\n        self._subapps: _Subapps = []\n\n        self._on_response_prepare: _RespPrepareSignal = Signal(self)\n        self._on_startup: _AppSignal = Signal(self)\n        self._on_shutdown: _AppSignal = Signal(self)\n        self._on_cleanup: _AppSignal = Signal(self)\n        self._cleanup_ctx = CleanupContext()\n        self._on_startup.append(self._cleanup_ctx._on_startup)\n        self._on_cleanup.append(self._cleanup_ctx._on_cleanup)\n        self._client_max_size = client_max_size\n\n    def __init_subclass__(cls: Type[\"Application\"]) -> None:\n        raise TypeError(\n            \"Inheritance class {} from web.Application \"\n            \"is forbidden\".format(cls.__name__)\n        )\n\n    # MutableMapping API\n\n    def __eq__(self, other: object) -> bool:\n        return self is other\n\n    @overload  # type: ignore[override]\n    def __getitem__(self, key: AppKey[_T]) -> _T:\n        ...\n\n    @overload\n    def __getitem__(self, key: str) -> Any:\n        ...\n\n    def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:\n        return self._state[key]\n\n    def _check_frozen(self) -> None:\n        if self._frozen:\n            raise RuntimeError(\n                \"Changing state of started or joined \" \"application is forbidden\"\n            )\n\n    @overload  # type: ignore[override]\n    def __setitem__(self, key: AppKey[_T], value: _T) -> None:\n        ...\n\n    @overload\n    def __setitem__(self, key: str, value: Any) -> None:\n        ...\n\n    def __setitem__(self, key: Union[str, AppKey[_T]], value: Any) -> None:\n        self._check_frozen()\n        if not isinstance(key, AppKey):\n            warnings.warn(\n                \"It is recommended to use web.AppKey instances for keys.\\n\"\n                + \"https://docs.aiohttp.org/en/stable/web_advanced.html\"\n                + \"#application-s-config\",\n                stacklevel=2,\n            )\n        self._state[key] = value\n\n    def __delitem__(self, key: Union[str, AppKey[_T]]) -> None:\n        self._check_frozen()\n        del self._state[key]\n\n    def __len__(self) -> int:\n        return len(self._state)\n\n    def __iter__(self) -> Iterator[Union[str, AppKey[Any]]]:\n        return iter(self._state)\n\n    @overload  # type: ignore[override]\n    def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]:\n        ...\n\n    @overload\n    def get(self, key: AppKey[_T], default: _U) -> Union[_T, _U]:\n        ...\n\n    @overload\n    def get(self, key: str, default: Any = ...) -> Any:\n        ...\n\n    def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:\n        return self._state.get(key, default)\n\n    ########\n    def _set_loop(self, loop: Optional[asyncio.AbstractEventLoop]) -> None:\n        warnings.warn(\n            \"_set_loop() is no-op since 4.0 \" \"and scheduled for removal in 5.0\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n\n    @property\n    def pre_frozen(self) -> bool:\n        return self._pre_frozen\n\n    def pre_freeze(self) -> None:\n        if self._pre_frozen:\n            return\n\n        self._pre_frozen = True\n        self._middlewares.freeze()\n        self._router.freeze()\n        self._on_response_prepare.freeze()\n        self._cleanup_ctx.freeze()\n        self._on_startup.freeze()\n        self._on_shutdown.freeze()\n        self._on_cleanup.freeze()\n        self._middlewares_handlers = tuple(self._prepare_middleware())\n\n        # If current app and any subapp do not have middlewares avoid run all\n        # of the code footprint that it implies, which have a middleware\n        # hardcoded per app that sets up the current_app attribute. If no\n        # middlewares are configured the handler will receive the proper\n        # current_app without needing all of this code.\n        self._run_middlewares = True if self.middlewares else False\n\n        for subapp in self._subapps:\n            subapp.pre_freeze()\n            self._run_middlewares = self._run_middlewares or subapp._run_middlewares\n\n    @property\n    def frozen(self) -> bool:\n        return self._frozen\n\n    def freeze(self) -> None:\n        if self._frozen:\n            return\n\n        self.pre_freeze()\n        self._frozen = True\n        for subapp in self._subapps:\n            subapp.freeze()\n\n    @property\n    def debug(self) -> bool:\n        warnings.warn(\n            \"debug property is deprecated since 4.0\" \"and scheduled for removal in 5.0\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n        return asyncio.get_event_loop().get_debug()\n\n    def _reg_subapp_signals(self, subapp: \"Application\") -> None:\n        def reg_handler(signame: str) -> None:\n            subsig = getattr(subapp, signame)\n\n            async def handler(app: \"Application\") -> None:\n                await subsig.send(subapp)\n\n            appsig = getattr(self, signame)\n            appsig.append(handler)\n\n        reg_handler(\"on_startup\")\n        reg_handler(\"on_shutdown\")\n        reg_handler(\"on_cleanup\")\n\n    def add_subapp(self, prefix: str, subapp: \"Application\") -> AbstractResource:\n        if not isinstance(prefix, str):\n            raise TypeError(\"Prefix must be str\")\n        prefix = prefix.rstrip(\"/\")\n        if not prefix:\n            raise ValueError(\"Prefix cannot be empty\")\n        factory = partial(PrefixedSubAppResource, prefix, subapp)\n        return self._add_subapp(factory, subapp)\n\n    def _add_subapp(\n        self, resource_factory: Callable[[], AbstractResource], subapp: \"Application\"\n    ) -> AbstractResource:\n        if self.frozen:\n            raise RuntimeError(\"Cannot add sub application to frozen application\")\n        if subapp.frozen:\n            raise RuntimeError(\"Cannot add frozen application\")\n        resource = resource_factory()\n        self.router.register_resource(resource)\n        self._reg_subapp_signals(subapp)\n        self._subapps.append(subapp)\n        subapp.pre_freeze()\n        return resource\n\n    def add_domain(self, domain: str, subapp: \"Application\") -> AbstractResource:\n        if not isinstance(domain, str):\n            raise TypeError(\"Domain must be str\")\n        elif \"*\" in domain:\n            rule: Domain = MaskDomain(domain)\n        else:\n            rule = Domain(domain)\n        factory = partial(MatchedSubAppResource, rule, subapp)\n        return self._add_subapp(factory, subapp)\n\n    def add_routes(self, routes: Iterable[AbstractRouteDef]) -> List[AbstractRoute]:\n        return self.router.add_routes(routes)\n\n    @property\n    def on_response_prepare(self) -> _RespPrepareSignal:\n        return self._on_response_prepare\n\n    @property\n    def on_startup(self) -> _AppSignal:\n        return self._on_startup\n\n    @property\n    def on_shutdown(self) -> _AppSignal:\n        return self._on_shutdown\n\n    @property\n    def on_cleanup(self) -> _AppSignal:\n        return self._on_cleanup\n\n    @property\n    def cleanup_ctx(self) -> \"CleanupContext\":\n        return self._cleanup_ctx\n\n    @property\n    def router(self) -> UrlDispatcher:\n        return self._router\n\n    @property\n    def middlewares(self) -> _Middlewares:\n        return self._middlewares\n\n    async def startup(self) -> None:\n        \"\"\"Causes on_startup signal\n\n        Should be called in the event loop along with the request handler.\n        \"\"\"\n        await self.on_startup.send(self)\n\n    async def shutdown(self) -> None:\n        \"\"\"Causes on_shutdown signal\n\n        Should be called before cleanup()\n        \"\"\"\n        await self.on_shutdown.send(self)\n\n    async def cleanup(self) -> None:\n        \"\"\"Causes on_cleanup signal\n\n        Should be called after shutdown()\n        \"\"\"\n        if self.on_cleanup.frozen:\n            await self.on_cleanup.send(self)\n        else:\n            # If an exception occurs in startup, ensure cleanup contexts are completed.\n            await self._cleanup_ctx._on_cleanup(self)\n\n    def _prepare_middleware(self) -> Iterator[Middleware]:\n        yield from reversed(self._middlewares)\n        yield _fix_request_current_app(self)\n\n    async def _handle(self, request: Request) -> StreamResponse:\n        match_info = await self._router.resolve(request)\n        match_info.add_app(self)\n        match_info.freeze()\n\n        resp = None\n        request._match_info = match_info\n        expect = request.headers.get(hdrs.EXPECT)\n        if expect:\n            resp = await match_info.expect_handler(request)\n            await request.writer.drain()\n\n        if resp is None:\n            handler = match_info.handler\n\n            if self._run_middlewares:\n                for app in match_info.apps[::-1]:\n                    assert app.pre_frozen, \"middleware handlers are not ready\"\n                    for m in app._middlewares_handlers:\n                        handler = update_wrapper(partial(m, handler=handler), handler)\n\n            resp = await handler(request)\n\n        return resp\n\n    def __call__(self) -> \"Application\":\n        \"\"\"gunicorn compatibility\"\"\"\n        return self\n\n    def __repr__(self) -> str:\n        return f\"<Application 0x{id(self):x}>\"\n\n    def __bool__(self) -> bool:\n        return True\n\n\nclass CleanupError(RuntimeError):\n    @property\n    def exceptions(self) -> List[BaseException]:\n        return cast(List[BaseException], self.args[1])\n\n\nif TYPE_CHECKING:  # pragma: no cover\n    _CleanupContextBase = FrozenList[Callable[[Application], AsyncIterator[None]]]\nelse:\n    _CleanupContextBase = FrozenList\n\n\nclass CleanupContext(_CleanupContextBase):\n    def __init__(self) -> None:\n        super().__init__()\n        self._exits: List[AsyncIterator[None]] = []\n\n    async def _on_startup(self, app: Application) -> None:\n        for cb in self:\n            it = cb(app).__aiter__()\n            await it.__anext__()\n            self._exits.append(it)\n\n    async def _on_cleanup(self, app: Application) -> None:\n        errors = []\n        for it in reversed(self._exits):\n            try:\n                await it.__anext__()\n            except StopAsyncIteration:\n                pass\n            except Exception as exc:\n                errors.append(exc)\n            else:\n                errors.append(RuntimeError(f\"{it!r} has more than one 'yield'\"))\n        if errors:\n            if len(errors) == 1:\n                raise errors[0]\n            else:\n                raise CleanupError(\"Multiple errors on cleanup stage\", errors)\n",
            "header": {
                "file": {
                    "path": "aiohttp/web_app.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "80956831",
                "new_commit_hash": "4b64dd8b",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/aiohttp/web_app.py"
            },
            "plus_file": {
                "path": "b/aiohttp/web_app.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 173,
                            "length": 7
                        },
                        "new_range": {
                            "start": 173,
                            "length": 8
                        },
                        "section": "class Application(MutableMapping[Union[str, AppKey[Any]], Any]):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "            warnings.warn(",
                                "type": "context"
                            },
                            {
                                "content": "                \"It is recommended to use web.AppKey instances for keys.\\n\"",
                                "type": "context"
                            },
                            {
                                "content": "                + \"https://docs.aiohttp.org/en/stable/web_advanced.html\"",
                                "type": "context"
                            },
                            {
                                "content": "                + \"#application-s-config\"",
                                "type": "deleted"
                            },
                            {
                                "content": "                + \"#application-s-config\",",
                                "type": "added"
                            },
                            {
                                "content": "                stacklevel=2,",
                                "type": "added"
                            },
                            {
                                "content": "            )",
                                "type": "context"
                            },
                            {
                                "content": "        self._state[key] = value",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "aiohttp/web_app.py",
                            "type": "method",
                            "name": "Application.__setitem__",
                            "content": "class Application(MutableMapping[Union[str, AppKey[Any]], Any]):\n    __slots__ = (\n        \"logger\",\n        \"_debug\",\n        \"_router\",\n        \"_loop\",\n        \"_handler_args\",\n        \"_middlewares\",\n        \"_middlewares_handlers\",\n        \"_run_middlewares\",\n        \"_state\",\n        \"_frozen\",\n        \"_pre_frozen\",\n        \"_subapps\",\n        \"_on_response_prepare\",\n        \"_on_startup\",\n        \"_on_shutdown\",\n        \"_on_cleanup\",\n        \"_client_max_size\",\n        \"_cleanup_ctx\",\n    )\n\n    def __init__(\n        self,\n        *,\n        logger: logging.Logger = web_logger,\n        middlewares: Iterable[Middleware] = (),\n        handler_args: Optional[Mapping[str, Any]] = None,\n        client_max_size: int = 1024**2,\n        debug: Any = ...,  # mypy doesn't support ellipsis\n    ) -> None:\n        if debug is not ...:\n            warnings.warn(\n                \"debug argument is no-op since 4.0 \" \"and scheduled for removal in 5.0\",\n                DeprecationWarning,\n                stacklevel=2,\n            )\n        self._router = UrlDispatcher()\n        self._handler_args = handler_args\n        self.logger = logger\n\n        self._middlewares: _Middlewares = FrozenList(middlewares)\n\n        # initialized on freezing\n        self._middlewares_handlers: _MiddlewaresHandlers = tuple()\n        # initialized on freezing\n        self._run_middlewares: Optional[bool] = None\n\n        self._state: Dict[Union[AppKey[Any], str], object] = {}\n        self._frozen = False\n        self._pre_frozen = False\n        self._subapps: _Subapps = []\n\n        self._on_response_prepare: _RespPrepareSignal = Signal(self)\n        self._on_startup: _AppSignal = Signal(self)\n        self._on_shutdown: _AppSignal = Signal(self)\n        self._on_cleanup: _AppSignal = Signal(self)\n        self._cleanup_ctx = CleanupContext()\n        self._on_startup.append(self._cleanup_ctx._on_startup)\n        self._on_cleanup.append(self._cleanup_ctx._on_cleanup)\n        self._client_max_size = client_max_size\n\n    def __init_subclass__(cls: Type[\"Application\"]) -> None:\n        raise TypeError(\n            \"Inheritance class {} from web.Application \"\n            \"is forbidden\".format(cls.__name__)\n        )\n\n    # MutableMapping API\n\n    def __eq__(self, other: object) -> bool:\n        return self is other\n\n    @overload  # type: ignore[override]\n    def __getitem__(self, key: AppKey[_T]) -> _T:\n        ...\n\n    @overload\n    def __getitem__(self, key: str) -> Any:\n        ...\n\n    def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:\n        return self._state[key]\n\n    def _check_frozen(self) -> None:\n        if self._frozen:\n            raise RuntimeError(\n                \"Changing state of started or joined \" \"application is forbidden\"\n            )\n\n    @overload  # type: ignore[override]\n    def __setitem__(self, key: AppKey[_T], value: _T) -> None:\n        ...\n\n    @overload\n    def __setitem__(self, key: str, value: Any) -> None:\n        ...\n\n    def __setitem__(self, key: Union[str, AppKey[_T]], value: Any) -> None:\n        self._check_frozen()\n        if not isinstance(key, AppKey):\n            warnings.warn(\n                \"It is recommended to use web.AppKey instances for keys.\\n\"\n                + \"https://docs.aiohttp.org/en/stable/web_advanced.html\"\n                + \"#application-s-config\"\n            )\n        self._state[key] = value\n\n    def __delitem__(self, key: Union[str, AppKey[_T]]) -> None:\n        self._check_frozen()\n        del self._state[key]\n\n    def __len__(self) -> int:\n        return len(self._state)\n\n    def __iter__(self) -> Iterator[Union[str, AppKey[Any]]]:\n        return iter(self._state)\n\n    @overload  # type: ignore[override]\n    def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]:\n        ...\n\n    @overload\n    def get(self, key: AppKey[_T], default: _U) -> Union[_T, _U]:\n        ...\n\n    @overload\n    def get(self, key: str, default: Any = ...) -> Any:\n        ...\n\n    def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:\n        return self._state.get(key, default)\n\n    ########\n    def _set_loop(self, loop: Optional[asyncio.AbstractEventLoop]) -> None:\n        warnings.warn(\n            \"_set_loop() is no-op since 4.0 \" \"and scheduled for removal in 5.0\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n\n    @property\n    def pre_frozen(self) -> bool:\n        return self._pre_frozen\n\n    def pre_freeze(self) -> None:\n        if self._pre_frozen:\n            return\n\n        self._pre_frozen = True\n        self._middlewares.freeze()\n        self._router.freeze()\n        self._on_response_prepare.freeze()\n        self._cleanup_ctx.freeze()\n        self._on_startup.freeze()\n        self._on_shutdown.freeze()\n        self._on_cleanup.freeze()\n        self._middlewares_handlers = tuple(self._prepare_middleware())\n\n        # If current app and any subapp do not have middlewares avoid run all\n        # of the code footprint that it implies, which have a middleware\n        # hardcoded per app that sets up the current_app attribute. If no\n        # middlewares are configured the handler will receive the proper\n        # current_app without needing all of this code.\n        self._run_middlewares = True if self.middlewares else False\n\n        for subapp in self._subapps:\n            subapp.pre_freeze()\n            self._run_middlewares = self._run_middlewares or subapp._run_middlewares\n\n    @property\n    def frozen(self) -> bool:\n        return self._frozen\n\n    def freeze(self) -> None:\n        if self._frozen:\n            return\n\n        self.pre_freeze()\n        self._frozen = True\n        for subapp in self._subapps:\n            subapp.freeze()\n\n    @property\n    def debug(self) -> bool:\n        warnings.warn(\n            \"debug property is deprecated since 4.0\" \"and scheduled for removal in 5.0\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n        return asyncio.get_event_loop().get_debug()\n\n    def _reg_subapp_signals(self, subapp: \"Application\") -> None:\n        def reg_handler(signame: str) -> None:\n            subsig = getattr(subapp, signame)\n\n            async def handler(app: \"Application\") -> None:\n                await subsig.send(subapp)\n\n            appsig = getattr(self, signame)\n            appsig.append(handler)\n\n        reg_handler(\"on_startup\")\n        reg_handler(\"on_shutdown\")\n        reg_handler(\"on_cleanup\")\n\n    def add_subapp(self, prefix: str, subapp: \"Application\") -> AbstractResource:\n        if not isinstance(prefix, str):\n            raise TypeError(\"Prefix must be str\")\n        prefix = prefix.rstrip(\"/\")\n        if not prefix:\n            raise ValueError(\"Prefix cannot be empty\")\n        factory = partial(PrefixedSubAppResource, prefix, subapp)\n        return self._add_subapp(factory, subapp)\n\n    def _add_subapp(\n        self, resource_factory: Callable[[], AbstractResource], subapp: \"Application\"\n    ) -> AbstractResource:\n        if self.frozen:\n            raise RuntimeError(\"Cannot add sub application to frozen application\")\n        if subapp.frozen:\n            raise RuntimeError(\"Cannot add frozen application\")\n        resource = resource_factory()\n        self.router.register_resource(resource)\n        self._reg_subapp_signals(subapp)\n        self._subapps.append(subapp)\n        subapp.pre_freeze()\n        return resource\n\n    def add_domain(self, domain: str, subapp: \"Application\") -> AbstractResource:\n        if not isinstance(domain, str):\n            raise TypeError(\"Domain must be str\")\n        elif \"*\" in domain:\n            rule: Domain = MaskDomain(domain)\n        else:\n            rule = Domain(domain)\n        factory = partial(MatchedSubAppResource, rule, subapp)\n        return self._add_subapp(factory, subapp)\n\n    def add_routes(self, routes: Iterable[AbstractRouteDef]) -> List[AbstractRoute]:\n        return self.router.add_routes(routes)\n\n    @property\n    def on_response_prepare(self) -> _RespPrepareSignal:\n        return self._on_response_prepare\n\n    @property\n    def on_startup(self) -> _AppSignal:\n        return self._on_startup\n\n    @property\n    def on_shutdown(self) -> _AppSignal:\n        return self._on_shutdown\n\n    @property\n    def on_cleanup(self) -> _AppSignal:\n        return self._on_cleanup\n\n    @property\n    def cleanup_ctx(self) -> \"CleanupContext\":\n        return self._cleanup_ctx\n\n    @property\n    def router(self) -> UrlDispatcher:\n        return self._router\n\n    @property\n    def middlewares(self) -> _Middlewares:\n        return self._middlewares\n\n    async def startup(self) -> None:\n        \"\"\"Causes on_startup signal\n\n        Should be called in the event loop along with the request handler.\n        \"\"\"\n        await self.on_startup.send(self)\n\n    async def shutdown(self) -> None:\n        \"\"\"Causes on_shutdown signal\n\n        Should be called before cleanup()\n        \"\"\"\n        await self.on_shutdown.send(self)\n\n    async def cleanup(self) -> None:\n        \"\"\"Causes on_cleanup signal\n\n        Should be called after shutdown()\n        \"\"\"\n        if self.on_cleanup.frozen:\n            await self.on_cleanup.send(self)\n        else:\n            # If an exception occurs in startup, ensure cleanup contexts are completed.\n            await self._cleanup_ctx._on_cleanup(self)\n\n    def _prepare_middleware(self) -> Iterator[Middleware]:\n        yield from reversed(self._middlewares)\n        yield _fix_request_current_app(self)\n\n    async def _handle(self, request: Request) -> StreamResponse:\n        match_info = await self._router.resolve(request)\n        match_info.add_app(self)\n        match_info.freeze()\n\n        resp = None\n        request._match_info = match_info\n        expect = request.headers.get(hdrs.EXPECT)\n        if expect:\n            resp = await match_info.expect_handler(request)\n            await request.writer.drain()\n\n        if resp is None:\n            handler = match_info.handler\n\n            if self._run_middlewares:\n                for app in match_info.apps[::-1]:\n                    assert app.pre_frozen, \"middleware handlers are not ready\"\n                    for m in app._middlewares_handlers:\n                        handler = update_wrapper(partial(m, handler=handler), handler)\n\n            resp = await handler(request)\n\n        return resp\n\n    def __call__(self) -> \"Application\":\n        \"\"\"gunicorn compatibility\"\"\"\n        return self\n\n    def __repr__(self) -> str:\n        return f\"<Application 0x{id(self):x}>\"\n\n    def __bool__(self) -> bool:\n        return True",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 170,
                            "end_lineno": 178,
                            "parent": {
                                "file_name": "aiohttp/web_app.py",
                                "type": "class",
                                "name": "Application",
                                "content": "class Application(MutableMapping[Union[str, AppKey[Any]], Any]):\n    __slots__ = (\n        \"logger\",\n        \"_debug\",\n        \"_router\",\n        \"_loop\",\n        \"_handler_args\",\n        \"_middlewares\",\n        \"_middlewares_handlers\",\n        \"_run_middlewares\",\n        \"_state\",\n        \"_frozen\",\n        \"_pre_frozen\",\n        \"_subapps\",\n        \"_on_response_prepare\",\n        \"_on_startup\",\n        \"_on_shutdown\",\n        \"_on_cleanup\",\n        \"_client_max_size\",\n        \"_cleanup_ctx\",\n    )\n\n    def __init__(\n        self,\n        *,\n        logger: logging.Logger = web_logger,\n        middlewares: Iterable[Middleware] = (),\n        handler_args: Optional[Mapping[str, Any]] = None,\n        client_max_size: int = 1024**2,\n        debug: Any = ...,  # mypy doesn't support ellipsis\n    ) -> None:\n        if debug is not ...:\n            warnings.warn(\n                \"debug argument is no-op since 4.0 \" \"and scheduled for removal in 5.0\",\n                DeprecationWarning,\n                stacklevel=2,\n            )\n        self._router = UrlDispatcher()\n        self._handler_args = handler_args\n        self.logger = logger\n\n        self._middlewares: _Middlewares = FrozenList(middlewares)\n\n        # initialized on freezing\n        self._middlewares_handlers: _MiddlewaresHandlers = tuple()\n        # initialized on freezing\n        self._run_middlewares: Optional[bool] = None\n\n        self._state: Dict[Union[AppKey[Any], str], object] = {}\n        self._frozen = False\n        self._pre_frozen = False\n        self._subapps: _Subapps = []\n\n        self._on_response_prepare: _RespPrepareSignal = Signal(self)\n        self._on_startup: _AppSignal = Signal(self)\n        self._on_shutdown: _AppSignal = Signal(self)\n        self._on_cleanup: _AppSignal = Signal(self)\n        self._cleanup_ctx = CleanupContext()\n        self._on_startup.append(self._cleanup_ctx._on_startup)\n        self._on_cleanup.append(self._cleanup_ctx._on_cleanup)\n        self._client_max_size = client_max_size\n\n    def __init_subclass__(cls: Type[\"Application\"]) -> None:\n        raise TypeError(\n            \"Inheritance class {} from web.Application \"\n            \"is forbidden\".format(cls.__name__)\n        )\n\n    # MutableMapping API\n\n    def __eq__(self, other: object) -> bool:\n        return self is other\n\n    @overload  # type: ignore[override]\n    def __getitem__(self, key: AppKey[_T]) -> _T:\n        ...\n\n    @overload\n    def __getitem__(self, key: str) -> Any:\n        ...\n\n    def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:\n        return self._state[key]\n\n    def _check_frozen(self) -> None:\n        if self._frozen:\n            raise RuntimeError(\n                \"Changing state of started or joined \" \"application is forbidden\"\n            )\n\n    @overload  # type: ignore[override]\n    def __setitem__(self, key: AppKey[_T], value: _T) -> None:\n        ...\n\n    @overload\n    def __setitem__(self, key: str, value: Any) -> None:\n        ...\n\n    def __setitem__(self, key: Union[str, AppKey[_T]], value: Any) -> None:\n        self._check_frozen()\n        if not isinstance(key, AppKey):\n            warnings.warn(\n                \"It is recommended to use web.AppKey instances for keys.\\n\"\n                + \"https://docs.aiohttp.org/en/stable/web_advanced.html\"\n                + \"#application-s-config\"\n            )\n        self._state[key] = value\n\n    def __delitem__(self, key: Union[str, AppKey[_T]]) -> None:\n        self._check_frozen()\n        del self._state[key]\n\n    def __len__(self) -> int:\n        return len(self._state)\n\n    def __iter__(self) -> Iterator[Union[str, AppKey[Any]]]:\n        return iter(self._state)\n\n    @overload  # type: ignore[override]\n    def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]:\n        ...\n\n    @overload\n    def get(self, key: AppKey[_T], default: _U) -> Union[_T, _U]:\n        ...\n\n    @overload\n    def get(self, key: str, default: Any = ...) -> Any:\n        ...\n\n    def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:\n        return self._state.get(key, default)\n\n    ########\n    def _set_loop(self, loop: Optional[asyncio.AbstractEventLoop]) -> None:\n        warnings.warn(\n            \"_set_loop() is no-op since 4.0 \" \"and scheduled for removal in 5.0\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n\n    @property\n    def pre_frozen(self) -> bool:\n        return self._pre_frozen\n\n    def pre_freeze(self) -> None:\n        if self._pre_frozen:\n            return\n\n        self._pre_frozen = True\n        self._middlewares.freeze()\n        self._router.freeze()\n        self._on_response_prepare.freeze()\n        self._cleanup_ctx.freeze()\n        self._on_startup.freeze()\n        self._on_shutdown.freeze()\n        self._on_cleanup.freeze()\n        self._middlewares_handlers = tuple(self._prepare_middleware())\n\n        # If current app and any subapp do not have middlewares avoid run all\n        # of the code footprint that it implies, which have a middleware\n        # hardcoded per app that sets up the current_app attribute. If no\n        # middlewares are configured the handler will receive the proper\n        # current_app without needing all of this code.\n        self._run_middlewares = True if self.middlewares else False\n\n        for subapp in self._subapps:\n            subapp.pre_freeze()\n            self._run_middlewares = self._run_middlewares or subapp._run_middlewares\n\n    @property\n    def frozen(self) -> bool:\n        return self._frozen\n\n    def freeze(self) -> None:\n        if self._frozen:\n            return\n\n        self.pre_freeze()\n        self._frozen = True\n        for subapp in self._subapps:\n            subapp.freeze()\n\n    @property\n    def debug(self) -> bool:\n        warnings.warn(\n            \"debug property is deprecated since 4.0\" \"and scheduled for removal in 5.0\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n        return asyncio.get_event_loop().get_debug()\n\n    def _reg_subapp_signals(self, subapp: \"Application\") -> None:\n        def reg_handler(signame: str) -> None:\n            subsig = getattr(subapp, signame)\n\n            async def handler(app: \"Application\") -> None:\n                await subsig.send(subapp)\n\n            appsig = getattr(self, signame)\n            appsig.append(handler)\n\n        reg_handler(\"on_startup\")\n        reg_handler(\"on_shutdown\")\n        reg_handler(\"on_cleanup\")\n\n    def add_subapp(self, prefix: str, subapp: \"Application\") -> AbstractResource:\n        if not isinstance(prefix, str):\n            raise TypeError(\"Prefix must be str\")\n        prefix = prefix.rstrip(\"/\")\n        if not prefix:\n            raise ValueError(\"Prefix cannot be empty\")\n        factory = partial(PrefixedSubAppResource, prefix, subapp)\n        return self._add_subapp(factory, subapp)\n\n    def _add_subapp(\n        self, resource_factory: Callable[[], AbstractResource], subapp: \"Application\"\n    ) -> AbstractResource:\n        if self.frozen:\n            raise RuntimeError(\"Cannot add sub application to frozen application\")\n        if subapp.frozen:\n            raise RuntimeError(\"Cannot add frozen application\")\n        resource = resource_factory()\n        self.router.register_resource(resource)\n        self._reg_subapp_signals(subapp)\n        self._subapps.append(subapp)\n        subapp.pre_freeze()\n        return resource\n\n    def add_domain(self, domain: str, subapp: \"Application\") -> AbstractResource:\n        if not isinstance(domain, str):\n            raise TypeError(\"Domain must be str\")\n        elif \"*\" in domain:\n            rule: Domain = MaskDomain(domain)\n        else:\n            rule = Domain(domain)\n        factory = partial(MatchedSubAppResource, rule, subapp)\n        return self._add_subapp(factory, subapp)\n\n    def add_routes(self, routes: Iterable[AbstractRouteDef]) -> List[AbstractRoute]:\n        return self.router.add_routes(routes)\n\n    @property\n    def on_response_prepare(self) -> _RespPrepareSignal:\n        return self._on_response_prepare\n\n    @property\n    def on_startup(self) -> _AppSignal:\n        return self._on_startup\n\n    @property\n    def on_shutdown(self) -> _AppSignal:\n        return self._on_shutdown\n\n    @property\n    def on_cleanup(self) -> _AppSignal:\n        return self._on_cleanup\n\n    @property\n    def cleanup_ctx(self) -> \"CleanupContext\":\n        return self._cleanup_ctx\n\n    @property\n    def router(self) -> UrlDispatcher:\n        return self._router\n\n    @property\n    def middlewares(self) -> _Middlewares:\n        return self._middlewares\n\n    async def startup(self) -> None:\n        \"\"\"Causes on_startup signal\n\n        Should be called in the event loop along with the request handler.\n        \"\"\"\n        await self.on_startup.send(self)\n\n    async def shutdown(self) -> None:\n        \"\"\"Causes on_shutdown signal\n\n        Should be called before cleanup()\n        \"\"\"\n        await self.on_shutdown.send(self)\n\n    async def cleanup(self) -> None:\n        \"\"\"Causes on_cleanup signal\n\n        Should be called after shutdown()\n        \"\"\"\n        if self.on_cleanup.frozen:\n            await self.on_cleanup.send(self)\n        else:\n            # If an exception occurs in startup, ensure cleanup contexts are completed.\n            await self._cleanup_ctx._on_cleanup(self)\n\n    def _prepare_middleware(self) -> Iterator[Middleware]:\n        yield from reversed(self._middlewares)\n        yield _fix_request_current_app(self)\n\n    async def _handle(self, request: Request) -> StreamResponse:\n        match_info = await self._router.resolve(request)\n        match_info.add_app(self)\n        match_info.freeze()\n\n        resp = None\n        request._match_info = match_info\n        expect = request.headers.get(hdrs.EXPECT)\n        if expect:\n            resp = await match_info.expect_handler(request)\n            await request.writer.drain()\n\n        if resp is None:\n            handler = match_info.handler\n\n            if self._run_middlewares:\n                for app in match_info.apps[::-1]:\n                    assert app.pre_frozen, \"middleware handlers are not ready\"\n                    for m in app._middlewares_handlers:\n                        handler = update_wrapper(partial(m, handler=handler), handler)\n\n            resp = await handler(request)\n\n        return resp\n\n    def __call__(self) -> \"Application\":\n        \"\"\"gunicorn compatibility\"\"\"\n        return self\n\n    def __repr__(self) -> str:\n        return f\"<Application 0x{id(self):x}>\"\n\n    def __bool__(self) -> bool:\n        return True",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 72,
                                "end_lineno": 404,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "aiohttp/web_app.py",
                            "type": "class",
                            "name": "Application",
                            "content": "class Application(MutableMapping[Union[str, AppKey[Any]], Any]):\n    __slots__ = (\n        \"logger\",\n        \"_debug\",\n        \"_router\",\n        \"_loop\",\n        \"_handler_args\",\n        \"_middlewares\",\n        \"_middlewares_handlers\",\n        \"_run_middlewares\",\n        \"_state\",\n        \"_frozen\",\n        \"_pre_frozen\",\n        \"_subapps\",\n        \"_on_response_prepare\",\n        \"_on_startup\",\n        \"_on_shutdown\",\n        \"_on_cleanup\",\n        \"_client_max_size\",\n        \"_cleanup_ctx\",\n    )\n\n    def __init__(\n        self,\n        *,\n        logger: logging.Logger = web_logger,\n        middlewares: Iterable[Middleware] = (),\n        handler_args: Optional[Mapping[str, Any]] = None,\n        client_max_size: int = 1024**2,\n        debug: Any = ...,  # mypy doesn't support ellipsis\n    ) -> None:\n        if debug is not ...:\n            warnings.warn(\n                \"debug argument is no-op since 4.0 \" \"and scheduled for removal in 5.0\",\n                DeprecationWarning,\n                stacklevel=2,\n            )\n        self._router = UrlDispatcher()\n        self._handler_args = handler_args\n        self.logger = logger\n\n        self._middlewares: _Middlewares = FrozenList(middlewares)\n\n        # initialized on freezing\n        self._middlewares_handlers: _MiddlewaresHandlers = tuple()\n        # initialized on freezing\n        self._run_middlewares: Optional[bool] = None\n\n        self._state: Dict[Union[AppKey[Any], str], object] = {}\n        self._frozen = False\n        self._pre_frozen = False\n        self._subapps: _Subapps = []\n\n        self._on_response_prepare: _RespPrepareSignal = Signal(self)\n        self._on_startup: _AppSignal = Signal(self)\n        self._on_shutdown: _AppSignal = Signal(self)\n        self._on_cleanup: _AppSignal = Signal(self)\n        self._cleanup_ctx = CleanupContext()\n        self._on_startup.append(self._cleanup_ctx._on_startup)\n        self._on_cleanup.append(self._cleanup_ctx._on_cleanup)\n        self._client_max_size = client_max_size\n\n    def __init_subclass__(cls: Type[\"Application\"]) -> None:\n        raise TypeError(\n            \"Inheritance class {} from web.Application \"\n            \"is forbidden\".format(cls.__name__)\n        )\n\n    # MutableMapping API\n\n    def __eq__(self, other: object) -> bool:\n        return self is other\n\n    @overload  # type: ignore[override]\n    def __getitem__(self, key: AppKey[_T]) -> _T:\n        ...\n\n    @overload\n    def __getitem__(self, key: str) -> Any:\n        ...\n\n    def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:\n        return self._state[key]\n\n    def _check_frozen(self) -> None:\n        if self._frozen:\n            raise RuntimeError(\n                \"Changing state of started or joined \" \"application is forbidden\"\n            )\n\n    @overload  # type: ignore[override]\n    def __setitem__(self, key: AppKey[_T], value: _T) -> None:\n        ...\n\n    @overload\n    def __setitem__(self, key: str, value: Any) -> None:\n        ...\n\n    def __setitem__(self, key: Union[str, AppKey[_T]], value: Any) -> None:\n        self._check_frozen()\n        if not isinstance(key, AppKey):\n            warnings.warn(\n                \"It is recommended to use web.AppKey instances for keys.\\n\"\n                + \"https://docs.aiohttp.org/en/stable/web_advanced.html\"\n                + \"#application-s-config\"\n            )\n        self._state[key] = value\n\n    def __delitem__(self, key: Union[str, AppKey[_T]]) -> None:\n        self._check_frozen()\n        del self._state[key]\n\n    def __len__(self) -> int:\n        return len(self._state)\n\n    def __iter__(self) -> Iterator[Union[str, AppKey[Any]]]:\n        return iter(self._state)\n\n    @overload  # type: ignore[override]\n    def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]:\n        ...\n\n    @overload\n    def get(self, key: AppKey[_T], default: _U) -> Union[_T, _U]:\n        ...\n\n    @overload\n    def get(self, key: str, default: Any = ...) -> Any:\n        ...\n\n    def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:\n        return self._state.get(key, default)\n\n    ########\n    def _set_loop(self, loop: Optional[asyncio.AbstractEventLoop]) -> None:\n        warnings.warn(\n            \"_set_loop() is no-op since 4.0 \" \"and scheduled for removal in 5.0\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n\n    @property\n    def pre_frozen(self) -> bool:\n        return self._pre_frozen\n\n    def pre_freeze(self) -> None:\n        if self._pre_frozen:\n            return\n\n        self._pre_frozen = True\n        self._middlewares.freeze()\n        self._router.freeze()\n        self._on_response_prepare.freeze()\n        self._cleanup_ctx.freeze()\n        self._on_startup.freeze()\n        self._on_shutdown.freeze()\n        self._on_cleanup.freeze()\n        self._middlewares_handlers = tuple(self._prepare_middleware())\n\n        # If current app and any subapp do not have middlewares avoid run all\n        # of the code footprint that it implies, which have a middleware\n        # hardcoded per app that sets up the current_app attribute. If no\n        # middlewares are configured the handler will receive the proper\n        # current_app without needing all of this code.\n        self._run_middlewares = True if self.middlewares else False\n\n        for subapp in self._subapps:\n            subapp.pre_freeze()\n            self._run_middlewares = self._run_middlewares or subapp._run_middlewares\n\n    @property\n    def frozen(self) -> bool:\n        return self._frozen\n\n    def freeze(self) -> None:\n        if self._frozen:\n            return\n\n        self.pre_freeze()\n        self._frozen = True\n        for subapp in self._subapps:\n            subapp.freeze()\n\n    @property\n    def debug(self) -> bool:\n        warnings.warn(\n            \"debug property is deprecated since 4.0\" \"and scheduled for removal in 5.0\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n        return asyncio.get_event_loop().get_debug()\n\n    def _reg_subapp_signals(self, subapp: \"Application\") -> None:\n        def reg_handler(signame: str) -> None:\n            subsig = getattr(subapp, signame)\n\n            async def handler(app: \"Application\") -> None:\n                await subsig.send(subapp)\n\n            appsig = getattr(self, signame)\n            appsig.append(handler)\n\n        reg_handler(\"on_startup\")\n        reg_handler(\"on_shutdown\")\n        reg_handler(\"on_cleanup\")\n\n    def add_subapp(self, prefix: str, subapp: \"Application\") -> AbstractResource:\n        if not isinstance(prefix, str):\n            raise TypeError(\"Prefix must be str\")\n        prefix = prefix.rstrip(\"/\")\n        if not prefix:\n            raise ValueError(\"Prefix cannot be empty\")\n        factory = partial(PrefixedSubAppResource, prefix, subapp)\n        return self._add_subapp(factory, subapp)\n\n    def _add_subapp(\n        self, resource_factory: Callable[[], AbstractResource], subapp: \"Application\"\n    ) -> AbstractResource:\n        if self.frozen:\n            raise RuntimeError(\"Cannot add sub application to frozen application\")\n        if subapp.frozen:\n            raise RuntimeError(\"Cannot add frozen application\")\n        resource = resource_factory()\n        self.router.register_resource(resource)\n        self._reg_subapp_signals(subapp)\n        self._subapps.append(subapp)\n        subapp.pre_freeze()\n        return resource\n\n    def add_domain(self, domain: str, subapp: \"Application\") -> AbstractResource:\n        if not isinstance(domain, str):\n            raise TypeError(\"Domain must be str\")\n        elif \"*\" in domain:\n            rule: Domain = MaskDomain(domain)\n        else:\n            rule = Domain(domain)\n        factory = partial(MatchedSubAppResource, rule, subapp)\n        return self._add_subapp(factory, subapp)\n\n    def add_routes(self, routes: Iterable[AbstractRouteDef]) -> List[AbstractRoute]:\n        return self.router.add_routes(routes)\n\n    @property\n    def on_response_prepare(self) -> _RespPrepareSignal:\n        return self._on_response_prepare\n\n    @property\n    def on_startup(self) -> _AppSignal:\n        return self._on_startup\n\n    @property\n    def on_shutdown(self) -> _AppSignal:\n        return self._on_shutdown\n\n    @property\n    def on_cleanup(self) -> _AppSignal:\n        return self._on_cleanup\n\n    @property\n    def cleanup_ctx(self) -> \"CleanupContext\":\n        return self._cleanup_ctx\n\n    @property\n    def router(self) -> UrlDispatcher:\n        return self._router\n\n    @property\n    def middlewares(self) -> _Middlewares:\n        return self._middlewares\n\n    async def startup(self) -> None:\n        \"\"\"Causes on_startup signal\n\n        Should be called in the event loop along with the request handler.\n        \"\"\"\n        await self.on_startup.send(self)\n\n    async def shutdown(self) -> None:\n        \"\"\"Causes on_shutdown signal\n\n        Should be called before cleanup()\n        \"\"\"\n        await self.on_shutdown.send(self)\n\n    async def cleanup(self) -> None:\n        \"\"\"Causes on_cleanup signal\n\n        Should be called after shutdown()\n        \"\"\"\n        if self.on_cleanup.frozen:\n            await self.on_cleanup.send(self)\n        else:\n            # If an exception occurs in startup, ensure cleanup contexts are completed.\n            await self._cleanup_ctx._on_cleanup(self)\n\n    def _prepare_middleware(self) -> Iterator[Middleware]:\n        yield from reversed(self._middlewares)\n        yield _fix_request_current_app(self)\n\n    async def _handle(self, request: Request) -> StreamResponse:\n        match_info = await self._router.resolve(request)\n        match_info.add_app(self)\n        match_info.freeze()\n\n        resp = None\n        request._match_info = match_info\n        expect = request.headers.get(hdrs.EXPECT)\n        if expect:\n            resp = await match_info.expect_handler(request)\n            await request.writer.drain()\n\n        if resp is None:\n            handler = match_info.handler\n\n            if self._run_middlewares:\n                for app in match_info.apps[::-1]:\n                    assert app.pre_frozen, \"middleware handlers are not ready\"\n                    for m in app._middlewares_handlers:\n                        handler = update_wrapper(partial(m, handler=handler), handler)\n\n            resp = await handler(request)\n\n        return resp\n\n    def __call__(self) -> \"Application\":\n        \"\"\"gunicorn compatibility\"\"\"\n        return self\n\n    def __repr__(self) -> str:\n        return f\"<Application 0x{id(self):x}>\"\n\n    def __bool__(self) -> bool:\n        return True",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 72,
                            "end_lineno": 404,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "import asyncio\nfrom typing import Any, AsyncIterator, Callable, Iterator, NoReturn\nfrom unittest import mock\n\nimport pytest\n\nfrom aiohttp import log, web\nfrom aiohttp.test_utils import make_mocked_coro\nfrom aiohttp.typedefs import Handler\n\n\nasync def test_app_ctor() -> None:\n    app = web.Application()\n    assert app.logger is log.web_logger\n\n\ndef test_app_call() -> None:\n    app = web.Application()\n    assert app is app()\n\n\nasync def test_app_register_on_finish() -> None:\n    app = web.Application()\n    cb1 = make_mocked_coro(None)\n    cb2 = make_mocked_coro(None)\n    app.on_cleanup.append(cb1)\n    app.on_cleanup.append(cb2)\n    app.freeze()\n    await app.cleanup()\n    cb1.assert_called_once_with(app)\n    cb2.assert_called_once_with(app)\n\n\nasync def test_app_register_coro() -> None:\n    app = web.Application()\n    fut = asyncio.get_event_loop().create_future()\n\n    async def cb(app: web.Application) -> None:\n        await asyncio.sleep(0.001)\n        fut.set_result(123)\n\n    app.on_cleanup.append(cb)\n    app.freeze()\n    await app.cleanup()\n    assert fut.done()\n    assert 123 == fut.result()\n\n\ndef test_logging() -> None:\n    logger = mock.Mock()\n    app = web.Application()\n    app.logger = logger\n    assert app.logger is logger\n\n\nasync def test_on_shutdown() -> None:\n    app = web.Application()\n    called = False\n\n    async def on_shutdown(app_param: web.Application) -> None:\n        nonlocal called\n        assert app is app_param\n        called = True\n\n    app.on_shutdown.append(on_shutdown)\n    app.freeze()\n    await app.shutdown()\n    assert called\n\n\nasync def test_on_startup() -> None:\n    app = web.Application()\n\n    long_running1_called = False\n    long_running2_called = False\n    all_long_running_called = False\n\n    async def long_running1(app_param: web.Application) -> None:\n        nonlocal long_running1_called\n        assert app is app_param\n        long_running1_called = True\n\n    async def long_running2(app_param: web.Application) -> None:\n        nonlocal long_running2_called\n        assert app is app_param\n        long_running2_called = True\n\n    async def on_startup_all_long_running(app_param: web.Application) -> None:\n        nonlocal all_long_running_called\n        assert app is app_param\n        all_long_running_called = True\n        await asyncio.gather(long_running1(app_param), long_running2(app_param))\n\n    app.on_startup.append(on_startup_all_long_running)\n    app.freeze()\n\n    await app.startup()\n    assert long_running1_called\n    assert long_running2_called\n    assert all_long_running_called\n\n\ndef test_appkey() -> None:\n    key = web.AppKey(\"key\", str)\n    app = web.Application()\n    app[key] = \"value\"\n    assert app[key] == \"value\"\n    assert len(app) == 1\n    del app[key]\n    assert len(app) == 0\n\n\ndef test_appkey_repr_concrete() -> None:\n    key = web.AppKey(\"key\", int)\n    assert repr(key) in (\n        \"<AppKey(__channelexec__.key, type=int)>\",  # pytest-xdist\n        \"<AppKey(__main__.key, type=int)>\",\n    )\n    key2 = web.AppKey(\"key\", web.Request)\n    assert repr(key2) in (\n        # pytest-xdist:\n        \"<AppKey(__channelexec__.key, type=aiohttp.web_request.Request)>\",\n        \"<AppKey(__main__.key, type=aiohttp.web_request.Request)>\",\n    )\n\n\ndef test_appkey_repr_nonconcrete() -> None:\n    key = web.AppKey(\"key\", Iterator[int])\n    assert repr(key) in (\n        # pytest-xdist:\n        \"<AppKey(__channelexec__.key, type=typing.Iterator[int])>\",\n        \"<AppKey(__main__.key, type=typing.Iterator[int])>\",\n    )\n\n\ndef test_appkey_repr_annotated() -> None:\n    key = web.AppKey[Iterator[int]](\"key\")\n    assert repr(key) in (\n        # pytest-xdist:\n        \"<AppKey(__channelexec__.key, type=typing.Iterator[int])>\",\n        \"<AppKey(__main__.key, type=typing.Iterator[int])>\",\n    )\n\n\ndef test_app_str_keys() -> None:\n    app = web.Application()\n    with pytest.warns(UserWarning, match=r\"web_advanced\\.html#application-s-config\"):\n        app[\"key\"] = \"value\"\n    assert app[\"key\"] == \"value\"\n\n\ndef test_app_get() -> None:\n    key = web.AppKey(\"key\", int)\n    app = web.Application()\n    assert app.get(key, \"foo\") == \"foo\"\n    app[key] = 5\n    assert app.get(key, \"foo\") == 5\n\n\ndef test_app_freeze() -> None:\n    app = web.Application()\n    subapp = mock.Mock()\n    subapp._middlewares = ()\n    app._subapps.append(subapp)\n\n    app.freeze()\n    assert subapp.freeze.called\n\n    app.freeze()\n    assert len(subapp.freeze.call_args_list) == 1\n\n\ndef test_equality() -> None:\n    app1 = web.Application()\n    app2 = web.Application()\n\n    assert app1 == app1\n    assert app1 != app2\n\n\ndef test_app_run_middlewares() -> None:\n    root = web.Application()\n    sub = web.Application()\n    root.add_subapp(\"/sub\", sub)\n    root.freeze()\n    assert root._run_middlewares is False\n\n    async def middleware(request: web.Request, handler: Handler) -> web.StreamResponse:\n        return await handler(request)\n\n    root = web.Application(middlewares=[middleware])\n    sub = web.Application()\n    root.add_subapp(\"/sub\", sub)\n    root.freeze()\n    assert root._run_middlewares is True\n\n    root = web.Application()\n    sub = web.Application(middlewares=[middleware])\n    root.add_subapp(\"/sub\", sub)\n    root.freeze()\n    assert root._run_middlewares is True\n\n\ndef test_subapp_pre_frozen_after_adding() -> None:\n    app = web.Application()\n    subapp = web.Application()\n\n    app.add_subapp(\"/prefix\", subapp)\n    assert subapp.pre_frozen\n    assert not subapp.frozen\n\n\ndef test_app_inheritance() -> None:\n    with pytest.raises(TypeError):\n\n        class A(web.Application):  # type: ignore[misc]\n            pass\n\n\ndef test_app_custom_attr() -> None:\n    app = web.Application()\n    with pytest.raises(AttributeError):\n        app.custom = None  # type: ignore[attr-defined]\n\n\nasync def test_cleanup_ctx() -> None:\n    app = web.Application()\n    out = []\n\n    def f(num: int) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            yield None\n            out.append(\"post_\" + str(num))\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.cleanup_ctx.append(f(2))\n    app.freeze()\n    await app.startup()\n    assert out == [\"pre_1\", \"pre_2\"]\n    await app.cleanup()\n    assert out == [\"pre_1\", \"pre_2\", \"post_2\", \"post_1\"]\n\n\nasync def test_cleanup_ctx_exception_on_startup() -> None:\n    app = web.Application()\n    out = []\n\n    exc = Exception(\"fail\")\n\n    def f(\n        num: int, fail: bool = False\n    ) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            if fail:\n                raise exc\n            yield None\n            out.append(\"post_\" + str(num))\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.cleanup_ctx.append(f(2, True))\n    app.cleanup_ctx.append(f(3))\n    app.freeze()\n    with pytest.raises(Exception) as ctx:\n        await app.startup()\n    assert ctx.value is exc\n    assert out == [\"pre_1\", \"pre_2\"]\n    await app.cleanup()\n    assert out == [\"pre_1\", \"pre_2\", \"post_1\"]\n\n\nasync def test_cleanup_ctx_exception_on_cleanup() -> None:\n    app = web.Application()\n    out = []\n\n    exc = Exception(\"fail\")\n\n    def f(\n        num: int, fail: bool = False\n    ) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            yield None\n            out.append(\"post_\" + str(num))\n            if fail:\n                raise exc\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.cleanup_ctx.append(f(2, True))\n    app.cleanup_ctx.append(f(3))\n    app.freeze()\n    await app.startup()\n    assert out == [\"pre_1\", \"pre_2\", \"pre_3\"]\n    with pytest.raises(Exception) as ctx:\n        await app.cleanup()\n    assert ctx.value is exc\n    assert out == [\"pre_1\", \"pre_2\", \"pre_3\", \"post_3\", \"post_2\", \"post_1\"]\n\n\nasync def test_cleanup_ctx_cleanup_after_exception() -> None:\n    app = web.Application()\n    ctx_state = None\n\n    async def success_ctx(app: web.Application) -> AsyncIterator[None]:\n        nonlocal ctx_state\n        ctx_state = \"START\"\n        yield\n        ctx_state = \"CLEAN\"\n\n    async def fail_ctx(app: web.Application) -> AsyncIterator[NoReturn]:\n        raise Exception()\n        yield\n\n    app.cleanup_ctx.append(success_ctx)\n    app.cleanup_ctx.append(fail_ctx)\n    runner = web.AppRunner(app)\n    try:\n        with pytest.raises(Exception):\n            await runner.setup()\n    finally:\n        await runner.cleanup()\n\n    assert ctx_state == \"CLEAN\"\n\n\nasync def test_cleanup_ctx_exception_on_cleanup_multiple() -> None:\n    app = web.Application()\n    out = []\n\n    def f(\n        num: int, fail: bool = False\n    ) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            yield None\n            out.append(\"post_\" + str(num))\n            if fail:\n                raise Exception(\"fail_\" + str(num))\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.cleanup_ctx.append(f(2, True))\n    app.cleanup_ctx.append(f(3, True))\n    app.freeze()\n    await app.startup()\n    assert out == [\"pre_1\", \"pre_2\", \"pre_3\"]\n    with pytest.raises(web.CleanupError) as ctx:\n        await app.cleanup()\n    exc = ctx.value\n    assert len(exc.exceptions) == 2\n    assert str(exc.exceptions[0]) == \"fail_3\"\n    assert str(exc.exceptions[1]) == \"fail_2\"\n    assert out == [\"pre_1\", \"pre_2\", \"pre_3\", \"post_3\", \"post_2\", \"post_1\"]\n\n\nasync def test_cleanup_ctx_multiple_yields() -> None:\n    app = web.Application()\n    out = []\n\n    def f(num: int) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            yield None\n            out.append(\"post_\" + str(num))\n            yield None\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.freeze()\n    await app.startup()\n    assert out == [\"pre_1\"]\n    with pytest.raises(RuntimeError) as ctx:\n        await app.cleanup()\n    assert \"has more than one 'yield'\" in str(ctx.value)\n    assert out == [\"pre_1\", \"post_1\"]\n\n\nasync def test_subapp_chained_config_dict_visibility(aiohttp_client: Any) -> None:\n    key1 = web.AppKey(\"key1\", str)\n    key2 = web.AppKey(\"key2\", str)\n\n    async def main_handler(request: web.Request) -> web.Response:\n        assert request.config_dict[key1] == \"val1\"\n        assert key2 not in request.config_dict\n        return web.Response(status=200)\n\n    root = web.Application()\n    root[key1] = \"val1\"\n    root.add_routes([web.get(\"/\", main_handler)])\n\n    async def sub_handler(request: web.Request) -> web.Response:\n        assert request.config_dict[key1] == \"val1\"\n        assert request.config_dict[key2] == \"val2\"\n        return web.Response(status=201)\n\n    sub = web.Application()\n    sub[key2] = \"val2\"\n    sub.add_routes([web.get(\"/\", sub_handler)])\n    root.add_subapp(\"/sub\", sub)\n\n    client = await aiohttp_client(root)\n\n    resp = await client.get(\"/\")\n    assert resp.status == 200\n    resp = await client.get(\"/sub/\")\n    assert resp.status == 201\n\n\nasync def test_subapp_chained_config_dict_overriding(aiohttp_client: Any) -> None:\n    key = web.AppKey(\"key\", str)\n\n    async def main_handler(request: web.Request) -> web.Response:\n        assert request.config_dict[key] == \"val1\"\n        return web.Response(status=200)\n\n    root = web.Application()\n    root[key] = \"val1\"\n    root.add_routes([web.get(\"/\", main_handler)])\n\n    async def sub_handler(request: web.Request) -> web.Response:\n        assert request.config_dict[key] == \"val2\"\n        return web.Response(status=201)\n\n    sub = web.Application()\n    sub[key] = \"val2\"\n    sub.add_routes([web.get(\"/\", sub_handler)])\n    root.add_subapp(\"/sub\", sub)\n\n    client = await aiohttp_client(root)\n\n    resp = await client.get(\"/\")\n    assert resp.status == 200\n    resp = await client.get(\"/sub/\")\n    assert resp.status == 201\n\n\nasync def test_subapp_on_startup(aiohttp_client: Any) -> None:\n    subapp = web.Application()\n    startup = web.AppKey(\"startup\", bool)\n    cleanup = web.AppKey(\"cleanup\", bool)\n\n    startup_called = False\n\n    async def on_startup(app: web.Application) -> None:\n        nonlocal startup_called\n        startup_called = True\n        app[startup] = True\n\n    subapp.on_startup.append(on_startup)\n\n    ctx_pre_called = False\n    ctx_post_called = False\n\n    async def cleanup_ctx(app: web.Application) -> AsyncIterator[None]:\n        nonlocal ctx_pre_called, ctx_post_called\n        ctx_pre_called = True\n        app[cleanup] = True\n        yield None\n        ctx_post_called = True\n\n    subapp.cleanup_ctx.append(cleanup_ctx)\n\n    shutdown_called = False\n\n    async def on_shutdown(app: web.Application) -> None:\n        nonlocal shutdown_called\n        shutdown_called = True\n\n    subapp.on_shutdown.append(on_shutdown)\n\n    cleanup_called = False\n\n    async def on_cleanup(app: web.Application) -> None:\n        nonlocal cleanup_called\n        cleanup_called = True\n\n    subapp.on_cleanup.append(on_cleanup)\n\n    app = web.Application()\n\n    app.add_subapp(\"/subapp\", subapp)\n\n    assert not startup_called\n    assert not ctx_pre_called\n    assert not ctx_post_called\n    assert not shutdown_called\n    assert not cleanup_called\n\n    assert subapp.on_startup.frozen\n    assert subapp.cleanup_ctx.frozen\n    assert subapp.on_shutdown.frozen\n    assert subapp.on_cleanup.frozen\n    assert subapp.router.frozen\n\n    client = await aiohttp_client(app)\n\n    assert startup_called\n    assert ctx_pre_called\n    assert not ctx_post_called\n    assert not shutdown_called\n    assert not cleanup_called\n\n    await client.close()\n\n    assert startup_called\n    assert ctx_pre_called\n    assert ctx_post_called\n    assert shutdown_called\n    assert cleanup_called\n\n\n@pytest.mark.filterwarnings(r\"ignore:.*web\\.AppKey:UserWarning\")\ndef test_app_iter() -> None:\n    app = web.Application()\n    b = web.AppKey(\"b\", str)\n    c = web.AppKey(\"c\", str)\n    app[\"a\"] = \"0\"\n    app[b] = \"1\"\n    app[c] = \"2\"\n    app[\"d\"] = \"4\"\n    assert sorted(list(app)) == [b, c, \"a\", \"d\"]\n\n\ndef test_app_forbid_nonslot_attr() -> None:\n    app = web.Application()\n    with pytest.raises(AttributeError):\n        app.unknow_attr  # type: ignore[attr-defined]\n    with pytest.raises(AttributeError):\n        app.unknow_attr = 1  # type: ignore[attr-defined]\n\n\ndef test_forbid_changing_frozen_app() -> None:\n    app = web.Application()\n    app.freeze()\n    with pytest.raises(RuntimeError):\n        app[\"key\"] = \"value\"\n\n\ndef test_app_boolean() -> None:\n    app = web.Application()\n    assert app\n",
            "new_file_content": "import asyncio\nfrom typing import Any, AsyncIterator, Callable, Iterator, NoReturn\nfrom unittest import mock\n\nimport pytest\n\nfrom aiohttp import log, web\nfrom aiohttp.test_utils import make_mocked_coro\nfrom aiohttp.typedefs import Handler\n\n\nasync def test_app_ctor() -> None:\n    app = web.Application()\n    assert app.logger is log.web_logger\n\n\ndef test_app_call() -> None:\n    app = web.Application()\n    assert app is app()\n\n\nasync def test_app_register_on_finish() -> None:\n    app = web.Application()\n    cb1 = make_mocked_coro(None)\n    cb2 = make_mocked_coro(None)\n    app.on_cleanup.append(cb1)\n    app.on_cleanup.append(cb2)\n    app.freeze()\n    await app.cleanup()\n    cb1.assert_called_once_with(app)\n    cb2.assert_called_once_with(app)\n\n\nasync def test_app_register_coro() -> None:\n    app = web.Application()\n    fut = asyncio.get_event_loop().create_future()\n\n    async def cb(app: web.Application) -> None:\n        await asyncio.sleep(0.001)\n        fut.set_result(123)\n\n    app.on_cleanup.append(cb)\n    app.freeze()\n    await app.cleanup()\n    assert fut.done()\n    assert 123 == fut.result()\n\n\ndef test_logging() -> None:\n    logger = mock.Mock()\n    app = web.Application()\n    app.logger = logger\n    assert app.logger is logger\n\n\nasync def test_on_shutdown() -> None:\n    app = web.Application()\n    called = False\n\n    async def on_shutdown(app_param: web.Application) -> None:\n        nonlocal called\n        assert app is app_param\n        called = True\n\n    app.on_shutdown.append(on_shutdown)\n    app.freeze()\n    await app.shutdown()\n    assert called\n\n\nasync def test_on_startup() -> None:\n    app = web.Application()\n\n    long_running1_called = False\n    long_running2_called = False\n    all_long_running_called = False\n\n    async def long_running1(app_param: web.Application) -> None:\n        nonlocal long_running1_called\n        assert app is app_param\n        long_running1_called = True\n\n    async def long_running2(app_param: web.Application) -> None:\n        nonlocal long_running2_called\n        assert app is app_param\n        long_running2_called = True\n\n    async def on_startup_all_long_running(app_param: web.Application) -> None:\n        nonlocal all_long_running_called\n        assert app is app_param\n        all_long_running_called = True\n        await asyncio.gather(long_running1(app_param), long_running2(app_param))\n\n    app.on_startup.append(on_startup_all_long_running)\n    app.freeze()\n\n    await app.startup()\n    assert long_running1_called\n    assert long_running2_called\n    assert all_long_running_called\n\n\ndef test_appkey() -> None:\n    key = web.AppKey(\"key\", str)\n    app = web.Application()\n    app[key] = \"value\"\n    assert app[key] == \"value\"\n    assert len(app) == 1\n    del app[key]\n    assert len(app) == 0\n\n\ndef test_appkey_repr_concrete() -> None:\n    key = web.AppKey(\"key\", int)\n    assert repr(key) in (\n        \"<AppKey(__channelexec__.key, type=int)>\",  # pytest-xdist\n        \"<AppKey(__main__.key, type=int)>\",\n    )\n    key2 = web.AppKey(\"key\", web.Request)\n    assert repr(key2) in (\n        # pytest-xdist:\n        \"<AppKey(__channelexec__.key, type=aiohttp.web_request.Request)>\",\n        \"<AppKey(__main__.key, type=aiohttp.web_request.Request)>\",\n    )\n\n\ndef test_appkey_repr_nonconcrete() -> None:\n    key = web.AppKey(\"key\", Iterator[int])\n    assert repr(key) in (\n        # pytest-xdist:\n        \"<AppKey(__channelexec__.key, type=typing.Iterator[int])>\",\n        \"<AppKey(__main__.key, type=typing.Iterator[int])>\",\n    )\n\n\ndef test_appkey_repr_annotated() -> None:\n    key = web.AppKey[Iterator[int]](\"key\")\n    assert repr(key) in (\n        # pytest-xdist:\n        \"<AppKey(__channelexec__.key, type=typing.Iterator[int])>\",\n        \"<AppKey(__main__.key, type=typing.Iterator[int])>\",\n    )\n\n\ndef test_app_str_keys() -> None:\n    app = web.Application()\n    with pytest.warns(\n        UserWarning, match=r\"web_advanced\\.html#application-s-config\"\n    ) as checker:\n        app[\"key\"] = \"value\"\n        # Check that the error is emitted at the call site (stacklevel=2)\n        assert checker[0].filename == __file__\n    assert app[\"key\"] == \"value\"\n\n\ndef test_app_get() -> None:\n    key = web.AppKey(\"key\", int)\n    app = web.Application()\n    assert app.get(key, \"foo\") == \"foo\"\n    app[key] = 5\n    assert app.get(key, \"foo\") == 5\n\n\ndef test_app_freeze() -> None:\n    app = web.Application()\n    subapp = mock.Mock()\n    subapp._middlewares = ()\n    app._subapps.append(subapp)\n\n    app.freeze()\n    assert subapp.freeze.called\n\n    app.freeze()\n    assert len(subapp.freeze.call_args_list) == 1\n\n\ndef test_equality() -> None:\n    app1 = web.Application()\n    app2 = web.Application()\n\n    assert app1 == app1\n    assert app1 != app2\n\n\ndef test_app_run_middlewares() -> None:\n    root = web.Application()\n    sub = web.Application()\n    root.add_subapp(\"/sub\", sub)\n    root.freeze()\n    assert root._run_middlewares is False\n\n    async def middleware(request: web.Request, handler: Handler) -> web.StreamResponse:\n        return await handler(request)\n\n    root = web.Application(middlewares=[middleware])\n    sub = web.Application()\n    root.add_subapp(\"/sub\", sub)\n    root.freeze()\n    assert root._run_middlewares is True\n\n    root = web.Application()\n    sub = web.Application(middlewares=[middleware])\n    root.add_subapp(\"/sub\", sub)\n    root.freeze()\n    assert root._run_middlewares is True\n\n\ndef test_subapp_pre_frozen_after_adding() -> None:\n    app = web.Application()\n    subapp = web.Application()\n\n    app.add_subapp(\"/prefix\", subapp)\n    assert subapp.pre_frozen\n    assert not subapp.frozen\n\n\ndef test_app_inheritance() -> None:\n    with pytest.raises(TypeError):\n\n        class A(web.Application):  # type: ignore[misc]\n            pass\n\n\ndef test_app_custom_attr() -> None:\n    app = web.Application()\n    with pytest.raises(AttributeError):\n        app.custom = None  # type: ignore[attr-defined]\n\n\nasync def test_cleanup_ctx() -> None:\n    app = web.Application()\n    out = []\n\n    def f(num: int) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            yield None\n            out.append(\"post_\" + str(num))\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.cleanup_ctx.append(f(2))\n    app.freeze()\n    await app.startup()\n    assert out == [\"pre_1\", \"pre_2\"]\n    await app.cleanup()\n    assert out == [\"pre_1\", \"pre_2\", \"post_2\", \"post_1\"]\n\n\nasync def test_cleanup_ctx_exception_on_startup() -> None:\n    app = web.Application()\n    out = []\n\n    exc = Exception(\"fail\")\n\n    def f(\n        num: int, fail: bool = False\n    ) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            if fail:\n                raise exc\n            yield None\n            out.append(\"post_\" + str(num))\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.cleanup_ctx.append(f(2, True))\n    app.cleanup_ctx.append(f(3))\n    app.freeze()\n    with pytest.raises(Exception) as ctx:\n        await app.startup()\n    assert ctx.value is exc\n    assert out == [\"pre_1\", \"pre_2\"]\n    await app.cleanup()\n    assert out == [\"pre_1\", \"pre_2\", \"post_1\"]\n\n\nasync def test_cleanup_ctx_exception_on_cleanup() -> None:\n    app = web.Application()\n    out = []\n\n    exc = Exception(\"fail\")\n\n    def f(\n        num: int, fail: bool = False\n    ) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            yield None\n            out.append(\"post_\" + str(num))\n            if fail:\n                raise exc\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.cleanup_ctx.append(f(2, True))\n    app.cleanup_ctx.append(f(3))\n    app.freeze()\n    await app.startup()\n    assert out == [\"pre_1\", \"pre_2\", \"pre_3\"]\n    with pytest.raises(Exception) as ctx:\n        await app.cleanup()\n    assert ctx.value is exc\n    assert out == [\"pre_1\", \"pre_2\", \"pre_3\", \"post_3\", \"post_2\", \"post_1\"]\n\n\nasync def test_cleanup_ctx_cleanup_after_exception() -> None:\n    app = web.Application()\n    ctx_state = None\n\n    async def success_ctx(app: web.Application) -> AsyncIterator[None]:\n        nonlocal ctx_state\n        ctx_state = \"START\"\n        yield\n        ctx_state = \"CLEAN\"\n\n    async def fail_ctx(app: web.Application) -> AsyncIterator[NoReturn]:\n        raise Exception()\n        yield\n\n    app.cleanup_ctx.append(success_ctx)\n    app.cleanup_ctx.append(fail_ctx)\n    runner = web.AppRunner(app)\n    try:\n        with pytest.raises(Exception):\n            await runner.setup()\n    finally:\n        await runner.cleanup()\n\n    assert ctx_state == \"CLEAN\"\n\n\nasync def test_cleanup_ctx_exception_on_cleanup_multiple() -> None:\n    app = web.Application()\n    out = []\n\n    def f(\n        num: int, fail: bool = False\n    ) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            yield None\n            out.append(\"post_\" + str(num))\n            if fail:\n                raise Exception(\"fail_\" + str(num))\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.cleanup_ctx.append(f(2, True))\n    app.cleanup_ctx.append(f(3, True))\n    app.freeze()\n    await app.startup()\n    assert out == [\"pre_1\", \"pre_2\", \"pre_3\"]\n    with pytest.raises(web.CleanupError) as ctx:\n        await app.cleanup()\n    exc = ctx.value\n    assert len(exc.exceptions) == 2\n    assert str(exc.exceptions[0]) == \"fail_3\"\n    assert str(exc.exceptions[1]) == \"fail_2\"\n    assert out == [\"pre_1\", \"pre_2\", \"pre_3\", \"post_3\", \"post_2\", \"post_1\"]\n\n\nasync def test_cleanup_ctx_multiple_yields() -> None:\n    app = web.Application()\n    out = []\n\n    def f(num: int) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            yield None\n            out.append(\"post_\" + str(num))\n            yield None\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.freeze()\n    await app.startup()\n    assert out == [\"pre_1\"]\n    with pytest.raises(RuntimeError) as ctx:\n        await app.cleanup()\n    assert \"has more than one 'yield'\" in str(ctx.value)\n    assert out == [\"pre_1\", \"post_1\"]\n\n\nasync def test_subapp_chained_config_dict_visibility(aiohttp_client: Any) -> None:\n    key1 = web.AppKey(\"key1\", str)\n    key2 = web.AppKey(\"key2\", str)\n\n    async def main_handler(request: web.Request) -> web.Response:\n        assert request.config_dict[key1] == \"val1\"\n        assert key2 not in request.config_dict\n        return web.Response(status=200)\n\n    root = web.Application()\n    root[key1] = \"val1\"\n    root.add_routes([web.get(\"/\", main_handler)])\n\n    async def sub_handler(request: web.Request) -> web.Response:\n        assert request.config_dict[key1] == \"val1\"\n        assert request.config_dict[key2] == \"val2\"\n        return web.Response(status=201)\n\n    sub = web.Application()\n    sub[key2] = \"val2\"\n    sub.add_routes([web.get(\"/\", sub_handler)])\n    root.add_subapp(\"/sub\", sub)\n\n    client = await aiohttp_client(root)\n\n    resp = await client.get(\"/\")\n    assert resp.status == 200\n    resp = await client.get(\"/sub/\")\n    assert resp.status == 201\n\n\nasync def test_subapp_chained_config_dict_overriding(aiohttp_client: Any) -> None:\n    key = web.AppKey(\"key\", str)\n\n    async def main_handler(request: web.Request) -> web.Response:\n        assert request.config_dict[key] == \"val1\"\n        return web.Response(status=200)\n\n    root = web.Application()\n    root[key] = \"val1\"\n    root.add_routes([web.get(\"/\", main_handler)])\n\n    async def sub_handler(request: web.Request) -> web.Response:\n        assert request.config_dict[key] == \"val2\"\n        return web.Response(status=201)\n\n    sub = web.Application()\n    sub[key] = \"val2\"\n    sub.add_routes([web.get(\"/\", sub_handler)])\n    root.add_subapp(\"/sub\", sub)\n\n    client = await aiohttp_client(root)\n\n    resp = await client.get(\"/\")\n    assert resp.status == 200\n    resp = await client.get(\"/sub/\")\n    assert resp.status == 201\n\n\nasync def test_subapp_on_startup(aiohttp_client: Any) -> None:\n    subapp = web.Application()\n    startup = web.AppKey(\"startup\", bool)\n    cleanup = web.AppKey(\"cleanup\", bool)\n\n    startup_called = False\n\n    async def on_startup(app: web.Application) -> None:\n        nonlocal startup_called\n        startup_called = True\n        app[startup] = True\n\n    subapp.on_startup.append(on_startup)\n\n    ctx_pre_called = False\n    ctx_post_called = False\n\n    async def cleanup_ctx(app: web.Application) -> AsyncIterator[None]:\n        nonlocal ctx_pre_called, ctx_post_called\n        ctx_pre_called = True\n        app[cleanup] = True\n        yield None\n        ctx_post_called = True\n\n    subapp.cleanup_ctx.append(cleanup_ctx)\n\n    shutdown_called = False\n\n    async def on_shutdown(app: web.Application) -> None:\n        nonlocal shutdown_called\n        shutdown_called = True\n\n    subapp.on_shutdown.append(on_shutdown)\n\n    cleanup_called = False\n\n    async def on_cleanup(app: web.Application) -> None:\n        nonlocal cleanup_called\n        cleanup_called = True\n\n    subapp.on_cleanup.append(on_cleanup)\n\n    app = web.Application()\n\n    app.add_subapp(\"/subapp\", subapp)\n\n    assert not startup_called\n    assert not ctx_pre_called\n    assert not ctx_post_called\n    assert not shutdown_called\n    assert not cleanup_called\n\n    assert subapp.on_startup.frozen\n    assert subapp.cleanup_ctx.frozen\n    assert subapp.on_shutdown.frozen\n    assert subapp.on_cleanup.frozen\n    assert subapp.router.frozen\n\n    client = await aiohttp_client(app)\n\n    assert startup_called\n    assert ctx_pre_called\n    assert not ctx_post_called\n    assert not shutdown_called\n    assert not cleanup_called\n\n    await client.close()\n\n    assert startup_called\n    assert ctx_pre_called\n    assert ctx_post_called\n    assert shutdown_called\n    assert cleanup_called\n\n\n@pytest.mark.filterwarnings(r\"ignore:.*web\\.AppKey:UserWarning\")\ndef test_app_iter() -> None:\n    app = web.Application()\n    b = web.AppKey(\"b\", str)\n    c = web.AppKey(\"c\", str)\n    app[\"a\"] = \"0\"\n    app[b] = \"1\"\n    app[c] = \"2\"\n    app[\"d\"] = \"4\"\n    assert sorted(list(app)) == [b, c, \"a\", \"d\"]\n\n\ndef test_app_forbid_nonslot_attr() -> None:\n    app = web.Application()\n    with pytest.raises(AttributeError):\n        app.unknow_attr  # type: ignore[attr-defined]\n    with pytest.raises(AttributeError):\n        app.unknow_attr = 1  # type: ignore[attr-defined]\n\n\ndef test_forbid_changing_frozen_app() -> None:\n    app = web.Application()\n    app.freeze()\n    with pytest.raises(RuntimeError):\n        app[\"key\"] = \"value\"\n\n\ndef test_app_boolean() -> None:\n    app = web.Application()\n    assert app\n",
            "header": {
                "file": {
                    "path": "tests/test_web_app.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "11cb34c0",
                "new_commit_hash": "5d6d52b7",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/tests/test_web_app.py"
            },
            "plus_file": {
                "path": "b/tests/test_web_app.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 144,
                            "length": 8
                        },
                        "new_range": {
                            "start": 144,
                            "length": 12
                        },
                        "section": "def test_appkey_repr_annotated() -> None:"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "def test_app_str_keys() -> None:",
                                "type": "context"
                            },
                            {
                                "content": "    app = web.Application()",
                                "type": "context"
                            },
                            {
                                "content": "    with pytest.warns(UserWarning, match=r\"web_advanced\\.html#application-s-config\"):",
                                "type": "deleted"
                            },
                            {
                                "content": "    with pytest.warns(",
                                "type": "added"
                            },
                            {
                                "content": "        UserWarning, match=r\"web_advanced\\.html#application-s-config\"",
                                "type": "added"
                            },
                            {
                                "content": "    ) as checker:",
                                "type": "added"
                            },
                            {
                                "content": "        app[\"key\"] = \"value\"",
                                "type": "context"
                            },
                            {
                                "content": "        # Check that the error is emitted at the call site (stacklevel=2)",
                                "type": "added"
                            },
                            {
                                "content": "        assert checker[0].filename == __file__",
                                "type": "added"
                            },
                            {
                                "content": "    assert app[\"key\"] == \"value\"",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "tests/test_web_app.py",
                            "type": "function",
                            "name": "test_app_str_keys",
                            "content": "def test_app_str_keys() -> None:\n    app = web.Application()\n    with pytest.warns(UserWarning, match=r\"web_advanced\\.html#application-s-config\"):\n        app[\"key\"] = \"value\"\n    assert app[\"key\"] == \"value\"",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 145,
                            "end_lineno": 149,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "466f1ebbac1bd4047d0eeaed582ac12834bad305^",
    "new_commit_hash": "466f1ebbac1bd4047d0eeaed582ac12834bad305",
    "commit_message": "Increase stacklevel for UserWarning about AppKey usage (#7484)",
    "commit_date": "2023-08-06T17:03:23Z",
    "metadata": {}
}
{
    "repo_name": "aiohttp",
    "new_commit_hash": "466f1ebbac1bd4047d0eeaed582ac12834bad305",
    "test_file_codes": [
        "import asyncio\nfrom typing import Any, AsyncIterator, Callable, Iterator, NoReturn\nfrom unittest import mock\n\nimport pytest\n\nfrom aiohttp import log, web\nfrom aiohttp.test_utils import make_mocked_coro\nfrom aiohttp.typedefs import Handler\n\n\nasync def test_app_ctor() -> None:\n    app = web.Application()\n    assert app.logger is log.web_logger\n\n\ndef test_app_call() -> None:\n    app = web.Application()\n    assert app is app()\n\n\nasync def test_app_register_on_finish() -> None:\n    app = web.Application()\n    cb1 = make_mocked_coro(None)\n    cb2 = make_mocked_coro(None)\n    app.on_cleanup.append(cb1)\n    app.on_cleanup.append(cb2)\n    app.freeze()\n    await app.cleanup()\n    cb1.assert_called_once_with(app)\n    cb2.assert_called_once_with(app)\n\n\nasync def test_app_register_coro() -> None:\n    app = web.Application()\n    fut = asyncio.get_event_loop().create_future()\n\n    async def cb(app: web.Application) -> None:\n        await asyncio.sleep(0.001)\n        fut.set_result(123)\n\n    app.on_cleanup.append(cb)\n    app.freeze()\n    await app.cleanup()\n    assert fut.done()\n    assert 123 == fut.result()\n\n\ndef test_logging() -> None:\n    logger = mock.Mock()\n    app = web.Application()\n    app.logger = logger\n    assert app.logger is logger\n\n\nasync def test_on_shutdown() -> None:\n    app = web.Application()\n    called = False\n\n    async def on_shutdown(app_param: web.Application) -> None:\n        nonlocal called\n        assert app is app_param\n        called = True\n\n    app.on_shutdown.append(on_shutdown)\n    app.freeze()\n    await app.shutdown()\n    assert called\n\n\nasync def test_on_startup() -> None:\n    app = web.Application()\n\n    long_running1_called = False\n    long_running2_called = False\n    all_long_running_called = False\n\n    async def long_running1(app_param: web.Application) -> None:\n        nonlocal long_running1_called\n        assert app is app_param\n        long_running1_called = True\n\n    async def long_running2(app_param: web.Application) -> None:\n        nonlocal long_running2_called\n        assert app is app_param\n        long_running2_called = True\n\n    async def on_startup_all_long_running(app_param: web.Application) -> None:\n        nonlocal all_long_running_called\n        assert app is app_param\n        all_long_running_called = True\n        await asyncio.gather(long_running1(app_param), long_running2(app_param))\n\n    app.on_startup.append(on_startup_all_long_running)\n    app.freeze()\n\n    await app.startup()\n    assert long_running1_called\n    assert long_running2_called\n    assert all_long_running_called\n\n\ndef test_appkey() -> None:\n    key = web.AppKey(\"key\", str)\n    app = web.Application()\n    app[key] = \"value\"\n    assert app[key] == \"value\"\n    assert len(app) == 1\n    del app[key]\n    assert len(app) == 0\n\n\ndef test_appkey_repr_concrete() -> None:\n    key = web.AppKey(\"key\", int)\n    assert repr(key) in (\n        \"<AppKey(__channelexec__.key, type=int)>\",  # pytest-xdist\n        \"<AppKey(__main__.key, type=int)>\",\n    )\n    key2 = web.AppKey(\"key\", web.Request)\n    assert repr(key2) in (\n        # pytest-xdist:\n        \"<AppKey(__channelexec__.key, type=aiohttp.web_request.Request)>\",\n        \"<AppKey(__main__.key, type=aiohttp.web_request.Request)>\",\n    )\n\n\ndef test_appkey_repr_nonconcrete() -> None:\n    key = web.AppKey(\"key\", Iterator[int])\n    assert repr(key) in (\n        # pytest-xdist:\n        \"<AppKey(__channelexec__.key, type=typing.Iterator[int])>\",\n        \"<AppKey(__main__.key, type=typing.Iterator[int])>\",\n    )\n\n\ndef test_appkey_repr_annotated() -> None:\n    key = web.AppKey[Iterator[int]](\"key\")\n    assert repr(key) in (\n        # pytest-xdist:\n        \"<AppKey(__channelexec__.key, type=typing.Iterator[int])>\",\n        \"<AppKey(__main__.key, type=typing.Iterator[int])>\",\n    )\n\n\ndef test_app_str_keys() -> None:\n    app = web.Application()\n    with pytest.warns(\n        UserWarning, match=r\"web_advanced\\.html#application-s-config\"\n    ) as checker:\n        app[\"key\"] = \"value\"\n        # Check that the error is emitted at the call site (stacklevel=2)\n        assert checker[0].filename == __file__\n    assert app[\"key\"] == \"value\"\n\n\ndef test_app_get() -> None:\n    key = web.AppKey(\"key\", int)\n    app = web.Application()\n    assert app.get(key, \"foo\") == \"foo\"\n    app[key] = 5\n    assert app.get(key, \"foo\") == 5\n\n\ndef test_app_freeze() -> None:\n    app = web.Application()\n    subapp = mock.Mock()\n    subapp._middlewares = ()\n    app._subapps.append(subapp)\n\n    app.freeze()\n    assert subapp.freeze.called\n\n    app.freeze()\n    assert len(subapp.freeze.call_args_list) == 1\n\n\ndef test_equality() -> None:\n    app1 = web.Application()\n    app2 = web.Application()\n\n    assert app1 == app1\n    assert app1 != app2\n\n\ndef test_app_run_middlewares() -> None:\n    root = web.Application()\n    sub = web.Application()\n    root.add_subapp(\"/sub\", sub)\n    root.freeze()\n    assert root._run_middlewares is False\n\n    async def middleware(request: web.Request, handler: Handler) -> web.StreamResponse:\n        return await handler(request)\n\n    root = web.Application(middlewares=[middleware])\n    sub = web.Application()\n    root.add_subapp(\"/sub\", sub)\n    root.freeze()\n    assert root._run_middlewares is True\n\n    root = web.Application()\n    sub = web.Application(middlewares=[middleware])\n    root.add_subapp(\"/sub\", sub)\n    root.freeze()\n    assert root._run_middlewares is True\n\n\ndef test_subapp_pre_frozen_after_adding() -> None:\n    app = web.Application()\n    subapp = web.Application()\n\n    app.add_subapp(\"/prefix\", subapp)\n    assert subapp.pre_frozen\n    assert not subapp.frozen\n\n\ndef test_app_inheritance() -> None:\n    with pytest.raises(TypeError):\n\n        class A(web.Application):  # type: ignore[misc]\n            pass\n\n\ndef test_app_custom_attr() -> None:\n    app = web.Application()\n    with pytest.raises(AttributeError):\n        app.custom = None  # type: ignore[attr-defined]\n\n\nasync def test_cleanup_ctx() -> None:\n    app = web.Application()\n    out = []\n\n    def f(num: int) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            yield None\n            out.append(\"post_\" + str(num))\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.cleanup_ctx.append(f(2))\n    app.freeze()\n    await app.startup()\n    assert out == [\"pre_1\", \"pre_2\"]\n    await app.cleanup()\n    assert out == [\"pre_1\", \"pre_2\", \"post_2\", \"post_1\"]\n\n\nasync def test_cleanup_ctx_exception_on_startup() -> None:\n    app = web.Application()\n    out = []\n\n    exc = Exception(\"fail\")\n\n    def f(\n        num: int, fail: bool = False\n    ) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            if fail:\n                raise exc\n            yield None\n            out.append(\"post_\" + str(num))\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.cleanup_ctx.append(f(2, True))\n    app.cleanup_ctx.append(f(3))\n    app.freeze()\n    with pytest.raises(Exception) as ctx:\n        await app.startup()\n    assert ctx.value is exc\n    assert out == [\"pre_1\", \"pre_2\"]\n    await app.cleanup()\n    assert out == [\"pre_1\", \"pre_2\", \"post_1\"]\n\n\nasync def test_cleanup_ctx_exception_on_cleanup() -> None:\n    app = web.Application()\n    out = []\n\n    exc = Exception(\"fail\")\n\n    def f(\n        num: int, fail: bool = False\n    ) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            yield None\n            out.append(\"post_\" + str(num))\n            if fail:\n                raise exc\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.cleanup_ctx.append(f(2, True))\n    app.cleanup_ctx.append(f(3))\n    app.freeze()\n    await app.startup()\n    assert out == [\"pre_1\", \"pre_2\", \"pre_3\"]\n    with pytest.raises(Exception) as ctx:\n        await app.cleanup()\n    assert ctx.value is exc\n    assert out == [\"pre_1\", \"pre_2\", \"pre_3\", \"post_3\", \"post_2\", \"post_1\"]\n\n\nasync def test_cleanup_ctx_cleanup_after_exception() -> None:\n    app = web.Application()\n    ctx_state = None\n\n    async def success_ctx(app: web.Application) -> AsyncIterator[None]:\n        nonlocal ctx_state\n        ctx_state = \"START\"\n        yield\n        ctx_state = \"CLEAN\"\n\n    async def fail_ctx(app: web.Application) -> AsyncIterator[NoReturn]:\n        raise Exception()\n        yield\n\n    app.cleanup_ctx.append(success_ctx)\n    app.cleanup_ctx.append(fail_ctx)\n    runner = web.AppRunner(app)\n    try:\n        with pytest.raises(Exception):\n            await runner.setup()\n    finally:\n        await runner.cleanup()\n\n    assert ctx_state == \"CLEAN\"\n\n\nasync def test_cleanup_ctx_exception_on_cleanup_multiple() -> None:\n    app = web.Application()\n    out = []\n\n    def f(\n        num: int, fail: bool = False\n    ) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            yield None\n            out.append(\"post_\" + str(num))\n            if fail:\n                raise Exception(\"fail_\" + str(num))\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.cleanup_ctx.append(f(2, True))\n    app.cleanup_ctx.append(f(3, True))\n    app.freeze()\n    await app.startup()\n    assert out == [\"pre_1\", \"pre_2\", \"pre_3\"]\n    with pytest.raises(web.CleanupError) as ctx:\n        await app.cleanup()\n    exc = ctx.value\n    assert len(exc.exceptions) == 2\n    assert str(exc.exceptions[0]) == \"fail_3\"\n    assert str(exc.exceptions[1]) == \"fail_2\"\n    assert out == [\"pre_1\", \"pre_2\", \"pre_3\", \"post_3\", \"post_2\", \"post_1\"]\n\n\nasync def test_cleanup_ctx_multiple_yields() -> None:\n    app = web.Application()\n    out = []\n\n    def f(num: int) -> Callable[[web.Application], AsyncIterator[None]]:\n        async def inner(app: web.Application) -> AsyncIterator[None]:\n            out.append(\"pre_\" + str(num))\n            yield None\n            out.append(\"post_\" + str(num))\n            yield None\n\n        return inner\n\n    app.cleanup_ctx.append(f(1))\n    app.freeze()\n    await app.startup()\n    assert out == [\"pre_1\"]\n    with pytest.raises(RuntimeError) as ctx:\n        await app.cleanup()\n    assert \"has more than one 'yield'\" in str(ctx.value)\n    assert out == [\"pre_1\", \"post_1\"]\n\n\nasync def test_subapp_chained_config_dict_visibility(aiohttp_client: Any) -> None:\n    key1 = web.AppKey(\"key1\", str)\n    key2 = web.AppKey(\"key2\", str)\n\n    async def main_handler(request: web.Request) -> web.Response:\n        assert request.config_dict[key1] == \"val1\"\n        assert key2 not in request.config_dict\n        return web.Response(status=200)\n\n    root = web.Application()\n    root[key1] = \"val1\"\n    root.add_routes([web.get(\"/\", main_handler)])\n\n    async def sub_handler(request: web.Request) -> web.Response:\n        assert request.config_dict[key1] == \"val1\"\n        assert request.config_dict[key2] == \"val2\"\n        return web.Response(status=201)\n\n    sub = web.Application()\n    sub[key2] = \"val2\"\n    sub.add_routes([web.get(\"/\", sub_handler)])\n    root.add_subapp(\"/sub\", sub)\n\n    client = await aiohttp_client(root)\n\n    resp = await client.get(\"/\")\n    assert resp.status == 200\n    resp = await client.get(\"/sub/\")\n    assert resp.status == 201\n\n\nasync def test_subapp_chained_config_dict_overriding(aiohttp_client: Any) -> None:\n    key = web.AppKey(\"key\", str)\n\n    async def main_handler(request: web.Request) -> web.Response:\n        assert request.config_dict[key] == \"val1\"\n        return web.Response(status=200)\n\n    root = web.Application()\n    root[key] = \"val1\"\n    root.add_routes([web.get(\"/\", main_handler)])\n\n    async def sub_handler(request: web.Request) -> web.Response:\n        assert request.config_dict[key] == \"val2\"\n        return web.Response(status=201)\n\n    sub = web.Application()\n    sub[key] = \"val2\"\n    sub.add_routes([web.get(\"/\", sub_handler)])\n    root.add_subapp(\"/sub\", sub)\n\n    client = await aiohttp_client(root)\n\n    resp = await client.get(\"/\")\n    assert resp.status == 200\n    resp = await client.get(\"/sub/\")\n    assert resp.status == 201\n\n\nasync def test_subapp_on_startup(aiohttp_client: Any) -> None:\n    subapp = web.Application()\n    startup = web.AppKey(\"startup\", bool)\n    cleanup = web.AppKey(\"cleanup\", bool)\n\n    startup_called = False\n\n    async def on_startup(app: web.Application) -> None:\n        nonlocal startup_called\n        startup_called = True\n        app[startup] = True\n\n    subapp.on_startup.append(on_startup)\n\n    ctx_pre_called = False\n    ctx_post_called = False\n\n    async def cleanup_ctx(app: web.Application) -> AsyncIterator[None]:\n        nonlocal ctx_pre_called, ctx_post_called\n        ctx_pre_called = True\n        app[cleanup] = True\n        yield None\n        ctx_post_called = True\n\n    subapp.cleanup_ctx.append(cleanup_ctx)\n\n    shutdown_called = False\n\n    async def on_shutdown(app: web.Application) -> None:\n        nonlocal shutdown_called\n        shutdown_called = True\n\n    subapp.on_shutdown.append(on_shutdown)\n\n    cleanup_called = False\n\n    async def on_cleanup(app: web.Application) -> None:\n        nonlocal cleanup_called\n        cleanup_called = True\n\n    subapp.on_cleanup.append(on_cleanup)\n\n    app = web.Application()\n\n    app.add_subapp(\"/subapp\", subapp)\n\n    assert not startup_called\n    assert not ctx_pre_called\n    assert not ctx_post_called\n    assert not shutdown_called\n    assert not cleanup_called\n\n    assert subapp.on_startup.frozen\n    assert subapp.cleanup_ctx.frozen\n    assert subapp.on_shutdown.frozen\n    assert subapp.on_cleanup.frozen\n    assert subapp.router.frozen\n\n    client = await aiohttp_client(app)\n\n    assert startup_called\n    assert ctx_pre_called\n    assert not ctx_post_called\n    assert not shutdown_called\n    assert not cleanup_called\n\n    await client.close()\n\n    assert startup_called\n    assert ctx_pre_called\n    assert ctx_post_called\n    assert shutdown_called\n    assert cleanup_called\n\n\n@pytest.mark.filterwarnings(r\"ignore:.*web\\.AppKey:UserWarning\")\ndef test_app_iter() -> None:\n    app = web.Application()\n    b = web.AppKey(\"b\", str)\n    c = web.AppKey(\"c\", str)\n    app[\"a\"] = \"0\"\n    app[b] = \"1\"\n    app[c] = \"2\"\n    app[\"d\"] = \"4\"\n    assert sorted(list(app)) == [b, c, \"a\", \"d\"]\n\n\ndef test_app_forbid_nonslot_attr() -> None:\n    app = web.Application()\n    with pytest.raises(AttributeError):\n        app.unknow_attr  # type: ignore[attr-defined]\n    with pytest.raises(AttributeError):\n        app.unknow_attr = 1  # type: ignore[attr-defined]\n\n\ndef test_forbid_changing_frozen_app() -> None:\n    app = web.Application()\n    app.freeze()\n    with pytest.raises(RuntimeError):\n        app[\"key\"] = \"value\"\n\n\ndef test_app_boolean() -> None:\n    app = web.Application()\n    assert app\n",
        "# type: ignore\nimport asyncio\nimport os\nimport socket\nimport ssl\nimport sys\nfrom hashlib import md5, sha256\nfrom pathlib import Path\nfrom tempfile import TemporaryDirectory\nfrom typing import Any, List\nfrom unittest import mock\nfrom uuid import uuid4\n\nimport pytest\n\nfrom aiohttp.test_utils import loop_context\n\ntry:\n    import trustme\n\n    # Check if the CA is available in runtime, MacOS on Py3.10 fails somehow\n    trustme.CA()\n\n    TRUSTME: bool = True\nexcept ImportError:\n    TRUSTME = False\n\npytest_plugins: List[str] = [\"aiohttp.pytest_plugin\", \"pytester\"]\n\nIS_HPUX = sys.platform.startswith(\"hp-ux\")\nIS_LINUX = sys.platform.startswith(\"linux\")\n\n\n@pytest.fixture\ndef tls_certificate_authority() -> Any:\n    if not TRUSTME:\n        pytest.xfail(\"trustme is not supported\")\n    return trustme.CA()\n\n\n@pytest.fixture\ndef tls_certificate(tls_certificate_authority: Any) -> Any:\n    return tls_certificate_authority.issue_cert(\n        \"localhost\",\n        \"127.0.0.1\",\n        \"::1\",\n    )\n\n\n@pytest.fixture\ndef ssl_ctx(tls_certificate: Any) -> ssl.SSLContext:\n    ssl_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)\n    tls_certificate.configure_cert(ssl_ctx)\n    return ssl_ctx\n\n\n@pytest.fixture\ndef client_ssl_ctx(tls_certificate_authority: Any) -> ssl.SSLContext:\n    ssl_ctx = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH)\n    tls_certificate_authority.configure_trust(ssl_ctx)\n    return ssl_ctx\n\n\n@pytest.fixture\ndef tls_ca_certificate_pem_path(tls_certificate_authority: Any) -> None:\n    with tls_certificate_authority.cert_pem.tempfile() as ca_cert_pem:\n        yield ca_cert_pem\n\n\n@pytest.fixture\ndef tls_certificate_pem_path(tls_certificate: Any) -> None:\n    with tls_certificate.private_key_and_cert_chain_pem.tempfile() as cert_pem:\n        yield cert_pem\n\n\n@pytest.fixture\ndef tls_certificate_pem_bytes(tls_certificate: Any) -> bytes:\n    return tls_certificate.cert_chain_pems[0].bytes()\n\n\n@pytest.fixture\ndef tls_certificate_fingerprint_sha256(tls_certificate_pem_bytes: Any) -> str:\n    tls_cert_der = ssl.PEM_cert_to_DER_cert(tls_certificate_pem_bytes.decode())\n    return sha256(tls_cert_der).digest()\n\n\n@pytest.fixture\ndef pipe_name() -> str:\n    name = rf\"\\\\.\\pipe\\{uuid4().hex}\"\n    return name\n\n\n@pytest.fixture\ndef create_mocked_conn(loop: Any):\n    def _proto_factory(conn_closing_result=None, **kwargs):\n        proto = mock.Mock(**kwargs)\n        proto.closed = loop.create_future()\n        proto.closed.set_result(conn_closing_result)\n        return proto\n\n    yield _proto_factory\n\n\n@pytest.fixture\ndef unix_sockname(tmp_path: Any, tmp_path_factory: Any):\n    # Generate an fs path to the UNIX domain socket for testing.\n\n    # N.B. Different OS kernels have different fs path length limitations\n    # for it. For Linux, it's 108, for HP-UX it's 92 (or higher) depending\n    # on its version. For most of the BSDs (Open, Free, macOS) it's\n    # mostly 104 but sometimes it can be down to 100.\n\n    # Ref: https://github.com/aio-libs/aiohttp/issues/3572\n    if not hasattr(socket, \"AF_UNIX\"):\n        pytest.skip(\"requires UNIX sockets\")\n\n    max_sock_len = 92 if IS_HPUX else 108 if IS_LINUX else 100\n    # Amount of bytes allocated for the UNIX socket path by OS kernel.\n    # Ref: https://unix.stackexchange.com/a/367012/27133\n\n    sock_file_name = \"unix.sock\"\n    unique_prefix = f\"{uuid4()!s}-\"\n    unique_prefix_len = len(unique_prefix.encode())\n\n    root_tmp_dir = Path(\"/tmp\").resolve()\n    os_tmp_dir = Path(os.getenv(\"TMPDIR\", \"/tmp\")).resolve()\n    original_base_tmp_path = Path(\n        str(tmp_path_factory.getbasetemp()),\n    ).resolve()\n\n    original_base_tmp_path_hash = md5(\n        str(original_base_tmp_path).encode(),\n    ).hexdigest()\n\n    def make_tmp_dir(base_tmp_dir):\n        return TemporaryDirectory(\n            dir=str(base_tmp_dir),\n            prefix=\"pt-\",\n            suffix=f\"-{original_base_tmp_path_hash!s}\",\n        )\n\n    def assert_sock_fits(sock_path):\n        sock_path_len = len(sock_path.encode())\n        # exit-check to verify that it's correct and simplify debugging\n        # in the future\n        assert sock_path_len <= max_sock_len, (\n            \"Suggested UNIX socket ({sock_path}) is {sock_path_len} bytes \"\n            \"long but the current kernel only has {max_sock_len} bytes \"\n            \"allocated to hold it so it must be shorter. \"\n            \"See https://github.com/aio-libs/aiohttp/issues/3572 \"\n            \"for more info.\"\n        ).format_map(locals())\n\n    paths = original_base_tmp_path, os_tmp_dir, root_tmp_dir\n    unique_paths = [p for n, p in enumerate(paths) if p not in paths[:n]]\n    paths_num = len(unique_paths)\n\n    for num, tmp_dir_path in enumerate(paths, 1):\n        with make_tmp_dir(tmp_dir_path) as tmpd:\n            tmpd = Path(tmpd).resolve()\n            sock_path = str(tmpd / sock_file_name)\n            sock_path_len = len(sock_path.encode())\n\n            if num >= paths_num:\n                # exit-check to verify that it's correct and simplify\n                # debugging in the future\n                assert_sock_fits(sock_path)\n\n            if sock_path_len <= max_sock_len:\n                if max_sock_len - sock_path_len >= unique_prefix_len:\n                    # If we're lucky to have extra space in the path,\n                    # let's also make it more unique\n                    sock_path = str(tmpd / \"\".join((unique_prefix, sock_file_name)))\n                    # Double-checking it:\n                    assert_sock_fits(sock_path)\n                yield sock_path\n                return\n\n\n@pytest.fixture\ndef selector_loop() -> None:\n    policy = asyncio.WindowsSelectorEventLoopPolicy()\n    asyncio.set_event_loop_policy(policy)\n\n    with loop_context(policy.new_event_loop) as _loop:\n        asyncio.set_event_loop(_loop)\n        yield _loop\n\n\n@pytest.fixture\ndef netrc_contents(\n    tmp_path: Path,\n    monkeypatch: pytest.MonkeyPatch,\n    request: pytest.FixtureRequest,\n):\n    \"\"\"\n    Prepare :file:`.netrc` with given contents.\n\n    Monkey-patches :envvar:`NETRC` to point to created file.\n    \"\"\"\n    netrc_contents = getattr(request, \"param\", None)\n\n    netrc_file_path = tmp_path / \".netrc\"\n    if netrc_contents is not None:\n        netrc_file_path.write_text(netrc_contents)\n\n    monkeypatch.setenv(\"NETRC\", str(netrc_file_path))\n\n    return netrc_file_path\n"
    ],
    "test_file_names": [
        "test_1.py",
        "conftest.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "re-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/requirements/cython.txt\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/tools/gen.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/hdrs.py\n./tools/gen.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/_helpers.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/_http_parser.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/_http_writer.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/_websocket.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/_helpers.pyi\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/_cparser.pxd\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/_find_header.pxd\ncython -3 -o aiohttp/_helpers.c aiohttp/_helpers.pyx -I aiohttp\ncython -3 -o aiohttp/_http_parser.c aiohttp/_http_parser.pyx -I aiohttp\ncython -3 -o aiohttp/_http_writer.c aiohttp/_http_writer.pyx -I aiohttp\ncython -3 -o aiohttp/_websocket.c aiohttp/_websocket.pyx -I aiohttp\ncd vendor/llhttp; npm install\n\n> llhttp@9.0.0 prepare\n> npm run clean && npm run build-ts\n\n\n> llhttp@9.0.0 clean\n> rm -rf lib && rm -rf test/tmp\n\n\n> llhttp@9.0.0 build-ts\n> tsc\n\n\nadded 157 packages, and audited 158 packages in 4s\n\n23 packages are looking for funding\n  run `npm fund` for details\n\n5 vulnerabilities (4 moderate, 1 high)\n\nTo address issues that do not require attention, run:\n  npm audit fix\n\nSome issues need review, and may require choosing\na different dependency.\n\nRun `npm audit` for details.\nmake -C vendor/llhttp generate\nmake[1]: Entering directory '/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/vendor/llhttp'\nnpx ts-node bin/generate.ts\nmake[1]: Leaving directory '/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/vendor/llhttp'\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/__init__.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/abc.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/base_protocol.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/client.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/client_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/client_proto.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/client_reqrep.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/client_ws.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/compression_utils.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/connector.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/cookiejar.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/formdata.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/helpers.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/http.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/http_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/http_parser.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/http_websocket.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/http_writer.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/locks.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/log.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/multipart.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/payload.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/pytest_plugin.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/resolver.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/streams.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/tcp_helpers.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/test_utils.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/tracing.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/typedefs.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_app.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_fileresponse.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_log.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_middlewares.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_protocol.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_request.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_response.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_routedef.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_runner.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_server.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_urldispatcher.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_ws.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/worker.py\nuv pip install -e . -c requirements/runtime-deps.txt\n",
    "setup_res_stderr": "Using CPython 3.9.21\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 1 package in 3ms\nPrepared 1 package in 0.34ms\nInstalled 1 package in 82ms\n + pip==24.3.1\nResolved 3 packages in 11ms\nInstalled 3 packages in 16ms\n + cython==3.0.0\n + multidict==6.0.4\n + typing-extensions==4.7.1\nwarning: aiohttp/_http_parser.pyx:50:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310\nwarning: aiohttp/_http_parser.pyx:83:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310\nwarning: aiohttp/_http_writer.pyx:10:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310\nResolved 95 packages in 52ms\nUninstalled 1 package in 21ms\nInstalled 93 packages in 136ms\n + aiodns==3.0.0\n + aiohttp-theme==0.1.6\n + aioredis==2.0.1\n + aiosignal==1.3.1\n + alabaster==0.7.13\n + async-timeout==4.0.2\n + babel==2.12.1\n + blockdiag==3.0.0\n + brotli==1.0.9\n + build==0.10.0\n + cchardet==2.1.7\n + certifi==2023.7.22\n + cffi==1.15.1\n + cfgv==3.3.1\n + charset-normalizer==3.2.0\n + cherry-picker==2.1.0\n + click==8.1.6\n + click-default-group==1.2.2\n + coverage==7.2.7\n + cryptography==41.0.3\n + distlib==0.3.7\n + docutils==0.20.1\n + exceptiongroup==1.1.2\n + filelock==3.12.2\n + freezegun==1.2.2\n + frozenlist==1.4.0\n + funcparserlib==1.0.1\n + gidgethub==5.3.0\n + gunicorn==21.2.0\n + identify==2.5.26\n + idna==3.4\n + imagesize==1.4.1\n + importlib-metadata==6.8.0\n + importlib-resources==6.0.0\n + incremental==22.10.0\n + iniconfig==2.0.0\n + jinja2==3.1.2\n + markupsafe==2.1.3\n + mypy==1.4.1\n + mypy-extensions==1.0.0\n + nodeenv==1.8.0\n + packaging==23.1\n + pillow==9.5.0\n - pip==24.3.1\n + pip==23.2.1\n + pip-tools==7.2.0\n + platformdirs==3.10.0\n + pluggy==1.2.0\n + pre-commit==3.3.3\n + proxy-py==2.4.3\n + pycares==4.3.0\n + pycparser==2.21\n + pydantic==1.10.12\n + pygments==2.15.1\n + pyjwt==2.8.0\n + pyproject-hooks==1.0.0\n + pytest==7.4.0\n + pytest-cov==4.1.0\n + pytest-mock==3.11.1\n + python-dateutil==2.8.2\n + python-on-whales==0.64.0\n + pyyaml==6.0.1\n + re-assert==1.1.0\n + regex==2023.6.3\n + requests==2.31.0\n + setuptools==68.0.0\n + setuptools-git==1.2\n + six==1.16.0\n + slotscheck==0.17.0\n + snowballstemmer==2.2.0\n + sphinx==7.1.2\n + sphinxcontrib-applehelp==1.0.4\n + sphinxcontrib-blockdiag==3.0.0\n + sphinxcontrib-devhelp==1.0.2\n + sphinxcontrib-htmlhelp==2.0.1\n + sphinxcontrib-jsmath==1.0.1\n + sphinxcontrib-qthelp==1.0.3\n + sphinxcontrib-serializinghtml==1.1.5\n + sphinxcontrib-towncrier==0.3.2a0\n + toml==0.10.2\n + tomli==2.0.1\n + towncrier==23.6.0\n + tqdm==4.65.0\n + trustme==1.1.0\n + typer==0.9.0\n + uritemplate==4.1.1\n + urllib3==2.0.4\n + uvloop==0.17.0\n + virtualenv==20.24.2\n + wait-for-it==2.2.2\n + webcolors==1.13\n + wheel==0.41.0\n + yarl==1.9.2\n + zipp==3.16.2\nResolved 8 packages in 1.42s\nPrepared 1 package in 15.74s\nInstalled 1 package in 1ms\n + aiohttp==4.0.0a2.dev0 (from file:///home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305)\nResolved 24 packages in 15ms\nInstalled 5 packages in 6ms\n + async-generator==1.10\n + brotlipy==0.7.0\n + chardet==5.2.0\n + multdict==0.0.5\n + pytest-asyncio==0.23.8\n",
    "new_commit_res_code": 0,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-7.4.0, pluggy-1.2.0 -- /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/.venv/bin/python\ncachedir: .pytest_cache\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305\nconfigfile: setup.cfg\nplugins: mock-3.11.1, asyncio-0.23.8, cov-4.1.0\nasyncio: mode=strict\ncollecting ... collected 32 items\n\nr2e_tests/test_1.py::test_app_ctor PASSED                                [  3%]\nr2e_tests/test_1.py::test_app_call PASSED                                [  6%]\nr2e_tests/test_1.py::test_app_register_on_finish PASSED                  [  9%]\nr2e_tests/test_1.py::test_app_register_coro PASSED                       [ 12%]\nr2e_tests/test_1.py::test_logging PASSED                                 [ 15%]\nr2e_tests/test_1.py::test_on_shutdown PASSED                             [ 18%]\nr2e_tests/test_1.py::test_on_startup PASSED                              [ 21%]\nr2e_tests/test_1.py::test_appkey PASSED                                  [ 25%]\nr2e_tests/test_1.py::test_appkey_repr_concrete PASSED                    [ 28%]\nr2e_tests/test_1.py::test_appkey_repr_nonconcrete PASSED                 [ 31%]\nr2e_tests/test_1.py::test_appkey_repr_annotated PASSED                   [ 34%]\nr2e_tests/test_1.py::test_app_str_keys PASSED                            [ 37%]\nr2e_tests/test_1.py::test_app_get PASSED                                 [ 40%]\nr2e_tests/test_1.py::test_app_freeze PASSED                              [ 43%]\nr2e_tests/test_1.py::test_equality PASSED                                [ 46%]\nr2e_tests/test_1.py::test_app_run_middlewares PASSED                     [ 50%]\nr2e_tests/test_1.py::test_subapp_pre_frozen_after_adding PASSED          [ 53%]\nr2e_tests/test_1.py::test_app_inheritance PASSED                         [ 56%]\nr2e_tests/test_1.py::test_app_custom_attr PASSED                         [ 59%]\nr2e_tests/test_1.py::test_cleanup_ctx PASSED                             [ 62%]\nr2e_tests/test_1.py::test_cleanup_ctx_exception_on_startup PASSED        [ 65%]\nr2e_tests/test_1.py::test_cleanup_ctx_exception_on_cleanup PASSED        [ 68%]\nr2e_tests/test_1.py::test_cleanup_ctx_cleanup_after_exception PASSED     [ 71%]\nr2e_tests/test_1.py::test_cleanup_ctx_exception_on_cleanup_multiple PASSED [ 75%]\nr2e_tests/test_1.py::test_cleanup_ctx_multiple_yields PASSED             [ 78%]\nr2e_tests/test_1.py::test_subapp_chained_config_dict_visibility[pyloop] PASSED [ 81%]\nr2e_tests/test_1.py::test_subapp_chained_config_dict_overriding[pyloop] PASSED [ 84%]\nr2e_tests/test_1.py::test_subapp_on_startup[pyloop] PASSED               [ 87%]\nr2e_tests/test_1.py::test_app_iter PASSED                                [ 90%]\nr2e_tests/test_1.py::test_app_forbid_nonslot_attr PASSED                 [ 93%]\nr2e_tests/test_1.py::test_forbid_changing_frozen_app PASSED              [ 96%]\nr2e_tests/test_1.py::test_app_boolean PASSED                             [100%]\n\n==================================== PASSES ====================================\n\n---------- coverage: platform linux, python 3.9.21-final-0 -----------\nName                                     Stmts   Miss Branch BrPart  Cover\n--------------------------------------------------------------------------\naiohttp/__init__.py                         26     10      2      0    57%\naiohttp/abc.py                              89      2      0      0    98%\naiohttp/base_protocol.py                    66     36     22      3    38%\naiohttp/client.py                          467    231    170     44    45%\naiohttp/client_exceptions.py               120     47     10      1    57%\naiohttp/client_proto.py                    153     50     56     20    60%\naiohttp/client_reqrep.py                   620    283    264     55    45%\naiohttp/client_ws.py                       212    165     66      0    18%\naiohttp/compression_utils.py                65     34     14      0    39%\naiohttp/connector.py                       673    378    297     48    37%\naiohttp/cookiejar.py                       255    166    118     11    27%\naiohttp/formdata.py                         94     77     46      0    12%\naiohttp/hdrs.py                             91      0      0      0   100%\naiohttp/helpers.py                         549    265    198     22    45%\naiohttp/http.py                              8      0      0      0   100%\naiohttp/http_exceptions.py                  51     21      6      0    53%\naiohttp/http_parser.py                     474    380    176      1    15%\naiohttp/http_websocket.py                  378    285    152      0    18%\naiohttp/http_writer.py                     118     44     50     13    53%\naiohttp/locks.py                            28     18      4      0    31%\naiohttp/log.py                               7      0      0      0   100%\naiohttp/multipart.py                       593    486    250      0    13%\naiohttp/payload.py                         220    107     56      1    43%\naiohttp/pytest_plugin.py                   159     58     42      6    61%\naiohttp/resolver.py                         50     31     14      0    30%\naiohttp/streams.py                         392    243    138     11    30%\naiohttp/tcp_helpers.py                      19      2      6      3    80%\naiohttp/test_utils.py                      307    106     56     16    61%\naiohttp/tracing.py                         191     69     32      0    69%\naiohttp/typedefs.py                         23      0      0      0   100%\naiohttp/web.py                             118     83     52      0    22%\naiohttp/web_app.py                         253     29     50      8    85%\naiohttp/web_exceptions.py                  211     50     24      0    71%\naiohttp/web_fileresponse.py                141    117     50      0    13%\naiohttp/web_log.py                         102     37     20      1    59%\naiohttp/web_middlewares.py                  54     38     20      0    22%\naiohttp/web_protocol.py                    352    152    157     38    47%\naiohttp/web_request.py                     450    246    138     10    37%\naiohttp/web_response.py                    430    217    178     30    40%\naiohttp/web_routedef.py                    106     41     10      1    60%\naiohttp/web_runner.py                      231     72     42     12    64%\naiohttp/web_server.py                       40      6      8      2    79%\naiohttp/web_urldispatcher.py               692    320    157     18    48%\naiohttp/web_ws.py                          318    255    106      0    15%\naiohttp/worker.py                          123    123     30      0     0%\ntests/__init__.py                            0      0      0      0   100%\ntests/conftest.py                          115    115     16      0     0%\ntests/test_base_protocol.py                198    198      2      0     0%\ntests/test_circular_imports.py              31     31     15      0     0%\ntests/test_classbasedview.py                39     39      0      0     0%\ntests/test_client_connection.py             93     93      2      0     0%\ntests/test_client_exceptions.py            165    165     14      0     0%\ntests/test_client_fingerprint.py            24     24      0      0     0%\ntests/test_client_functional.py           2164   2164     70      0     0%\ntests/test_client_proto.py                 100    100      0      0     0%\ntests/test_client_request.py               724    724     18      0     0%\ntests/test_client_response.py              467    467      2      0     0%\ntests/test_client_session.py               450    450     23      0     0%\ntests/test_client_ws.py                    416    416      2      0     0%\ntests/test_client_ws_functional.py         624    624     14      0     0%\ntests/test_connector.py                   1509   1509     76      0     0%\ntests/test_cookiejar.py                    338    338     22      0     0%\ntests/test_flowcontrol_streams.py          101    101      0      0     0%\ntests/test_formdata.py                      77     77      6      0     0%\ntests/test_helpers.py                      510    510     14      0     0%\ntests/test_http_exceptions.py              109    109     10      0     0%\ntests/test_http_parser.py                  775    775     38      0     0%\ntests/test_http_writer.py                  183    183     10      0     0%\ntests/test_imports.py                       31     31      6      0     0%\ntests/test_locks.py                         40     40      0      0     0%\ntests/test_loop.py                          36     36      0      0     0%\ntests/test_multipart.py                    771    771     28      0     0%\ntests/test_multipart_helpers.py            446    446      0      0     0%\ntests/test_payload.py                       79     79      0      0     0%\ntests/test_proxy.py                        244    244      0      0     0%\ntests/test_proxy_functional.py             470    470     20      0     0%\ntests/test_pytest_plugin.py                 47     47      0      0     0%\ntests/test_resolver.py                     127    127     10      0     0%\ntests/test_route_def.py                    211    211      0      0     0%\ntests/test_run_app.py                      460    460     24      0     0%\ntests/test_streams.py                     1052   1052     40      0     0%\ntests/test_tcp_helpers.py                   52     52      2      0     0%\ntests/test_test_utils.py                   231    231      6      0     0%\ntests/test_tracing.py                       49     49      0      0     0%\ntests/test_urldispatch.py                  846    846     24      0     0%\ntests/test_web_app.py                      383    383      6      0     0%\ntests/test_web_cli.py                       76     76      0      0     0%\ntests/test_web_exceptions.py               230    230     30      0     0%\ntests/test_web_functional.py              1484   1484     32      0     0%\ntests/test_web_log.py                      143    143      2      0     0%\ntests/test_web_middleware.py               230    230      2      0     0%\ntests/test_web_request.py                  543    543      8      0     0%\ntests/test_web_request_handler.py           40     40      0      0     0%\ntests/test_web_response.py                 767    767      4      0     0%\ntests/test_web_runner.py                   177    177      4      0     0%\ntests/test_web_sendfile.py                  77     77      0      0     0%\ntests/test_web_sendfile_functional.py      634    634     18      0     0%\ntests/test_web_server.py                   175    175      0      0     0%\ntests/test_web_urldispatcher.py            273    273     14      0     0%\ntests/test_web_websocket.py                287    287      4      0     0%\ntests/test_web_websocket_functional.py     573    573     20      0     0%\ntests/test_websocket_handshake.py          153    153     12      0     0%\ntests/test_websocket_parser.py             293    293     12      0     0%\ntests/test_websocket_writer.py              69     69      0      0     0%\ntests/test_worker.py                       190    190      4      0     0%\n--------------------------------------------------------------------------\nTOTAL                                    31320  26581   3973    375    15%\n\n============================= slowest 10 durations =============================\n0.02s call     r2e_tests/test_1.py::test_app_ctor\n0.02s teardown r2e_tests/test_1.py::test_subapp_chained_config_dict_overriding[pyloop]\n0.01s teardown r2e_tests/test_1.py::test_subapp_chained_config_dict_visibility[pyloop]\n0.01s call     r2e_tests/test_1.py::test_cleanup_ctx\n0.01s call     r2e_tests/test_1.py::test_app_register_coro\n0.01s teardown r2e_tests/test_1.py::test_subapp_on_startup[pyloop]\n0.01s call     r2e_tests/test_1.py::test_on_shutdown\n0.01s call     r2e_tests/test_1.py::test_app_register_on_finish\n0.01s call     r2e_tests/test_1.py::test_on_startup\n0.01s call     r2e_tests/test_1.py::test_cleanup_ctx_multiple_yields\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::test_app_ctor\nPASSED r2e_tests/test_1.py::test_app_call\nPASSED r2e_tests/test_1.py::test_app_register_on_finish\nPASSED r2e_tests/test_1.py::test_app_register_coro\nPASSED r2e_tests/test_1.py::test_logging\nPASSED r2e_tests/test_1.py::test_on_shutdown\nPASSED r2e_tests/test_1.py::test_on_startup\nPASSED r2e_tests/test_1.py::test_appkey\nPASSED r2e_tests/test_1.py::test_appkey_repr_concrete\nPASSED r2e_tests/test_1.py::test_appkey_repr_nonconcrete\nPASSED r2e_tests/test_1.py::test_appkey_repr_annotated\nPASSED r2e_tests/test_1.py::test_app_str_keys\nPASSED r2e_tests/test_1.py::test_app_get\nPASSED r2e_tests/test_1.py::test_app_freeze\nPASSED r2e_tests/test_1.py::test_equality\nPASSED r2e_tests/test_1.py::test_app_run_middlewares\nPASSED r2e_tests/test_1.py::test_subapp_pre_frozen_after_adding\nPASSED r2e_tests/test_1.py::test_app_inheritance\nPASSED r2e_tests/test_1.py::test_app_custom_attr\nPASSED r2e_tests/test_1.py::test_cleanup_ctx\nPASSED r2e_tests/test_1.py::test_cleanup_ctx_exception_on_startup\nPASSED r2e_tests/test_1.py::test_cleanup_ctx_exception_on_cleanup\nPASSED r2e_tests/test_1.py::test_cleanup_ctx_cleanup_after_exception\nPASSED r2e_tests/test_1.py::test_cleanup_ctx_exception_on_cleanup_multiple\nPASSED r2e_tests/test_1.py::test_cleanup_ctx_multiple_yields\nPASSED r2e_tests/test_1.py::test_subapp_chained_config_dict_visibility[pyloop]\nPASSED r2e_tests/test_1.py::test_subapp_chained_config_dict_overriding[pyloop]\nPASSED r2e_tests/test_1.py::test_subapp_on_startup[pyloop]\nPASSED r2e_tests/test_1.py::test_app_iter\nPASSED r2e_tests/test_1.py::test_app_forbid_nonslot_attr\nPASSED r2e_tests/test_1.py::test_forbid_changing_frozen_app\nPASSED r2e_tests/test_1.py::test_app_boolean\n============================== 32 passed in 3.35s ==============================\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-7.4.0, pluggy-1.2.0 -- /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/.venv/bin/python\ncachedir: .pytest_cache\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305\nconfigfile: setup.cfg\nplugins: mock-3.11.1, asyncio-0.23.8, cov-4.1.0\nasyncio: mode=strict\ncollecting ... collected 32 items\n\nr2e_tests/test_1.py::test_app_ctor PASSED                                [  3%]\nr2e_tests/test_1.py::test_app_call PASSED                                [  6%]\nr2e_tests/test_1.py::test_app_register_on_finish PASSED                  [  9%]\nr2e_tests/test_1.py::test_app_register_coro PASSED                       [ 12%]\nr2e_tests/test_1.py::test_logging PASSED                                 [ 15%]\nr2e_tests/test_1.py::test_on_shutdown PASSED                             [ 18%]\nr2e_tests/test_1.py::test_on_startup PASSED                              [ 21%]\nr2e_tests/test_1.py::test_appkey PASSED                                  [ 25%]\nr2e_tests/test_1.py::test_appkey_repr_concrete PASSED                    [ 28%]\nr2e_tests/test_1.py::test_appkey_repr_nonconcrete PASSED                 [ 31%]\nr2e_tests/test_1.py::test_appkey_repr_annotated PASSED                   [ 34%]\nr2e_tests/test_1.py::test_app_str_keys FAILED                            [ 37%]\nr2e_tests/test_1.py::test_app_get PASSED                                 [ 40%]\nr2e_tests/test_1.py::test_app_freeze PASSED                              [ 43%]\nr2e_tests/test_1.py::test_equality PASSED                                [ 46%]\nr2e_tests/test_1.py::test_app_run_middlewares PASSED                     [ 50%]\nr2e_tests/test_1.py::test_subapp_pre_frozen_after_adding PASSED          [ 53%]\nr2e_tests/test_1.py::test_app_inheritance PASSED                         [ 56%]\nr2e_tests/test_1.py::test_app_custom_attr PASSED                         [ 59%]\nr2e_tests/test_1.py::test_cleanup_ctx PASSED                             [ 62%]\nr2e_tests/test_1.py::test_cleanup_ctx_exception_on_startup PASSED        [ 65%]\nr2e_tests/test_1.py::test_cleanup_ctx_exception_on_cleanup PASSED        [ 68%]\nr2e_tests/test_1.py::test_cleanup_ctx_cleanup_after_exception PASSED     [ 71%]\nr2e_tests/test_1.py::test_cleanup_ctx_exception_on_cleanup_multiple PASSED [ 75%]\nr2e_tests/test_1.py::test_cleanup_ctx_multiple_yields PASSED             [ 78%]\nr2e_tests/test_1.py::test_subapp_chained_config_dict_visibility[pyloop] PASSED [ 81%]\nr2e_tests/test_1.py::test_subapp_chained_config_dict_overriding[pyloop] PASSED [ 84%]\nr2e_tests/test_1.py::test_subapp_on_startup[pyloop] PASSED               [ 87%]\nr2e_tests/test_1.py::test_app_iter PASSED                                [ 90%]\nr2e_tests/test_1.py::test_app_forbid_nonslot_attr PASSED                 [ 93%]\nr2e_tests/test_1.py::test_forbid_changing_frozen_app PASSED              [ 96%]\nr2e_tests/test_1.py::test_app_boolean PASSED                             [100%]\n\n=================================== FAILURES ===================================\n______________________________ test_app_str_keys _______________________________\n\n    def test_app_str_keys() -> None:\n        app = web.Application()\n        with pytest.warns(\n            UserWarning, match=r\"web_advanced\\.html#application-s-config\"\n        ) as checker:\n            app[\"key\"] = \"value\"\n            # Check that the error is emitted at the call site (stacklevel=2)\n>           assert checker[0].filename == __file__\nE           AssertionError: assert '/home/gcpuse...tp/web_app.py' == '/home/gcpuse...sts/test_1.py'\nE             - /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/r2e_tests/test_1.py\nE             ?                                                                                                    ^^  ^^^^^^^^^^^^\nE             + /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_466f1ebbac1bd4047d0eeaed582ac12834bad305/aiohttp/web_app.py\nE             ?                                                                                                    ^^^^^^^^^ + ^^^\n\napp        = <Application 0x7c50d886d930>\nchecker    = WarningsChecker(record=True)\n\nr2e_tests/test_1.py:152: AssertionError\n==================================== PASSES ====================================\n\n---------- coverage: platform linux, python 3.9.21-final-0 -----------\nName                                     Stmts   Miss Branch BrPart  Cover\n--------------------------------------------------------------------------\naiohttp/__init__.py                         26     10      2      0    57%\naiohttp/abc.py                              89      2      0      0    98%\naiohttp/base_protocol.py                    66     36     22      3    38%\naiohttp/client.py                          467    231    170     44    45%\naiohttp/client_exceptions.py               120     47     10      1    57%\naiohttp/client_proto.py                    153     50     56     20    60%\naiohttp/client_reqrep.py                   620    283    264     55    45%\naiohttp/client_ws.py                       212    165     66      0    18%\naiohttp/compression_utils.py                65     34     14      0    39%\naiohttp/connector.py                       673    378    297     48    37%\naiohttp/cookiejar.py                       255    166    118     11    27%\naiohttp/formdata.py                         94     77     46      0    12%\naiohttp/hdrs.py                             91      0      0      0   100%\naiohttp/helpers.py                         549    265    198     22    45%\naiohttp/http.py                              8      0      0      0   100%\naiohttp/http_exceptions.py                  51     21      6      0    53%\naiohttp/http_parser.py                     474    380    176      1    15%\naiohttp/http_websocket.py                  378    285    152      0    18%\naiohttp/http_writer.py                     118     44     50     13    53%\naiohttp/locks.py                            28     18      4      0    31%\naiohttp/log.py                               7      0      0      0   100%\naiohttp/multipart.py                       593    486    250      0    13%\naiohttp/payload.py                         220    107     56      1    43%\naiohttp/pytest_plugin.py                   159     58     42      6    61%\naiohttp/resolver.py                         50     31     14      0    30%\naiohttp/streams.py                         392    243    138     11    30%\naiohttp/tcp_helpers.py                      19      2      6      3    80%\naiohttp/test_utils.py                      307    106     56     16    61%\naiohttp/tracing.py                         191     69     32      0    69%\naiohttp/typedefs.py                         23      0      0      0   100%\naiohttp/web.py                             118     83     52      0    22%\naiohttp/web_app.py                         253     28     50      8    85%\naiohttp/web_exceptions.py                  211     50     24      0    71%\naiohttp/web_fileresponse.py                141    117     50      0    13%\naiohttp/web_log.py                         102     37     20      1    59%\naiohttp/web_middlewares.py                  54     38     20      0    22%\naiohttp/web_protocol.py                    352    152    157     38    47%\naiohttp/web_request.py                     450    246    138     10    37%\naiohttp/web_response.py                    430    217    178     30    40%\naiohttp/web_routedef.py                    106     41     10      1    60%\naiohttp/web_runner.py                      231     72     42     12    64%\naiohttp/web_server.py                       40      6      8      2    79%\naiohttp/web_urldispatcher.py               692    320    157     18    48%\naiohttp/web_ws.py                          318    255    106      0    15%\naiohttp/worker.py                          123    123     30      0     0%\ntests/__init__.py                            0      0      0      0   100%\ntests/conftest.py                          115    115     16      0     0%\ntests/test_base_protocol.py                198    198      2      0     0%\ntests/test_circular_imports.py              31     31     15      0     0%\ntests/test_classbasedview.py                39     39      0      0     0%\ntests/test_client_connection.py             93     93      2      0     0%\ntests/test_client_exceptions.py            165    165     14      0     0%\ntests/test_client_fingerprint.py            24     24      0      0     0%\ntests/test_client_functional.py           2164   2164     70      0     0%\ntests/test_client_proto.py                 100    100      0      0     0%\ntests/test_client_request.py               724    724     18      0     0%\ntests/test_client_response.py              467    467      2      0     0%\ntests/test_client_session.py               450    450     23      0     0%\ntests/test_client_ws.py                    416    416      2      0     0%\ntests/test_client_ws_functional.py         624    624     14      0     0%\ntests/test_connector.py                   1509   1509     76      0     0%\ntests/test_cookiejar.py                    338    338     22      0     0%\ntests/test_flowcontrol_streams.py          101    101      0      0     0%\ntests/test_formdata.py                      77     77      6      0     0%\ntests/test_helpers.py                      510    510     14      0     0%\ntests/test_http_exceptions.py              109    109     10      0     0%\ntests/test_http_parser.py                  775    775     38      0     0%\ntests/test_http_writer.py                  183    183     10      0     0%\ntests/test_imports.py                       31     31      6      0     0%\ntests/test_locks.py                         40     40      0      0     0%\ntests/test_loop.py                          36     36      0      0     0%\ntests/test_multipart.py                    771    771     28      0     0%\ntests/test_multipart_helpers.py            446    446      0      0     0%\ntests/test_payload.py                       79     79      0      0     0%\ntests/test_proxy.py                        244    244      0      0     0%\ntests/test_proxy_functional.py             470    470     20      0     0%\ntests/test_pytest_plugin.py                 47     47      0      0     0%\ntests/test_resolver.py                     127    127     10      0     0%\ntests/test_route_def.py                    211    211      0      0     0%\ntests/test_run_app.py                      460    460     24      0     0%\ntests/test_streams.py                     1052   1052     40      0     0%\ntests/test_tcp_helpers.py                   52     52      2      0     0%\ntests/test_test_utils.py                   231    231      6      0     0%\ntests/test_tracing.py                       49     49      0      0     0%\ntests/test_urldispatch.py                  846    846     24      0     0%\ntests/test_web_app.py                      382    382      6      0     0%\ntests/test_web_cli.py                       76     76      0      0     0%\ntests/test_web_exceptions.py               230    230     30      0     0%\ntests/test_web_functional.py              1484   1484     32      0     0%\ntests/test_web_log.py                      143    143      2      0     0%\ntests/test_web_middleware.py               230    230      2      0     0%\ntests/test_web_request.py                  543    543      8      0     0%\ntests/test_web_request_handler.py           40     40      0      0     0%\ntests/test_web_response.py                 767    767      4      0     0%\ntests/test_web_runner.py                   177    177      4      0     0%\ntests/test_web_sendfile.py                  77     77      0      0     0%\ntests/test_web_sendfile_functional.py      634    634     18      0     0%\ntests/test_web_server.py                   175    175      0      0     0%\ntests/test_web_urldispatcher.py            273    273     14      0     0%\ntests/test_web_websocket.py                287    287      4      0     0%\ntests/test_web_websocket_functional.py     573    573     20      0     0%\ntests/test_websocket_handshake.py          153    153     12      0     0%\ntests/test_websocket_parser.py             293    293     12      0     0%\ntests/test_websocket_writer.py              69     69      0      0     0%\ntests/test_worker.py                       190    190      4      0     0%\n--------------------------------------------------------------------------\nTOTAL                                    31319  26579   3973    375    15%\n\n============================= slowest 10 durations =============================\n0.01s call     r2e_tests/test_1.py::test_app_ctor\n0.01s call     r2e_tests/test_1.py::test_cleanup_ctx\n0.01s teardown r2e_tests/test_1.py::test_subapp_chained_config_dict_visibility[pyloop]\n0.01s teardown r2e_tests/test_1.py::test_subapp_chained_config_dict_overriding[pyloop]\n0.01s call     r2e_tests/test_1.py::test_app_register_on_finish\n0.01s call     r2e_tests/test_1.py::test_app_register_coro\n0.01s call     r2e_tests/test_1.py::test_cleanup_ctx_exception_on_startup\n0.01s call     r2e_tests/test_1.py::test_cleanup_ctx_exception_on_cleanup\n0.01s teardown r2e_tests/test_1.py::test_subapp_on_startup[pyloop]\n0.01s call     r2e_tests/test_1.py::test_on_startup\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::test_app_ctor\nPASSED r2e_tests/test_1.py::test_app_call\nPASSED r2e_tests/test_1.py::test_app_register_on_finish\nPASSED r2e_tests/test_1.py::test_app_register_coro\nPASSED r2e_tests/test_1.py::test_logging\nPASSED r2e_tests/test_1.py::test_on_shutdown\nPASSED r2e_tests/test_1.py::test_on_startup\nPASSED r2e_tests/test_1.py::test_appkey\nPASSED r2e_tests/test_1.py::test_appkey_repr_concrete\nPASSED r2e_tests/test_1.py::test_appkey_repr_nonconcrete\nPASSED r2e_tests/test_1.py::test_appkey_repr_annotated\nPASSED r2e_tests/test_1.py::test_app_get\nPASSED r2e_tests/test_1.py::test_app_freeze\nPASSED r2e_tests/test_1.py::test_equality\nPASSED r2e_tests/test_1.py::test_app_run_middlewares\nPASSED r2e_tests/test_1.py::test_subapp_pre_frozen_after_adding\nPASSED r2e_tests/test_1.py::test_app_inheritance\nPASSED r2e_tests/test_1.py::test_app_custom_attr\nPASSED r2e_tests/test_1.py::test_cleanup_ctx\nPASSED r2e_tests/test_1.py::test_cleanup_ctx_exception_on_startup\nPASSED r2e_tests/test_1.py::test_cleanup_ctx_exception_on_cleanup\nPASSED r2e_tests/test_1.py::test_cleanup_ctx_cleanup_after_exception\nPASSED r2e_tests/test_1.py::test_cleanup_ctx_exception_on_cleanup_multiple\nPASSED r2e_tests/test_1.py::test_cleanup_ctx_multiple_yields\nPASSED r2e_tests/test_1.py::test_subapp_chained_config_dict_visibility[pyloop]\nPASSED r2e_tests/test_1.py::test_subapp_chained_config_dict_overriding[pyloop]\nPASSED r2e_tests/test_1.py::test_subapp_on_startup[pyloop]\nPASSED r2e_tests/test_1.py::test_app_iter\nPASSED r2e_tests/test_1.py::test_app_forbid_nonslot_attr\nPASSED r2e_tests/test_1.py::test_forbid_changing_frozen_app\nPASSED r2e_tests/test_1.py::test_app_boolean\nFAILED r2e_tests/test_1.py::test_app_str_keys - AssertionError: assert '/home...\n========================= 1 failed, 31 passed in 3.16s =========================\n",
    "old_commit_res_stderr": ""
}
CONTRIBUTORS.txt aiohttp/web_app.py tests/test_web_app.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** UserWarning for AppKey Usage Points to Internal aiohttp Code Instead of User Code

**Description:**
When assigning a string key to the `aiohttp.web.Application` instance, a `UserWarning` is triggered to recommend using `AppKey` instances. However, the warning incorrectly references the internal `web_app.py` file of the aiohttp library rather than the location in the user's code where the assignment occurs. This makes it harder for developers to identify and resolve the issue in their own codebase.

**Example Code:**
```python
import warnings
from aiohttp import web

# Configure warnings to always display UserWarnings
warnings.simplefilter("always", UserWarning)

app = web.Application()

# Assigning a string key instead of using AppKey
app["key"] = "value"
```

**Expected Behavior:**
The `UserWarning` should indicate the exact line in the user's code where the string key assignment is made. This would help developers quickly locate and address the usage of string keys by switching to `AppKey` instances.

**Actual Behavior:**
The `UserWarning` points to the internal `web_app.py` file within the aiohttp library, obscuring the actual location in the user's code where the string key is assigned. This misleading reference complicates the debugging process for developers.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### aiohttp/web_app.py
import asyncio
import logging
import warnings
from functools import partial, update_wrapper
from typing import (  # noqa
    TYPE_CHECKING,
    Any,
    AsyncIterator,
    Awaitable,
    Callable,
    Dict,
    Iterable,
    Iterator,
    List,
    Mapping,
    MutableMapping,
    Optional,
    Sequence,
    Tuple,
    Type,
    TypeVar,
    Union,
    cast,
    overload,
)

from aiosignal import Signal
from frozenlist import FrozenList
from typing_extensions import final

from . import hdrs
from .helpers import AppKey
from .log import web_logger
from .typedefs import Middleware
from .web_middlewares import _fix_request_current_app
from .web_request import Request
from .web_response import StreamResponse
from .web_routedef import AbstractRouteDef
from .web_urldispatcher import (
    AbstractResource,
    AbstractRoute,
    Domain,
    MaskDomain,
    MatchedSubAppResource,
    PrefixedSubAppResource,
    UrlDispatcher,
)

__all__ = ("Application", "CleanupError")


if TYPE_CHECKING:  # pragma: no cover
    _AppSignal = Signal[Callable[["Application"], Awaitable[None]]]
    _RespPrepareSignal = Signal[Callable[[Request, StreamResponse], Awaitable[None]]]
    _Middlewares = FrozenList[Middleware]
    _MiddlewaresHandlers = Sequence[Middleware]
    _Subapps = List["Application"]
else:
    # No type checker mode, skip types
    _AppSignal = Signal
    _RespPrepareSignal = Signal
    _Handler = Callable
    _Middlewares = FrozenList
    _MiddlewaresHandlers = Sequence
    _Subapps = List

_T = TypeVar("_T")
_U = TypeVar("_U")


@final
class Application(MutableMapping[Union[str, AppKey[Any]], Any]):
    __slots__ = (
        "logger",
        "_debug",
        "_router",
        "_loop",
        "_handler_args",
        "_middlewares",
        "_middlewares_handlers",
        "_run_middlewares",
        "_state",
        "_frozen",
        "_pre_frozen",
        "_subapps",
        "_on_response_prepare",
        "_on_startup",
        "_on_shutdown",
        "_on_cleanup",
        "_client_max_size",
        "_cleanup_ctx",
    )

    def __init__(
        self,
        *,
        logger: logging.Logger = web_logger,
        middlewares: Iterable[Middleware] = (),
        handler_args: Optional[Mapping[str, Any]] = None,
        client_max_size: int = 1024**2,
        debug: Any = ...,  # mypy doesn't support ellipsis
    ) -> None:
        if debug is not ...:
            warnings.warn(
                "debug argument is no-op since 4.0 " "and scheduled for removal in 5.0",
                DeprecationWarning,
                stacklevel=2,
            )
        self._router = UrlDispatcher()
        self._handler_args = handler_args
        self.logger = logger

        self._middlewares: _Middlewares = FrozenList(middlewares)

        # initialized on freezing
        self._middlewares_handlers: _MiddlewaresHandlers = tuple()
        # initialized on freezing
        self._run_middlewares: Optional[bool] = None

        self._state: Dict[Union[AppKey[Any], str], object] = {}
        self._frozen = False
        self._pre_frozen = False
        self._subapps: _Subapps = []

        self._on_response_prepare: _RespPrepareSignal = Signal(self)
        self._on_startup: _AppSignal = Signal(self)
        self._on_shutdown: _AppSignal = Signal(self)
        self._on_cleanup: _AppSignal = Signal(self)
        self._cleanup_ctx = CleanupContext()
        self._on_startup.append(self._cleanup_ctx._on_startup)
        self._on_cleanup.append(self._cleanup_ctx._on_cleanup)
        self._client_max_size = client_max_size

    def __init_subclass__(cls: Type["Application"]) -> None:
        raise TypeError(
            "Inheritance class {} from web.Application "
            "is forbidden".format(cls.__name__)
        )

    # MutableMapping API

    def __eq__(self, other: object) -> bool:
        return self is other

    @overload  # type: ignore[override]
    def __getitem__(self, key: AppKey[_T]) -> _T:
        ...

    @overload
    def __getitem__(self, key: str) -> Any:
        ...

    def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:
        return self._state[key]

    def _check_frozen(self) -> None:
        if self._frozen:
            raise RuntimeError(
                "Changing state of started or joined " "application is forbidden"
            )

    @overload  # type: ignore[override]
    def __setitem__(self, key: AppKey[_T], value: _T) -> None:
        ...

    @overload
    def __setitem__(self, key: str, value: Any) -> None:
        ...

    def __setitem__(self, key: Union[str, AppKey[_T]], value: Any) -> None:
        self._check_frozen()
        if not isinstance(key, AppKey):
            warnings.warn(
                "It is recommended to use web.AppKey instances for keys.\n"
                + "https://docs.aiohttp.org/en/stable/web_advanced.html"
                + "#application-s-config"
            )
        self._state[key] = value

    def __delitem__(self, key: Union[str, AppKey[_T]]) -> None:
        self._check_frozen()
        del self._state[key]

    def __len__(self) -> int:
        return len(self._state)

    def __iter__(self) -> Iterator[Union[str, AppKey[Any]]]:
        return iter(self._state)

    @overload  # type: ignore[override]
    def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]:
        ...

    @overload
    def get(self, key: AppKey[_T], default: _U) -> Union[_T, _U]:
        ...

    @overload
    def get(self, key: str, default: Any = ...) -> Any:
        ...

    def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:
        return self._state.get(key, default)

    ########
    def _set_loop(self, loop: Optional[asyncio.AbstractEventLoop]) -> None:
        warnings.warn(
            "_set_loop() is no-op since 4.0 " "and scheduled for removal in 5.0",
            DeprecationWarning,
            stacklevel=2,
        )

    @property
    def pre_frozen(self) -> bool:
        return self._pre_frozen

    def pre_freeze(self) -> None:
        if self._pre_frozen:
            return

        self._pre_frozen = True
        self._middlewares.freeze()
        self._router.freeze()
        self._on_response_prepare.freeze()
        self._cleanup_ctx.freeze()
        self._on_startup.freeze()
        self._on_shutdown.freeze()
        self._on_cleanup.freeze()
        self._middlewares_handlers = tuple(self._prepare_middleware())

        # If current app and any subapp do not have middlewares avoid run all
        # of the code footprint that it implies, which have a middleware
        # hardcoded per app that sets up the current_app attribute. If no
        # middlewares are configured the handler will receive the proper
        # current_app without needing all of this code.
        self._run_middlewares = True if self.middlewares else False

        for subapp in self._subapps:
            subapp.pre_freeze()
            self._run_middlewares = self._run_middlewares or subapp._run_middlewares

    @property
    def frozen(self) -> bool:
        return self._frozen

    def freeze(self) -> None:
        if self._frozen:
            return

        self.pre_freeze()
        self._frozen = True
        for subapp in self._subapps:
            subapp.freeze()

    @property
    def debug(self) -> bool:
        warnings.warn(
            "debug property is deprecated since 4.0" "and scheduled for removal in 5.0",
            DeprecationWarning,
            stacklevel=2,
        )
        return asyncio.get_event_loop().get_debug()

    def _reg_subapp_signals(self, subapp: "Application") -> None:
        def reg_handler(signame: str) -> None:
            subsig = getattr(subapp, signame)

            async def handler(app: "Application") -> None:
                await subsig.send(subapp)

            appsig = getattr(self, signame)
            appsig.append(handler)

        reg_handler("on_startup")
        reg_handler("on_shutdown")
        reg_handler("on_cleanup")

    def add_subapp(self, prefix: str, subapp: "Application") -> AbstractResource:
        if not isinstance(prefix, str):
            raise TypeError("Prefix must be str")
        prefix = prefix.rstrip("/")
        if not prefix:
            raise ValueError("Prefix cannot be empty")
        factory = partial(PrefixedSubAppResource, prefix, subapp)
        return self._add_subapp(factory, subapp)

    def _add_subapp(
        self, resource_factory: Callable[[], AbstractResource], subapp: "Application"
    ) -> AbstractResource:
        if self.frozen:
            raise RuntimeError("Cannot add sub application to frozen application")
        if subapp.frozen:
            raise RuntimeError("Cannot add frozen application")
        resource = resource_factory()
        self.router.register_resource(resource)
        self._reg_subapp_signals(subapp)
        self._subapps.append(subapp)
        subapp.pre_freeze()
        return resource

    def add_domain(self, domain: str, subapp: "Application") -> AbstractResource:
        if not isinstance(domain, str):
            raise TypeError("Domain must be str")
        elif "*" in domain:
            rule: Domain = MaskDomain(domain)
        else:
            rule = Domain(domain)
        factory = partial(MatchedSubAppResource, rule, subapp)
        return self._add_subapp(factory, subapp)

    def add_routes(self, routes: Iterable[AbstractRouteDef]) -> List[AbstractRoute]:
        return self.router.add_routes(routes)

    @property
    def on_response_prepare(self) -> _RespPrepareSignal:
        return self._on_response_prepare

    @property
    def on_startup(self) -> _AppSignal:
        return self._on_startup

    @property
    def on_shutdown(self) -> _AppSignal:
        return self._on_shutdown

    @property
    def on_cleanup(self) -> _AppSignal:
        return self._on_cleanup

    @property
    def cleanup_ctx(self) -> "CleanupContext":
        return self._cleanup_ctx

    @property
    def router(self) -> UrlDispatcher:
        return self._router

    @property
    def middlewares(self) -> _Middlewares:
        return self._middlewares

    async def startup(self) -> None:
        """Causes on_startup signal

        Should be called in the event loop along with the request handler.
        """
        await self.on_startup.send(self)

    async def shutdown(self) -> None:
        """Causes on_shutdown signal

        Should be called before cleanup()
        """
        await self.on_shutdown.send(self)

    async def cleanup(self) -> None:
        """Causes on_cleanup signal

        Should be called after shutdown()
        """
        if self.on_cleanup.frozen:
            await self.on_cleanup.send(self)
        else:
            # If an exception occurs in startup, ensure cleanup contexts are completed.
            await self._cleanup_ctx._on_cleanup(self)

    def _prepare_middleware(self) -> Iterator[Middleware]:
        yield from reversed(self._middlewares)
        yield _fix_request_current_app(self)

    async def _handle(self, request: Request) -> StreamResponse:
        match_info = await self._router.resolve(request)
        match_info.add_app(self)
        match_info.freeze()

        resp = None
        request._match_info = match_info
        expect = request.headers.get(hdrs.EXPECT)
        if expect:
            resp = await match_info.expect_handler(request)
            await request.writer.drain()

        if resp is None:
            handler = match_info.handler

            if self._run_middlewares:
                for app in match_info.apps[::-1]:
                    assert app.pre_frozen, "middleware handlers are not ready"
                    for m in app._middlewares_handlers:
                        handler = update_wrapper(partial(m, handler=handler), handler)

            resp = await handler(request)

        return resp

    def __call__(self) -> "Application":
        """gunicorn compatibility"""
        return self

    def __repr__(self) -> str:
        return f"<Application 0x{id(self):x}>"

    def __bool__(self) -> bool:
        return True


class CleanupError(RuntimeError):
    @property
    def exceptions(self) -> List[BaseException]:
        return cast(List[BaseException], self.args[1])


if TYPE_CHECKING:  # pragma: no cover
    _CleanupContextBase = FrozenList[Callable[[Application], AsyncIterator[None]]]
else:
    _CleanupContextBase = FrozenList


class CleanupContext(_CleanupContextBase):
    def __init__(self) -> None:
        super().__init__()
        self._exits: List[AsyncIterator[None]] = []

    async def _on_startup(self, app: Application) -> None:
        for cb in self:
            it = cb(app).__aiter__()
            await it.__anext__()
            self._exits.append(it)

    async def _on_cleanup(self, app: Application) -> None:
        errors = []
        for it in reversed(self._exits):
            try:
                await it.__anext__()
            except StopAsyncIteration:
                pass
            except Exception as exc:
                errors.append(exc)
            else:
                errors.append(RuntimeError(f"{it!r} has more than one 'yield'"))
        if errors:
            if len(errors) == 1:
                raise errors[0]
            else:
                raise CleanupError("Multiple errors on cleanup stage", errors)

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]
**Title:** UserWarning for AppKey Usage Points to Internal aiohttp Code Instead of User Code

**Description:**
When assigning a string key to the `aiohttp.web.Application` instance, a `UserWarning` is triggered to recommend using `AppKey` instances. However, the warning incorrectly references the internal `web_app.py` file of the aiohttp library rather than the location in the user's code where the assignment occurs. This makes it harder for developers to identify and resolve the issue in their own codebase.

**Example Code:**
```python
import warnings
from aiohttp import web

# Configure warnings to always display UserWarnings
warnings.simplefilter("always", UserWarning)

app = web.Application()

# Assigning a string key instead of using AppKey
app["key"] = "value"
```

**Expected Behavior:**
The `UserWarning` should indicate the exact line in the user's code where the string key assignment is made. This would help developers quickly locate and address the usage of string keys by switching to `AppKey` instances.

**Actual Behavior:**
The `UserWarning` points to the internal `web_app.py` file within the aiohttp library, obscuring the actual location in the user's code where the string key is assigned. This misleading reference complicates the debugging process for developers.

[/ISSUE]
{
    "test_app_ctor": "PASSED",
    "test_app_call": "PASSED",
    "test_app_register_on_finish": "PASSED",
    "test_app_register_coro": "PASSED",
    "test_logging": "PASSED",
    "test_on_shutdown": "PASSED",
    "test_on_startup": "PASSED",
    "test_appkey": "PASSED",
    "test_appkey_repr_concrete": "PASSED",
    "test_appkey_repr_nonconcrete": "PASSED",
    "test_appkey_repr_annotated": "PASSED",
    "test_app_str_keys": "PASSED",
    "test_app_get": "PASSED",
    "test_app_freeze": "PASSED",
    "test_equality": "PASSED",
    "test_app_run_middlewares": "PASSED",
    "test_subapp_pre_frozen_after_adding": "PASSED",
    "test_app_inheritance": "PASSED",
    "test_app_custom_attr": "PASSED",
    "test_cleanup_ctx": "PASSED",
    "test_cleanup_ctx_exception_on_startup": "PASSED",
    "test_cleanup_ctx_exception_on_cleanup": "PASSED",
    "test_cleanup_ctx_cleanup_after_exception": "PASSED",
    "test_cleanup_ctx_exception_on_cleanup_multiple": "PASSED",
    "test_cleanup_ctx_multiple_yields": "PASSED",
    "test_subapp_chained_config_dict_visibility[pyloop]": "PASSED",
    "test_subapp_chained_config_dict_overriding[pyloop]": "PASSED",
    "test_subapp_on_startup[pyloop]": "PASSED",
    "test_app_iter": "PASSED",
    "test_app_forbid_nonslot_attr": "PASSED",
    "test_forbid_changing_frozen_app": "PASSED",
    "test_app_boolean": "PASSED"
}
diff --git a/aiohttp/web_app.py b/aiohttp/web_app.py
index 80956831..4b64dd8b 100644
--- a/aiohttp/web_app.py
+++ b/aiohttp/web_app.py
@@ -173,7 +173,8 @@ class Application(MutableMapping[Union[str, AppKey[Any]], Any]):
             warnings.warn(
                 "It is recommended to use web.AppKey instances for keys.\n"
                 + "https://docs.aiohttp.org/en/stable/web_advanced.html"
-                + "#application-s-config"
+                + "#application-s-config",
+                stacklevel=2,
             )
         self._state[key] = value
 

{"aiohttp/web_app.py": "import asyncio\nimport logging\nimport warnings\nfrom functools import partial, update_wrapper\nfrom typing import (  # noqa\n    TYPE_CHECKING,\n    Any,\n    AsyncIterator,\n    Awaitable,\n    Callable,\n    Dict,\n    Iterable,\n    Iterator,\n    List,\n    Mapping,\n    MutableMapping,\n    Optional,\n    Sequence,\n    Tuple,\n    Type,\n    TypeVar,\n    Union,\n    cast,\n    overload,\n)\n\nfrom aiosignal import Signal\nfrom frozenlist import FrozenList\nfrom typing_extensions import final\n\nfrom . import hdrs\nfrom .helpers import AppKey\nfrom .log import web_logger\nfrom .typedefs import Middleware\nfrom .web_middlewares import _fix_request_current_app\nfrom .web_request import Request\nfrom .web_response import StreamResponse\nfrom .web_routedef import AbstractRouteDef\nfrom .web_urldispatcher import (\n    AbstractResource,\n    AbstractRoute,\n    Domain,\n    MaskDomain,\n    MatchedSubAppResource,\n    PrefixedSubAppResource,\n    UrlDispatcher,\n)\n\n__all__ = (\"Application\", \"CleanupError\")\n\n\nif TYPE_CHECKING:  # pragma: no cover\n    _AppSignal = Signal[Callable[[\"Application\"], Awaitable[None]]]\n    _RespPrepareSignal = Signal[Callable[[Request, StreamResponse], Awaitable[None]]]\n    _Middlewares = FrozenList[Middleware]\n    _MiddlewaresHandlers = Sequence[Middleware]\n    _Subapps = List[\"Application\"]\nelse:\n    # No type checker mode, skip types\n    _AppSignal = Signal\n    _RespPrepareSignal = Signal\n    _Handler = Callable\n    _Middlewares = FrozenList\n    _MiddlewaresHandlers = Sequence\n    _Subapps = List\n\n_T = TypeVar(\"_T\")\n_U = TypeVar(\"_U\")\n\n\n@final\nclass Application(MutableMapping[Union[str, AppKey[Any]], Any]):\n    __slots__ = (\n        \"logger\",\n        \"_debug\",\n        \"_router\",\n        \"_loop\",\n        \"_handler_args\",\n        \"_middlewares\",\n        \"_middlewares_handlers\",\n        \"_run_middlewares\",\n        \"_state\",\n        \"_frozen\",\n        \"_pre_frozen\",\n        \"_subapps\",\n        \"_on_response_prepare\",\n        \"_on_startup\",\n        \"_on_shutdown\",\n        \"_on_cleanup\",\n        \"_client_max_size\",\n        \"_cleanup_ctx\",\n    )\n\n    def __init__(\n        self,\n        *,\n        logger: logging.Logger = web_logger,\n        middlewares: Iterable[Middleware] = (),\n        handler_args: Optional[Mapping[str, Any]] = None,\n        client_max_size: int = 1024**2,\n        debug: Any = ...,  # mypy doesn't support ellipsis\n    ) -> None:\n        if debug is not ...:\n            warnings.warn(\n                \"debug argument is no-op since 4.0 \" \"and scheduled for removal in 5.0\",\n                DeprecationWarning,\n                stacklevel=2,\n            )\n        self._router = UrlDispatcher()\n        self._handler_args = handler_args\n        self.logger = logger\n\n        self._middlewares: _Middlewares = FrozenList(middlewares)\n\n        # initialized on freezing\n        self._middlewares_handlers: _MiddlewaresHandlers = tuple()\n        # initialized on freezing\n        self._run_middlewares: Optional[bool] = None\n\n        self._state: Dict[Union[AppKey[Any], str], object] = {}\n        self._frozen = False\n        self._pre_frozen = False\n        self._subapps: _Subapps = []\n\n        self._on_response_prepare: _RespPrepareSignal = Signal(self)\n        self._on_startup: _AppSignal = Signal(self)\n        self._on_shutdown: _AppSignal = Signal(self)\n        self._on_cleanup: _AppSignal = Signal(self)\n        self._cleanup_ctx = CleanupContext()\n        self._on_startup.append(self._cleanup_ctx._on_startup)\n        self._on_cleanup.append(self._cleanup_ctx._on_cleanup)\n        self._client_max_size = client_max_size\n\n    def __init_subclass__(cls: Type[\"Application\"]) -> None:\n        raise TypeError(\n            \"Inheritance class {} from web.Application \"\n            \"is forbidden\".format(cls.__name__)\n        )\n\n    # MutableMapping API\n\n    def __eq__(self, other: object) -> bool:\n        return self is other\n\n    @overload  # type: ignore[override]\n    def __getitem__(self, key: AppKey[_T]) -> _T:\n        ...\n\n    @overload\n    def __getitem__(self, key: str) -> Any:\n        ...\n\n    def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:\n        return self._state[key]\n\n    def _check_frozen(self) -> None:\n        if self._frozen:\n            raise RuntimeError(\n                \"Changing state of started or joined \" \"application is forbidden\"\n            )\n\n    @overload  # type: ignore[override]\n    def __setitem__(self, key: AppKey[_T], value: _T) -> None:\n        ...\n\n    @overload\n    def __setitem__(self, key: str, value: Any) -> None:\n        ...\n\n    def __setitem__(self, key: Union[str, AppKey[_T]], value: Any) -> None:\n        self._check_frozen()\n        if not isinstance(key, AppKey):\n            warnings.warn(\n                \"It is recommended to use web.AppKey instances for keys.\\n\"\n                + \"https://docs.aiohttp.org/en/stable/web_advanced.html\"\n                + \"#application-s-config\"\n            )\n        self._state[key] = value\n\n    def __delitem__(self, key: Union[str, AppKey[_T]]) -> None:\n        self._check_frozen()\n        del self._state[key]\n\n    def __len__(self) -> int:\n        return len(self._state)\n\n    def __iter__(self) -> Iterator[Union[str, AppKey[Any]]]:\n        return iter(self._state)\n\n    @overload  # type: ignore[override]\n    def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]:\n        ...\n\n    @overload\n    def get(self, key: AppKey[_T], default: _U) -> Union[_T, _U]:\n        ...\n\n    @overload\n    def get(self, key: str, default: Any = ...) -> Any:\n        ...\n\n    def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:\n        return self._state.get(key, default)\n\n    ########\n    def _set_loop(self, loop: Optional[asyncio.AbstractEventLoop]) -> None:\n        warnings.warn(\n            \"_set_loop() is no-op since 4.0 \" \"and scheduled for removal in 5.0\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n\n    @property\n    def pre_frozen(self) -> bool:\n        return self._pre_frozen\n\n    def pre_freeze(self) -> None:\n        if self._pre_frozen:\n            return\n\n        self._pre_frozen = True\n        self._middlewares.freeze()\n        self._router.freeze()\n        self._on_response_prepare.freeze()\n        self._cleanup_ctx.freeze()\n        self._on_startup.freeze()\n        self._on_shutdown.freeze()\n        self._on_cleanup.freeze()\n        self._middlewares_handlers = tuple(self._prepare_middleware())\n\n        # If current app and any subapp do not have middlewares avoid run all\n        # of the code footprint that it implies, which have a middleware\n        # hardcoded per app that sets up the current_app attribute. If no\n        # middlewares are configured the handler will receive the proper\n        # current_app without needing all of this code.\n        self._run_middlewares = True if self.middlewares else False\n\n        for subapp in self._subapps:\n            subapp.pre_freeze()\n            self._run_middlewares = self._run_middlewares or subapp._run_middlewares\n\n    @property\n    def frozen(self) -> bool:\n        return self._frozen\n\n    def freeze(self) -> None:\n        if self._frozen:\n            return\n\n        self.pre_freeze()\n        self._frozen = True\n        for subapp in self._subapps:\n            subapp.freeze()\n\n    @property\n    def debug(self) -> bool:\n        warnings.warn(\n            \"debug property is deprecated since 4.0\" \"and scheduled for removal in 5.0\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n        return asyncio.get_event_loop().get_debug()\n\n    def _reg_subapp_signals(self, subapp: \"Application\") -> None:\n        def reg_handler(signame: str) -> None:\n            subsig = getattr(subapp, signame)\n\n            async def handler(app: \"Application\") -> None:\n                await subsig.send(subapp)\n\n            appsig = getattr(self, signame)\n            appsig.append(handler)\n\n        reg_handler(\"on_startup\")\n        reg_handler(\"on_shutdown\")\n        reg_handler(\"on_cleanup\")\n\n    def add_subapp(self, prefix: str, subapp: \"Application\") -> AbstractResource:\n        if not isinstance(prefix, str):\n            raise TypeError(\"Prefix must be str\")\n        prefix = prefix.rstrip(\"/\")\n        if not prefix:\n            raise ValueError(\"Prefix cannot be empty\")\n        factory = partial(PrefixedSubAppResource, prefix, subapp)\n        return self._add_subapp(factory, subapp)\n\n    def _add_subapp(\n        self, resource_factory: Callable[[], AbstractResource], subapp: \"Application\"\n    ) -> AbstractResource:\n        if self.frozen:\n            raise RuntimeError(\"Cannot add sub application to frozen application\")\n        if subapp.frozen:\n            raise RuntimeError(\"Cannot add frozen application\")\n        resource = resource_factory()\n        self.router.register_resource(resource)\n        self._reg_subapp_signals(subapp)\n        self._subapps.append(subapp)\n        subapp.pre_freeze()\n        return resource\n\n    def add_domain(self, domain: str, subapp: \"Application\") -> AbstractResource:\n        if not isinstance(domain, str):\n            raise TypeError(\"Domain must be str\")\n        elif \"*\" in domain:\n            rule: Domain = MaskDomain(domain)\n        else:\n            rule = Domain(domain)\n        factory = partial(MatchedSubAppResource, rule, subapp)\n        return self._add_subapp(factory, subapp)\n\n    def add_routes(self, routes: Iterable[AbstractRouteDef]) -> List[AbstractRoute]:\n        return self.router.add_routes(routes)\n\n    @property\n    def on_response_prepare(self) -> _RespPrepareSignal:\n        return self._on_response_prepare\n\n    @property\n    def on_startup(self) -> _AppSignal:\n        return self._on_startup\n\n    @property\n    def on_shutdown(self) -> _AppSignal:\n        return self._on_shutdown\n\n    @property\n    def on_cleanup(self) -> _AppSignal:\n        return self._on_cleanup\n\n    @property\n    def cleanup_ctx(self) -> \"CleanupContext\":\n        return self._cleanup_ctx\n\n    @property\n    def router(self) -> UrlDispatcher:\n        return self._router\n\n    @property\n    def middlewares(self) -> _Middlewares:\n        return self._middlewares\n\n    async def startup(self) -> None:\n        \"\"\"Causes on_startup signal\n\n        Should be called in the event loop along with the request handler.\n        \"\"\"\n        await self.on_startup.send(self)\n\n    async def shutdown(self) -> None:\n        \"\"\"Causes on_shutdown signal\n\n        Should be called before cleanup()\n        \"\"\"\n        await self.on_shutdown.send(self)\n\n    async def cleanup(self) -> None:\n        \"\"\"Causes on_cleanup signal\n\n        Should be called after shutdown()\n        \"\"\"\n        if self.on_cleanup.frozen:\n            await self.on_cleanup.send(self)\n        else:\n            # If an exception occurs in startup, ensure cleanup contexts are completed.\n            await self._cleanup_ctx._on_cleanup(self)\n\n    def _prepare_middleware(self) -> Iterator[Middleware]:\n        yield from reversed(self._middlewares)\n        yield _fix_request_current_app(self)\n\n    async def _handle(self, request: Request) -> StreamResponse:\n        match_info = await self._router.resolve(request)\n        match_info.add_app(self)\n        match_info.freeze()\n\n        resp = None\n        request._match_info = match_info\n        expect = request.headers.get(hdrs.EXPECT)\n        if expect:\n            resp = await match_info.expect_handler(request)\n            await request.writer.drain()\n\n        if resp is None:\n            handler = match_info.handler\n\n            if self._run_middlewares:\n                for app in match_info.apps[::-1]:\n                    assert app.pre_frozen, \"middleware handlers are not ready\"\n                    for m in app._middlewares_handlers:\n                        handler = update_wrapper(partial(m, handler=handler), handler)\n\n            resp = await handler(request)\n\n        return resp\n\n    def __call__(self) -> \"Application\":\n        \"\"\"gunicorn compatibility\"\"\"\n        return self\n\n    def __repr__(self) -> str:\n        return f\"<Application 0x{id(self):x}>\"\n\n    def __bool__(self) -> bool:\n        return True\n\n\nclass CleanupError(RuntimeError):\n    @property\n    def exceptions(self) -> List[BaseException]:\n        return cast(List[BaseException], self.args[1])\n\n\nif TYPE_CHECKING:  # pragma: no cover\n    _CleanupContextBase = FrozenList[Callable[[Application], AsyncIterator[None]]]\nelse:\n    _CleanupContextBase = FrozenList\n\n\nclass CleanupContext(_CleanupContextBase):\n    def __init__(self) -> None:\n        super().__init__()\n        self._exits: List[AsyncIterator[None]] = []\n\n    async def _on_startup(self, app: Application) -> None:\n        for cb in self:\n            it = cb(app).__aiter__()\n            await it.__anext__()\n            self._exits.append(it)\n\n    async def _on_cleanup(self, app: Application) -> None:\n        errors = []\n        for it in reversed(self._exits):\n            try:\n                await it.__anext__()\n            except StopAsyncIteration:\n                pass\n            except Exception as exc:\n                errors.append(exc)\n            else:\n                errors.append(RuntimeError(f\"{it!r} has more than one 'yield'\"))\n        if errors:\n            if len(errors) == 1:\n                raise errors[0]\n            else:\n                raise CleanupError(\"Multiple errors on cleanup stage\", errors)\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** UserWarning for AppKey Usage Points to Internal aiohttp Code Instead of User Code

**Description:**
When assigning a string key to the `aiohttp.web.Application` instance, a `UserWarning` is triggered to recommend using `AppKey` instances. However, the warning incorrectly references the internal `web_app.py` file of the aiohttp library rather than the location in the user's code where the assignment occurs. This makes it harder for developers to identify and resolve the issue in their own codebase.

**Example Code:**
```python
import warnings
from aiohttp import web

# Configure warnings to always display UserWarnings
warnings.simplefilter("always", UserWarning)

app = web.Application()

# Assigning a string key instead of using AppKey
app["key"] = "value"
```

**Expected Behavior:**
The `UserWarning` should indicate the exact line in the user's code where the string key assignment is made. This would help developers quickly locate and address the usage of string keys by switching to `AppKey` instances.

**Actual Behavior:**
The `UserWarning` points to the internal `web_app.py` file within the aiohttp library, obscuring the actual location in the user's code where the string key is assigned. This misleading reference complicates the debugging process for developers.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### aiohttp/web_app.py
import asyncio
import logging
import warnings
from functools import partial, update_wrapper
from typing import (  # noqa
    TYPE_CHECKING,
    Any,
    AsyncIterator,
    Awaitable,
    Callable,
    Dict,
    Iterable,
    Iterator,
    List,
    Mapping,
    MutableMapping,
    Optional,
    Sequence,
    Tuple,
    Type,
    TypeVar,
    Union,
    cast,
    overload,
)

from aiosignal import Signal
from frozenlist import FrozenList
from typing_extensions import final

from . import hdrs
from .helpers import AppKey
from .log import web_logger
from .typedefs import Middleware
from .web_middlewares import _fix_request_current_app
from .web_request import Request
from .web_response import StreamResponse
from .web_routedef import AbstractRouteDef
from .web_urldispatcher import (
    AbstractResource,
    AbstractRoute,
    Domain,
    MaskDomain,
    MatchedSubAppResource,
    PrefixedSubAppResource,
    UrlDispatcher,
)

__all__ = ("Application", "CleanupError")


if TYPE_CHECKING:  # pragma: no cover
    _AppSignal = Signal[Callable[["Application"], Awaitable[None]]]
    _RespPrepareSignal = Signal[Callable[[Request, StreamResponse], Awaitable[None]]]
    _Middlewares = FrozenList[Middleware]
    _MiddlewaresHandlers = Sequence[Middleware]
    _Subapps = List["Application"]
else:
    # No type checker mode, skip types
    _AppSignal = Signal
    _RespPrepareSignal = Signal
    _Handler = Callable
    _Middlewares = FrozenList
    _MiddlewaresHandlers = Sequence
    _Subapps = List

_T = TypeVar("_T")
_U = TypeVar("_U")


@final
class Application(MutableMapping[Union[str, AppKey[Any]], Any]):
    __slots__ = (
        "logger",
        "_debug",
        "_router",
        "_loop",
        "_handler_args",
        "_middlewares",
        "_middlewares_handlers",
        "_run_middlewares",
        "_state",
        "_frozen",
        "_pre_frozen",
        "_subapps",
        "_on_response_prepare",
        "_on_startup",
        "_on_shutdown",
        "_on_cleanup",
        "_client_max_size",
        "_cleanup_ctx",
    )

    def __init__(
        self,
        *,
        logger: logging.Logger = web_logger,
        middlewares: Iterable[Middleware] = (),
        handler_args: Optional[Mapping[str, Any]] = None,
        client_max_size: int = 1024**2,
        debug: Any = ...,  # mypy doesn't support ellipsis
    ) -> None:
        if debug is not ...:
            warnings.warn(
                "debug argument is no-op since 4.0 " "and scheduled for removal in 5.0",
                DeprecationWarning,
                stacklevel=2,
            )
        self._router = UrlDispatcher()
        self._handler_args = handler_args
        self.logger = logger

        self._middlewares: _Middlewares = FrozenList(middlewares)

        # initialized on freezing
        self._middlewares_handlers: _MiddlewaresHandlers = tuple()
        # initialized on freezing
        self._run_middlewares: Optional[bool] = None

        self._state: Dict[Union[AppKey[Any], str], object] = {}
        self._frozen = False
        self._pre_frozen = False
        self._subapps: _Subapps = []

        self._on_response_prepare: _RespPrepareSignal = Signal(self)
        self._on_startup: _AppSignal = Signal(self)
        self._on_shutdown: _AppSignal = Signal(self)
        self._on_cleanup: _AppSignal = Signal(self)
        self._cleanup_ctx = CleanupContext()
        self._on_startup.append(self._cleanup_ctx._on_startup)
        self._on_cleanup.append(self._cleanup_ctx._on_cleanup)
        self._client_max_size = client_max_size

    def __init_subclass__(cls: Type["Application"]) -> None:
        raise TypeError(
            "Inheritance class {} from web.Application "
            "is forbidden".format(cls.__name__)
        )

    # MutableMapping API

    def __eq__(self, other: object) -> bool:
        return self is other

    @overload  # type: ignore[override]
    def __getitem__(self, key: AppKey[_T]) -> _T:
        ...

    @overload
    def __getitem__(self, key: str) -> Any:
        ...

    def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:
        return self._state[key]

    def _check_frozen(self) -> None:
        if self._frozen:
            raise RuntimeError(
                "Changing state of started or joined " "application is forbidden"
            )

    @overload  # type: ignore[override]
    def __setitem__(self, key: AppKey[_T], value: _T) -> None:
        ...

    @overload
    def __setitem__(self, key: str, value: Any) -> None:
        ...

    def __setitem__(self, key: Union[str, AppKey[_T]], value: Any) -> None:
        self._check_frozen()
        if not isinstance(key, AppKey):
            warnings.warn(
                "It is recommended to use web.AppKey instances for keys.\n"
                + "https://docs.aiohttp.org/en/stable/web_advanced.html"
                + "#application-s-config"
            )
        self._state[key] = value

    def __delitem__(self, key: Union[str, AppKey[_T]]) -> None:
        self._check_frozen()
        del self._state[key]

    def __len__(self) -> int:
        return len(self._state)

    def __iter__(self) -> Iterator[Union[str, AppKey[Any]]]:
        return iter(self._state)

    @overload  # type: ignore[override]
    def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]:
        ...

    @overload
    def get(self, key: AppKey[_T], default: _U) -> Union[_T, _U]:
        ...

    @overload
    def get(self, key: str, default: Any = ...) -> Any:
        ...

    def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:
        return self._state.get(key, default)

    ########
    def _set_loop(self, loop: Optional[asyncio.AbstractEventLoop]) -> None:
        warnings.warn(
            "_set_loop() is no-op since 4.0 " "and scheduled for removal in 5.0",
            DeprecationWarning,
            stacklevel=2,
        )

    @property
    def pre_frozen(self) -> bool:
        return self._pre_frozen

    def pre_freeze(self) -> None:
        if self._pre_frozen:
            return

        self._pre_frozen = True
        self._middlewares.freeze()
        self._router.freeze()
        self._on_response_prepare.freeze()
        self._cleanup_ctx.freeze()
        self._on_startup.freeze()
        self._on_shutdown.freeze()
        self._on_cleanup.freeze()
        self._middlewares_handlers = tuple(self._prepare_middleware())

        # If current app and any subapp do not have middlewares avoid run all
        # of the code footprint that it implies, which have a middleware
        # hardcoded per app that sets up the current_app attribute. If no
        # middlewares are configured the handler will receive the proper
        # current_app without needing all of this code.
        self._run_middlewares = True if self.middlewares else False

        for subapp in self._subapps:
            subapp.pre_freeze()
            self._run_middlewares = self._run_middlewares or subapp._run_middlewares

    @property
    def frozen(self) -> bool:
        return self._frozen

    def freeze(self) -> None:
        if self._frozen:
            return

        self.pre_freeze()
        self._frozen = True
        for subapp in self._subapps:
            subapp.freeze()

    @property
    def debug(self) -> bool:
        warnings.warn(
            "debug property is deprecated since 4.0" "and scheduled for removal in 5.0",
            DeprecationWarning,
            stacklevel=2,
        )
        return asyncio.get_event_loop().get_debug()

    def _reg_subapp_signals(self, subapp: "Application") -> None:
        def reg_handler(signame: str) -> None:
            subsig = getattr(subapp, signame)

            async def handler(app: "Application") -> None:
                await subsig.send(subapp)

            appsig = getattr(self, signame)
            appsig.append(handler)

        reg_handler("on_startup")
        reg_handler("on_shutdown")
        reg_handler("on_cleanup")

    def add_subapp(self, prefix: str, subapp: "Application") -> AbstractResource:
        if not isinstance(prefix, str):
            raise TypeError("Prefix must be str")
        prefix = prefix.rstrip("/")
        if not prefix:
            raise ValueError("Prefix cannot be empty")
        factory = partial(PrefixedSubAppResource, prefix, subapp)
        return self._add_subapp(factory, subapp)

    def _add_subapp(
        self, resource_factory: Callable[[], AbstractResource], subapp: "Application"
    ) -> AbstractResource:
        if self.frozen:
            raise RuntimeError("Cannot add sub application to frozen application")
        if subapp.frozen:
            raise RuntimeError("Cannot add frozen application")
        resource = resource_factory()
        self.router.register_resource(resource)
        self._reg_subapp_signals(subapp)
        self._subapps.append(subapp)
        subapp.pre_freeze()
        return resource

    def add_domain(self, domain: str, subapp: "Application") -> AbstractResource:
        if not isinstance(domain, str):
            raise TypeError("Domain must be str")
        elif "*" in domain:
            rule: Domain = MaskDomain(domain)
        else:
            rule = Domain(domain)
        factory = partial(MatchedSubAppResource, rule, subapp)
        return self._add_subapp(factory, subapp)

    def add_routes(self, routes: Iterable[AbstractRouteDef]) -> List[AbstractRoute]:
        return self.router.add_routes(routes)

    @property
    def on_response_prepare(self) -> _RespPrepareSignal:
        return self._on_response_prepare

    @property
    def on_startup(self) -> _AppSignal:
        return self._on_startup

    @property
    def on_shutdown(self) -> _AppSignal:
        return self._on_shutdown

    @property
    def on_cleanup(self) -> _AppSignal:
        return self._on_cleanup

    @property
    def cleanup_ctx(self) -> "CleanupContext":
        return self._cleanup_ctx

    @property
    def router(self) -> UrlDispatcher:
        return self._router

    @property
    def middlewares(self) -> _Middlewares:
        return self._middlewares

    async def startup(self) -> None:
        """Causes on_startup signal

        Should be called in the event loop along with the request handler.
        """
        await self.on_startup.send(self)

    async def shutdown(self) -> None:
        """Causes on_shutdown signal

        Should be called before cleanup()
        """
        await self.on_shutdown.send(self)

    async def cleanup(self) -> None:
        """Causes on_cleanup signal

        Should be called after shutdown()
        """
        if self.on_cleanup.frozen:
            await self.on_cleanup.send(self)
        else:
            # If an exception occurs in startup, ensure cleanup contexts are completed.
            await self._cleanup_ctx._on_cleanup(self)

    def _prepare_middleware(self) -> Iterator[Middleware]:
        yield from reversed(self._middlewares)
        yield _fix_request_current_app(self)

    async def _handle(self, request: Request) -> StreamResponse:
        match_info = await self._router.resolve(request)
        match_info.add_app(self)
        match_info.freeze()

        resp = None
        request._match_info = match_info
        expect = request.headers.get(hdrs.EXPECT)
        if expect:
            resp = await match_info.expect_handler(request)
            await request.writer.drain()

        if resp is None:
            handler = match_info.handler

            if self._run_middlewares:
                for app in match_info.apps[::-1]:
                    assert app.pre_frozen, "middleware handlers are not ready"
                    for m in app._middlewares_handlers:
                        handler = update_wrapper(partial(m, handler=handler), handler)

            resp = await handler(request)

        return resp

    def __call__(self) -> "Application":
        """gunicorn compatibility"""
        return self

    def __repr__(self) -> str:
        return f"<Application 0x{id(self):x}>"

    def __bool__(self) -> bool:
        return True


class CleanupError(RuntimeError):
    @property
    def exceptions(self) -> List[BaseException]:
        return cast(List[BaseException], self.args[1])


if TYPE_CHECKING:  # pragma: no cover
    _CleanupContextBase = FrozenList[Callable[[Application], AsyncIterator[None]]]
else:
    _CleanupContextBase = FrozenList


class CleanupContext(_CleanupContextBase):
    def __init__(self) -> None:
        super().__init__()
        self._exits: List[AsyncIterator[None]] = []

    async def _on_startup(self, app: Application) -> None:
        for cb in self:
            it = cb(app).__aiter__()
            await it.__anext__()
            self._exits.append(it)

    async def _on_cleanup(self, app: Application) -> None:
        errors = []
        for it in reversed(self._exits):
            try:
                await it.__anext__()
            except StopAsyncIteration:
                pass
            except Exception as exc:
                errors.append(exc)
            else:
                errors.append(RuntimeError(f"{it!r} has more than one 'yield'"))
        if errors:
            if len(errors) == 1:
                raise errors[0]
            else:
                raise CleanupError("Multiple errors on cleanup stage", errors)

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user