{"html_url": "https://github.com/simonw/datasette/issues/957#issuecomment-683355508", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/957", "id": 683355508, "node_id": "MDEyOklzc3VlQ29tbWVudDY4MzM1NTUwOA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-29T23:54:01Z", "updated_at": "2020-08-29T23:54:01Z", "author_association": "OWNER", "body": "Reviewing https://github.com/search?q=user%3Asimonw+%22from+datasette%22&type=Code I spotted these others:\r\n\r\n```python\r\n# Various:\r\nfrom datasette.utils import path_with_replaced_args\r\nfrom datasette.plugins import pm\r\nfrom datasette.utils import QueryInterrupted\r\nfrom datasette.utils.asgi import Response, Forbidden, NotFound\r\n\r\n# datasette-publish-vercel:\r\nfrom datasette.publish.common import (\r\n add_common_publish_arguments_and_options,\r\n fail_if_publish_binary_not_installed\r\n)\r\nfrom datasette.utils import temporary_docker_directory\r\n\r\n# datasette-insert\r\nfrom datasette.utils import actor_matches_allow, sqlite3\r\n\r\n# obsolete: russian-ira-facebook-ads-datasette \r\nfrom datasette.utils import TableFilter\r\n\r\n# simonw/museums\r\nfrom datasette.utils.asgi import asgi_send\r\n\r\n# datasette-media\r\nfrom datasette.utils.asgi import Response, asgi_send_file\r\n\r\n# datasette/tests/plugins/my_plugin.py\r\nfrom datasette.facets import Facet\r\n\r\n# datasette-graphql\r\nfrom datasette.views.table import TableView\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 688622148, "label": "Simplify imports of common classes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/957#issuecomment-683355598", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/957", "id": 683355598, "node_id": "MDEyOklzc3VlQ29tbWVudDY4MzM1NTU5OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-29T23:55:10Z", "updated_at": "2020-08-29T23:55:34Z", "author_association": "OWNER", "body": "Of these I think I'm going to promote the following to being importable directly `from datasette`:\r\n\r\n- `from datasette.app import Datasette`\r\n- `from datasette.utils import QueryInterrupted`\r\n- `from datasette.utils.asgi import Response, Forbidden, NotFound`\r\n- `from datasette.utils import actor_matches_allow`\r\n\r\nAll of the rest are infrequently used enough (or clearly named enough) that I'm happy to leave them as-is.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 688622148, "label": "Simplify imports of common classes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/957#issuecomment-683355993", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/957", "id": 683355993, "node_id": "MDEyOklzc3VlQ29tbWVudDY4MzM1NTk5Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-30T00:02:11Z", "updated_at": "2020-08-30T00:04:18Z", "author_association": "OWNER", "body": "I tried doing this and got this error:\r\n```\r\n(datasette) datasette % pytest\r\n==================================================================== test session starts =====================================================================\r\nplatform darwin -- Python 3.8.5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1\r\nrootdir: /Users/simon/Dropbox/Development/datasette, configfile: pytest.ini\r\nplugins: asyncio-0.14.0, timeout-1.4.2\r\ncollected 1 item / 23 errors \r\n\r\n=========================================================================== ERRORS ===========================================================================\r\n_____________________________________________________________ ERROR collecting tests/test_api.py _____________________________________________________________\r\nImportError while importing test module '/Users/simon/Dropbox/Development/datasette/tests/test_api.py'.\r\nHint: make sure your test modules/packages have valid Python names.\r\nTraceback:\r\n/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py:127: in import_module\r\n return _bootstrap._gcd_import(name[level:], package, level)\r\ntests/test_api.py:1: in \r\n from datasette.plugins import DEFAULT_PLUGINS\r\ndatasette/__init__.py:2: in \r\n from .app import Datasette\r\ndatasette/app.py:30: in \r\n from .views.base import DatasetteError, ureg\r\ndatasette/views/base.py:12: in \r\n from datasette.plugins import pm\r\ndatasette/plugins.py:26: in \r\n mod = importlib.import_module(plugin)\r\n/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py:127: in import_module\r\n return _bootstrap._gcd_import(name[level:], package, level)\r\ndatasette/publish/heroku.py:2: in \r\n from datasette import hookimpl\r\nE ImportError: cannot import name 'hookimpl' from partially initialized module 'datasette' (most likely due to a circular import) (/Users/simon/Dropbox/Development/datasette/datasette/__init__.py)\r\n```\r\nThat's with `datasette/__init__.py` looking like this:\r\n```python\r\nfrom datasette.version import __version_info__, __version__ # noqa\r\nfrom .app import Datasette\r\nfrom .utils.asgi import Forbidden, NotFound, Response\r\nfrom .utils import actor_matches_allow, QueryInterrupted\r\nfrom .hookspecs import hookimpl # noqa\r\nfrom .hookspecs import hookspec # noqa\r\n\r\n\r\n__all__ = [\r\n \"actor_matches_allow\",\r\n \"hookimpl\",\r\n \"hookspec\",\r\n \"QueryInterrupted\",\r\n \"Forbidden\",\r\n \"NotFound\",\r\n \"Response\",\r\n \"Datasette\",\r\n]\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 688622148, "label": "Simplify imports of common classes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/957#issuecomment-683356440", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/957", "id": 683356440, "node_id": "MDEyOklzc3VlQ29tbWVudDY4MzM1NjQ0MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-30T00:08:18Z", "updated_at": "2020-08-30T00:10:26Z", "author_association": "OWNER", "body": "Annoyingly this seems to be the line that causes the circular import:\r\n```python\r\nfrom .utils.asgi import Forbidden, NotFound, Response\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 688622148, "label": "Simplify imports of common classes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/957#issuecomment-683357092", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/957", "id": 683357092, "node_id": "MDEyOklzc3VlQ29tbWVudDY4MzM1NzA5Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-30T00:15:51Z", "updated_at": "2020-08-30T00:16:02Z", "author_association": "OWNER", "body": "Weirdly even removing this single `datasette` import from `utils/asgi.py` didn't fix the circular import:\r\n\r\nhttps://github.com/simonw/datasette/blob/44cf424a94a85b74552075272660bb96a7432661/datasette/utils/asgi.py#L1-L3", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 688622148, "label": "Simplify imports of common classes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/957#issuecomment-1030761625", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/957", "id": 1030761625, "node_id": "IC_kwDOBm6k_c49cCyZ", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-02-06T06:30:32Z", "updated_at": "2022-02-06T06:31:44Z", "author_association": "OWNER", "body": "I'm just going with:\r\n\r\n```python\r\nfrom datasette import Response\r\nfrom datasette import Forbidden\r\nfrom datasette import NotFound\r\nfrom datasette import hookimpl\r\nfrom datasette import actor_matches_allow\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 688622148, "label": "Simplify imports of common classes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/957#issuecomment-1030762140", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/957", "id": 1030762140, "node_id": "IC_kwDOBm6k_c49cC6c", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-02-06T06:36:41Z", "updated_at": "2022-02-06T06:36:41Z", "author_association": "OWNER", "body": "Documented here: https://docs.datasette.io/en/latest/internals.html#import-shortcuts", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 688622148, "label": "Simplify imports of common classes"}, "performed_via_github_app": null}