home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1503832422

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions issue performed_via_github_app
https://github.com/simonw/datasette/issues/2057#issuecomment-1503832422 https://api.github.com/repos/simonw/datasette/issues/2057 1503832422 IC_kwDOBm6k_c5Zoqlm 9599 2023-04-11T17:42:57Z 2023-04-11T17:46:42Z OWNER

I ran this prompt against ChatGPT with the Browsing alpha:

python if pkg_resources.resource_isdir(plugin.__name__, "static"): static_path = pkg_resources.resource_filename( plugin.__name__, "static" ) if pkg_resources.resource_isdir(plugin.__name__, "templates"): templates_path = pkg_resources.resource_filename( plugin.__name__, "templates" ) This code gives a deprecation warning in Python 3.11 - fix it

It looked up the fix for me:

And suggested:

```python import importlib.resources

Replace pkg_resources.resource_isdir with importlib.resources.files().is_file()

if importlib.resources.files(plugin.name).joinpath("static").is_file(): static_path = importlib.resources.as_file( importlib.resources.files(plugin.name).joinpath("static") ) if importlib.resources.files(plugin.name).joinpath("templates").is_file(): templates_path = importlib.resources.as_file( importlib.resources.files(plugin.name).joinpath("templates") ) `` This looks wrong to me - I would expect something likeis_directory()notis_file()for telling ifstatic/` is a directory.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
1662951875  
Powered by Datasette · Queries took 3.227ms · About: github-to-sqlite