Skip to content

fix: remove erroneous pyi file messing up client typehints #1749

New issue

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

By clicking “No 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? No Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

AstreaTSS
Copy link
Member

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

This PR is the same issue of #1748, but fixes the issue library-wide instead of just for extensions.

To recap: using client: Client as a class variable for classes resulted in the client being of type Unknown to Pyright thanks to a "class cannot derive from itself" issue.

Eventually, I narrowed down the issue to _template.pyi which made EventMixinTemplate, the class used in all processors and so in Client, inherit from Client, causing a self-derivative.

The file as a whole was added in 2022, evidentially to make type hinting better when using EventMixinTemplate. While it would be nice to keep these typehints, this PR removes the pyi file instead and adjusts some of the code so that what is currently there is typehinted enough for convenience.

Changes

  • Remove _template.pyi.
  • Adjust _template.py to add attributes to EventMixinTemplate used in certain places.
  • Adjust processors to rely on attributes defined in EventMixinTemplate.

Related Issues

Test Scenarios

import interactions
bot = interactions.Client()
reveal_type(bot.user._client)

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

@silasary silasary merged commit 337c204 into unstable Jan 16, 2025
9 of 12 checks passed
@silasary silasary deleted the fix-client-typehint branch January 16, 2025 07:15
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants