Skip to content

Include module name in docstring examples#59

Merged
hagenw merged 1 commit into
mainfrom
doc-module-name
Jul 10, 2026
Merged

Include module name in docstring examples#59
hagenw merged 1 commit into
mainfrom
doc-module-name

Conversation

@hagenw

@hagenw hagenw commented Jul 10, 2026

Copy link
Copy Markdown
Member

To make it easier to copy and paste code examples, we have started to include module names in docstring examples in other packages (e.g. audb). Here we update audmodel to do so as well.

image

@sourcery-ai

sourcery-ai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Docstring examples across the audmodel core API now consistently use fully-qualified audmodel.* calls, and the doctest configuration injects the audmodel module into the doctest namespace so these examples run correctly.

Sequence diagram for doctest namespace including audmodel module

sequenceDiagram
    participant Pytest
    participant docstring_examples
    participant doctest_namespace
    participant audmodel

    Pytest->>docstring_examples: docstring_examples(doctest_namespace)
    docstring_examples->>doctest_namespace: set model_root
    docstring_examples->>doctest_namespace: set repository
    docstring_examples->>doctest_namespace: set audmodel
    Pytest-->>audmodel: execute doctest audmodel.author
    Pytest-->>audmodel: execute doctest audmodel.Repository
    Pytest-->>audmodel: execute doctest audmodel.config
Loading

File-Level Changes

Change Details Files
Qualify top-level API docstring examples with the audmodel module name.
  • Updated author/date/default_cache_root/exists/header/latest_version/legacy_uid/load/meta/name/parameters/publish/resolve_alias/aliases/set_alias/subgroup/uid/update_meta/url/version/versions examples to call functions as audmodel. rather than relying on bare names.
  • Adjusted multi-line doctest examples to preserve correct indentation and readability while adding the audmodel prefix.
audmodel/core/api.py
Qualify Repository usage and registration examples with audmodel and improve multi-line example formatting.
  • Changed Repository constructor example to audmodel.Repository(...) to match the new docstring style.
  • Reformatted Repository.register doctest into a multi-line call scoped under audmodel.Repository.register for better copy-paste usability.
audmodel/core/repository.py
Qualify config usage in docstring examples with audmodel.config.
  • Replaced bare config.CACHE_ROOT doctest references with audmodel.config.CACHE_ROOT for consistency with other examples.
audmodel/core/config.py
Expose the audmodel module in doctest namespace to support the new fully qualified examples.
  • Extended docstring_examples fixture comment to mention audmodel and assigned doctest_namespace['audmodel'] = audmodel so doctest examples using audmodel.* run without additional imports.
audmodel/core/conftest.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@hagenw
hagenw merged commit b2cc0df into main Jul 10, 2026
12 checks passed
@hagenw
hagenw deleted the doc-module-name branch July 10, 2026 11:34
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.

1 participant