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

Improve the frozenset.is(sub|super)set docstrings #129622

Open
JDoepro-ctrl opened this issue Feb 3, 2025 · 10 comments
Open

Improve the frozenset.is(sub|super)set docstrings #129622

JDoepro-ctrl opened this issue Feb 3, 2025 · 10 comments
Labels
docs Documentation in the Doc dir

Comments

@JDoepro-ctrl
Copy link

JDoepro-ctrl commented Feb 3, 2025

Documentation

RE: Documentation provided by built-in function help()

While reviewing built-in methods in detail I made note of:

  • "help(frozenset)" issubset and issuperset methods both return bool type
Other comments that were not issues

See #129622 (comment).

  • "help(slice)" third parameter typo
  • "help(range)" third parameter typo
  • "help(float)" quizzical hex method example
  • "help(bool)" is bit_length method also for absolute value of self?
  • "help(bool)" is_integer appears duck-like compatible with int (TypeError with float)
  • "help(bool)" from_bytes appears to return a bool from byte array

Regards,
'EntryLevelJobSeeker'

Linked PRs

@JDoepro-ctrl JDoepro-ctrl added the docs Documentation in the Doc dir label Feb 3, 2025
@AA-Turner
Copy link
Member

AA-Turner commented Feb 3, 2025

Hi, this isn't a usable issue. Please provide sufficient context in bug reports, and consider first opening a discussion on Discourse.

A

@AA-Turner AA-Turner closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2025
@terryjreedy
Copy link
Member

terryjreedy commented Feb 4, 2025

The comments are clearer if one tries the given commands. My response for each argument.

slice and range: no typo. OP likely misunderstands that [, step] means 'optional.

float: the help response incorporates docstrings; OP likely does not understand p in float 'hex'. Must read doc to understand. Docstrings are reminders, not complete documentation.

frozenset.issubset: "Report whether another set contains this set." .issuperset: has similar docstring. These are very unusual docstrings. All others for frozenset say "Return ...", as is standard. OP is suggesting new docstring, something like "Return True if self is a subset of other, else False. Similarly for issuperset. I agree.

bool.bit_length: Docstring, inherited from 'int' uses 37 as an example, which is not applicable to bool. (Nor is question about absolute value. But (-37).bit_length() is 6, as for 37.) A customized docstring for bool.bit_length would require a customized function which seems a pain. Users should notice that bool subclasses int and then ignore example.

bool.is_integer: Inherited int docstring is "Returns True. Exists for duck type compatibility with float.is_integer." The second sentence makes more sense as an explanation of why ints have an 'is_integer'. float.is_integer works; (1.0).is_integer() returns True and (1.1).is_integer is False. No type error.

bool.from_bytes: this is not int.from_bytes. The docstring, which likely copies the int.from_bytes docstring, says "Return the integer ...", which is not wrong in that bools, like ints, are integers. It is proper that the subclass return a subclass instance.

To me (EDIT), the only valid issue is the frozenset docstrings. A new title might be "Improve the frozenset.is(sub|super)set docstrings"

@terryjreedy terryjreedy reopened this Feb 4, 2025
@AA-Turner AA-Turner changed the title Documentation return: help() Improve the frozenset.is(sub|super)set docstrings Feb 4, 2025
@picnixz picnixz added the easy label Feb 4, 2025
@JDoepro-ctrl
Copy link
Author

help(slice) and help(range) should be:
"slice(start, stop, step)". Maybe your system accepts the square bracket syntax. Mine does not.

help(float): Thanks. As a beginner my syntax is more like "float.hex(3.14)" not "3.14.hex()"

help(frozenset): Thank you for understanding.

help(bool): bool.bit_length: I will learn to ignore examples. I do not expect customization for a built-in child class. However it is good to know where the Boolean methods are inconsistent. When I write a Boolean 'test' for a collection which is a pain, I am well-informed that bool methods do not count the way I expect, specifically by sometimes accepting non-zero-or-one values. This is a critical observation of bool methods.

help(bool): bool.is_integer: The built-in bool.is_integer may only accept 0 and 1 equivalents. You discuss float.is_integer. I noticed that some bool-methods accept values other than 0 and 1.

help(bool): bool.from_bytes: The built-in method appeared to only accept inputs with byte-array representation of a binary value (as I recall).

@skirpichev
Copy link
Member

"slice(start, stop, step)". Maybe your system accepts the square bracket syntax.

As for range issue, #125897, I think we should use correct Python syntax here to describe function signatures.

@hridyasadanand
Copy link

Hi! I'm Hridya, a first-year BTech student eager to contribute to CPython's documentation. I'd like to work on this issue as part of my GSoC 2025 preparation. Could you please assign it to me?

@picnixz
Copy link
Member

picnixz commented Mar 28, 2025

The issue can be considered stalled as per #129637 (comment) so there is nothing else to do for that one. You can however try to pick up other easy-labeled issues that do not have an associated open PR.

@hridyasadanand
Copy link

Hi! I’m Hridya, a first-year BTech student learning Python. I’d love to work on this issue as part of my GSoC preparation. Can I take it?

@skirpichev skirpichev removed the easy label Mar 29, 2025
@skirpichev
Copy link
Member

Removed "easy" label. That doesn't seems to be an easy issue for me.

@AA-Turner
Copy link
Member

@hridyasadanand please stop spamming issues (#124210, #124210, #127541, #130536) etc. We don't assign issues. Please read the Developer's Guide on contributing to documentation.

A

@hridyasadanand
Copy link

@hridyasadanand please stop spamming issues (#124210, #124210, #127541, #130536) etc. We don't assign issues. Please read the Developer's Guide on contributing to documentation.

A

Sorry about that! I’m new to CPython contributions and didn’t realize I should just start working without assignment. I’ll go through the Developer’s Guide and pick an issue properly. Thanks for the clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
Status: Todo
Development

No branches or pull requests

6 participants