Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 62b7059

Browse filesBrowse files
committed
Deduplicate inherited docstrings.
Since Py3.5, inspect.getdoc inherits method docstrings from super-methods (pydoc, sphinx, and IPython's ? do the same). Take advantage of this to deduplicate some docstrings that were already defined for the Artist base methods. Note that Text.set_clip_path's docstring had actually not been updated when we updated the docstring of Artist.set_clip_path... We could add a decorator to check that the docstring is *actually* getting inherited but that seems totally overkill.
1 parent 8d66b47 commit 62b7059
Copy full SHA for 62b7059

File tree

Expand file treeCollapse file tree

3 files changed

+11
-44
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+11
-44
lines changed

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ def get_aliases(self):
11911191
if not self.is_alias(func):
11921192
continue
11931193
propname = re.search("`({}.*)`".format(name[:4]), # get_.*/set_.*
1194-
func.__doc__).group(1)
1194+
inspect.getdoc(func)).group(1)
11951195
aliases.setdefault(propname, set()).add(name[4:])
11961196
return aliases
11971197

@@ -1213,7 +1213,7 @@ def get_valid_values(self, attr):
12131213
raise AttributeError('%s has no function %s' % (self.o, name))
12141214
func = getattr(self.o, name)
12151215

1216-
docstring = func.__doc__
1216+
docstring = inspect.getdoc(func)
12171217
if docstring is None:
12181218
return 'unknown'
12191219

@@ -1279,7 +1279,7 @@ def get_setters(self):
12791279

12801280
def is_alias(self, o):
12811281
"""Return whether method object *o* is an alias for another method."""
1282-
ds = o.__doc__
1282+
ds = inspect.getdoc(o)
12831283
if ds is None:
12841284
return False
12851285
return ds.startswith('Alias for ')

‎lib/matplotlib/tests/test_artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_artist.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,12 @@ def test_None_zorder():
258258

259259
@pytest.mark.parametrize('accept_clause, expected', [
260260
('', 'unknown'),
261-
("ACCEPTS: [ '-' | '--' | '-.' ]", "[ '-' | '--' | '-.' ] "),
262-
('ACCEPTS: Some description.', 'Some description. '),
263-
('.. ACCEPTS: Some description.', 'Some description. '),
261+
("ACCEPTS: [ '-' | '--' | '-.' ]", "[ '-' | '--' | '-.' ]"),
262+
('ACCEPTS: Some description.', 'Some description.'),
263+
('.. ACCEPTS: Some description.', 'Some description.'),
264264
('arg : int', 'int'),
265265
('*arg : int', 'int'),
266-
('arg : int\nACCEPTS: Something else.', 'Something else. '),
266+
('arg : int\nACCEPTS: Something else.', 'Something else.'),
267267
])
268268
def test_artist_inspector_get_valid_values(accept_clause, expected):
269269
class TestArtist(martist.Artist):

‎lib/matplotlib/text.py

Copy file name to clipboardExpand all lines: lib/matplotlib/text.py
+4-37Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -542,50 +542,17 @@ def _update_clip_properties(self):
542542
bbox = self._bbox_patch.update(clipprops)
543543

544544
def set_clip_box(self, clipbox):
545-
"""
546-
Set the artist's clip `~.transforms.Bbox`.
547-
548-
Parameters
549-
----------
550-
clipbox : `matplotlib.transforms.Bbox`
551-
"""
545+
# docstring inherited.
552546
super().set_clip_box(clipbox)
553547
self._update_clip_properties()
554548

555549
def set_clip_path(self, path, transform=None):
556-
"""
557-
Set the artist's clip path, which may be:
558-
559-
* a `~matplotlib.patches.Patch` (or subclass) instance
560-
561-
* a `~matplotlib.path.Path` instance, in which case
562-
an optional `~matplotlib.transforms.Transform`
563-
instance may be provided, which will be applied to the
564-
path before using it for clipping.
565-
566-
* *None*, to remove the clipping path
567-
568-
For efficiency, if the path happens to be an axis-aligned
569-
rectangle, this method will set the clipping box to the
570-
corresponding rectangle and set the clipping path to *None*.
571-
572-
ACCEPTS: { (`.path.Path`, `.transforms.Transform`),
573-
`.patches.Patch`, None }
574-
"""
550+
# docstring inherited.
575551
super().set_clip_path(path, transform)
576552
self._update_clip_properties()
577553

578554
def set_clip_on(self, b):
579-
"""
580-
Set whether artist uses clipping.
581-
582-
When False, artists will be visible outside of the axes, which can lead
583-
to unexpected results.
584-
585-
Parameters
586-
----------
587-
b : bool
588-
"""
555+
# docstring inherited.
589556
super().set_clip_on(b)
590557
self._update_clip_properties()
591558

@@ -1261,7 +1228,7 @@ def get_usetex(self):
12611228

12621229
def set_fontname(self, fontname):
12631230
"""
1264-
Alias for `.set_family`.
1231+
Alias for `set_family`.
12651232
12661233
One-way alias only: the getter differs.
12671234

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.