Various IDEs complain about the Cursor
type not being iterable even though it is.
For example:
def example(): with connect( user="***", password="***", dsn="***") as connection: with connection.cursor() as cursor: execute_stmt = cursor.execute("select * from table") if execute_stmt: return [r for r in execute_stmt]
When using the pyright lsp with neovim, I get this error:
"Type[Cursor]" is not iterable
When using pycharm I get a warning of:
Expected type 'collections.Iterable', got 'Type[Cursor]' instead
As temporary work around I have modified the signature of the execute
method of Cursor
class in oracledb/cursor.py
to return Union['Cursor', None]
instead of Union[Type["Cursor"], None]
.
original:
def execute(self, statement: Union[str, None], parameters: Union[list, tuple, dict]=None, **keyword_parameters: dict) -> Union[Type["Cursor"], None]:
new:
def execute(self, statement: Union[str, None], parameters: Union[list, tuple, dict]=None, **keyword_parameters: dict) -> Union['Cursor', None]:
OS: macOS BigSur v11.6.1
pycharm 2022.1.4 (Professional Edition)
NVIM v0.7.2
pyright 1.1.270
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4