Skip to content

Remove obsolete comments from turtle.pyi #14474

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 1 commit into from
Jul 27, 2025

Conversation

srittau
Copy link
Collaborator

@srittau srittau commented Jul 27, 2025

While it would be possible to use the hack described in the comment
now that pytype support has been removed, that hack is a bit too
"magical" for stubs that are supposed to be fairly straight-forward
API descriptions. This would also introduce extra stub-only attributes
and would imply that e.g. _Screen.setup() and setup() refer to the
same object at runtime when they don't.

While it would be possible to use the hack described in the comment
now that pytype support has been removed, that hack is a bit too
"magical" for stubs that are supposed to be fairly straight-forward
API descriptions. This would also introduce extra stub-only attributes
and would imply that e.g. `_Screen.setup()` and `setup()` refer to the
same object at runtime when they don't.
@AlexWaygood
Copy link
Member

that hack is a bit too "magical" for stubs that are supposed to be fairly straight-forward API descriptions

Hmm, we already use this technique in random.pyi to reduce duplication between signatures:

typeshed/stdlib/random.pyi

Lines 103 to 128 in 981bd8e

_inst: Random
seed = _inst.seed
random = _inst.random
uniform = _inst.uniform
triangular = _inst.triangular
randint = _inst.randint
choice = _inst.choice
randrange = _inst.randrange
sample = _inst.sample
shuffle = _inst.shuffle
choices = _inst.choices
normalvariate = _inst.normalvariate
lognormvariate = _inst.lognormvariate
expovariate = _inst.expovariate
vonmisesvariate = _inst.vonmisesvariate
gammavariate = _inst.gammavariate
gauss = _inst.gauss
if sys.version_info >= (3, 12):
binomialvariate = _inst.binomialvariate
betavariate = _inst.betavariate
paretovariate = _inst.paretovariate
weibullvariate = _inst.weibullvariate
getstate = _inst.getstate
setstate = _inst.setstate
getrandbits = _inst.getrandbits
randbytes = _inst.randbytes

I think that we probably could have started using a similar technique in turtle.pyi some time ago; it looks like the comment was added six years ago

@AlexWaygood
Copy link
Member

Hmm, I see what you mean about _Screen.setup not actually being the same object at runtime as setup, though. In this respect, it's different to the random module. In that case, I agree that what you propose here seems best.

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit d5c3781 into python:main Jul 27, 2025
63 checks passed
@srittau srittau deleted the rm-turtle-comments branch July 27, 2025 11:33
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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy