Skip to content

gh-148330: Add docstrings to module colorsys in all functions#148332

Open
aiwonderland wants to merge 3 commits intopython:mainfrom
aiwonderland:doc-colorsys-add-docstrings
Open

gh-148330: Add docstrings to module colorsys in all functions#148332
aiwonderland wants to merge 3 commits intopython:mainfrom
aiwonderland:doc-colorsys-add-docstrings

Conversation

@aiwonderland
Copy link
Copy Markdown

@aiwonderland aiwonderland commented Apr 10, 2026

gh-148330: colorsys: Add docstrings to module and all functions

Add module-level __doc__ and consistent docstrings to all colorsys conversion functions.
Fixes help() output for colorsys APIs and follows standard library style.

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot bot commented Apr 10, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Apr 10, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@aiwonderland aiwonderland force-pushed the doc-colorsys-add-docstrings branch from 4a1a16c to 5209a13 Compare April 10, 2026 13:39
@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Apr 10, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@aiwonderland aiwonderland changed the title gh-148830: Add docstrings to module colorsys in all functions gh-148330: Add docstrings to module colorsys in all functions Apr 10, 2026
Lib/colorsys.py Outdated
# The ones in this library uses constants from the FCC version of NTSC.

def rgb_to_yiq(r, g, b):
"""Convert RGB to YIQ.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good, but just to clean it up a little more, just put the string next to the start of the doctoring on another line. For example:
Instead of

"""Convert RGB to YIQ.
"""

It becomes

"""
Convert RGB to YIQ.
"""

And this change would apply to the other lines that follow this pattern as well.

@aisk aisk added the skip news label Apr 10, 2026
@sharktide
Copy link
Copy Markdown
Contributor

@aiwonderland Could you please retry signing the CLA?

@aiwonderland
Copy link
Copy Markdown
Author

OK.

Copy link
Copy Markdown
Contributor

@sharktide sharktide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I basically added @MazinSharaf suggestions so you can commit them without editing the file yourself :)

return (y, i, q)

def yiq_to_rgb(y, i, q):
"""Convert YIQ to RGB.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Convert YIQ to RGB.
"""
Convert YIQ to RGB.

# V: color brightness

def rgb_to_hsv(r, g, b):
"""Convert RGB to HSV (Hue, Saturation, Value).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Convert RGB to HSV (Hue, Saturation, Value).
"""
Convert RGB to HSV (Hue, Saturation, Value).

# S: color saturation

def rgb_to_hls(r, g, b):
"""Convert RGB to HLS (Hue, Lightness, Saturation).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Convert RGB to HLS (Hue, Lightness, Saturation).
"""
Convert RGB to HLS (Hue, Lightness, Saturation).

return h, l, s

def hls_to_rgb(h, l, s):
"""Convert HLS (Hue, Lightness, Saturation) to RGB.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Convert HLS (Hue, Lightness, Saturation) to RGB.
"""
Convert HLS (Hue, Lightness, Saturation) to RGB.

return h, s, v

def hsv_to_rgb(h, s, v):
"""Convert HSV (Hue, Saturation, Value) to RGB.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Convert HSV (Hue, Saturation, Value) to RGB.
"""
Convert HSV (Hue, Saturation, Value) to RGB.

@MazinSharaf
Copy link
Copy Markdown
Contributor

Alright changes look good now. Looks neater!

@aiwonderland
Copy link
Copy Markdown
Author

/rerun

Co-authored-by: Rihaan Meher <sharktidedev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants