Skip to content

gh-107805: Fix signatures of module-level generated functions in turtle #107807

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 7 commits into from
Sep 1, 2023

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Aug 9, 2023

Now we are using inspect.signature which works correct for all possible parameter types.
There are no / params to test it, but it uses the same branch as regular pos-or-keyword params, so it should be fine.

Related #103974

@sobolevn sobolevn requested review from gpshead and terryjreedy August 9, 2023 10:52
@sobolevn
Copy link
Member Author

sobolevn commented Aug 9, 2023

I think that this can go into rc2, because it fixes a bug which makes turtle.teleport unusable.

@gpshead gpshead added type-bug An unexpected behavior, bug, or error needs backport to 3.12 only security fixes release-blocker labels Aug 10, 2023
@gpshead gpshead self-assigned this Aug 10, 2023
Copy link
Member

@gpshead gpshead left a comment

Choose a reason for hiding this comment

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

likely good, but i'll take a closer look tomorrow. one suggestion added.

'pen': '(pen=None, **pendict)',
}

for name in turtle.__all__:
Copy link
Member

Choose a reason for hiding this comment

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

The purpose of this test is only to verify known signatures, correct?

In that case, looping over known_signatures.items() rather than turtle.__all__ makes more sense. Otherwise a typo in a known_signatures name key would go silently unnoticed and we're otherwise creating subtests for all names in turtle even though most of them don't test anything.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Well, I think that it would be nice to add also tests for the original issue:

  • Call teleport() without arguments.
  • Call teleport() with three positional arguments (it should fail).

@sobolevn
Copy link
Member Author

I've addressed @gpshead comments about the test case, but I don't think that I can actually test these functions:

  1. Nothing similar is tested in test_turtle, it simply does not have any Turtle class tests at all
  2. I don't know anything about tkinter
  3. I don't really think that we should add test foundation for it in this specific PR
  4. inspect works with real python function signature, so it is at least something

If anyone wants to contribute some tkinter-based tests for Turtle class, I would be happy to include teleport test there 👍

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Well, testing module-level turtle function is a non-trivial task.

Copy link
Member

@gpshead gpshead left a comment

Choose a reason for hiding this comment

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

I manually tested that turtle.Turtle() appears to work and that Turtle.teleport works.

@gpshead gpshead merged commit 044b8b3 into python:main Sep 1, 2023
@miss-islington
Copy link
Contributor

Thanks @sobolevn for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 1, 2023
…n `turtle` (pythonGH-107807)

(cherry picked from commit 044b8b3)

Co-authored-by: Nikita Sobolev <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Yhg1s pushed a commit that referenced this pull request Sep 1, 2023
…in `turtle` (GH-107807) (#108749)

gh-107805: Fix signatures of module-level generated functions in `turtle` (GH-107807)
(cherry picked from commit 044b8b3)

Co-authored-by: Nikita Sobolev <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-blocker type-bug An unexpected behavior, bug, or error
Projects
Development

Successfully merging this pull request may close these issues.

5 participants