GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Minor mistake in dataclasses documentation update · Issue #108267 · python/cpython

Minor mistake in dataclasses documentation update #108267

New issue
Copy link
New issue
Copy link
Closed
Closed
Minor mistake in dataclasses documentation update#108267
Copy link
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dir

Description

@FrozenBob
FrozenBob
opened on Aug 22, 2023
Issue body actions

An update to the dataclasses docs, intended to make magic method names link to the relevant data model documentation, accidentally changed a line that shouldn't have been changed.

The docs used to say

There is a tiny performance penalty when using frozen=True: __init__() cannot use simple assignment to initialize fields, and must use object.__setattr__().

The documentation update accidentally changed object.__setattr__ to just __setattr__ here, so now it reads

There is a tiny performance penalty when using frozen=True: __init__() cannot use simple assignment to initialize fields, and must use __setattr__().

This line was specifically meant to refer to object.__setattr__, the __setattr__ method of the base object class, as simple attribute assignment would hit the frozen dataclass's __setattr__ override.

This part of the documentation should be reverted. I think it should just take a 1-character change, simply removing a tilde.

Linked PRs

  • gh-108267: Dataclasses docs line should have said "object.__setattr__" instead of just "__setattr__" #108355
  • [3.11] gh-108267: Dataclasses docs: Fix object.__setattr__ typo (GH-108355) #108357
  • [3.12] gh-108267: Dataclasses docs: Fix object.__setattr__ typo (GH-108355) #108358
  • gh-108267: Fix object.__setattr__ regression in dataclasses docs #119082
  • [3.13] gh-108267: Fix object.__setattr__ regression in dataclasses docs (GH-119082) #119097
  • [3.12] gh-108267: Fix object.__setattr__ regression in dataclasses docs (GH-119082) #119098
  • gh-108267 Fix another dataclasses docs typo #119277
  • [3.13] gh-108267 Fix another dataclasses docs typo (GH-119277) #119279
  • [3.12] gh-108267 Fix another dataclasses docs typo (GH-119277) #119280
Reacted by Alex Waygood

Activity

