Skip to content

dataclasses.dataclass wrapper brokes Fraction #134014

@TiunovNN

Description

@TiunovNN

Bug report

Bug description:

from dataclasses import dataclass
from fractions import Fraction

print(Fraction('30/1'))
dataclass(Fraction)
print(Fraction('30/1'))

If the dataclass function is called with argument Fraction, it brokes __init__ for Fraction

output is:

30
Traceback (most recent call last):
  File "/Users/tiunovnn/git/video-compression-model/web/api/src/tasks/test.py", line 6, in <module>
    print(Fraction('30/1'))
          ~~~~~~~~^^^^^^^^
TypeError: Fraction.__init__() takes 1 positional argument but 2 were given

expected output is:

30
30

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-dataclassestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions