Skip to content

Don't run whats_left with older CPython versions #4847

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

Merged
merged 2 commits into from
Apr 11, 2023

Conversation

verhovsky
Copy link
Contributor

@verhovsky verhovsky commented Apr 4, 2023

I added a check that whats_left is being run with CPython 3.11 or newer, as suggested here #4255 (comment) and also put one signature under the other to make them easier to compare

@verhovsky verhovsky changed the title Improve whats_left --signature output Don't run whats_left with older CPython versions Apr 4, 2023
print(f"{item}{rustpy_value}")
if cpython_value is None or cpython_value.startswith("ValueError("):
cpython_value = f" {cpython_value}"
print(f"{' ' * len(item)}{cpython_value}")
Copy link
Member

Choose a reason for hiding this comment

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

also, minor nit here, but we don't account for the potential space added in the rustpy_value on line 491 so the alignment might be off by one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea is that ValueError/None aren't signatures. The output is like

func_name(arg1, arg2)
func_name(arg1, arg2, arg3)

but we don't repeat "func_name" a second time since it's always the same and this way the output is less busy visually

func_name(arg1, arg2)
         (arg1, arg2, arg3)

Then for value errors we have

func_name ValueError()
func_name(arg1, arg2, arg3)

or

func_name(arg1, arg2)
func_name None

Copy link
Member

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

ran this locally and looks good to me, like the alignment of signatures! Apart from youknowone's suggestion, should be gtg. Thanks!

Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
@youknowone youknowone merged commit c9546c2 into RustPython:main Apr 11, 2023
@youknowone
Copy link
Member

Thank you for contributing!

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