Type TAllowedParameterValue more completely

Đang mở
#669 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
database

Hướng nghiên cứu

Bắt đầu trong src/databricks/sql/parameters/native.py tại định nghĩa TAllowedParameterValue được liên kết trong issue. Kiểm tra các dạng tham số mà connector chấp nhận trước khi tạo các annotation đệ quy, sau đó chạy các kiểm tra pyright nghiêm ngặt của dự án bằng một wrapper sử dụng sql_params_dict. Hoàn tất có nghĩa là các giá trị list, dict và tuple được hỗ trợ đều được định kiểu đầy đủ mà không có lỗi kiểu không xác định một phần.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
233
Fork
152
Merge trung bình
21 giờ 5 phút
Pull request đã merge (30 ngày)
10

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của databricks/databricks-sql-python

Tất cả issue của databricks/databricks-sql-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.