Fix checks not properly handling Group commands type #6577

Closed
Sutaai wants to merge 1 commit from patch-1 into V3/develop
Sutaai commented 2025-05-25 02:45:50 +02:00 (Migrated from github.com)

Description of the changes

This PR propose to add the type Group to the type variable used in Requires.get_decorator (Which is used by Red's checks).

This was made as creating a command group, in addition of one of Red's provided check, would alert Pylance of incorrect type, expecting type Command only.

Before

image

After
image
image

The correct type is now reflected.
Same issue and fix apply for @commands.hybrid_group

Have the changes in this PR been tested?

Yes

### Description of the changes This PR propose to add the type `Group` to the type variable used in `Requires.get_decorator` (Which is used by [Red's checks](https://docs.discord.red/en/stable/framework_checks.html)). This was made as creating a command group, in addition of one of Red's provided check, would alert Pylance of incorrect type, expecting type `Command` only. **Before** ![image](https://github.com/user-attachments/assets/a17b134c-5ad0-4ab3-9966-59db33f2acbe) **After** ![image](https://github.com/user-attachments/assets/8e38adc4-ba7d-4e0c-aedc-62512d5743da) ![image](https://github.com/user-attachments/assets/89c17c55-9484-439e-85c6-7d22d3132a1f) The correct type is now reflected. Same issue and fix apply for `@commands.hybrid_group` ### Have the changes in this PR been tested? Yes
Flame442 commented 2025-05-25 02:53:13 +02:00 (Migrated from github.com)

I would be interested to know if swapping the order of your checks on the group would make the error go away - put the is_owner below the @commands.group().

I would be interested to know if swapping the order of your checks on the group would make the error go away - put the `is_owner` below the `@commands.group()`.
Sutaai commented 2025-05-25 03:00:40 +02:00 (Migrated from github.com)

It does, but raise another error that I believe is rather more of an issue from discord.py.
image

This issue (This screenshot) apply to anything as long as @commands.group()/.command() is not the last decorator as far as I've seen. Some other combination could work.

It does, but raise another error that I believe is rather more of an issue from discord.py. ![image](https://github.com/user-attachments/assets/7ce233a8-774b-452b-9e50-24b666a469c8) This issue (This screenshot) apply to anything as long as `@commands.group()/.command()` is not the last decorator as far as I've seen. Some other combination could work.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!6577
No description provided.