home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 868881033

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/sqlite-utils/issues/37#issuecomment-868881033 https://api.github.com/repos/simonw/sqlite-utils/issues/37 868881033 MDEyOklzc3VlQ29tbWVudDg2ODg4MTAzMw== 9599 2021-06-25T23:23:49Z 2021-06-25T23:23:49Z OWNER

Twitter conversation about how to add types to the .create_table(columns=) parameter: https://twitter.com/simonw/status/1408532867592818693

Anyone know how to write a mypy type definition for this?

{"id": int, "name": str, "image": bytes, "weight": float}

It's a dict where keys are strings and values are one of int/str/bytes/float (weird API design I know, but I designed this long before I was thinking about mypy)

Looks like this could work:

python def create_table( self, name, columns: Dict[str, Union[Type[int], Type[bytes], Type[str], Type[float]]], pk=None, foreign_keys=None, column_order=None, not_null=None, defaults=None, hash_id=None, extracts=None, ): Except... that method can optionally also accept numpy types if numpy is installed. I don't know if it's possible to dynamically change a signature based on an import, since mypy is a static type analyzer and doesn't ever execute the code.

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