Skip to content

fix: allow num_labels property to return None when id2label is unset#47069

Open
SebTardif wants to merge 2 commits into
huggingface:mainfrom
SebTardif:fix/num-labels-optional-type
Open

fix: allow num_labels property to return None when id2label is unset#47069
SebTardif wants to merge 2 commits into
huggingface:mainfrom
SebTardif:fix/num-labels-optional-type

Conversation

@SebTardif

@SebTardif SebTardif commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

CI

Summary

PretrainedConfig.num_labels was annotated as -> int but returned None when id2label is not set.

Change

Use int | None and document the optional return value.

Testing

Type annotation aligns with runtime behavior; no logic change.

The property was annotated as returning int but returned None when
id2label is missing, which contradicts the type and can break type
checkers and careful callers.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>

@zucchini-nlp zucchini-nlp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 28774617734:2
Result: failure | Jobs: 15 | Tests: 171,521 | Failures: 6 | Duration: 23h 30m

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.

2 participants