Type TAllowedParameterValue more completely

Open
#669 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
database

Research direction

Start in src/databricks/sql/parameters/native.py at the TAllowedParameterValue definition linked in the issue. Check the connector's accepted parameter shapes before making the recursive annotations, then run the project's strict pyright checks with a wrapper using sql_params_dict. Done means the supported list, dict, and tuple values are fully typed without partially unknown errors.

Written by the indexing model from the issue text.

Description

Currently, the type definition of TAllowedParameterValue is

TAllowedParameterValue = Union[
    str,
    int,
    float,
    datetime.datetime,
    datetime.date,
    bool,
    decimal.Decimal,
    None,
    list,
    dict,
    tuple,
]

list, dict, and tuple are incomplete types. That means when I try to write a wrapper function around cursor.execute using that type as the type of a parameter sql_params_dict, pyright strict yells at me Type of parameter "sql_params_dict" is partially unknown.

I think this can easily be fixed. My guess is, this could simply be a recursive type definition, and those last three lines could be changed to

    list[TAllowedParameterValue],
    dict[TAllowedParameterValue, TAllowedParameterValue],
    tuple[TAllowedParameterValue, ...]
]

However, there may be more or fewer restrictions on those types. I didn't look into it very hard.

Dominant language
Python
Stars
233
Forks
152
Avg merge
21h 5m
Merged PRs (30d)
10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from databricks/databricks-sql-python

All issues in databricks/databricks-sql-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.