incomplete type declaration at `sqlite3.Connection.create_aggregate()`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 5.1k
- Forks
- 2.1k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 82
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem sqlite3 dbapi2.pyi-Stub und vergleiche create_aggregate mit dem dokumentierten Verhalten von sqlite3.Connection.create_aggregate. Prüfe _AnyParamWindowAggregateClass und _SqliteData in derselben Datei und ermittle dann die kompatible Deklaration für mehrere Eingabewerte und nicht-ganzzahlige Aggregationsergebnisse; abgeschlossen ist die Aufgabe, wenn der Stub die dokumentierten Anwendungsfälle korrekt akzeptiert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100