PyGithub icon indicating copy to clipboard operation
PyGithub copied to clipboard

`Repository.create_label()` should allow `color` to be unspecified

Open jwodder opened this issue 2 years ago • 2 comments

The Repository.create_label() method should support being called without a color argument. The GitHub API accepts label creation requests that do not specify a color; the resulting labels are assigned random colors.

jwodder avatar Sep 24 '23 17:09 jwodder

Definitely the case for the 2022-11-28 version of the REST API?

Looking at what Repository.create_label() calls, https://docs.github.com/en/rest/issues/labels?apiVersion=2022-11-28#create-a-label, it states:

Creates a label for the specified repository with the given name and color. The name and color parameters are required.

Unless you were seeing it somewhere else that it's optional?

amnuts avatar Oct 03 '23 18:10 amnuts

Despite what the API docs say, GitHub will accept a request to create a label that omits the "color" field, though it seems that the color will then always be set to some fixed grey value rather than being randomized.

jwodder avatar Oct 03 '23 18:10 jwodder