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

mypy: add --disallow-incomplete-defs option #2616

Merged
merged 9 commits into from
Oct 18, 2024

Conversation

Exirel
Copy link
Contributor

@Exirel Exirel commented Sep 1, 2024

Description

Tin, with the necessary type definition fix. Related to #2603 for Sopel 8.0.1.

Note: I used Any in several places, in particular in sopel.tools.identifiers. I'm not really happy about it. However, the best fix is to properly type annotate instances, i.e. doing something like users: dict[str, User] = SopelIdentifierMemory() as it should properly type check the users sopel memory object.

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make lint and make test)
  • I have tested the functionality of the things this change touches

@Exirel Exirel added the Housekeeping Code cleanup, removal of deprecated stuff, etc. label Sep 1, 2024
@Exirel Exirel added this to the 8.0.1 milestone Sep 1, 2024
@Exirel Exirel force-pushed the mypy-option-disallow-incomplete-defs branch from b71b791 to ed8f641 Compare October 12, 2024 11:23
@Exirel
Copy link
Contributor Author

Exirel commented Oct 12, 2024

I rebased that over master and it passes the 3.13 mypy check as well!

@Exirel Exirel requested a review from a team October 12, 2024 11:42
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a constant battle to keep the docs clean, with only the type annotations or hints in the :param: declarations, but not both.

While you go through and look for those (I didn't annotate every one, especially since many are outside where GH will allow line notes), also double check that merging #2285 didn't introduce any new wrinkles for this mypy option? 🙏

sopel/bot.py Show resolved Hide resolved
@dgw dgw mentioned this pull request Oct 14, 2024
4 tasks
@Exirel
Copy link
Contributor Author

Exirel commented Oct 14, 2024

but not both.

I fixed the functions I touched, and then fixed some for good measure!

double check that merging #2285 didn't introduce any new wrinkles for this mypy option? 🙏

That would require a rebase first, so you tell me if it's OK and I'll do.

Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of good stuff in here, but I do have a few questions (the same one in multiple places, actually) about the choice of type annotation syntax. Overall very impressed with how thorough you were with cleaning up the docstrings!

double check that merging #2285 didn't introduce any new wrinkles for this mypy option? 🙏

That would require a rebase first, so you tell me if it's OK and I'll do.

Now that I think about it, your fixups were tested against the latest master, including the merged changes from #2285. It passed, so you can just squash out the fixups after we settle the syntax question.

sopel/db.py Show resolved Hide resolved
sopel/plugins/rules.py Show resolved Hide resolved
sopel/tools/calculation.py Show resolved Hide resolved
sopel/tools/memories.py Show resolved Hide resolved
@Exirel Exirel force-pushed the mypy-option-disallow-incomplete-defs branch from bc7b2b5 to dcb9467 Compare October 14, 2024 19:57
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaned history all good.

I'll have to check other open PRs against this after merging, or make them re-run CI somehow. That's a future-me problem, for later in the week. 😁

Copy link
Contributor

@SnoopJ SnoopJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had some remarks, but if the type checker is happy then so am I!

sopel/bot.py Outdated Show resolved Hide resolved
sopel/builtins/units.py Show resolved Hide resolved
sopel/builtins/units.py Show resolved Hide resolved
sopel/lifecycle.py Show resolved Hide resolved
sopel/lifecycle.py Show resolved Hide resolved
sopel/bot.py Show resolved Hide resolved
sopel/plugins/rules.py Show resolved Hide resolved
sopel/tools/calculation.py Show resolved Hide resolved
sopel/tools/memories.py Outdated Show resolved Hide resolved
sopel/bot.py Outdated Show resolved Hide resolved
@Exirel Exirel force-pushed the mypy-option-disallow-incomplete-defs branch from 0690270 to 5cf930d Compare October 18, 2024 16:51
@dgw dgw merged commit 0e5c976 into sopel-irc:master Oct 18, 2024
17 checks passed
@dgw dgw mentioned this pull request Oct 18, 2024
4 tasks
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants