datalite icon indicating copy to clipboard operation
datalite copied to clipboard

Enhancement: proper fetch* type hinting

Open CHerSun opened this issue 3 years ago • 0 comments

Current implementation of fetch methods do not type hint objects returned, which makes it more difficult to use.

Suggestion:

Add a TypeVar to fetch.py:

from typing import TypeVar
T = TypeVar('T')

Modify fetch* functions type hinting from:

  def fetch_from(class_: type, obj_id: int) -> Any:

to:

  def fetch_from(class_: type[T], obj_id: int) -> T:

That will give a proper type hint to IDE.

CHerSun avatar Aug 12 '22 22:08 CHerSun