kineticadb / kinetica-airflow

Kinetica provider for Apache Airflow.
MIT License
2 stars 3 forks source link

Typing #4

Open fjmacagno opened 4 weeks ago

fjmacagno commented 4 weeks ago

Any chance this library could be typed for use with mypy?

chadj2 commented 4 weeks ago

Most of the arguments and return values are typed. Can you give an example?

fjmacagno commented 4 weeks ago

I think that the "typed" flag is needed for mypy to recognize this; i have to include an ignore comment when using these classes and mypy:

from kinetica_provider.hooks.sql import KineticaSqlHook  # type: ignore[import-untyped]

otherwise, i get errors like

error: Skipping analyzing "kinetica_provider.operator.sql": module is installed, but missing library stubs or py.typed marker  [import-untyped]
chadj2 commented 3 weeks ago

The mypy package generates this warning if a library is missing a stub file. We don't add this file automatically and most 3rd party libraries don't either. Are you seeing other libraries in airflow that distribute the file?

fjmacagno commented 3 weeks ago

We use mypy with most of Airflow without issue; you shouldnt need to add a stub file since you are actually typing everything, you just need to add a "py.typed marker" at your package root.

Per https://typing.readthedocs.io/en/latest/spec/distributing.html#packaging-typed-libraries: "Package maintainers who wish to support type checking of their code MUST add a marker file named py.typed to their package supporting typing. This marker applies recursively: if a top-level package includes it, all its sub-packages MUST support type checking as well."