Skip to content

docs: explicitly document that @dispatch must be the inner decorator#254

Open
Copilot wants to merge 6 commits intomasterfrom
copilot/update-docs-dispatch-decorator
Open

docs: explicitly document that @dispatch must be the inner decorator#254
Copilot wants to merge 6 commits intomasterfrom
copilot/update-docs-dispatch-decorator

Conversation

Copy link

Copilot AI commented Feb 19, 2026

Users combining @dispatch with decorators like @staticmethod may encounter confusing errors if the decorator order is wrong. The docs previously showed @dispatch as an inner decorator without ever stating this is a requirement.

fixes #201

Changes

  • docs/classes.md: Updated the "Decorators" section to explicitly state that @dispatch must always be the inner decorator (closest to the function definition), and added a @staticmethod example illustrating the correct ordering:
from plum import dispatch

class MyClass:
    @staticmethod
    @dispatch
    def my_func(a: int, b: int) -> int:
        return a + b

    @staticmethod
    @dispatch
    def my_func(a: float, b: float) -> float:
        return a + b

Placing @dispatch outer (e.g. @dispatch above @staticmethod) breaks dispatch silently; the rule is now called out explicitly.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…xample

Co-authored-by: nstarman <8949649+nstarman@users.noreply.github.com>
Copilot AI changed the title [WIP] Update documentation to clarify @dispatch as inner decorator docs: explicitly document that @dispatch must be the inner decorator Feb 19, 2026
Copilot AI requested a review from nstarman February 19, 2026 17:03
@coveralls
Copy link

coveralls commented Feb 19, 2026

Pull Request Test Coverage Report for Build 22192585753

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 99.591%

Totals Coverage Status
Change from base Build 22190629474: 0.0%
Covered Lines: 973
Relevant Lines: 977

💛 - Coveralls

@nstarman nstarman marked this pull request as ready for review February 19, 2026 17:15
Copilot AI review requested due to automatic review settings February 19, 2026 17:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the documentation in docs/classes.md to explicitly state that @dispatch must be the inner decorator when combined with other decorators. The documentation previously showed this pattern implicitly in examples but never explicitly stated it as a requirement, which could lead to confusing errors for users.

Changes:

  • Added explicit statement that @dispatch should generally be the inner decorator when combined with other decorators
  • Added a new example demonstrating the correct decorator ordering with @staticmethod
  • Provided example output showing the expected behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nstarman nstarman requested a review from Copilot February 19, 2026 17:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

Py3.8 staticmethod decorator no attribute __qualname__

3 participants

Comments