Skip to content

chore: Minor refactor #1

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

chore: Minor refactor #1

wants to merge 6 commits into from

Conversation

NotAussie
Copy link
Member

@NotAussie NotAussie commented Jun 4, 2025

Minor refactor that corrects usage of "bot" to "client" when referring to the API client and cleans up some other stuff.

Also adds a pylint workflow because linting is cool

Summary by CodeRabbit

  • Chores
    • Updated linting configuration and added plugins to enhance code quality checks.
    • Introduced a new automated workflow for running Pylint on Python code during pushes and pull requests.
    • Added new TODO item to track an issue with shutdown behaviour.
  • Refactor
    • Replaced all "bot" references with "client" for consistent terminology across the application.
    • Added and improved docstrings to clarify functionality and improve maintainability.
    • Removed deprecated permission mapping and related exports.
  • Style
    • Improved documentation style and consistency throughout multiple modules.

Minor refactor that corrects usage of "bot" to "client" when referring to the API client and cleans up some other stuff.

Also adds a pylint workflow because linting is cool
Copy link

coderabbitai bot commented Jun 4, 2025

Walkthrough

G'day mate! This update mainly swaps out references from "bot" to "client" across multiple modules for consistency, spruces up docstrings, and removes the old permissionMap mapping. There's also a new GitHub Actions workflow for Pylint checks, tweaks to Pylint config, and a couple of minor doc and config changes. No major logic changes—just a tidy-up and some automation.

Changes

File(s) Change Summary
.pylintrc Updated ignored directories, added plugins, and tweaked disabled messages.
TODO.md Added a new TODO about shutdown waiting for a websocket payload.
.github/workflows/pylint.yml Added a GitHub Actions workflow for automated Pylint checks.
src/documents/action.py Added a docstring to the Settings inner class.
src/main.py Changed Sentry default server name from "encore-bot" to "encore".
src/models/consumer.py Added a docstring to the validate_reason method.
src/modules/commands/debug.py Renamed "bot" to "client" throughout, updated docstrings, and changed function signatures accordingly.
src/modules/listeners/_entryway.py Renamed "bot" to "client", updated docstrings, and changed function signatures.
src/modules/listeners/automod.py Renamed "bot" to "client", added comprehensive docstrings, and updated shutdown logic reference.
src/modules/listeners/errors.py Renamed "bot" to "client", improved docstrings, and changed function signatures.
src/modules/listeners/join_handler.py Renamed "bot" to "client", expanded docstrings, and updated function signatures.
src/modules/special/on_startup.py Renamed "bot" to "client", added docstrings, and updated function signatures and parameter names.
src/utilities/__init__.py Removed import and export of permissionMap.
src/utilities/client.py Improved class and method docstrings for clarity and consistency.
src/utilities/mappings.py Deleted file containing the permissionMap dictionary.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant GitHub as GitHub Actions
    participant Pylint as Pylint

    Dev->>GitHub: Push or PR to any branch
    GitHub->>GitHub: Trigger "Pylint Check" workflow
    GitHub->>GitHub: Setup Python, install deps, install Pylint
    GitHub->>Pylint: Run Pylint on src/
    Pylint-->>GitHub: Output results
    GitHub->>GitHub: Show last 100 lines of Pylint output
    alt If PR event
        GitHub->>GitHub: Comment Pylint output on PR
    end
Loading

That's the lot, mate! Just a bit of a spring clean and some automation to keep things shipshape.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Pylint (3.3.7)
src/modules/listeners/errors.py

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a82d5d8 and 297c1ef.

