{"id":350765,"date":"2023-07-25T21:00:49","date_gmt":"2023-07-25T21:00:49","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=350765"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=350765","title":{"rendered":"<span>Python \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u043a\u0430\u0445. \u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0446\u0435\u043f\u0442 \u043f\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0438 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0442 \u043c\u0430\u043b\u0430 \u0434\u043e \u0432\u0435\u043b\u0438\u043a\u0430<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0414\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 &#8212; \u044d\u0442\u043e, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0441\u0430\u043c\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0441\u0440\u0435\u0434\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0438 \u0441\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u0444\u0438\u0447 \u044f\u0437\u044b\u043a\u0430 <strong>Python<\/strong>. \u0421 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0432\u0441\u0435 \u0434\u0436\u0443\u043d\u044b (\u0445\u043e\u0442\u044f \u0431\u044b \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043a \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u043c). \u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u0440\u0430\u0439\u043d\u0435 \u043c\u0430\u043b\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043f\u0438\u0448\u0443\u0442 \u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f \u0432\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0442\u0435\u043d\u0434\u0435\u043d\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043b\u0435\u0442 \u043a \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0432\u0441\u0435\u0433\u043e \u0438 \u0432\u0441\u044f. \u0414\u0430\u0436\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 <em>open-source<\/em> \u043f\u0440\u043e\u0435\u043a\u0442\u044b (\u0435\u0441\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u0445 \u043a\u043e\u0434\u0430 \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0434\u043e 2018 \u0433\u043e\u0434\u0430) \u0432\u0440\u044f\u0434 \u043b\u0438 \u0434\u0430\u0434\u0443\u0442 \u0432\u0430\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0445 \u0432\u0441\u0435\u043c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c \u043a \u043a\u043e\u0434\u0443.<\/p>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 2 \u043c\u0438\u043d\u0443\u0442\u044b, \u043d\u043e \u0441 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u043f\u043e\u0440\u043e\u0433\u043e\u043c \u0432\u0445\u043e\u0434\u0430, \u043e\u0434\u043d\u0430\u043a\u043e, \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0432\u0430\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0434\u043b\u044f 5\u0442\u0438 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 <s>\u043e\u0442\u0431\u0438\u0442\u044b\u0445<\/s> \u044d\u043d\u0442\u0443\u0437\u0438\u0430\u0441\u0442\u043e\u0432. \u041f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0432\u0441\u0435\u043c. \u041f\u0440\u043e\u0448\u0443 \u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0437\u0430 \u043b\u043e\u043d\u0433\u0440\u0438\u0434 \u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 <strong>Python<\/strong> \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u043b\u043e\u0436\u043d\u043e\u043c\u0443. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438 \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0435 \u0441\u0442\u0440\u0430\u0434\u0430\u043b\u0438 \u043e\u0442 \u0431\u043b\u0438\u0437\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 \u043d\u0438\u043c. \u0423\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u043e\u0432\u0435\u0442\u044b (\u0445\u043e\u0442\u044f \u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u043b\u0438\u0434\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430).<\/p>\n<p>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0439 <strong>Python3.7-3.11<\/strong> (\u0438 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e <strong>3.12<\/strong>), \u043e\u0434\u043d\u0430\u043a\u043e, \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441 \u0432\u044b\u0445\u043e\u0434\u043e\u043c \u043d\u043e\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0432 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u043b\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0418 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0437\u0430\u0431\u043b\u0443\u0434\u0438\u0442\u044c\u0441\u044f:<\/p>\n<ul>\n<li>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0428\u0440\u0435\u0434\u0438\u043d\u0433\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p>\u0410\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 <\/p>\n<ul>\n<li>\n<p>typing.Callable<\/p>\n<\/li>\n<li>\n<p>typing.TypeVar<\/p>\n<\/li>\n<li>\n<p>typing.ParamSpec<\/p>\n<\/li>\n<li>\n<p>\u0410\u043d\u043d\u043e\u0442\u0438\u0440\u0443\u0435\u043c \u0428\u0440\u0435\u0434\u0438\u043d\u0433\u0435\u0440\u0430<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Class-based \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 <\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u043e\u0432\u0435\u0442<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0442\u043e \u0442\u0430\u043a\u0438\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b<\/h3>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0435\u0435 \u043a\u043e\u0434. \u041e\u043d\u0438 \u0447\u0430\u0441\u0442\u043e \u043b\u0435\u0436\u0430\u0442 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u043d\u043e\u0433\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u0432\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0441 \u043d\u0438\u043c\u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u044b, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0438\u0441\u0430\u043b\u0438 (\u043f\u0440\u0438\u0432\u0435\u0442 <em>FastAPI<\/em>, <em>Flask<\/em> \u0438 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u0445).<\/p>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0432\u0430\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043e\/\u043f\u043e\u0441\u043b\u0435\/\u0432\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044f \u0435\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0430\u0439\u0434-\u044d\u0444\u0444\u0435\u043a\u0442\u044b.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>\u0440\u0435\u0442\u0440\u0430\u0438 &#8212; <a href=\"https:\/\/tenacity.readthedocs.io\/en\/latest\/\" rel=\"noopener noreferrer nofollow\">tenacity<\/a><\/p>\n<\/li>\n<li>\n<p>\u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a &#8212; <a href=\"https:\/\/loguru.readthedocs.io\/en\/stable\/overview.html\" rel=\"noopener noreferrer nofollow\">loguru<\/a><\/p>\n<\/li>\n<li>\n<p>\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; <a href=\"https:\/\/github.com\/Lancetnik\/FastDepends\" rel=\"noopener noreferrer nofollow\">FastDepends<\/a><\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 &#8212; \u043b\u044e\u0431\u043e\u0439 <strong>HTTP<\/strong> (\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e) \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u044e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c\u0438 \u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u0434\u0430\u043b\u0431\u043b\u0438\u0432\u0430\u044e \u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435:<\/p>\n<blockquote>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 &#8212; \u044d\u0442\u043e <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/strong>, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0430\u044f \u043d\u0430 \u0432\u0445\u043e\u0434 <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/strong>, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f (\u0434\u0440\u0443\u0433\u0443\u044e) <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/strong><\/p>\n<\/blockquote>\n<p>P.S. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438 \u043d\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0430 \u043b\u044e\u0431\u043e\u0439 <em>Callable<\/em> \u043e\u0431\u044a\u0435\u043a\u0442, \u0434\u0430 \u0438 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e. \u041d\u043e \u043e\u0431\u043e \u0432\u0441\u0435\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<h3>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440<\/h3>\n<p>\u0418\u0442\u0430\u043a, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0430\u043c\u044b\u0439-\u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">def decorator(     # \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f     call           # \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u044e ):     def wrapper(*args, **kwargs):         # \u043a\u043e\u0434 \u0434\u043e \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438         r = call(*args, **kwargs)         # \u043a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438         return r     return wrapper # \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 <s>\u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e<\/s> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043b\u044e\u0431\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0438\u0445 \u0432 \u0437\u0430\u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430:<\/p>\n<pre><code class=\"python\">def call(a: int) -> str:     return str(a)  decorated_call = decorator(call)  # \u0432\u044b\u0437\u043e\u0432 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 assert decorated_call(1) == \"1\" <\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0432 <strong>Python<\/strong> \u0435\u0441\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0430\u0445\u0430\u0440\u0430 \u0438 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439. \u042f \u0434\u0443\u043c\u0430\u044e, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0432\u0430\u043c \u0437\u043d\u0430\u043a\u043e\u043c:<\/p>\n<pre><code class=\"python\">@decorator def call(a: int) -> str:     return str(a) <\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043a \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u044e\u0430\u043d\u0441\u044b, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u043e\u0438\u0442 \u0437\u043d\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0432\u0430\u0448\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>call<\/code> \u0437\u0430\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>wrapper<\/code>, \u0438 \u0432\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a <code>call<\/code> \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0432 \u0432\u0430\u0448 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 &#8212; \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0438\u0435\u043c\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043e\u0432\u0435\u0442: \u0432\u043e\u0437\u044c\u043c\u0438\u0442\u0435 \u0432 \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0443 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u0448 wrapper \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>functools.wraps<\/code>. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u044e \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0443\u044e \u043c\u0435\u0442\u0430\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 (\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0434\u043e\u043a\u0441\u0442\u0440\u0438\u043d\u0433\u0438, \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0438\u0445 \u0442\u0438\u043f\u044b \u0438 \u0442\u0434).<\/p>\n<p>\u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0430\u0448\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0447\u0435\u0440\u0435\u0437 \u043c\u043e\u0434\u0443\u043b\u044c <code>inspect<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e (\u0442\u043e\u0442 \u0436\u0435 <strong>FastAPI<\/strong> \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e).<\/p>\n<p>\u0412\u0441\u0435\u0433\u043e \u043f\u0430\u0440\u0430 &#171;\u043b\u0438\u0448\u043d\u0438\u0445&#187; \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430, \u043d\u0435 \u043b\u0435\u043d\u0438\u0442\u0435\u0441\u044c:<\/p>\n<pre><code class=\"python\">from functools import wraps  def decorator(func):     @wraps(func)     def wrapper(*args, **kwargs):         return func(*args, **kwargs)     return wrapper <\/code><\/pre>\n<h3>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0442\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0441 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c (\u0445\u043e\u0442\u044f \u0431\u044b \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435):<\/p>\n<pre><code class=\"python\">@some_decorator(arg1, arg2) def func():     ... <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u043f\u0430\u0442\u043a\u0430 \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0433\u043d\u0430\u0442\u044c \u0432 \u0441\u0442\u0443\u043f\u043e\u0440: \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0436\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0430 \u0442\u0443\u0442 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b?<\/p>\n<p>\u0412\u0441\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0437\u0430\u0438\u0447\u043d\u043e: <code>some_decorator<\/code> \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u0430 <em>\u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440<\/em>.<\/p>\n<p>\u0422.\u0435. \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u0431\u0435\u0437 \u0441\u0430\u0445\u0430\u0440\u0430) \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443:<\/p>\n<pre><code class=\"python\"># \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 decorated_func = decorator(call)  # \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 decorator_wrapper = decorator(arg1, arg2) decorated_func = decorator_wrapper(call)  # \u0438\u043b\u0438 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 decorated_func = decorator(arg1, arg2)(call) <\/code><\/pre>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u0443\u0436\u0435 \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c, \u043a\u0430\u043a \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u043d\u043e \u044f \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"python\">def decorator_wrapper(arg1, arg2):     def real_decorator(func): # \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440         @wraps(func)         def wrapper(*args, **kwargs):             return func(*args, **kwargs)         return wrapper      return real_decorator     # \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440   @decorator_wrapper(1, 2) def func():     ... <\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Closure_(computer_programming)\" rel=\"noopener noreferrer nofollow\">\u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435<\/a>, \u0442\u043e \u0432\u044b \u0438\u043c\u0435\u0435\u0442\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043a <code>arg1<\/code> \u0438 <code>arg2<\/code> \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0415\u0449\u0435 \u043e\u0434\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u0435: \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u043e\u043c <strong>Python<\/strong> \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 (\u043a\u043e\u0433\u0434\u0430 <strong>Python<\/strong> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435).<\/p>\n<p>\u0422.\u0435. \u0432 \u0441\u0430\u043c\u043e\u043c \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 (\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438) \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 <code>wrapper<\/code>&#8216;\u0430.<\/p>\n<p>\u0421\u0430\u043c \u0436\u0435 \u043a\u043e\u0434 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0434\u043e\u0439\u0434\u0435\u0442 \u0434\u043e \u0441\u0442\u0440\u043e\u043a\u0438 <code>@decorator<\/code>. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u043a\u0430\u043a \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d <code>wrapper<\/code>).<\/p>\n<h3>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0428\u0440\u0435\u0434\u0438\u043d\u0433\u0435\u0440\u0430<\/h3>\n<p>\u0422\u0430\u043a, \u0437\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u0441\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0443\u0436\u0435 \u043c\u0430\u0442\u0435\u0440\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438 \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u044e\u0437\u043a\u0435\u0439\u0441\u044b \u043f\u043e-\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435.<\/p>\n<p>\u0412\u044b, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0428\u0440\u0435\u0434\u0438\u043d\u0433\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0442\u0430\u043a, \u0438 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">@pytest.fixture def simple_fixture(): ...  @pytest.fixture(scope=\"session\") def session_fixture(): ...  @dataclass class SimpleDataclass: ...  @dataclass(slots=True) class SimpleDataclass: ... <\/code><\/pre>\n<p>\u0412\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c?<\/p>\n<p>\u042f \u0432\u043e\u0442 \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0441\u044f. \u0410 \u043f\u043e\u0442\u043e\u043c \u043a\u0430\u043a \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0441\u044f! &#8212; \u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043f\u0430\u043b \u0432 \u0441\u0442\u0443\u043f\u043e\u0440.<br \/> \u0412\u0435\u0434\u044c \u044d\u0442\u043e \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f (\u0442\u043e\u0447\u043d\u043e \u043e\u0434\u043d\u0430, \u0432 \u043f\u0438\u0442\u043e\u043d\u0435 \u0436\u0435 \u043d\u0435\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a, <a href=\"https:\/\/docs.python.org\/3\/library\/functools.html#functools.singledispatch\" rel=\"noopener noreferrer nofollow\"><s>\u0438\u043b\u0438 \u0435\u0441\u0442\u044c<\/s><\/a>), \u0445\u043e\u0442\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u043d\u0430 \u0434\u0432\u0443\u043c\u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 \u043e\u0434\u0438\u043d \u0442\u043e\u0436\u0435 \u043a\u0430\u043a-\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 2 \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c &#8212; 3. \u0412 \u043e\u0431\u0449\u0435\u043c, \u0437\u0430\u0433\u0430\u0434\u043a\u0430.<\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438 \u0437\u0434\u0435\u0441\u044c \u0442\u043e\u0436\u0435 \u043d\u0435\u0442. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 (\u0430 \u0442\u043e 3\u0435\u0445 \u043d\u0430\u043c &#171;\u043c\u0430\u043b\u043e&#187;).<\/p>\n<blockquote>\n<p>\u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 \u0432\u0430\u0448 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 &#8212; \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/p>\n<\/blockquote>\n<p>\u041f\u043e\u043c\u043d\u0438\u0442\u0435 \u0442\u0430\u043a\u043e\u0435? \u042d\u0442\u043e \u043d\u0430\u0448 \u043a\u043b\u044e\u0447 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0433\u0430\u0434\u043a\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0428\u0440\u0435\u0434\u0438\u043d\u0433\u0435\u0440\u0430.<\/p>\n<p>\u0421\u043e\u0432\u043c\u0435\u0449\u0430\u0435\u043c <strong>\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440<\/strong> \u0438 <strong>\u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438<\/strong> \u0432\u043c\u0435\u0441\u0442\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u0442\u0430\u043a\u043e\u0435:<\/p>\n<pre><code class=\"python\">def schrodinger_decorator(     call = None,     *,     arg1 = None,     arg2 = None, ): ... <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c <em>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/em> \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <code>call<\/code>, \u0432 \u0434\u0440\u0443\u0433\u043e\u043c &#8212; \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0438\u0448\u0435\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0435\u0449\u0435 \u0440\u0430\u0437:<\/p>\n<pre><code class=\"python\">def decorator_wrapper(arg1, arg2):     def real_decorator(func):         @wraps(func)         def wrapper(*args, **kwargs):             return func(*args, **kwargs)         return wrapper     return real_decorator <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0434\u0432\u0430 \u043d\u0430\u0448\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 <code>if call is None<\/code>.<\/p>\n<pre><code class=\"python\">def schrodinger_decorator(     call = None,     *,     arg1 = None,     arg2 = None, ):     wrap_decorator = decorator_wrapper(arg1, arg2)      # \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440     # \u043a\u0430\u043a \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438     if call is None:         return wrap_decorator          # \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439     ## arg1 \u0438 arg2 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442     ## \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e     else:         return wrap_decorator(Call) <\/code><\/pre>\n<p>\u0418 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"python\"># call=func, arg1=None, arg2=None @schrodinger_decorator def func(): ...  # call=None, arg1=1, arg2=2 @schrodinger_decorator(arg1=1, arg2=2) def func(): ... <\/code><\/pre>\n<h3>\u0410\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432<\/h3>\n<p>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <strong>Python<\/strong> \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0431\u0435\u0437 <a href=\"https:\/\/peps.python.org\/pep-0484\/\" rel=\"noopener noreferrer nofollow\">\u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432<\/a>. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 &#8212; \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0442\u0438\u043f\u0430\u0445 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0438 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0434\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043b\u044e\u0448\u0435\u043a, \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u044e\u0449\u0438\u0445 <a href=\"https:\/\/www.getclockwise.com\/blog\/what-is-developer-experience\" rel=\"noopener noreferrer nofollow\"><em>Developer Experience<\/em><\/a>.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0431\u0430\u043b\u0443\u044f\u0441\u044c \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438, \u044d\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u0441\u043b\u043e\u043c\u0430\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0435\u043b\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u043d\u043e\u0433\u0438.<\/p>\n<p>\u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0431\u0440\u0430\u0442\u044c\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.python.org\/3\/library\/typing.html#typing.Callable\" rel=\"noopener noreferrer nofollow\"><code>typing.Callable<\/code><\/a> &#8212; \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u043b\u044e\u0431\u043e\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 <strong>Python<\/strong> (\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435)<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.python.org\/3\/library\/typing.html#typing.TypeVar\" rel=\"noopener noreferrer nofollow\"><code>typing.TypeVar<\/code><\/a> &#8212; \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0442\u0438\u043f\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.python.org\/3\/library\/typing.html#typing.ParamSpec\" rel=\"noopener noreferrer nofollow\"><code>typing.ParamSpec<\/code><\/a> (\u0434\u043e <strong>py3.10<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437 <code>typing_extensions<\/code>) &#8212; \u043e\u0431\u0449\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u044f\u0436\u0435\u043b\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0431\u0435\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430 \u043d\u0438\u0445 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c.<\/p>\n<h4>typing.Callable<\/h4>\n<p><code>Callable<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f &#171;\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445&#187; \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0444\u0443\u043d\u043a\u0446\u0438\u0439). \u042d\u0442\u043e generic \u043e\u0431\u044a\u0435\u043a\u0442, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c 2 \u0442\u0438\u043f\u0430:<\/p>\n<ul>\n<li>\n<p>\u0442\u0438\u043f \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>\u0442\u0438\u043f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0430\u0440\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432:<\/p>\n<pre><code class=\"python\"># \u043b\u044e\u0431\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043b\u044e\u0431\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 Callable[..., Any]  # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0438\u0434\u0430 `func(a: int, b: float)` Callable[[int, float], Any]  # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0438\u0434\u0430 `func(a: int, b: float) -> int` Callable[[int, float], int] <\/code><\/pre>\n<h4>typing.TypeVar<\/h4>\n<pre><code class=\"python\">T = TypeVar(\"T\")  def func(a: T) -> T:     ... <\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>a<\/code> \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043d\u043e \u0435\u0435 \u043e\u0442\u0432\u0435\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0442\u043e\u0433\u043e \u0436\u0435 \u0442\u0438\u043f\u0430, \u0447\u0442\u043e <code>a<\/code>:<\/p>\n<p><code>int -> int, str -> str, float -> float<\/code>, e.t.c<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0442\u0438\u043f\u044b \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438.<\/p>\n<h4>typing.ParamSpec<\/h4>\n<p><code>ParamSpec<\/code> \u0431\u044b\u043b \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d \u0434\u043b\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code class=\"python\">F_Spec = ParamSpec(\"F_Spec\") F_Return = TypeVar(\"F_Return\")  def decorator(     call: Callable[         F_Spec,  # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u043c\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438         F_Return     ] ) -> Callable[     F_Spec,      # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441 \u0442\u0435\u043c\u0438 \u0436\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438     F_Return ]:     @wraps(func)     def wrapper(         *args: F_Spec.args,      # \u044d\u0442\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b         **kwargs: F_Spec.kwargs  # \u044d\u0442\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b     ) -> F_Return:         return call(*args, **kwargs):     return wrapper <\/code><\/pre>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0441 \u0432\u044b\u0445\u043e\u0434\u0430 <strong>py3.10<\/strong><\/p>\n<p>\u0418 \u0437\u0430\u043a\u0440\u0435\u043f\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<\/p>\n<pre><code class=\"python\">def decorator_wrapper(     arg1: Any,     arg2: Any ) -> Callable[  # \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439     # \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u044e     [Callable[F_Spec, F_Return]],     # \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e     Callable[F_Spec, F_Return] ]: ... <\/code><\/pre>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u0443\u044f \u0442\u0438\u043f\u043e\u043c, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u043a\u043e\u043c\u043f\u043b\u0438\u0442\u044b \u0437\u0430\u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u0438 (\u043d\u043e \u0441 \u044d\u0442\u0438\u043c \u0432\u044b \u043f\u043e\u0438\u0433\u0440\u0430\u0435\u0442\u0435\u0441\u044c \u0441\u0430\u043c\u0438).<\/p>\n<h4>\u0410\u043d\u043d\u043e\u0442\u0438\u0440\u0443\u0435\u043c \u0428\u0440\u0435\u0434\u0438\u043d\u0433\u0435\u0440\u0430<\/h4>\n<p>\u0410 \u043a\u0430\u043a \u043d\u0430\u043c \u0431\u044b\u0442\u044c \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0428\u0440\u0435\u0434\u0438\u043d\u0433\u0435\u0440\u0430? \u041e\u043d \u0442\u043e \u0443\u0436 \u0442\u043e\u0447\u043d\u043e \u043b\u043e\u043c\u0430\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c.<\/p>\n<p>\u0422.\u0435. \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043e\u043d \u0438\u043c\u0435\u0435\u0442 2 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\"># \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 def schrodinger_decorator(     call: Callable[F_Spec, F_Return],     *,     arg1: None = None,     arg2: None = None, ) -> Callable[F_Spec, F_Return]: ...  # \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 def schrodinger_decorator(     call: None = None,     *,     arg1: Any = None,     arg2: Any = None, ) -> Callable[     [Callable[F_Spec, F_Return]],     Callable[F_Spec, F_Return] ]: ... <\/code><\/pre>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c <a href=\"https:\/\/docs.python.org\/3\/library\/typing.html#typing.overload\" rel=\"noopener noreferrer nofollow\"><code>typing.overload<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u043d \u043a\u0430\u043a \u0440\u0430\u0437 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e: \u0434\u0430\u043d\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0438 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0432 \u043e\u0434\u0438\u043d \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439:<\/p>\n<pre><code class=\"python\"># \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 @overload def schrodinger_decorator(     call: Callable[F_Spec, F_Return],     *,     arg1: None = None,     arg2: None = None, ) -> Callable[F_Spec, F_Return]:     # \u0442\u0435\u043b\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c     # \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438     ...  # \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 @overload def schrodinger_decorator(     call: None = None,     *,     arg1: Any = None,     arg2: Any = None, ) -> Callable[     [Callable[F_Spec, F_Return]],     Callable[F_Spec, F_Return] ]: ...   # \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u043e\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 def schrodinger_decorator(     call: Callable[F_Spec, F_Return] | None = None,     *,     arg1: Any | None = None,     arg2: Any | None = None, ) -> Callable[     [Callable[F_Spec, F_Return]],     Callable[F_Spec, F_Return] ] | Callable[     F_Spec,     F_Return ]:     wrap_decorator = decorator_wrapper(arg1, arg2)     if call is None:         return wrap_decorator     else:         return wrap_decorator(Call) <\/code><\/pre>\n<h3>Class-based \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b<\/h3>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0441\u0435 \u0443\u0436\u0435 \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0435\u043c, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">decorated_func = decorator(func) result = decorated_func(*args, **kwargs) <\/code><\/pre>\n<p>\u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0442\u0430\u043a\u043e\u0435?<\/p>\n<pre><code class=\"python\">decorated_func = DecoratorClass(func) result = decorated_func(*args, **kwargs) <\/code><\/pre>\n<p>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c!<\/p>\n<pre><code class=\"python\">class DecoratorClass:     def __init__(self, func):         # \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438         self.original_call = func          def __call__(self, *args, **kwargs):         # \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435         return self.original_call(*args, **kwargs) <\/code><\/pre>\n<p>\u0410 \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0430\u043c \u0434\u0430\u0435\u0442? \u041d\u0443, \u0430 \u0432\u043e\u0442 \u044d\u0442\u043e \u0443\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435.<\/p>\n<h3>\u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435<\/h3>\n<h4>\u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443<\/h4>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0435 \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u043e\u0439, \u0430 \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0433\u0434\u0435-\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438.<\/p>\n<pre><code class=\"python\"># \u043b\u044e\u0431\u043e\u0439 HTTP \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a @app.get(\"\/\") def handler(...): ... <\/code><\/pre>\n<p>\u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437?<\/p>\n<pre><code class=\"python\">@app.get(\"\/\") @app.get(\"\/index\") def handler(...): ... <\/code><\/pre>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"python\"># \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 FastAPI class FastAPI:     def get(route: str):  # \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c         def decorator(func):             self.routes.append(APIRoute(func))             return func   # \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043d\u0435 \u0432\u0435\u0448\u0430\u0439, \u043e\u043d\u0438 \u0432\u0441\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e.<\/p>\n<p>\u041d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u044b\u043b\u0430 \u0437\u0430\u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0434\u043e \u043d\u0430\u0441? \u0410 \u043a\u0435\u043c \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0437\u0430\u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430? \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b? \u0410 \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u0446\u0438\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437?<\/p>\n<h4>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h4>\n<p>\u0423\u0436\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u043e. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u0438 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <em>class-based<\/em> \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440. \u041c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u0449\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u043e\u043c, \u0430 \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u043f\u0440\u0438\u0448\u043b\u0430 \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043b\u0438 \u0443\u0436\u0435 \u043a\u043b\u0430\u0441\u0441-\u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440. \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<pre><code class=\"python\">class FuncWrapper:     wrapped_call: Callable      def __init__(self, call):         if not isinstance(call, FuncWrapper):             self.wrapped_call = call         else:             # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u0436\u0435 \u0437\u0430\u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430             # \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439      def __call__(self, *args, **kwargs):         return self.wrapped_call(*args, **kwargs)   @FuncWrapper @FuncWrapper def func(a: int) -> str:     ... <\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0435\u0449\u0435 \u0438 \u043d\u0435 \u0441\u043b\u043e\u043c\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u0430\u043a \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c. \u0422\u0443\u0442 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"https:\/\/docs.python.org\/3\/library\/typing.html#typing.Generic\" rel=\"noopener noreferrer nofollow\"><code>typing.Generic<\/code><\/a>: \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043a\u0430\u043a generic \u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438.<\/p>\n<pre><code class=\"python\">from typing import Generic, Callable, ParamSpec, TypeVar  F_Spec = ParamSpec(\"F_Spec\") F_Return = TypeVar(\"F_Return\")  class FuncWrapper(Generic[F_Spec, F_Return]):     wrapped_call: Callable[F_Spec, F_Return]      def __init__(         self,         call: Callable[F_Spec, F_Return]     ) -> None:         if not isinstance(call, FuncWrapper):             self.wrapped_call = call      def __call__(         self,         *args: F_Spec.args,         **kwargs: F_Spec.kwargs,     ) -> F_Return:         return self.wrapped_call(*args, **kwargs)  @FuncWrapper def func(a: int) -> str:     ... <\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 <strong>IDE<\/strong> \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443: \u0433\u0434\u0435-\u0442\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u044f\u0442\u0441\u044f, \u0433\u0434\u0435-\u0442\u043e \u043d\u0435\u0442.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0440\u044e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u0435\u0437\u0434\u0435: \u043f\u0438\u0448\u0435\u043c &#171;\u043b\u0438\u0448\u043d\u044e\u044e&#187; \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u041a\u0441\u0442\u0430\u0442\u0438, \u044d\u0442\u043e \u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438.<\/p>\n<pre><code class=\"python\">def decorator(     call: Callable[F_Spec, F_Return] ) -> FuncWrapper[F_Spec, F_Return]:     return FuncWrapper(call)  @decorator def func(a: int) -> str:     ... <\/code><\/pre>\n<p>\u041d\u0443 \u0430 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u0442\u043e \u0438 \u043a\u0430\u043a \u0443\u0436\u0435 \u0437\u0430\u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<pre><code class=\"python\">class FuncWrapper:     wrapped_call: Callable     decorators: list[object]      def __init__(self, call):         if not isinstance(call, FuncWrapper):             self.wrapped_call = call             self.decorators = []         else:             self.wrapped_call = call.wrapped_call             self.decorators = call.decorators         self.decorators.append(self) <\/code><\/pre>\n<h4>\u0414\u0435\u043b\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435<\/h4>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u0442\u043e \u0438 \u043a\u0430\u043a \u0443\u0436\u0435 \u0437\u0430\u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c. \u041d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b <strong>\u0432\u044b\u0448\u0435 \u043d\u0430\u0441<\/strong> \u0437\u043d\u0430\u044e\u0442, \u043a\u0442\u043e \u0442\u0430\u043c \u0431\u044b\u043b \u0434\u043e \u043d\u0435\u0433\u043e. \u0410 \u0432\u043e\u0442 \u0442\u0435, \u043a\u0442\u043e <strong>\u043d\u0438\u0436\u0435<\/strong> \u043d\u0435 \u0437\u043d\u0430\u044e\u0442 \u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u0445 \u0441\u0432\u0435\u0440\u0445\u0443. \u041d\u0435\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u0430\u043a\u043e\u0439-\u0442\u043e, \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0435?<\/p>\n<pre><code class=\"python\">@FuncWrapper  # \u0437\u043d\u0430\u0435\u0442 \u043e \u0441\u043e\u0441\u0435\u0434\u0435 \u0441\u043d\u0438\u0437\u0443 @FuncWrapper  # \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 def func(a: int) -> str:     ... <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c, \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u043d\u0435\u0442, \u043d\u043e \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u043c\u0435\u0435\u0442\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 (\u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u043c\u043e\u044f \u043d\u043e\u0433\u0430 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0431\u043e\u043b\u0438\u0442).<\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430: \u0432 \u043d\u043e\u0432\u043e\u0439 \u043c\u0430\u0436\u043e\u0440\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043c\u043e\u0435\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0440\u043e\u043a\u0435\u0440\u0430\u043c\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 <a href=\"https:\/\/github.com\/Lancetnik\/Propan\" rel=\"noopener noreferrer nofollow\"><strong>Propan<\/strong><\/a> \u0432\u044b c\u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">@broker.subscriber(\"in-topic\")  # \u043e\u0442\u0441\u044e\u0434\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f @broker.publisher(\"out-topic\")  # \u0441\u044e\u0434\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0442\u0432\u0435\u0442 async def handler(msg):     return \"processed\" <\/code><\/pre>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0435\u043d\u043d\u043e, \u043d\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e <code>publisher<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d <em>\u0434\u043e<\/em> <code>subscriber<\/code> (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 publisher&#8217;\u0430\u0445). \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0441\u0445\u0438\u0442\u0440\u044f\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f: \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0443\u0436\u0435 \u0437\u0430\u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043c\u044b <em>\u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430<\/em> \u0432 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0430 <em>\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442<\/em>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u043e \u0432\u0441\u0435\u0445 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u0445 \u043c\u044b \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c, \u0438 \u043f\u043e\u043b\u044f, \u0434\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 (\u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0438\u0437\u0432\u043d\u0435), \u0431\u0443\u0434\u0443\u0442 \u0432\u0438\u0434\u043d\u044b \u043d\u0430 \u0432\u0441\u0435\u0439 \u0433\u043b\u0443\u0431\u0438\u043d\u0435 &#171;\u043c\u0430\u0442\u0440\u0435\u0448\u043a\u0438&#187;.<\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>__new__<\/code>.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>__new__<\/code> &#8212; \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 <strong>Python<\/strong>. \u0418\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u043e\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u0442\u0435\u043c \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>__init__<\/code>. \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u0438 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445, \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0435\u043d\u044c.<\/p>\n<pre><code class=\"python\">class FuncWrapper(Generic[F_Spec, F_Return]):     wrapped_call: Callable[F_Spec, F_Return]     decorators: list[object]      def __new__(cls, call: Callable[F_Spec, F_Return]) -> Self:         if isinstance(call, FuncWrapper):             # \u0435\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u0436\u0435 \u0437\u0430\u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430,             # \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0442\u043e\u0442 \u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442             return call         # \u0438\u043d\u0430\u0447\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442         return super().__new__(cls)      def __init__(self, call: Callable[F_Spec, F_Return]) -> None:         # \u043c\u0435\u0442\u043e\u0434 __init__ \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u0432 \u043e\u0431\u043e\u0438\u0445 \u0432\u0435\u0442\u043a\u0430\u0445 __new__         if not isinstance(call, FuncWrapper):             self.wrapped_call = call             self.decorators = []         self.decorators.append(self)   # \u0432\u0441\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u044e\u0442 @FuncWrapper @FuncWrapper def func(a: int) -> str:     ... <\/code><\/pre>\n<h4>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u043e\u0432\u0435\u0442<\/h4>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>asyncio.iscoroutinefunction<\/code> (\u0442\u043e\u0442 \u0436\u0435 <strong>FastAPI<\/strong> \u0438\u043b\u0438 \u043c\u043e\u0439 <a href=\"https:\/\/github.com\/Lancetnik\/FastDepends\" rel=\"noopener noreferrer nofollow\"><strong>FastDepends<\/strong><\/a>).<\/p>\n<pre><code class=\"python\"># \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 asyncio def iscoroutinefunction(func):     \"\"\"Return True if func is a decorated coroutine function.\"\"\"     return (inspect.iscoroutinefunction(func) or             getattr(func, '_is_coroutine', None) is _is_coroutine) <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 <code>_is_coroutine<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0441\u0442\u044b\u043b\u0435\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u0435\u043a\u0442 <code>AsyncMock<\/code> \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043b\u0441\u044f \u043a\u0430\u043a \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434, \u0430 \u043d\u0435 <code>inspect.iscoroutinefunction<\/code> (\u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u0442\u0430\u043a\u0430\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c). \u0414\u0430, \u044d\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e <a href=\"https:\/\/github.com\/python\/cpython\/issues\/94912\" rel=\"noopener noreferrer nofollow\">\u0441\u0431\u0438\u0432\u0430\u0435\u0442 \u0441 \u0442\u043e\u043b\u043a\u0443<\/a>.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441-\u0434\u0435\u043a\u043e\u0440\u0442\u0430\u0442\u043e\u0440 \u0438\u043c\u0435\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <code>__call__<\/code>:<\/p>\n<pre><code class=\"python\">class FuncWrapper:     def __call__(self, *args, **kwargs):         return self.wrapped_call(*args, **kwargs) <\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0441\u0435 \u0435\u0449\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u0443\u0435\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Awaitable \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u043c <code>asyncio<\/code> \u043a\u0430\u043a \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0442\u0430\u043a\u0438\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c, \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0432\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u043b\u0435 <code>_is_coroutine<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 <code>asyncio<\/code> \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 &#8212; \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440.<\/p>\n<pre><code class=\"python\">from asyncio.coroutines import iscoroutinefunction, _is_coroutine  class FuncWrapper(Generic[F_Spec, F_Return]):     wrapped_call: Callable[F_Spec, F_Return]     _is_coroutine: None      def __init__(self, call: Callable[F_Spec, F_Return]) -> None:         if not isinstance(call, FuncWrapper):             if iscoroutinefunction(call):                 self._is_coroutine = _is_coroutine             self.wrapped_call = call  @FuncWrapper async def func()     ...  assert iscoroutinefunction(func) is True <\/code><\/pre>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 <strong>Python3.12<\/strong> \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u043e\u043b\u044f <code>_is_coroutine<\/code> \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>_is_coroutine_marker<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043c\u043e\u0434\u0443\u043b\u044e <code>inspect<\/code> \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/github.com\/python\/cpython\/pull\/99247\" rel=\"noopener noreferrer nofollow\">\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430<\/a>.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u042f \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0432 99.9% \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0432\u0430\u043c \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441 <em>Class-based<\/em> \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0441 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c <strong><em>new<\/em><\/strong> \u0438 \u043f\u0440\u043e\u0447\u0435\u0439 \u0437\u0430\u043f\u0440\u0435\u0442\u043d\u043e\u0439 \u043c\u0430\u0433\u0438\u0435\u0439. \u041e\u0434\u043d\u0430\u043a\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0435\u043a\u043e\u0440\u043e\u0442\u0430\u0440\u043e\u0432: \u043e\u0442 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445, \u0441 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u0434\u043e\/\u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0434\u043e \u0441\u0430\u043c\u044b\u0445 \u0441\u043b\u043e\u0436\u043d\u044b\u0445, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431\u043e \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u0445.<\/p>\n<p>\u0418 \u044d\u0442\u0438 \u0437\u043d\u0430\u043d\u0438\u044f \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043b\u0435\u0433\u043a\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435.<\/p>\n<p>\u0410 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0438\u0448\u0435\u043d\u043a\u0438 \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0441 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c <strong>Python<\/strong>. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0431\u044b\u043b \u0434\u043b\u044f \u0432\u0430\u0441 \u043f\u043e\u043b\u0435\u0437\u0435\u043d.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/750312\/\"> https:\/\/habr.com\/ru\/articles\/750312\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0414\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 &#8212; \u044d\u0442\u043e, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0441\u0430\u043c\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0441\u0440\u0435\u0434\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0438 \u0441\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u0444\u0438\u0447 \u044f\u0437\u044b\u043a\u0430 <strong>Python<\/strong>. \u0421 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0432\u0441\u0435 \u0434\u0436\u0443\u043d\u044b (\u0445\u043e\u0442\u044f \u0431\u044b \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043a \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u043c). \u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u0440\u0430\u0439\u043d\u0435 \u043c\u0430\u043b\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043f\u0438\u0448\u0443\u0442 \u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f \u0432\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0442\u0435\u043d\u0434\u0435\u043d\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043b\u0435\u0442 \u043a \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0432\u0441\u0435\u0433\u043e \u0438 \u0432\u0441\u044f. \u0414\u0430\u0436\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 <em>open-source<\/em> \u043f\u0440\u043e\u0435\u043a\u0442\u044b (\u0435\u0441\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u0445 \u043a\u043e\u0434\u0430 \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0434\u043e 2018 \u0433\u043e\u0434\u0430) \u0432\u0440\u044f\u0434 \u043b\u0438 \u0434\u0430\u0434\u0443\u0442 \u0432\u0430\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0445 \u0432\u0441\u0435\u043c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c \u043a \u043a\u043e\u0434\u0443.<\/p>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 2 \u043c\u0438\u043d\u0443\u0442\u044b, \u043d\u043e \u0441 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u043f\u043e\u0440\u043e\u0433\u043e\u043c \u0432\u0445\u043e\u0434\u0430, \u043e\u0434\u043d\u0430\u043a\u043e, \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0432\u0430\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0434\u043b\u044f 5\u0442\u0438 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 <s>\u043e\u0442\u0431\u0438\u0442\u044b\u0445<\/s> \u044d\u043d\u0442\u0443\u0437\u0438\u0430\u0441\u0442\u043e\u0432. \u041f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0432\u0441\u0435\u043c. \u041f\u0440\u043e\u0448\u0443 \u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0437\u0430 \u043b\u043e\u043d\u0433\u0440\u0438\u0434 \u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 <strong>Python<\/strong> \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u043b\u043e\u0436\u043d\u043e\u043c\u0443. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438 \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0435 \u0441\u0442\u0440\u0430\u0434\u0430\u043b\u0438 \u043e\u0442 \u0431\u043b\u0438\u0437\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 \u043d\u0438\u043c. \u0423\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u043e\u0432\u0435\u0442\u044b (\u0445\u043e\u0442\u044f \u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u043b\u0438\u0434\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430).<\/p>\n<p>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0439 <strong>Python3.7-3.11<\/strong> (\u0438 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e <strong>3.12<\/strong>), \u043e\u0434\u043d\u0430\u043a\u043e, \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441 \u0432\u044b\u0445\u043e\u0434\u043e\u043c \u043d\u043e\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0432 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u043b\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0418 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0437\u0430\u0431\u043b\u0443\u0434\u0438\u0442\u044c\u0441\u044f:<\/p>\n<ul>\n<li>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0428\u0440\u0435\u0434\u0438\u043d\u0433\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p>\u0410\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 <\/p>\n<ul>\n<li>\n<p>typing.Callable<\/p>\n<\/li>\n<li>\n<p>typing.TypeVar<\/p>\n<\/li>\n<li>\n<p>typing.ParamSpec<\/p>\n<\/li>\n<li>\n<p>\u0410\u043d\u043d\u043e\u0442\u0438\u0440\u0443\u0435\u043c \u0428\u0440\u0435\u0434\u0438\u043d\u0433\u0435\u0440\u0430<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Class-based \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 <\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u043e\u0432\u0435\u0442<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0442\u043e \u0442\u0430\u043a\u0438\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b<\/h3>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0435\u0435 \u043a\u043e\u0434. \u041e\u043d\u0438 \u0447\u0430\u0441\u0442\u043e \u043b\u0435\u0436\u0430\u0442 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u043d\u043e\u0433\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u0432\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0441 \u043d\u0438\u043c\u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u044b, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0438\u0441\u0430\u043b\u0438 (\u043f\u0440\u0438\u0432\u0435\u0442 <em>FastAPI<\/em>, <em>Flask<\/em> \u0438 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u0445).<\/p>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0432\u0430\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043e\/\u043f\u043e\u0441\u043b\u0435\/\u0432\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044f \u0435\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0430\u0439\u0434-\u044d\u0444\u0444\u0435\u043a\u0442\u044b.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>\u0440\u0435\u0442\u0440\u0430\u0438 &#8212; <a href=\"https:\/\/tenacity.readthedocs.io\/en\/latest\/\" rel=\"noopener noreferrer nofollow\">tenacity<\/a><\/p>\n<\/li>\n<li>\n<p>\u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a &#8212; <a href=\"https:\/\/loguru.readthedocs.io\/en\/stable\/overview.html\" rel=\"noopener noreferrer nofollow\">loguru<\/a><\/p>\n<\/li>\n<li>\n<p>\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; <a href=\"https:\/\/github.com\/Lancetnik\/FastDepends\" rel=\"noopener noreferrer nofollow\">FastDepends<\/a><\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 &#8212; \u043b\u044e\u0431\u043e\u0439 <strong>HTTP<\/strong> (\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e) \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u044e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c\u0438 \u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u0434\u0430\u043b\u0431\u043b\u0438\u0432\u0430\u044e \u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435:<\/p>\n<blockquote>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 &#8212; \u044d\u0442\u043e <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/strong>, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0430\u044f \u043d\u0430 \u0432\u0445\u043e\u0434 <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/strong>, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f (\u0434\u0440\u0443\u0433\u0443\u044e) <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/strong><\/p>\n<\/blockquote>\n<p>P.S. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438 \u043d\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0430 \u043b\u044e\u0431\u043e\u0439 <em>Callable<\/em> \u043e\u0431\u044a\u0435\u043a\u0442, \u0434\u0430 \u0438 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e. \u041d\u043e \u043e\u0431\u043e \u0432\u0441\u0435\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<h3>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440<\/h3>\n<p>\u0418\u0442\u0430\u043a, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0430\u043c\u044b\u0439-\u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">def decorator(     # \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f     call           # \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u044e ):     def wrapper(*args, **kwargs):         # \u043a\u043e\u0434 \u0434\u043e \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438         r = call(*args, **kwargs)         # \u043a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438         return r     return wrapper # \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 <s>\u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e<\/s> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043b\u044e\u0431\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0438\u0445 \u0432 \u0437\u0430\u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430:<\/p>\n<pre><code class=\"python\">def call(a: int) -> str:     return str(a)  decorated_call = decorator(call)  # \u0432\u044b\u0437\u043e\u0432 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 assert decorated_call(1) == \"1\" <\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0432 <strong>Python<\/strong> \u0435\u0441\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0430\u0445\u0430\u0440\u0430 \u0438 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439. \u042f \u0434\u0443\u043c\u0430\u044e, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0432\u0430\u043c \u0437\u043d\u0430\u043a\u043e\u043c:<\/p>\n<pre><code class=\"python\">@decorator def call(a: int) -> str:     return str(a) <\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043a \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u044e\u0430\u043d\u0441\u044b, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u043e\u0438\u0442 \u0437\u043d\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0432\u0430\u0448\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>call<\/code> \u0437\u0430\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>wrapper<\/code>, \u0438 \u0432\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a <code>call<\/code> \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0432 \u0432\u0430\u0448 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 &#8212; \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0438\u0435\u043c\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043e\u0432\u0435\u0442: \u0432\u043e\u0437\u044c\u043c\u0438\u0442\u0435 \u0432 \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0443 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u0448 wrapper \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>functools.wraps<\/code>. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u044e \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0443\u044e \u043c\u0435\u0442\u0430\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 (\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0434\u043e\u043a\u0441\u0442\u0440\u0438\u043d\u0433\u0438, \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0438\u0445 \u0442\u0438\u043f\u044b \u0438 \u0442\u0434).<\/p>\n<p>\u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0430\u0448\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0447\u0435\u0440\u0435\u0437 \u043c\u043e\u0434\u0443\u043b\u044c <code>inspect<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e (\u0442\u043e\u0442 \u0436\u0435 <strong>FastAPI<\/strong> \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e).<\/p>\n<p>\u0412\u0441\u0435\u0433\u043e \u043f\u0430\u0440\u0430 &#171;\u043b\u0438\u0448\u043d\u0438\u0445&#187; \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430, \u043d\u0435 \u043b\u0435\u043d\u0438\u0442\u0435\u0441\u044c:<\/p>\n<pre><code class=\"python\">from functools import wraps  def decorator(func):     @wraps(func)     def wrapper(*args, **kwargs):         return func(*args, **kwargs)     return wrapper <\/code><\/pre>\n<h3>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0442\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0441 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c (\u0445\u043e\u0442\u044f \u0431\u044b \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435):<\/p>\n<pre><code class=\"python\">@some_decorator(arg1, arg2) def func():     ... <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u043f\u0430\u0442\u043a\u0430 \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0433\u043d\u0430\u0442\u044c \u0432 \u0441\u0442\u0443\u043f\u043e\u0440: \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0436\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0430 \u0442\u0443\u0442 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b?<\/p>\n<p>\u0412\u0441\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0437\u0430\u0438\u0447\u043d\u043e: <code>some_decorator<\/code> \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u0430 <em>\u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440<\/em>.<\/p>\n<p>\u0422.\u0435. \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u0431\u0435\u0437 \u0441\u0430\u0445\u0430\u0440\u0430) \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443:<\/p>\n<pre><code class=\"python\"># \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 decorated_func = decorator(call)  # \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 decorator_wrapper = decorator(arg1, arg2) decorated_func = decorator_wrapper(call)  # \u0438\u043b\u0438 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 decorated_func = decorator(arg1, arg2)(call) <\/code><\/pre>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u0443\u0436\u0435 \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c, \u043a\u0430\u043a \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u043d\u043e \u044f \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"python\">def decorator_wrapper(arg1, arg2):     def real_decorator(func): # \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440         @wraps(func)         def wrapper(*args, **kwargs):             return func(*args, **kwargs)         return wrapper      return real_decorator     # \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440   @decorator_wrapper(1, 2) def func():     ... <\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Closure_(computer_programming)\" rel=\"noopener noreferrer nofollow\">\u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435<\/a>, \u0442\u043e \u0432\u044b \u0438\u043c\u0435\u0435\u0442\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043a <code>arg1<\/code> \u0438 <code>arg2<\/code> \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0415\u0449\u0435 \u043e\u0434\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u0435: \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u043e\u043c <strong>Python<\/strong> \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 (\u043a\u043e\u0433\u0434\u0430 <strong>Python<\/strong> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435).<\/p>\n<p>\u0422.\u0435. \u0432 \u0441\u0430\u043c\u043e\u043c \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 (\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438) \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 <code>wrapper<\/code>&#8216;\u0430.<\/p>\n<p>\u0421\u0430\u043c \u0436\u0435 \u043a\u043e\u0434 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0434\u043e\u0439\u0434\u0435\u0442 \u0434\u043e \u0441\u0442\u0440\u043e\u043a\u0438 <code>@decorator<\/code>. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u043a\u0430\u043a \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d <code>wrapper<\/code>).<\/p>\n<h3>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0428\u0440\u0435\u0434\u0438\u043d\u0433\u0435\u0440\u0430<\/h3>\n<p>\u0422\u0430\u043a, \u0437\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u0441\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0443\u0436\u0435 \u043c\u0430\u0442\u0435\u0440\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438 \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u044e\u0437\u043a\u0435\u0439\u0441\u044b \u043f\u043e-\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435.<\/p>\n<p>\u0412\u044b, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0428\u0440\u0435\u0434\u0438\u043d\u0433\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0442\u0430\u043a, \u0438 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">@pytest.fixture def simple_fixture(): ...  @pytest.fixture(scope=\"session\") def session_fixture(): ...  @dataclass class SimpleDataclass: ...  @dataclass(slots=True) class SimpleDataclass: ... <\/code><\/pre>\n<p>\u0412\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c?<\/p>\n<p>\u042f \u0432\u043e\u0442 \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0441\u044f. \u0410 \u043f\u043e\u0442\u043e\u043c \u043a\u0430\u043a \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0441\u044f! &#8212; \u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043f\u0430\u043b \u0432 \u0441\u0442\u0443\u043f\u043e\u0440.<br \/> \u0412\u0435\u0434\u044c \u044d\u0442\u043e \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f (\u0442\u043e\u0447\u043d\u043e \u043e\u0434\u043d\u0430, \u0432 \u043f\u0438\u0442\u043e\u043d\u0435 \u0436\u0435 \u043d\u0435\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a, <a href=\"https:\/\/docs.python.org\/3\/library\/functools.html#functools.singledispatch\" rel=\"noopener noreferrer nofollow\"><s>\u0438\u043b\u0438 \u0435\u0441\u0442\u044c<\/s><\/a>), \u0445\u043e\u0442\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u043d\u0430 \u0434\u0432\u0443\u043c\u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 \u043e\u0434\u0438\u043d \u0442\u043e\u0436\u0435 \u043a\u0430\u043a-\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 2 \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c &#8212; 3. \u0412 \u043e\u0431\u0449\u0435\u043c, \u0437\u0430\u0433\u0430\u0434\u043a\u0430.<\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438 \u0437\u0434\u0435\u0441\u044c \u0442\u043e\u0436\u0435 \u043d\u0435\u0442. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 (\u0430 \u0442\u043e 3\u0435\u0445 \u043d\u0430\u043c &#171;\u043c\u0430\u043b\u043e&#187;).<\/p>\n<blockquote>\n<p>\u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 \u0432\u0430\u0448 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 &#8212; \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/p>\n<\/blockquote>\n<p>\u041f\u043e\u043c\u043d\u0438\u0442\u0435 \u0442\u0430\u043a\u043e\u0435? \u042d\u0442\u043e \u043d\u0430\u0448 \u043a\u043b\u044e\u0447 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0433\u0430\u0434\u043a\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0428\u0440\u0435\u0434\u0438\u043d\u0433\u0435\u0440\u0430.<\/p>\n<p>\u0421\u043e\u0432\u043c\u0435\u0449\u0430\u0435\u043c <strong>\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440<\/strong> \u0438 <strong>\u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438<\/strong> \u0432\u043c\u0435\u0441\u0442\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u0442\u0430\u043a\u043e\u0435:<\/p>\n<pre><code class=\"python\">def schrodinger_decorator(     call = None,     *,     arg1 = None,     arg2 = None, ): ... <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c <em>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/em> \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <code>call<\/code>, \u0432 \u0434\u0440\u0443\u0433\u043e\u043c &#8212; \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0438\u0448\u0435\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0435\u0449\u0435 \u0440\u0430\u0437:<\/p>\n<pre><code class=\"python\">def decorator_wrapper(arg1, arg2):     def real_decorator(func):         @wraps(func)         def wrapper(*args, **kwargs):             return func(*args, **kwargs)         return wrapper     return real_decorator <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0434\u0432\u0430 \u043d\u0430\u0448\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 <code>if call is None<\/code>.<\/p>\n<pre><code class=\"python\">def schrodinger_decorator(     call = None,     *,     arg1 = None,     arg2 = None, ):     wrap_decorator = decorator_wrapper(arg1, arg2)      # \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440     # \u043a\u0430\u043a \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438     if call is None:         return wrap_decorator          # \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439     ## arg1 \u0438 arg2 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442     ## \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e     else:         return wrap_decorator(Call) <\/code><\/pre>\n<p>\u0418 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"python\"># call=func, arg1=None, arg2=None @schrodinger_decorator def func(): ...  # call=None, arg1=1, arg2=2 @schrodinger_decorator(arg1=1, arg2=2) def func(): ... <\/code><\/pre>\n<h3>\u0410\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432<\/h3>\n<p>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <strong>Python<\/strong> \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0431\u0435\u0437 <a href=\"https:\/\/peps.python.org\/pep-0484\/\" rel=\"noopener noreferrer nofollow\">\u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432<\/a>. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0430\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 &#8212; \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0442\u0438\u043f\u0430\u0445 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0438 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0434\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043b\u044e\u0448\u0435\u043a, \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u044e\u0449\u0438\u0445 <a href=\"https:\/\/www.getclockwise.com\/blog\/what-is-developer-experience\" rel=\"noopener noreferrer nofollow\"><em>Developer Experience<\/em><\/a>.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0431\u0430\u043b\u0443\u044f\u0441\u044c \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438, \u044d\u0442\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u0441\u043b\u043e\u043c\u0430\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0435\u043b\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u043d\u043e\u0433\u0438.<\/p>\n<p>\u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0431\u0440\u0430\u0442\u044c\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.python.org\/3\/library\/typing.html#typing.Callable\" rel=\"noopener noreferrer nofollow\"><code>typing.Callable<\/code><\/a> &#8212; \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u043b\u044e\u0431\u043e\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 <strong>Python<\/strong> (\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435)<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.python.org\/3\/library\/typing.html#typing.TypeVar\" rel=\"noopener noreferrer nofollow\"><code>typing.TypeVar<\/code><\/a> &#8212; \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0442\u0438\u043f\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.python.org\/3\/library\/typing.html#typing.ParamSpec\" rel=\"noopener noreferrer nofollow\"><code>typing.ParamSpec<\/code><\/a> (\u0434\u043e <strong>py3.10<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437 <code>typing_extensions<\/code>) &#8212; \u043e\u0431\u0449\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u044f\u0436\u0435\u043b\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0431\u0435\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430 \u043d\u0438\u0445 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c.<\/p>\n<h4>typing.Callable<\/h4>\n<p><code>Callable<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f &#171;\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445&#187; \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0444\u0443\u043d\u043a\u0446\u0438\u0439). \u042d\u0442\u043e generic \u043e\u0431\u044a\u0435\u043a\u0442, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c 2 \u0442\u0438\u043f\u0430:<\/p>\n<ul>\n<li>\n<p>\u0442\u0438\u043f \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>\u0442\u0438\u043f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0430\u0440\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432:<\/p>\n<pre><code class=\"python\"># \u043b\u044e\u0431\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043b\u044e\u0431\u043e\u0439<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-350765","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=350765"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350765\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}