Skip to content

feat: Improve Parameter type safety with typed defaults and Unpack[_ParameterKwargs]#3394

Merged
dlstadther merged 3 commits intospotify:masterfrom
kitagry:add-init-type
Feb 21, 2026
Merged

feat: Improve Parameter type safety with typed defaults and Unpack[_ParameterKwargs]#3394
dlstadther merged 3 commits intospotify:masterfrom
kitagry:add-init-type

Conversation

@kitagry
Copy link
Contributor

@kitagry kitagry commented Feb 19, 2026

Description

  • Replace _no_value = object() sentinel with a proper singleton class _NoValueType
  • Explicitly add typed default argument to __init__ of all Parameter subclasses
  • Introduce _ParameterKwargs (TypedDict) with Unpack to make **kwargs type-safe

Motivation and Context

Previously, **kwargs had no type information, making IDE autocompletion and static analysis with mypy ineffective. Additionally, _no_value = object() had an unclear repr during debugging and could not be used in type annotations.

Have you tested this? If so, how?

@kitagry kitagry requested review from a team and dlstadther as code owners February 19, 2026 15:37
@kitagry kitagry marked this pull request as draft February 20, 2026 00:59
@kitagry kitagry marked this pull request as ready for review February 20, 2026 12:43
dlstadther
dlstadther previously approved these changes Feb 21, 2026
@dlstadther dlstadther merged commit 1638d78 into spotify:master Feb 21, 2026
49 checks passed
@kitagry kitagry deleted the add-init-type branch February 21, 2026 12:26
@kitagry
Copy link
Contributor Author

kitagry commented Feb 22, 2026

@dlstadther Thank you for the merge! I'm excited to use it, so please release it whenever you have a chance.

@dlstadther
Copy link
Collaborator

Will do @kitagry . I'd like to get the 3.8/3.9 removal merged before I release, if that's ok.

@kitagry
Copy link
Contributor Author

kitagry commented Feb 24, 2026

No problem at all! Sounds like a good plan.
By the way, I just submitted a PR. I’d appreciate it if you could take a look when you have a chance!

#3401

@dlstadther
Copy link
Collaborator

@kitagry v3.8.0 was just released

@kitagry
Copy link
Contributor Author

kitagry commented Mar 6, 2026

Thank you!

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