Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#753): API documentation for unittest.mock #754

Merged
merged 3 commits into from
Oct 23, 2024

Conversation

bryant-finney
Copy link
Contributor

@bryant-finney bryant-finney commented Oct 23, 2024

Closes #753

Resolve the TypeError by testing for the __contains__ attribute

@bryant-finney bryant-finney changed the title fix(mitmproxy/pdoc#753): Fix API documentation for unittest.mock fix(#753): Fix API documentation for unittest.mock Oct 23, 2024
... by checking for the `__contains__` attribute

Signed-off-by: Bryant Finney <[email protected]>
@bryant-finney bryant-finney marked this pull request as ready for review October 23, 2024 01:13
@bryant-finney bryant-finney changed the title fix(#753): Fix API documentation for unittest.mock fix(#753): API documentation for unittest.mock Oct 23, 2024
Copy link
Member

@mhils mhils left a comment

Choose a reason for hiding this comment

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

Thanks! 🍰

pdoc/doc.py Outdated
@@ -445,7 +445,7 @@ def _taken_from(self, member_name: str, obj: Any) -> tuple[str, str]:

mod = _safe_getattr(obj, "__module__", None)
qual = _safe_getattr(obj, "__qualname__", None)
if mod and qual and "<locals>" not in qual:
if mod and hasattr(qual, "__contains__") and "<locals>" not in qual:
Copy link
Member

Choose a reason for hiding this comment

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

Do you think

Suggested change
if mod and hasattr(qual, "__contains__") and "<locals>" not in qual:
if mod and isinstance(qual, str) and "<locals>" not in qual:

would maybe be more appropriate here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, nice catch 👍 (should have checked the signature)

bryant-finney added a commit to bryant-finney/pdoc that referenced this pull request Oct 23, 2024
... from @mhils during mitmproxy#754

Signed-off-by: Bryant Finney <[email protected]>
... from @mhils during mitmproxy#754

Signed-off-by: Bryant Finney <[email protected]>
Copy link
Member

@mhils mhils left a comment

Choose a reason for hiding this comment

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

Thanks!

@mhils mhils merged commit d44d4f8 into mitmproxy:main Oct 23, 2024
14 checks passed
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.

TypeError: argument of type '_SentinelObject' is not iterable (unittest.mock)
2 participants