📒 Files selected for processing (2)
  • github/workflows/pylint.yml (1 hunks)
  • src/modules/listeners/errors.py (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • github/workflows/pylint.yml
  • src/modules/listeners/errors.py
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Docstrings generation was requested by @NotAussie.

* #1 (comment)

The following files were modified:

* `src/models/consumer.py`
* `src/modules/commands/debug.py`
* `src/modules/listeners/_entryway.py`
* `src/modules/listeners/automod.py`
* `src/modules/listeners/errors.py`
* `src/modules/listeners/join_handler.py`
* `src/modules/special/on_startup.py`
* `src/utilities/client.py`
@coderabbitai coderabbitai bot mentioned this pull request Jun 4, 2025
Copy link

coderabbitai bot commented Jun 4, 2025

Note

Generated docstrings for this pull request at #2

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (5)
TODO.md (1)

4-4: Document the root cause of shutdown behaviour. G'day mate, this TODO is a tad vague – consider referencing an issue or adding more detail so we can track that shutdown quirk properly.

src/main.py (1)

51-51: Update docs for SENTRY_NAME default. Changed default from "encore-bot""encore"; good on ya, just ensure docs or env samples reflect this tweak.

src/modules/listeners/_entryway.py (2)

157-161: Refine role command docstring. Nice docstring, mate – consider renaming the role parameter (e.g. role_input) to avoid the del role trick for better clarity.


442-447: Docstring still mentions "bot". Consider updating to "client" for consistency in the setup function doc.

src/modules/listeners/errors.py (1)

90-90: Fix the casing inconsistency in the embed title, mate.

You've got "client Missing Permissions" with a lowercase 'c', but all your other error titles use proper case. This'll look a bit dodgy to users.

Apply this diff to fix the casing:

-                title="client Missing Permissions",
+                title="Client Missing Permissions",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d6a2b3 and a82d5d8.

📒 Files selected for processing (15)
  • .pylintrc (3 hunks)
  • TODO.md (1 hunks)
  • github/workflows/pylint.yml (1 hunks)
  • src/documents/action.py (1 hunks)
  • src/main.py (1 hunks)
  • src/models/consumer.py (1 hunks)
  • src/modules/commands/debug.py (4 hunks)
  • src/modules/listeners/_entryway.py (11 hunks)
  • src/modules/listeners/automod.py (12 hunks)
  • src/modules/listeners/errors.py (4 hunks)
  • src/modules/listeners/join_handler.py (2 hunks)
  • src/modules/special/on_startup.py (1 hunks)
  • src/utilities/__init__.py (0 hunks)
  • src/utilities/client.py (4 hunks)
  • src/utilities/mappings.py (0 hunks)
💤 Files with no reviewable changes (2)
  • src/utilities/mappings.py
  • src/utilities/init.py
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/modules/special/on_startup.py (2)
src/utilities/client.py (1)
  • Client (11-200)
src/events/startup.py (1)
  • StartupEvent (4-4)
src/modules/commands/debug.py (6)
src/utilities/client.py (2)
  • Client (11-200)
  • getch_user (101-126)
src/modules/listeners/join_handler.py (1)
  • setup (66-72)
src/modules/special/on_startup.py (1)
  • setup (34-38)
src/modules/listeners/automod.py (1)
  • setup (259-260)
src/modules/listeners/errors.py (1)
  • setup (167-173)
src/modules/listeners/_entryway.py (1)
  • setup (442-448)
🔇 Additional comments (43)
.pylintrc (3)

25-25: Good change, mate!

Switching from third_party to .venv makes heaps more sense for a Python project. Virtual environments definitely shouldn't be linted.


36-36: Ripper addition of Pylint extensions!

Adding the docstyle and code_style plugins will give you better linting coverage. These extensions will help catch documentation and style issues that the core Pylint might miss.


68-68: Smart move disabling this warning.

The docstring-first-line-empty warning can be a bit pedantic, especially when you've got multi-line docstrings that follow other style conventions. Good call adding it to the disabled list.

src/documents/action.py (1)

55-55: Brief docstring added for Settings class. Looks ace, mate – that one-liner helps clarify the inner class purpose.

src/models/consumer.py (1)

28-32: Nice docstring for validator. Spot on, mate – that adds clarity to validate_reason.

src/modules/listeners/_entryway.py (10)

23-28: Constructor docstring & client rename. Good on ya for adding that constructor docstring and swapping botclient – helps maintainability, mate.


31-33: Instance attribute renamed to client. Spot-on update for consistency across cogs, mate.


42-46: Enhanced on_startup docstring. That description is bonza – clear and to the point. Cheers, mate.


55-56: Dispatch using client. Swapping dispatch call to client is clean as, mate.


59-63: Docstring for on_entryway_completed. Top-notch summary of the listener behaviour, mate.


173-177: Renamed server fetch to client.getch_server. Looks tidy, mate – consistent with the refactor.


255-259: Updated on_member_join to use client. All good for consistency, mate.


329-333: Enhanced verification_flow docstring. Solid clarity on the verification steps, mate.


349-353: wait_for switched to client. Refactored wait_for usage is spot-on, mate.


383-386: Updated verify command server retrieval. Swapped to client.getch_server – looks spot-on, mate.

src/modules/commands/debug.py (6)

9-9: Beaut work on the docstring update, mate!

The class docstring now clearly describes the purpose as implementing debug commands for the client rather than the generic previous version.


11-19: Solid refactor from bot to client terminology!

The constructor changes are spot on - the parameter rename to client is consistent with the codebase-wide terminology update, and the detailed docstring provides excellent clarity about what the initialisation does.


47-50: Comprehensive docstring improvement, good on ya!

The detailed docstring for the guild method now properly explains the functionality, error handling, and what information gets displayed in the embed.


68-68: Method call updated correctly, mate!

The change from self.bot.getch_user to self.client.getch_user is consistent with the terminology refactor and matches the Client class interface shown in the relevant code snippets.


89-94: Top-notch docstring enhancement!

The permission check method now has clear documentation explaining its purpose and the exception it raises when authorization fails.


101-107: Setup function refactor looks ace!

The parameter change to client and the detailed docstring follow the established pattern seen across other modules. Consistent implementation throughout the codebase.

src/modules/special/on_startup.py (3)

10-18: Excellent constructor refactor, mate!

The parameter rename to client and the comprehensive docstring clearly explain the gear's purpose and setup process. The instance variable change is consistent throughout.


22-29: Good use of underscore for unused parameter!

Changing the event parameter to _ properly indicates it's unused, and the detailed docstring explains the one-time startup event dispatch logic beautifully.


34-38: Setup function follows the established pattern perfectly!

The client parameter and comprehensive docstring are consistent with the pattern shown in other modules. Well done on maintaining consistency across the codebase.

src/modules/listeners/join_handler.py (4)

13-21: Ripper job on the constructor refactor!

The parameter rename to client with the detailed docstring clearly explains the initialization process. Instance variable update is spot on.


26-38: Comprehensive docstring for bot addition logic!

The detailed explanation of the cleanup-then-create logic and analytics event tracking is excellent. The client reference update maintains consistency.


45-60: Well-documented bot removal handling, mate!

The docstring clearly explains the cleanup process, logging, and analytics tracking. The client reference is properly updated throughout.


66-72: Setup function documentation is ace!

The comprehensive docstring and client parameter follow the established pattern perfectly. Consistent implementation across the module.

src/modules/listeners/automod.py (9)

24-31: Brilliant constructor refactor with comprehensive docs!

The parameter rename to client and the detailed docstring explaining queue setup and consumer initialization is top-notch work, mate.


53-57: Excellent documentation for consumer startup logic!

The docstring clearly explains the task creation and scheduling process for queue consumers. Great level of detail.


70-90: Comprehensive dispatch method documentation and updates!

The docstring thoroughly explains the message enqueuing process, and all client method calls (getch_channel, getch_server) are properly updated. Solid work!


93-97: Outstanding documentation for the consume method!

This docstring brilliantly explains the complex async processing logic, error handling, and termination conditions. Really well done, mate!


109-134: Client method calls consistently updated!

All the getch_channel, getch_server, and getch_member calls properly use the client reference. The refactor is thorough and consistent.


164-179: Shutdown method properly documented and updated!

The docstring clearly explains the graceful shutdown process, and the client.close() call is properly updated. Good work on maintaining the logic while updating references.


183-187: Beaut documentation for startup event handling!

The docstring clearly explains the consumer initialization and signal handler registration process.


219-234: Message event handling consistently updated!

All client method calls in the message event handler are properly updated, and the docstring clearly explains the filtering logic for bot messages.


238-256: Message update handling looks ace!

The client references are consistently updated throughout the message update handler, and the docstring explains the filtering conditions well.

src/modules/listeners/errors.py (3)

12-27: G'day mate! LGTM on the terminology shift and constructor improvements.

The change from "bot" to "client" makes perfect sense for consistency, and the expanded docstrings are much clearer. Nice work on detailing what the constructor actually does!


52-68: Beaut documentation improvements, mate!

The expanded docstrings for both on_startup and on_command_error methods provide much better clarity on what these listeners actually do. Really helps understand the error handling flow.


167-173: Perfect setup function update!

The parameter rename and improved docstring are spot on. Consistent with the rest of the changes.

src/utilities/client.py (3)

12-29: Ripper improvements to the class docstring and constructor docs, mate!

The updated class docstring removes the "Bot" reference nicely, and the new constructor docstring is much more detailed. Good on ya for explaining the PostHog integration and Motor client setup.


37-50: Top-notch documentation upgrade for the start method!

The expanded docstring clearly explains the Beanie ODM initialization, authentication setup, and error conditions. The updated error message is much clearer too.


132-174: Excellent comprehensive docstrings for the getch methods!

Both getch_server and getch_channel now have proper documentation that explains the caching behaviour, required permissions, and possible exceptions. These are much more helpful than the old sparse docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant