trino-python-client icon indicating copy to clipboard operation
trino-python-client copied to clipboard

Make this package PEP-561 compatible by adding a py.typed marker

Open Priyansh121096 opened this issue 1 year ago • 1 comments

Description

Fixes #482 so that dependent packages can type check themselves against trino.

Non-technical explanation

Release notes

( ) This is not user-visible or docs only and no release notes are required. ( ) Release notes are required, please propose a release note for me. (x) Release notes are required, with the following suggested text:

* Make this package PEP-561 compatible ({issue}`482`)

Priyansh121096 avatar Jan 13 '25 13:01 Priyansh121096

how can I verify this works as expected? Is it as simple as importing trino module and seeing if mypy for example can do type checking for a script which calls methods from trino module?

hashhar avatar Jan 15 '25 18:01 hashhar

Hi @hashhar - just checking if this is something y'all would be able to merge?

To answer your question - yes. As I understand, mypy will assume the package is untyped unless it presents a py.typed on the package meaning that by default mypy says "sorry! cannot type against this package, please add type: ignored or disable the package", and needs some overrides to get around it (e.g. follow_untyped_imports).

The presence of the marker file is an intent that "yes, this package is reasonably well typed" to avoid incidentally typing against low quality packages that is untyped and lead to Any getting tossed around everywhere.

lgo avatar Aug 19 '25 16:08 lgo

I checked and it wasn't obvious to me that mypy doesn't check types from libraries unless they have py.typed marker.

IDEs for example use type information always (even when using mypy as the backend) so I didn't notice.

Thanks for your change. Merging this.

hashhar avatar Aug 20 '25 12:08 hashhar

Thanks @hashhar !

Priyansh121096 avatar Aug 20 '25 13:08 Priyansh121096

I'll update here once a new version with this is released (probably in a couple of weeks).

hashhar avatar Aug 20 '25 13:08 hashhar