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

Use different colour for 'Return value: Borrowed reference' #188

Merged
merged 2 commits into from
Apr 26, 2024

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Apr 17, 2024

Follow on from python/cpython#117926.

Currently light green is used for all return types:

  • "Return value: Always NULL."
  • "Return value: New reference."
  • "Return value: Borrowed reference."

For example: https://docs.python.org/3/c-api/exceptions.html

image

image

image

A borrowed reference is not necessarily a "bad" thing, but we may want to use something other than green that indicates it's "good", to indicate they should be treated with care.

This PR uses the same yellow/orange colour as the "Changed in version x.y" text in #185 - I've already checked the contrast ratios in that PR and both meet WCAG AAA. By using the same colour, it will be easier to check/change when we audit.

image image

For example: https://python-docs-theme-previews--188.org.readthedocs.build/en/188/c-api/exceptions.html#querying-the-error-indicator

@vstinner
Copy link
Member

This PR uses the same yellow/orange colour as the "Changed in version x.y" text in #185

FYI As a color blind person, I don't see the difference between "Borrowed reference" and "New reference" colors in the light mode. Well, I'm also color blind, so my opinion may not matter :-)

In the dark mode, I see clearly that the two colors are very different.

@flying-sheep
Copy link

If you’re reusing existing colors, how about you centralize their definition as a CSS variables and then use it from both your new CSS rules and the old ones that originally defined the color?

@hugovk
Copy link
Member Author

hugovk commented Apr 19, 2024

Good idea, shall we also replace the pale green for the other "Return value" with the "New in version" green?

image

The light mode ones are much closer, but we could replace one with the other here too?

image

@hugovk
Copy link
Member Author

hugovk commented Apr 24, 2024

Updated:

image

image

image

image

Suggestions for better variable names welcome :)

Copy link

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

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

I don't have a strong opinion regarding naming, but I like the change! Personally, I would prefer borrowed references to be labelled as "bad", but that is a different discussion.

@hugovk hugovk merged commit 97952b5 into python:main Apr 26, 2024
9 checks passed
@hugovk hugovk deleted the refcount-return-borrowed-ref branch April 26, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants