Skip to content

Conversation

@Tpt
Copy link
Contributor

@Tpt Tpt commented Nov 12, 2025

Makes internal macros always require a module and a name (using builtins for Python builtins)

These values are then used to fill PyTypeInfo::MODULE and PyTypeInfo::TYPE_HINT (PyTypeInfo::NAME stays unchanged)

This changes some values of PyTypeInfo::MODULE

@Tpt
Copy link
Contributor Author

Tpt commented Nov 12, 2025

Not sure if it's fine to change the values of PyTypeInfo::MODULE. Glad to revert this change if useful.

@Tpt Tpt force-pushed the tpt/builtin-type-hint branch from 85eedf0 to 9fbb660 Compare November 12, 2025 13:12
@Tpt Tpt marked this pull request as ready for review November 12, 2025 16:20
@Tpt Tpt force-pushed the tpt/builtin-type-hint branch from 9fbb660 to a91b0df Compare November 13, 2025 14:23
Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks, I am happy with the changes this adds, just one tidy up I think we can do with the macro implementation before we merge.

src/types/mod.rs Outdated
unsafe impl<$($generics,)*> $crate::type_object::PyTypeInfo for $name {
const NAME: &'static str = stringify!($name);
const MODULE: ::std::option::Option<&'static str> = $module;

Copy link
Member

Choose a reason for hiding this comment

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

Idea: rather than duplicating the whole macro, what we might be able to do is have $crate::pyobject_type_info_type_hint!($type_hint_module, $type_hint_expr) macro which we call here, and that macro can be the one with two defintitions. A noop one without the feature enabled, and one which expands to const TYPE_HINT = ... with the feature enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea! Thanks! Done d9a3e18

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Perfect, thanks!

Tpt added 5 commits November 18, 2025 15:55
Makes internal macros always require a module and a name

These values are then used to fill PyTypeInfo::MODULE and PyTypeInfo::TYPE_HINT (PyTypeInfo::NAME stays unchanged)

This changes some values of PyTypeInfo::MODULE
auto-merge was automatically disabled November 18, 2025 14:56

Head branch was pushed to by a user without write access

@Tpt
Copy link
Contributor Author

Tpt commented Nov 18, 2025

Rebase done

@Tpt Tpt force-pushed the tpt/builtin-type-hint branch from d9a3e18 to 39c7c60 Compare November 18, 2025 14:57
@davidhewitt davidhewitt added this pull request to the merge queue Nov 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 18, 2025
@Tpt
Copy link
Contributor Author

Tpt commented Nov 18, 2025

CI seems to have failed because of an internal error in the runner system

@LilyFirefly LilyFirefly added this pull request to the merge queue Nov 18, 2025
Merged via the queue into PyO3:main with commit d8e9a38 Nov 18, 2025
43 checks passed
@Tpt Tpt deleted the tpt/builtin-type-hint branch November 19, 2025 08:45
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.

3 participants