-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
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
WalkthroughG'day mate! This update mainly swaps out references from "bot" to "client" across multiple modules for consistency, spruces up docstrings, and removes the old Changes
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
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 detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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`
Note Generated docstrings for this pull request at #2 |
There was a problem hiding this 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 forSENTRY_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
: Refinerole
command docstring. Nice docstring, mate – consider renaming therole
parameter (e.g.role_input
) to avoid thedel role
trick for better clarity.
442-447
: Docstring still mentions "bot". Consider updating to "client" for consistency in thesetup
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
📒 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 tovalidate_reason
.src/modules/listeners/_entryway.py (10)
23-28
: Constructor docstring & client rename. Good on ya for adding that constructor docstring and swappingbot
→client
– helps maintainability, mate.
31-33
: Instance attribute renamed toclient
. Spot-on update for consistency across cogs, mate.
42-46
: Enhancedon_startup
docstring. That description is bonza – clear and to the point. Cheers, mate.
55-56
: Dispatch usingclient
. Swapping dispatch call toclient
is clean as, mate.
59-63
: Docstring foron_entryway_completed
. Top-notch summary of the listener behaviour, mate.
173-177
: Renamed server fetch toclient.getch_server
. Looks tidy, mate – consistent with the refactor.
255-259
: Updatedon_member_join
to useclient
. All good for consistency, mate.
329-333
: Enhancedverification_flow
docstring. Solid clarity on the verification steps, mate.
349-353
:wait_for
switched toclient
. Refactored wait_for usage is spot-on, mate.
383-386
: Updatedverify
command server retrieval. Swapped toclient.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
toself.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
, andgetch_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
andon_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
andgetch_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.
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