Skip to content

improve type hints for notify/indicate subscriber(s) methods#915

Merged
barbibulle merged 1 commit intogoogle:mainfrom
dlech:notify-subscribers-type-hints
Apr 27, 2026
Merged

improve type hints for notify/indicate subscriber(s) methods#915
barbibulle merged 1 commit intogoogle:mainfrom
dlech:notify-subscribers-type-hints

Conversation

@dlech
Copy link
Copy Markdown
Contributor

@dlech dlech commented Apr 25, 2026

Pyright expects generic type parameters to be specified for the Attribute class, otherwise it treats the type as Unknown which can trigger reportUnknownMemberType errors.

This can be solved by using a generic type parameter for these methods which also has the benefit of making sure that the value parameter has the correct type for the attribute.

@dlech dlech force-pushed the notify-subscribers-type-hints branch from e64d360 to f8953cd Compare April 26, 2026 14:43
Pyright expects generic type parameters to be specified for the
Attribute class, otherwise it treats the type as Unknown which can
trigger reportUnknownMemberType errors.

This can be solved by using a generic type parameter for these methods
which also has the benefit of making sure that the value parameter has
the correct type for the attribute.

In some cases, a new local `value_as_bytes` variable is needed to avoid
type errors and makes the code less confusing by not overwriting the
original `value` variable.
@dlech dlech force-pushed the notify-subscribers-type-hints branch from f8953cd to baa5257 Compare April 26, 2026 14:43
@dlech
Copy link
Copy Markdown
Contributor Author

dlech commented Apr 26, 2026

Updated to fix failing CI (passing invoke project.pre-commit locally now).

@barbibulle barbibulle merged commit a1ff183 into google:main Apr 27, 2026
55 checks passed
@dlech dlech deleted the notify-subscribers-type-hints branch April 27, 2026 19:52
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