Describe the bug
cursor.fetchall, cursor.fetchmany and cursor.fetchone both fail to type-check under ty
To reproduce
# setup a connection
cursor.execute("SELECT 1")
cursor.fetchone()
# or any of the below:
cursor.fetchmany()
cursor.fetchall()
The above snippet when checked with ty check repro.py gives the following:
error[missing-argument]: No argument provided for required parameter `self` of function `fetchone`
--> repro.py:103:1
|
102 | cursor.execute("SELECT 1")
103 | cursor.fetchone()
| ^^^^^^^^^^^^^^^^^
|
info: Union variant `def fetchone(self) -> None | Row` is incompatible with this call site
info: Attempted to call union type `Unknown | (bound method Cursor.fetchone() -> None | Row) | (def fetchone(self) -> None | Row)`
info: rule `missing-argument` is enabled by default
It seems ty thinks this is a union of either a bound method or static method?
I believe this could also be an issue in ty as well but thought I'd ask here first.
Expected behavior
The methods should type check correctly.
Further technical details
Python version: 3.12.11
SQL Server version: SQL Server 2017
Operating system: MacOs 26.5
ty version: Observed on both 0.29 and 0.40
I have just been getting around this with # ty: ignore[missing-argument] but I'd rather not silence the lint.
Reactions are currently unavailable
Describe the bug
cursor.fetchall, cursor.fetchmany and cursor.fetchone both fail to type-check under ty
To reproduce
The above snippet when checked with ty check repro.py gives the following:
error[missing-argument]: No argument provided for required parameter `self` of function `fetchone` --> repro.py:103:1 | 102 | cursor.execute("SELECT 1") 103 | cursor.fetchone() | ^^^^^^^^^^^^^^^^^ | info: Union variant `def fetchone(self) -> None | Row` is incompatible with this call site info: Attempted to call union type `Unknown | (bound method Cursor.fetchone() -> None | Row) | (def fetchone(self) -> None | Row)` info: rule `missing-argument` is enabled by defaultIt seems ty thinks this is a union of either a bound method or static method?
I believe this could also be an issue in ty as well but thought I'd ask here first.
Expected behavior
The methods should type check correctly.
Further technical details
Python version: 3.12.11
SQL Server version: SQL Server 2017
Operating system: MacOs 26.5
ty version: Observed on both 0.29 and 0.40
I have just been getting around this with # ty: ignore[missing-argument] but I'd rather not silence the lint.