Skip to content

Conversation

@damusss
Copy link
Member

@damusss damusss commented Jul 11, 2024

After the discussion in this PR the focus of it has changed. This can be considered stubs polish.

  • I changed the _to/from_string_format name to _to/from_bytes_format as the previous was referring to deprecated functions
  • I removed the final import from window.pyi as Window is not a final class anymore
  • Most relevant, I've added the new 3.13 (using typing_extension) @deprecated decorator to note deprecated functions and classes. This makes the stubs stay up to date with the python type systems and add useful messages (and visual effects like a strikethrough in VSCode) about deprecated features so users don't confuse them with the correct ones and are able to know if something is deprecated without documentation/running the code.

@damusss damusss requested a review from a team as a code owner July 11, 2024 12:44
@damusss damusss marked this pull request as draft July 11, 2024 12:56
@damusss
Copy link
Member Author

damusss commented Jul 11, 2024

I realized later that some checks check if the stubs are present, so I'll convert to draft, get some feedback and decide what to do with the PR

Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

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

If you are doing this change, you need to add the removed API to the stubtest ignore file.

@damusss damusss marked this pull request as ready for review July 11, 2024 14:27
@damusss
Copy link
Member Author

damusss commented Jul 11, 2024

Alright, thanks, I didn't know that was possible, the checks are passing now.

@damusss damusss added Code quality/robustness Code quality and resilience to changes docs labels Jul 11, 2024
@Starbuck5
Copy link
Member

I would like to not do this.

Deprecations are now part of the type system in 3.13: https://peps.python.org/pep-0702/

In my VS code deprecations show up like this:
image

And it's backed by a pyi file that has the feature:
image

(Using typing_extensions since I'm on 3.9)

@damusss
Copy link
Member Author

damusss commented Jul 12, 2024

do we have some sort of access to @deprecated in the lower python supported version of pygame?

I'm sorry for the person which got pinged 💀 I forgot the code block

@damusss
Copy link
Member Author

damusss commented Jul 12, 2024

For now I added back everything adding a docstring for deprecation. Would be even better to use the deprecated decorator

@ankith26
Copy link
Member

You can import @deprecated from typing_extensions which should serve as a backport of the feature for older python versions

@damusss damusss changed the title Remove deprecated features from the stubs Polish stubs with deprecated decorator Jul 12, 2024
Copy link
Member

@oddbookworm oddbookworm left a comment

Choose a reason for hiding this comment

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

I've just got a few clarifying suggestions

Copy link
Member

@oddbookworm oddbookworm left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

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

You missed the deprecation of mouse.set_system_cursor too

@bilhox
Copy link
Contributor

bilhox commented Jul 16, 2024

You missed the deprecation of mouse.set_system_cursor too

Thanks, going to add it in #2943 .

@damusss
Copy link
Member Author

damusss commented Jul 16, 2024

You missed the deprecation of mouse.set_system_cursor too

Thanks, going to add it in #2943 .

hold on, I didn't know it was deprecated, I need to add it here aswell!

Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the PR 🥳

@ankith26 ankith26 added this to the 2.5.1 milestone Jul 16, 2024
@ankith26 ankith26 merged commit 932b5f6 into pygame-community:main Jul 16, 2024
@damusss damusss deleted the remove-deprecated-stubs branch July 16, 2024 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code quality/robustness Code quality and resilience to changes docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants