Skip to content

Add missing __doctest_skip__ directive in some methods/functions - #4309

Merged
seisman merged 1 commit into
mainfrom
doctest_skip
Dec 20, 2025
Merged

Add missing __doctest_skip__ directive in some methods/functions#4309
seisman merged 1 commit into
mainfrom
doctest_skip

Conversation

@seisman

Copy link
Copy Markdown
Member

Some doctests are mainly intended to demonstrate the usage of functions or methods rather than for actual testing. Such tests can be skipped using the __doctest_skip__ directive (initially introduced in PR #1790). However, it's easy to forget to add this directive to some methods or functions.

To help identify these cases, I asked ChatGPT to write a simple Python script that finds modules containing doctests but missing the __doctest_skip__ directive. It works, but still flags modules that shouldn't be reported. Thus, we can't add it to our CI workflow, but we can sometimes run it and review the report manually.

importdoctestimportpkgutilimportpygmtTARGETS= ("pygmt.src", "pygmt.datasets", "pygmt.params")
missing= []
formodinfoinpkgutil.walk_packages(pygmt.__path__, pygmt.__name__+"."):
name=modinfo.nameifnotname.startswith(TARGETS):
continuemodule=__import__(name, fromlist=["*"])
# Detect whether the module actually contains doctestsfinder=doctest.DocTestFinder()
tests=finder.find(module)
ifnotany(test.examplesfortestintests):
continueif"__doctest_skip__"notinmodule.__dict__:
missing.append(name)
ifmissing:
print(
"__doctest_skip__ missing in modules that contain doctests:\n"+"\n".join(f" - {m}"forminmissing)
)

This PR adds the missing __doctest_skip__ directives to the appropriate methods and functions.

@seismanseisman added this to the 0.18.0 milestone Dec 20, 2025
@seismanseisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog final review call This PR requires final review and approval from a second reviewer labels Dec 20, 2025
@seismanseisman removed the final review call This PR requires final review and approval from a second reviewer label Dec 20, 2025
@seisman
seisman merged commit 3f7c24d into mainDec 20, 2025
23 checks passed
@seisman
seisman deleted the doctest_skip branch December 20, 2025 18:10
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenanceBoring but important stuff for the core devsskip-changelogSkip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@seisman@yvonnefroehlich