Skip to content

Conversation

@tristanlatr
Copy link
Contributor

When option -W is used, all warnings issued with the warnings module now makes pydoctor exit with code 3.

As a drive-by-change stop emitting warnings when parsing a regex.

Fixes #930

…now makes pydoctor exit with code 3.

As a drive-by-change stop emitting warnings when parsing a regex.

Fixes #930
@codecov
Copy link

codecov bot commented Nov 8, 2025

Codecov Report

❌ Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.28%. Comparing base (3268e1c) to head (442e201).

Files with missing lines Patch % Lines
pydoctor/templatewriter/util.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #933      +/-   ##
==========================================
+ Coverage   93.26%   93.28%   +0.01%     
==========================================
  Files          48       48              
  Lines        8895     8906      +11     
  Branches     1634     1634              
==========================================
+ Hits         8296     8308      +12     
  Misses        339      339              
+ Partials      260      259       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@tristanlatr tristanlatr requested a review from a team November 13, 2025 02:04
@github-actions

This comment has been minimized.

Copy link
Member

@twm twm left a comment

Choose a reason for hiding this comment

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

Looks good! Please do fix the changelog message before merge.

Thanks!

from pydoctor.utils import warn
warn(f"Your custom template '{template.name}' is out of date, "
"information might be missing. "
"Latest templates are available to download from our github." )
Copy link
Member

Choose a reason for hiding this comment

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

FWIW, a link would be more actionable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I agree, but the chalenge is to provide the right link. And that depends on the current pydoctor version, so this would add more complexity

"""
import warnings
warnings.warn(msg, category=PydoctorWarning)
_warned.set(True)
Copy link
Member

Choose a reason for hiding this comment

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

It feels a little delicate that all warnings emitted by pydoctor need to go through this function for the error status to track. There's nothing beyond familiarity with the codebase to guide future contributions down this path.

Could this be made more robust? Perhaps a lint rule could forbid direct use of warnings.warn()?

Copy link
Contributor Author

@tristanlatr tristanlatr Nov 16, 2025

Choose a reason for hiding this comment

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

We don’t have this kind of custom linting in place at the moment. I suppose this can be implemented with a semgrep pattern. But do you have another idea to enforce this ?

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps flake8-tidy-imports banned-api? I've used it to banish os.system() before.

Co-authored-by: Tom Most <[email protected]>
@tristanlatr
Copy link
Contributor Author

Many thanks for your review @twm, I’ll fix the CI, create issues for improvements cited and merge the PR.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link

According to pydoctor_primer, this change doesn't affect pydoctor warnings on a corpus of open source code. ✅

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.

When option -W is used, an warning internally issued with the warnings module should make pydoctor exit with code 3

2 participants