Skip to content

Add type stub for colour package#15823

Open
absolutely-vivid wants to merge 1 commit into
python:mainfrom
absolutely-vivid:colour-stubs
Open

Add type stub for colour package#15823
absolutely-vivid wants to merge 1 commit into
python:mainfrom
absolutely-vivid:colour-stubs

Conversation

@absolutely-vivid
Copy link
Copy Markdown

This PR adds type stubs for the colour package.

There were a few small issues when writing the stubs that might need changes before merging:

  • stubtest didn't like the type I wrote for colour.Color.set_hex_l, it said the runtime type was Callable[[Any], Any]. I think that's because set_hex_l isn't defined as a method, but as a class variable with a lambda. I added colour.COlor.set_hex_l to the allowlist
  • colour.Color.__eq__'s implementation can return (not raise) NotImplemented. Mypy and pyright both disallow that, so I set a noqa
  • Mypy complains about the colour.Color.hash_or_str overload, saying overload 1 is wider than overload 2. However Hashable is narrower than object (set is object but not hashable), so that shouldn't be the case. I ignored with a noqa comment

If there are more idiomatic ways to fix any of those, let me know and I can make the changes.

@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

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.

1 participant