Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradual enforcement plan for stricter mypy checks #2603

Open
dgw opened this issue Mar 21, 2024 · 3 comments
Open

Gradual enforcement plan for stricter mypy checks #2603

dgw opened this issue Mar 21, 2024 · 3 comments
Labels
Housekeeping Code cleanup, removal of deprecated stuff, etc. Long-term Planning Things that need to happen at some point in the future, but need to NOT happen soon.
Milestone

Comments

@dgw
Copy link
Member

dgw commented Mar 21, 2024

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:

  • --disallow-incomplete-defs: raises an error for function definitions where some, but not all, parameters are typed
  • --disallow-untyped-decorators: errors when a type-hinted function is decorated by an untyped decorator
    (not sure how useful this one is for us, but it's around)
  • --disallow-untyped-defs: superset of --disallow-incomplete-defs; any def without type hints is an error
    This would be our final endgame, once EVERYTHING is typed, even the internals and built-in plugins.

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. 😜)

@dgw dgw added Long-term Planning Things that need to happen at some point in the future, but need to NOT happen soon. Housekeeping Code cleanup, removal of deprecated stuff, etc. labels Mar 21, 2024
@dgw dgw added this to the 8.0.1 milestone Mar 21, 2024
@Exirel
Copy link
Contributor

Exirel commented Sep 1, 2024

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 Exirel modified the milestones: 8.0.1, 8.1.0 Oct 18, 2024
@Exirel
Copy link
Contributor

Exirel commented Oct 18, 2024

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

@Exirel
Copy link
Contributor

Exirel commented Oct 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Housekeeping Code cleanup, removal of deprecated stuff, etc. Long-term Planning Things that need to happen at some point in the future, but need to NOT happen soon.
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants