Skip to content

[autodoc] please avoid evaluating default function arguments #2844

Closed

Description

@mitya57

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.)

Activity

  1. peterjc commented on Sep 24, 2018

    @peterjc
    Contributor

    This looks like a duplicate of #759 to me.

  2. tgandor commented on Feb 12, 2020

    @tgandor

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

  3. mitya57 commented on Feb 12, 2020

    @mitya57
    ContributorAuthor

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

  4. tk0miya commented on Feb 13, 2020

    @tk0miya
    Member

    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.

  5. added this to the 3.0.0 milestone on Feb 13, 2020
  6. modified the milestones: 3.0.0, 3.1.0 on Mar 14, 2020
  7. modified the milestones: 3.1.0, 3.2.0 on May 30, 2020
  8. modified the milestones: 3.2.0, 3.3.0 on Aug 7, 2020
  9. modified the milestones: 3.3.0, 3.4.0 on Nov 1, 2020
  10. modified the milestones: 3.4.0, 3.5.0 on Dec 19, 2020
  11. modified the milestones: 3.5.0, 4.0.0 on Feb 4, 2021
  12. tk0miya commented on Mar 6, 2021

    @tk0miya
    Member

    Will be fixed by #8771. Closing.

  13. locked as resolved and limited conversation to collaborators on Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions