cappa icon indicating copy to clipboard operation
cappa copied to clipboard

forcing less strict type checking on projects that use cappa

Open beauxq opened this issue 10 months ago • 3 comments

The biggest barrier preventing me from using cappa right now is that it forces me to use less strict type-checking in my project, because of all of the untyped parts of the cappa API.

I see that it would be a lot of work to introduce strict typing to the whole cappa code base.

A way to help make less of this untyped API bleed over into the public interface could be to do a stricter type check on just the examples directory (since that uses a lot of the public interface). This would be much less work than introducing strict type checking into the whole cappa code base.

beauxq avatar Apr 24 '25 22:04 beauxq

I'd be interested in any type checking problems, and would consider them bugs. i see you addressed some of them in your PR. I dont currently encounter with the settings i'm using personally, which is why they're not currently fixed :P

DanCardin avatar Apr 25 '25 13:04 DanCardin

If you want to see what I'm seeing, you can add this to the pyproject.toml:

[tool.pyright]
typeCheckingMode = "strict"

I use something close to that setting (a little bit of customization around it), and I can't use cappa without it reporting lots of issues all over the cappa API.

That reports thousands of issues if you check the whole cappa code base. That's why I say it would be a lot of work to address all of that. But it's significantly less work to just address what it reports on the examples, and that covers a lot of the API that users will see.

beauxq avatar Apr 25 '25 18:04 beauxq

from that, i would believe that the untyped params on the inputs of @command would be causing what at least I am seeing on my own CLIs, but i wouldnt think (from reading their docs) that dict vs dict[Any, Any] would be meaningfully different.

I certainly have been typing like that when i can't be meaningfully more specific than the concrete part of the type. kind of annoying if that's not "strict" compliant, but i can definitely look more into it.

you only addressed some of the issues yes? like i said on the PR, i'm definitely seeing conflicting issues with mypy given your PR, and I believe i'm seeing similar issues on the invoke api.

DanCardin avatar Apr 25 '25 19:04 DanCardin

Fixed by https://github.com/DanCardin/cappa/pull/222

DanCardin avatar Jul 17 '25 17:07 DanCardin