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 #8883: autodoc: AttributeError on assigning __annotations__ #8896

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Features added
Bugs fixed
----------

* #8883: autodoc: AttributeError is raised on assigning __annotations__ on
read-only class
* #8884: html: minified js stemmers not included in the distributed package
* #8880: viewcode: ExtensionError is raised on incremental build after
unparsable python module found
Expand Down
6 changes: 3 additions & 3 deletions sphinx/ext/autodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,7 @@ def annotate_to_first_argument(self, func: Callable, typ: Type) -> None:
params[0] = params[0].replace(annotation=typ)
try:
func.__signature__ = sig.replace(parameters=params) # type: ignore
except TypeError:
except (AttributeError, TypeError):
# failed to update signature (ex. built-in or extension types)
return

Expand Down Expand Up @@ -2177,7 +2177,7 @@ def annotate_to_first_argument(self, func: Callable, typ: Type) -> None:
params[1] = params[1].replace(annotation=typ)
try:
func.__signature__ = sig.replace(parameters=params) # type: ignore
except TypeError:
except (AttributeError, TypeError):
# failed to update signature (ex. built-in or extension types)
return

Expand Down Expand Up @@ -2443,7 +2443,7 @@ def update_annotations(self, parent: Any) -> None:
annotations[attrname] = annotation
except (AttributeError, PycodeError):
pass
except TypeError:
except (AttributeError, TypeError):
# Failed to set __annotations__ (built-in, extensions, etc.)
pass

Expand Down