Next
  1. FrozenBob
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Aug 22, 2023
  2. ericvsmith commented on Aug 22, 2023

    @ericvsmith
    ericvsmith
    on Aug 22, 2023
    Member
    More actions

    I'm no sphinx expert. Would removing a tilde restore the output text to be object.__setattr__? That's what I think should be displayed.

  3. hugovk commented on Aug 22, 2023

    @hugovk
    hugovk
    on Aug 22, 2023
    Member
    More actions

    Yes, removing the tilde gives object.__setattr__():

    image

    @FrozenBob Thanks for the report, would you like to create a PR to fix this?

  4. hugovk
    added
    3.11only security fixesonly security fixes
    3.12only security fixesonly security fixes
    3.13only security fixesonly security fixes
    on Aug 22, 2023
  5. ericvsmith commented on Aug 22, 2023

    @ericvsmith
    ericvsmith
    on Aug 22, 2023
    Member
    More actions

    Yes, removing the tilde gives object.__setattr__():

    How on earth is someone supposed to know that? Seriously: where could I find out more info? I'd like to get better at this.

  6. AlexWaygood commented on Aug 22, 2023

    @AlexWaygood
    AlexWaygood
    on Aug 22, 2023
    Member
    More actions

    @ericvsmith there's some useful info on the markup in the devguide here (in particular, see the "quick reference" section at the top of the page): https://devguide.python.org/documentation/markup/

    Reacted by Eric V. Smith
  7. AlexWaygood commented on Aug 22, 2023

    @AlexWaygood
    AlexWaygood
    on Aug 22, 2023
    Member
    More actions

    If we just remove the tilde, the link will take people to the entry in the data model documentation for the __setattr__ magic method, rather than the docs for object.__setattr__ itself (we have no docs for object.__setattr__ itself). Maybe it would be better in this case to suppress the link entirely?

    :meth:`!object.__setattr__`

    That will render as object.__setattr__() in the HTML documentation, but won't add a link.

    Reacted by Hugo van Kemenade
  8. FrozenBob commented on Aug 22, 2023

    @FrozenBob
    FrozenBob
    on Aug 22, 2023
    ContributorAuthor
    More actions

    Suppressing the link sounds reasonable to me.

  9. ericvsmith commented on Aug 22, 2023

    @ericvsmith
    ericvsmith
    on Aug 22, 2023
    Member
    More actions

    Suppressing the link sounds reasonable to me.

    Agreed.

  10. AlexWaygood
    added a commit that references this issue on Aug 23, 2023

    gh-108267: Dataclasses docs: Fix object.__setattr__ typo (#108355)

    79fdacc
  11. miss-islington
    added 2 commits that reference this issue on Aug 23, 2023

    pythongh-108267: Dataclasses docs: Fix object.__setattr__ typo (pytho…

    dc39f83

    pythongh-108267: Dataclasses docs: Fix object.__setattr__ typo (pytho…

    3276d2b
  12. AlexWaygood
    added a commit that references this issue on Aug 23, 2023

    [3.11] gh-108267: Dataclasses docs: Fix object.__setattr__ typo (GH-1…

    1ecbe78
  13. 12 remaining items

  14. AlexWaygood
    added 2 commits that reference this issue on May 16, 2024

    [3.12] gh-108267: Fix object.__setattr__ regression in dataclasses do…

    a3db4e8

    [3.13] gh-108267: Fix object.__setattr__ regression in dataclasses do…

    c69fe80
  15. FrozenBob commented on May 17, 2024

    @FrozenBob
    FrozenBob
    on May 17, 2024
    ContributorAuthor
    More actions

    I think you might need an extra blank line before the comment or something - it's rendering in the generated documentation.

    Reacted by Alex Waygood
  16. AlexWaygood
    reopened this on May 17, 2024
  17. FrozenBob commented on May 17, 2024

    @FrozenBob
    FrozenBob
    on May 17, 2024
    ContributorAuthor
    More actions

    I see a confused emoji. In case it wasn't clear, this is what's showing up in the docs now:

    There is a tiny performance penalty when using frozen=True: __init__() cannot use simple assignment to initialize fields, and must use object.__setattr__(). .. Make sure to not remove “object” from “object.__setattr__” in the above markup

    The part starting with the ".." looks like it was supposed to be a reStructuredText comment, but it's showing up in the actual documentation. I think this may be because it needs a blank line above it.

  18. AlexWaygood commented on May 17, 2024

    @AlexWaygood
    AlexWaygood
    on May 17, 2024
    Member
    More actions

    I understood the problem — sorry for the ambiguous reaction emoji I applied! I suppose I intended to convey that I was frustrated at myself for not checking the docs preview before merging, but sadly there's no reaction emoji for that exact sentiment ;-)

    Reacted by Jelle Zijlstra
  19. AlexWaygood
    added 2 commits that reference this issue on May 20, 2024

    pythongh-108267 Fix another dataclasses docs typo

    8712526

    gh-108267 Fix another dataclasses docs typo (#119277)

    423bbcb
  20. miss-islington
    added 2 commits that reference this issue on May 20, 2024

    pythongh-108267 Fix another dataclasses docs typo (pythonGH-119277)

    eef7822

    pythongh-108267 Fix another dataclasses docs typo (pythonGH-119277)

    fedf28d
  21. AlexWaygood
    added 2 commits that reference this issue on May 20, 2024

    [3.12] gh-108267 Fix another dataclasses docs typo (GH-119277) (#119280)

    cdccafb

    [3.13] gh-108267 Fix another dataclasses docs typo (GH-119277) (#119279)

    d8fbe5b
  22. AlexWaygood
    closed this as completedon May 20, 2024
  23. estyxx
    added 2 commits that reference this issue on Jul 17, 2024

    pythongh-108267: Fix object.__setattr__ regression in dataclasses docs (

    4926303

    pythongh-108267 Fix another dataclasses docs typo (python#119277)

    966463a
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

    3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.