python / python/typeshed

incomplete type declaration at `sqlite3.Connection.create_aggregate()`

Đang mở
#12,141 3 bình luận 2 reaction 0 người được giao Xem trên GitHub

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

stubs: false positive
Ngôn ngữ chính
Python
Star
5.1k
Fork
2.1k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
82

Mô tả

Bug report

Bug description:

The create_aggregate documentation does not specify a result type of the aggregation and even allows for multiple aggregating values per row (n_arg parameter).

However, the type declaration at dbapi2.pyi does not reflect that (comments added by me):

def create_aggregate(self, name: str, n_arg: int, aggregate_class: Callable[[], _AggregateProtocol]) -> None: ...

class _AggregateProtocol(Protocol):
    def step(self, value: int, /) -> object: ...  # <-- just one aggregating value of type int
    def finalize(self) -> int: ...   # <-- result has to be int

I think that this is not correct. At least, I have working code that aggregates multiple strings into a combined one.

Also, it is in stark contrast to other, way more generic, type declarations at the same place (comments added by me):

class _AnyParamWindowAggregateClass(Protocol):
    def step(self, *args: Any) -> object: ... # <-- multiple aggregating values of any type allowed
    def inverse(self, *args: Any) -> object: ...
    def value(self) -> _SqliteData: ...
    def finalize(self) -> _SqliteData: ... # <-- result can be many more types

_SqliteData: TypeAlias = str | ReadableBuffer | int | float | None
CPython versions tested on:

3.12

Operating systems tested on:

Windows

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.

Hướng nghiên cứu

Bắt đầu với stub sqlite3 dbapi2.pyi và so sánh create_aggregate với hành vi được ghi lại của sqlite3.Connection.create_aggregate. Xem xét _AnyParamWindowAggregateClass và _SqliteData trong cùng tệp, sau đó xác định khai báo tương thích cho nhiều giá trị đầu vào và các kết quả tổng hợp không phải số nguyên; hoàn thành khi stub chấp nhận chính xác các trường hợp sử dụng được ghi lại.

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

Đánh giá

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

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.