Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(types): Add special case for empty C++ tuple type annotation #5214

Merged
merged 2 commits into from
Jun 30, 2024

Conversation

InvincibleRMC
Copy link
Contributor

@InvincibleRMC InvincibleRMC commented Jun 30, 2024

Description

Split off from #5212

Due to how tuple_caster implements it's type generation it works for all tuples except the empty tuple which previously generated tuple[] rather than the correct tuple[()]

static constexpr auto name = const_name("tuple[")
+ ::pybind11::detail::concat(make_caster<Ts>::name...)
+ const_name("]");

Suggested changelog entry:

   Add a special type annotation for C++ empty tuple.

public:
// PEP 484 specifies this syntax for an empty tuple
static constexpr auto name = const_name("tuple[()]");
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please insert an empty line right after this one?

@rwgk rwgk merged commit d805e99 into pybind:master Jun 30, 2024
86 checks passed
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Jun 30, 2024
@InvincibleRMC InvincibleRMC deleted the special-case-empty-c++-tuple branch June 30, 2024 16:58
wenqing pushed a commit to wenqing/pybind11 that referenced this pull request Jul 6, 2024
henryiii pushed a commit that referenced this pull request Aug 12, 2024
)

* add special case and unit test

* add newline
@henryiii henryiii changed the title feat(types) Adds special Case for empty C++ tuple type annotation feat(types): Add special case for empty C++ tuple type annotation Aug 12, 2024
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Aug 13, 2024
henryiii pushed a commit that referenced this pull request Aug 13, 2024
)

* add special case and unit test

* add newline
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.

None yet

3 participants