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

[autodoc] please avoid evaluating default function arguments #2844

Closed
mitya57 opened this issue Aug 11, 2016 · 5 comments
Closed

[autodoc] please avoid evaluating default function arguments #2844

mitya57 opened this issue Aug 11, 2016 · 5 comments
Labels
Milestone

Comments

@mitya57
Copy link
Contributor

mitya57 commented Aug 11, 2016

Currently if Sphinx encounters a function like this:

def age(self, now=datetime.datetime.utcnow()):

It generates output like this:

age(now=datetime.datetime(2016, 8, 5, 7, 33, 8, 845335))

I think it is confusing and should be avoided.
(Originally reported at Debian #833820.)

@peterjc
Copy link
Contributor

peterjc commented Sep 24, 2018

This looks like a duplicate of #759 to me.

@tgandor
Copy link

tgandor commented Feb 12, 2020

@mitya57 - this example is cool, however the function is wrong ;) The default now would be only evaluated at time of function definition.

@mitya57
Copy link
Contributor Author

mitya57 commented Feb 12, 2020

I know, I said exactly that in the linked downstream bug.

@tk0miya
Copy link
Member

tk0miya commented Feb 13, 2020

I made a super experimental extension for this.
https://gist.github.com/4279adc2d6ff4da52ea73c18cfdd229a
スクリーンショット 2020-02-13 2 04 31

I'd like to know side effect to enable this by default. So it might be needed to add a new option to enable it.

@tk0miya tk0miya added this to the 3.0.0 milestone Feb 13, 2020
@tk0miya tk0miya modified the milestones: 3.0.0, 3.1.0 Mar 14, 2020
@tk0miya tk0miya modified the milestones: 3.1.0, 3.2.0 May 30, 2020
@tk0miya tk0miya modified the milestones: 3.2.0, 3.3.0 Aug 7, 2020
@tk0miya tk0miya modified the milestones: 3.3.0, 3.4.0 Nov 1, 2020
@tk0miya tk0miya modified the milestones: 3.4.0, 3.5.0 Dec 19, 2020
@tk0miya tk0miya modified the milestones: 3.5.0, 4.0.0 Feb 4, 2021
@tk0miya
Copy link
Member

tk0miya commented Mar 6, 2021

Will be fixed by #8771. Closing.

@tk0miya tk0miya closed this as completed Mar 6, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants