sopel-irc / sopel

:robot::speech_balloon: An easy-to-use and highly extensible IRC Bot framework. Formerly Willie.
https://sopel.chat
Other
948 stars 402 forks source link

Gradual enforcement plan for stricter `mypy` checks #2603

Open dgw opened 8 months ago

dgw commented 8 months ago

As I've started to work with modern Sopel in the context of plugins that want to do their own type-checking (e.g. sopel-iplookup), I've also built up an opinion that we should really give ourselves a concrete target for officially declaring sopel as supporting type-checks, i.e. adding the py.typed file that it needs to silence mypy's missing-imports warning.

I propose that the target be "every piece of Sopel's public API has complete type hints". We can go above and beyond that with type hints for internal functions or plugin callables, but anything that we expect a plugin developer to import or touch (including the types passed through the bot and trigger args and all of the things they contain) should be fully hinted.

To help us find shortcomings, the following mypy options are available:

For 8.0.1 we should definitely do a pass with --disallow-incomplete-defs and fix those as a first step. The goal—or at least, my goal—is to do the rest of the typing work along the road to 9.0 and ship py.typed with --disallow-untyped-defs enforcement by then.

(In case you're wondering who to blame for this "make more work" issue, in my own defense, it was @SnoopJ who said "probably a good thing to start tracking for 9.0.0 milestone tho" in our IRC channel when I mentioned --disallow-incomplete-defs. 😜)

Exirel commented 2 months ago

I'm on it for the 8.0.1 milestone, and we are starting with few errors:

Found 61 errors in 15 files (checked 81 source files)

That looks doable, I'll see if it's that easy.

Exirel commented 1 month ago

The 8.0.1 portion is done. I'm moving the target to 8.1.0!

Exirel commented 1 month ago

Just for information, as of today:

Found 674 errors in 66 files (checked 81 source files)

Yeah OK. There is some work to be done here.