Skip to content

fix(commands): apply injection autocompleters to nested injections - #1578

Open
Sanjays2402 wants to merge 1 commit into
DisnakeDev:masterfrom
Sanjays2402:fix/nested-injection-autocomplete
Open

fix(commands): apply injection autocompleters to nested injections#1578
Sanjays2402 wants to merge 1 commit into
DisnakeDev:masterfrom
Sanjays2402:fix/nested-injection-autocomplete

Conversation

@Sanjays2402

Copy link
Copy Markdown

Summary

Closes #982.

Injection.autocomplete() registrations were only applied to injections attached
directly to a command's callback. collect_nested_params() recurses into nested
injections but never looked at their autocompleters, so an option belonging to an
injection nested inside another injection was registered with "autocomplete": false.
With the issue's example, only c autocompleted; a did not.

The lookup/assign logic is extracted into apply_injection_autocompleters() and now
also runs per nested injection, so nested options behave like top-level ones
(including the unknown-option ValueError).

Checklist

  • If code changes were made, then they have been tested
    • I have updated the documentation to reflect the changes
    • I have formatted the code properly by running uv run nox -s lint
    • I have type-checked the code by running uv run nox -s pyright
  • This PR fixes an issue
  • This PR adds something new (e.g. new method or parameters)
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

Injection.autocomplete() registrations were only applied to injections
directly attached to a command's callback. collect_nested_params()
recursed into nested injections but never looked at their autocompleters,
so an option belonging to an injection nested inside another injection was
registered with "autocomplete": false and never autocompleted.

The lookup/assign logic is extracted into apply_injection_autocompleters()
and now also runs for each nested injection, so nested options behave the
same as top-level ones (including the unknown-option ValueError).

Closes DisnakeDev#982
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 disnake | 🛠️ Build #33755700 | 📁 Comparing d511006 against latest (6692351)

  🔍 Preview build  

48 files changed · ± 48 modified

± Modified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Parameter injections don't support autocomplete when nested

2 participants