Skip to content

Commit

Permalink
Don't fail when docstrings have been stripped by -OO mode (#2473)
Browse files Browse the repository at this point in the history
* Don't fail when docstrings have been stripped by -OO mode

Fixes #2470

* Fix comment

* Clarify language
  • Loading branch information
mwaskom authored Feb 5, 2021
1 parent a19db39 commit 8f83a4d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions seaborn/_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,22 @@ def __init__(self, comp_dict, strip_whitespace=True):
self.entries = entries

def __getattr__(self, attr):
"""Provided dot access to entries."""
"""Provide dot access to entries for clean raw docstrings."""
if attr in self.entries:
return self.entries[attr]
else:
return self.__getattribute__(attr)
try:
return self.__getattribute__(attr)
except AttributeError as err:
# If Python is run with -OO, it will strip docstrings and our lookup
# from self.entries will fail. We check for __debug__, which is actually
# set to False by -O (it is True for normal execution).
# But we only want to see an error when building the docs;
# not something users should see, so this slight inconsistency is fine.
if __debug__:
raise err
else:
pass

@classmethod
def from_nested_components(cls, **kwargs):
Expand Down

0 comments on commit 8f83a4d

Please sign in to comment.