{"html_url": "https://github.com/simonw/datasette/pull/1512#issuecomment-970718337", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1512", "id": 970718337, "node_id": "IC_kwDOBm6k_c452_yB", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-11-16T22:02:30Z", "updated_at": "2021-11-16T22:02:30Z", "author_association": "OWNER", "body": "I've decided to make the clever `asyncio` dependency injection opt-in - so you can either decorate with `@inject` or you can set `inject_all = True` on the class - for example:\r\n```python\r\nimport asyncio\r\nfrom datasette.utils.asyncdi import AsyncBase, inject\r\n\r\n\r\nclass Simple(AsyncBase):\r\n def __init__(self):\r\n self.log = []\r\n\r\n @inject\r\n async def two(self):\r\n self.log.append(\"two\")\r\n\r\n @inject\r\n async def one(self, two):\r\n self.log.append(\"one\")\r\n return self.log\r\n\r\n async def not_inject(self, one, two):\r\n return one + two\r\n\r\n\r\nclass Complex(AsyncBase):\r\n inject_all = True\r\n\r\n def __init__(self):\r\n self.log = []\r\n\r\n async def b(self):\r\n self.log.append(\"b\")\r\n\r\n async def a(self, b):\r\n self.log.append(\"a\")\r\n\r\n async def go(self, a):\r\n self.log.append(\"go\")\r\n return self.log\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1055402144, "label": "New pattern for async view classes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1512#issuecomment-970718652", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1512", "id": 970718652, "node_id": "IC_kwDOBm6k_c452_28", "user": {"value": 22429695, "label": "codecov[bot]"}, "created_at": "2021-11-16T22:02:59Z", "updated_at": "2021-11-16T23:51:48Z", "author_association": "NONE", "body": "# [Codecov](https://codecov.io/gh/simonw/datasette/pull/1512?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) Report\n> Merging [#1512](https://codecov.io/gh/simonw/datasette/pull/1512?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) (8f757da) into [main](https://codecov.io/gh/simonw/datasette/commit/0156c6b5e52d541e93f0d68e9245f20ae83bc933?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) (0156c6b) will **decrease** coverage by `2.10%`.\n> The diff coverage is `36.20%`.\n\n[![Impacted file tree graph](https://codecov.io/gh/simonw/datasette/pull/1512/graphs/tree.svg?width=650&height=150&src=pr&token=eSahVY7kw1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison)](https://codecov.io/gh/simonw/datasette/pull/1512?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison)\n\n```diff\n@@ Coverage Diff @@\n## main #1512 +/- ##\n==========================================\n- Coverage 91.82% 89.72% -2.11% \n==========================================\n Files 34 36 +2 \n Lines 4430 4604 +174 \n==========================================\n+ Hits 4068 4131 +63 \n- Misses 362 473 +111 \n```\n\n\n| [Impacted Files](https://codecov.io/gh/simonw/datasette/pull/1512?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) | Coverage \u0394 | |\n|---|---|---|\n| [datasette/utils/vendored\\_graphlib.py](https://codecov.io/gh/simonw/datasette/pull/1512/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL3V0aWxzL3ZlbmRvcmVkX2dyYXBobGliLnB5) | `0.00% <0.00%> (\u00f8)` | |\n| [datasette/utils/asyncdi.py](https://codecov.io/gh/simonw/datasette/pull/1512/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL3V0aWxzL2FzeW5jZGkucHk=) | `96.92% <96.92%> (\u00f8)` | |\n\n------\n\n[Continue to review full report at Codecov](https://codecov.io/gh/simonw/datasette/pull/1512?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison).\n> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison)\n> `\u0394 = absolute (impact)`, `\u00f8 = not affected`, `? = missing data`\n> Powered by [Codecov](https://codecov.io/gh/simonw/datasette/pull/1512?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). Last update [0156c6b...8f757da](https://codecov.io/gh/simonw/datasette/pull/1512?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison).\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1055402144, "label": "New pattern for async view classes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1512#issuecomment-970857411", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1512", "id": 970857411, "node_id": "IC_kwDOBm6k_c453hvD", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-11-16T23:43:21Z", "updated_at": "2021-11-16T23:43:21Z", "author_association": "OWNER", "body": "```\r\nE File \"/home/runner/work/datasette/datasette/datasette/utils/vendored_graphlib.py\", line 56\r\nE if (result := self._node2info.get(node)) is None:\r\nE ^\r\nE SyntaxError: invalid syntax\r\n```\r\nOh no - the vendored code I use has `:=` so doesn't work on Python 3.6! Will have to backport it more thoroughly.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1055402144, "label": "New pattern for async view classes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1512#issuecomment-970861628", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1512", "id": 970861628, "node_id": "IC_kwDOBm6k_c453iw8", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-11-16T23:46:07Z", "updated_at": "2021-11-16T23:46:07Z", "author_association": "OWNER", "body": "I made the changes locally and tested them with Python 3.6 like so:\r\n```\r\ncd /tmp\r\nmkdir v\r\ncd v\r\npipenv shell --python=python3.6\r\ncd ~/Dropbox/Development/datasette\r\npip install -e '.[test]'\r\npytest tests/test_asyncdi.py\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1055402144, "label": "New pattern for async view classes"}, "performed_via_github_app": null}