beangulp icon indicating copy to clipboard operation
beangulp copied to clipboard

add py.typed marker

Open yagebu opened this issue 1 year ago • 8 comments

yagebu avatar Jan 02 '25 12:01 yagebu

Build failures are unrelated, see #142 for a PR that fixes them.

Tested locally by installing it, the py.typed marker was installed as well.

yagebu avatar Jan 02 '25 13:01 yagebu

There isn't much value in declaring the package has having typing annotations without verifying that they are complete and correct. It would be counterproductive, actually. Given that the recent work on adding typing to Beancount has created more issue than what it solved, I really don't want to replicate the experience for beangulp users.

dnicolodi avatar Jan 02 '25 18:01 dnicolodi

@dnicolodi Why didn't we modernize all the projects to more recent requirements? 3.10 and above. Gotta let go of the past at some point

blais avatar Jan 02 '25 18:01 blais

There isn't much value in declaring the package has having typing annotations without verifying that they are complete and correct. It would be counterproductive, actually.

I disagree. I find it very helpful to have working types for base classes like Importer already even if not all functions and modules are fully typed. I think the incremental approach suggested by mypy (https://mypy.readthedocs.io/en/stable/existing_code.html) works on an ecosystem level as well. Currently, to get type-checking for the bits that are used in Fava I maintain type stubs - those could be removed and all beangulp users could profit from the type annotations.

yagebu avatar Jan 02 '25 18:01 yagebu

I can also create a PR to run mypy in CI so that the types are checked. There's only a handful of errors

yagebu avatar Jan 02 '25 19:01 yagebu

I think you misunderstood my reply. Typing annotations are useful. Wrong typing annotations are not. A py.typed marker indicates that typing information has at least a good chance to be correct. Because no effort has been put into verifying that typing for beangulp is correct, I'm sure it is not. Thus adding a py.typed marker seems premature. The process should be to verify that typing is correct and then add a py.typed marker. Not the other way around.

If you want to use the existing typing annotations, you can instruct mypy to do it:

[[tool.mypy.overrides]]
module = ["beangulp.*"]
follow_untyped_imports = true

dnicolodi avatar Jan 02 '25 20:01 dnicolodi

See #143 which adds a CI run of mypy to ensure beangulp has a consistent set of type annotations

yagebu avatar Jan 03 '25 08:01 yagebu

If you want to use the existing typing annotations, you can instruct mypy to do it:

Thanks, TIL - didn't know of this brand-new 1.14 mypy feature yet, that's very useful.

yagebu avatar Jan 03 '25 11:01 yagebu