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

Improve default values for str, numbers and bool in text_signature #3050

Merged
merged 1 commit into from Mar 25, 2023

Conversation

messense
Copy link
Member

xref #2863

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.

Nice! I think this is technically a breaking change, so will land in 0.19.

// has a default, just use ... for now
output.push_str("=...");
output.push('=');
output.push_str(&self.default_value_for_parameter(parameter));
Copy link
Member

Choose a reason for hiding this comment

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

So because self.default_value_for_parameter does a search of the arguments by name, this is O(n²), but only for small n, so it's probably fine.

I was planning to avoid that by storing the default expressions in self.python_signature, but that was harder with the deprecated args attribute still present.

Copy link
Member Author

Choose a reason for hiding this comment

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

So because self.default_value_for_parameter does a search of the arguments by name, this is O(n²), but only for small n, so it's probably fine.

Yeah, I think the same.

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! With 0.18.2 released, let's merge this!

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 25, 2023

Build succeeded:

@bors bors bot merged commit ebedcfb into PyO3:main Mar 25, 2023
30 of 31 checks passed
@messense messense deleted the text-signature-lit branch March 25, 2023 12:36
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

2 participants