Skip to content

Make Rule's unasync functions public for overwriting#84

Merged
pquentin merged 3 commits intopython-trio:masterfrom
robsdedude:feat/public-rule-unasync-funcs
Feb 5, 2026
Merged

Make Rule's unasync functions public for overwriting#84
pquentin merged 3 commits intopython-trio:masterfrom
robsdedude:feat/public-rule-unasync-funcs

Conversation

@robsdedude
Copy link
Contributor

I propose to make the unasync functions of Rule public so that custom Rule implementations can more easily inherit from Rule and change the exact replacement mechanisms.

Here are my use-cases that this would enable without having to rely on internal APIs:

  • I have code examples in doc strings and I want to unasync those as well. Hence the need for a custom unasync_string)
  • I have doc references that I want to unasync. E.g., from :ref:`async-thingamajig` to :ref:`thingamajig`.
  • I want to have a more complex replacement customization that just a hard-coded mapping of identifiers. E.g. something like this
    len(name) > 6 and name.startswith("async_"):
        return name[6:]

@robsdedude robsdedude force-pushed the feat/public-rule-unasync-funcs branch from 5d08d89 to aff9c84 Compare September 29, 2025 15:39
Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

I'm not sure I want to encourage Rule inheritance, since we could break it later, especially since there are no tests. But happy to merge if it helps you.

@pquentin pquentin merged commit 0470588 into python-trio:master Feb 5, 2026
23 checks passed
@trio-bot
Copy link

trio-bot bot commented Feb 5, 2026

Hey @robsdedude, it looks like that was the first time we merged one of your PRs! Thanks so much! 🎉 🎂

If you want to keep contributing, we'd love to have you. So, I just sent you an invitation to join the python-trio organization on Github! If you accept, then here's what will happen:

  • Github will automatically subscribe you to notifications on all our repositories. (But you can unsubscribe again if you don't want the spam.)

  • You'll be able to help us manage issues (add labels, close them, etc.)

  • You'll be able to review and merge other people's pull requests

  • You'll get a [member] badge next to your name when participating in the Trio repos, and you'll have the option of adding your name to our member's page and putting our icon on your Github profile (details)

If you want to read more, here's the relevant section in our contributing guide.

Alternatively, you're free to decline or ignore the invitation. You'll still be able to contribute as much or as little as you like, and I won't hassle you about joining again. But if you ever change your mind, just let us know and we'll send another invitation. We'd love to have you, but more importantly we want you to do whatever's best for you.

If you have any questions, well... I am just a humble Python script, so I probably can't help. But please do post a comment here, or in our chat, or on our forum, whatever's easiest, and someone will help you out!

@robsdedude robsdedude deleted the feat/public-rule-unasync-funcs branch February 5, 2026 09:55
@robsdedude
Copy link
Contributor Author

I'm not sure I want to encourage Rule inheritance, since we could break it later, especially since there are no tests. But happy to merge if it helps you.

Thanks, I really appreciate the pragmatic approach. If you have suggestions on a more solid design/approach, I'm happy work on it. Maybe configurable callbacks/hook or such?

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.

2 participants