asottile / cfgv

Validate configuration and produce human readable error messages
MIT License
44 stars 7 forks source link

Interest in cfgv being typed? #135

Closed Sachaa-Thanasius closed 4 months ago

Sachaa-Thanasius commented 4 months ago

I'm curious if cfgv being typed would be seen as a net benefit and thus if a PR that implements that would be considered. More than willing to attempt the PR if so. I'm partially motivated by interest in using it for a hobby project and wanted better typing support, but figured it isn't a bad quality-of-life idea in general.

asottile commented 4 months ago

please search the issue tracker for duplicates

Sachaa-Thanasius commented 4 months ago

I'll admit I was pretty vague in my initial message, but I think the only possible duplicate is #75, which is pretty different.

I'm not referring to making the results of cfgv somehow refer to specific, generated classes that a type-checker understands a la the way dataclasses work; I meant just adding some type annotations to the library and making it "typed" in the sense that type-checker wouldn't complain about it. That could include generally adding type annotations, changing collections.namedtuples to typing.NamedTuples, maybe making a Protocol for schemas (with check, remove_defaults, add_defaults function stubs) that type-checkers can check custom schema classes against, that kind of thing.

Am I missing a more obvious duplicate about general improvement of the type annotations for the library? If so, I apologize and would appreciate a link to it to confirm it's covering the same issue.

Sachaa-Thanasius commented 4 months ago

Just following up to confirm, hope you don't mind, @asottile:

I couldn't find the duplicate you mentioned, as the only other seemingly related issue wasn't about adding/improving type annotations for the library, but about cfgv being understood by mypy as a class generator a la dataclasses. Am I missing something, or do you prefer this library entirely unannotated at this time anyhow?

Either way is fine, I'd just like to understand better what you want for cfgv. I thought a few type annotations would be a plus for maintenance and possible user experience, but I guess I was mistaken.

Anyway, I'll stop badgering you after this, just wanted to be perfectly clear on your stance for the idea of adding type-hints to cfgv's code, since the duplicate seemed unrelated to that. Thanks for the nice library!