Skip to content

Commit

Permalink
Merge pull request #8896 from tk0miya/8883_AttributeError_assigning_a…
Browse files Browse the repository at this point in the history
…nnotations

Fix #8883: autodoc: AttributeError on assigning __annotations__
  • Loading branch information
tk0miya committed Feb 16, 2021
2 parents 66539af + b29ee3d commit e2bef2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES
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
* #8885: html: AttributeError is raised if CSS/JS files are installed via
:confval:`html_context`
Expand Down
6 changes: 3 additions & 3 deletions sphinx/ext/autodoc/__init__.py
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

0 comments on commit e2bef2d

Please sign in to comment.