incomplete type declaration at `sqlite3.Connection.create_aggregate()`
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 5.1k
- Fork
- 2.1k
- Merge medio
- 1g 19h
- PR unite (30g)
- 82
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con lo stub sqlite3 dbapi2.pyi e confronta create_aggregate con il comportamento documentato di sqlite3.Connection.create_aggregate. Esamina _AnyParamWindowAggregateClass e _SqliteData nello stesso file, quindi determina la dichiarazione compatibile per più valori di input e risultati di aggregazione non interi; il lavoro è terminato quando lo stub accetta correttamente i casi d’uso documentati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100