Skip to content

Use a TypedDict for turtle._PenState #13152

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
Nov 28, 2024
Merged

Use a TypedDict for turtle._PenState #13152

merged 1 commit into from
Nov 28, 2024

Conversation

kbaikov
Copy link
Contributor

@kbaikov kbaikov commented Nov 28, 2024

Copy link
Contributor

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

Copy link
Collaborator

@Akuli Akuli left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks!

Comment on lines +147 to +148
pencolor: _Color
fillcolor: _Color
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are always returned as strings. For example:

>>> import turtle
>>> turtle.pen(pencolor=(1,0,0))
>>> turtle.pen()
{'shown': True, 'pendown': True, 'pencolor': '#ff0000', ...

However, using str here is not any better, because it is not wrong to have tuples in pen state dicts:

>>> p = turtle.pen().copy()
>>> p['pencolor'] = (0,1,0)
>>> turtle.pen(p)
>>> turtle.pen()['pencolor']
'#00ff00'

@Akuli Akuli changed the title Extend PenState dict in turtle Use a TypedDict for turtle._PenState (#13152) Nov 28, 2024
@Akuli Akuli changed the title Use a TypedDict for turtle._PenState (#13152) Use a TypedDict for turtle._PenState Nov 28, 2024
@Akuli Akuli merged commit cba73d9 into python:main Nov 28, 2024
63 checks passed
@kbaikov kbaikov deleted the fix-turtle branch November 28, 2024 20:19
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