mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
test_autodoc: fix mutable function default argument in do_autodoc
Setting mutable types as default arguments is bad practice because the value is only initialised once. This means that defaults arguments of lists and dictionaries which are modified during code execution *stay* modified between calls. In this case, the `options` dictionary accumulated options as more and more test cases were executed. Without this change, the tests added in the next commit do not pass. See: https://stackoverflow.com/questions/1132941/least-astonishment-and-the-mutable-default-argument
This commit is contained in:
parent
9cddc344db
commit
87029392fd
@ -34,7 +34,9 @@ else:
|
||||
ROGER_METHOD = ' .. py:classmethod:: Class.roger(a, e=5, f=6)'
|
||||
|
||||
|
||||
def do_autodoc(app, objtype, name, options={}):
|
||||
def do_autodoc(app, objtype, name, options=None):
|
||||
if options is None:
|
||||
options = {}
|
||||
doccls = app.registry.documenters[objtype]
|
||||
docoptions = process_documenter_options(doccls, app.config, options)
|
||||
bridge = DocumenterBridge(app.env, LoggingReporter(''), docoptions, 1)
|
||||
|
Loading…
Reference in New Issue
Block a user