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

documentation: numbers module nitpick #76314

Closed
abcdef mannequin opened this issue Nov 25, 2017 · 8 comments
Closed

documentation: numbers module nitpick #76314

abcdef mannequin opened this issue Nov 25, 2017 · 8 comments
Assignees
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy type-feature A feature request or enhancement

Comments

@abcdef
Copy link
Mannequin

abcdef mannequin commented Nov 25, 2017

BPO 32133
Nosy @rhettinger, @skirpichev, @miss-islington, @miguendes
PRs
  • bpo-32133: Improve numbers docs #26124
  • [3.9] bpo-32133: Improve numbers docs (GH-26124) #26147
  • [3.10] bpo-32133: Improve numbers docs (GH-26124) #26149
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/rhettinger'
    closed_at = <Date 2021-05-15.17:29:29.146>
    created_at = <Date 2017-11-25.18:31:43.555>
    labels = ['easy', '3.9', '3.10', '3.11', 'type-feature', 'docs']
    title = 'documentation: numbers module nitpick'
    updated_at = <Date 2021-05-15.17:29:29.146>
    user = 'https://bugs.python.org/abcdef'

    bugs.python.org fields:

    activity = <Date 2021-05-15.17:29:29.146>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2021-05-15.17:29:29.146>
    closer = 'rhettinger'
    components = ['Documentation']
    creation = <Date 2017-11-25.18:31:43.555>
    creator = 'abcdef'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32133
    keywords = ['patch', 'easy']
    message_count = 8.0
    messages = ['306970', '393636', '393673', '393679', '393705', '393706', '393720', '393721']
    nosy_count = 7.0
    nosy_names = ['rhettinger', 'docs@python', 'abcdef', 'Sergey.Kirpichev', 'miss-islington', 'miguendes', 'adityasriram.b']
    pr_nums = ['26124', '26147', '26149']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32133'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @abcdef
    Copy link
    Mannequin Author

    abcdef mannequin commented Nov 25, 2017

    Documentation of the numbers module:
    https://docs.python.org/3/library/numbers.html
    states "None of the types defined in this module can be instantiated."

    This is true for Complex, Real, Rational, Integral but not for Number:

    >>> numbers.Number()
    <numbers.Number object at 0x7fcccc71f3c0>
    >>> numbers.Real()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: Can't instantiate abstract class Real...

    Since Number doesn't have any abstract methods, the correct fix seems to be changing the documentation. I would try to convey something like this:

    "The types defined in this module can be used for subclassing and checking whether a specific class is in the numeric hierarchy; they are not used directly for instantiation. For this, you can use types such as complex or fractions.Fraction".

    @abcdef abcdef mannequin assigned docspython Nov 25, 2017
    @abcdef abcdef mannequin added docs Documentation in the Doc dir type-feature A feature request or enhancement labels Nov 25, 2017
    @iritkatriel iritkatriel added easy 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes labels May 9, 2021
    @miguendes
    Copy link
    Mannequin

    miguendes mannequin commented May 14, 2021

    Seen that nobody is working on this I transformed the suggestion into a PR.

    @adityasriramb
    Copy link
    Mannequin

    adityasriramb mannequin commented May 14, 2021

    I would like work on this, but I'm very new to fixing bugs. Could someone please help me on how to proceed with this bug. Thank You in advance

    @rhettinger
    Copy link
    Contributor

    Here's a minimal change:

    • None of the types defined in this module can be instantiated.
      + None of the types defined in this module are intended to be instantiated.

    @miguendes
    Copy link
    Mannequin

    miguendes mannequin commented May 15, 2021

    @rhettinger added your suggestion.

    @skirpichev
    Copy link
    Mannequin

    skirpichev mannequin commented May 15, 2021

    Maybe some methods from the Complex class could be moved to the Number class?

    I think, that something like the ring structure (probably even a commutative ring) is expected from the number classes in the Python. I.e. there should be __add__/sub/mul/pos/neg/pow/etc. But not __truediv__/floordiv.

    Even simpler idea: move the __eq__ method to the Number class.

    Then it would be impossible to instantiate a Number.

    @rhettinger
    Copy link
    Contributor

    New changeset 3767401 by Miss Islington (bot) in branch '3.9':
    bpo-32133: Improve numbers docs (GH-26124) (GH-26147)
    3767401

    @rhettinger
    Copy link
    Contributor

    New changeset a38db84 by Miss Islington (bot) in branch '3.10':
    bpo-32133: Improve numbers docs (GH-26124) (GH-26149)
    a38db84

    @rhettinger rhettinger assigned rhettinger and unassigned docspython May 15, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants