## Change Summary

Fix `defer_build` behavior with `TypeAdapter`, see #7727 for details on bug.

## Related issue number

Fix #7727

## Other Notes
* Can implement support for `defer_build` for `dataclasses` in the future
* Can reassign `serializer` and `validator` attributes of the `TypeAdapter` in the future

## Checklist

* [x] The pull request title is a good summary of the changes - it will be used in the changelog
* [x] Unit tests for the changes exist
* [ ] Tests pass on CI
* [ ] Documentation reflects the changes where applicable
* [x] My PR is ready to review, **please add a comment including the phrase "please review" to assign reviewers**


Selected Reviewer: @adriangb
Fix `defer_build` behavior with `TypeAdapter`. ## Change Summary

Fix `defer_build` behavior with `TypeAdapter`, see #7727 for details on bug.

## Related issue number

Fix #7727

## Other Notes
* Can implement support for `defer_build` for `dataclasses` in the future
* Can reassign `serializer` and `validator` attributes of the `TypeAdapter` in the future

## Checklist

* [x] The pull request title is a good summary of the changes - it will be used in the changelog
* [x] Unit tests for the changes exist
* [ ] Tests pass on CI
* [ ] Documentation reflects the changes where applicable
* [x] My PR is ready to review, **please add a comment including the phrase "please review" to assign reviewers**


Selected Reviewer: @adriangb
"""Short helper script to check that a PR has exactly one relnotes label."""

import json
import os
import sys

if __name__ == '__main__':
    event_path = os.environ.get('GITHUB_EVENT_PATH')
    if event_path is None:
        raise RuntimeError('Can only check changelog on github actions')

    with open(event_path) as event_file:
        event = json.load(event_file)

    labels = [
        label['name']
        for label in event['pull_request']['labels']
        if label['name'].startswith('relnotes-') or label['name'] == 'documentation'
    ]

    if not labels:
        print(
            'No suitable label found, please add either one of the `relnotes-` or `documentation` labels.',
            file=sys.stderr,
        )
        exit(1)

    if len(labels) > 1:
        print(f'Multiple relnotes labels found: `{"`, `".join(labels)}`', file=sys.stderr)
        exit(1)

    print('Found suitable label:', labels[0])
    exit(0)

"""Short helper script to check that a PR has exactly one relnotes label."""

import json
import os
import sys

if __name__ == '__main__':
    event_path = os.environ.get('GITHUB_EVENT_PATH')
    if event_path is None:
        raise RuntimeError('Can only check changelog on github actions')

    with open(event_path) as event_file:
        event = json.load(event_file)

    labels = [
        label['name']
        for label in event['pull_request']['labels']
        if label['name'].startswith('relnotes-') or label['name'] == 'documentation'
    ]

    if not labels:
        print(
            'No suitable label found, please add either one of the `relnotes-` or `documentation` labels.',
            file=sys.stderr,
        )
        exit(1)

    if len(labels) > 1:
        print(f'Multiple relnotes labels found: `{"`, `".join(labels)}`', file=sys.stderr)
        exit(1)

    print('Found suitable label:', labels[0])
    exit(0)
