Introducing `warnings._deprecated()`

And it’s use is nice and simple.

I wrote this function to help with PEP 594, but it’s meant to be general enough for any deprecations with a slated removal target. The key thing is the RuntimeError if the code isn’t removed by b1 of the target version. That means never forgetting to remove code. :grin:

Once PEP 594 is done it may be worth going through the code base to find warnings that could be updated to this for bookkeeping purposes.

8 Likes

Nice! But why the underscore?

See the discussion on Discord, but basically it makes no sense outside the stdlib; no one else should be deprecating things based on the Python release schedule.

1 Like

Fair enough!

[Completely offtopic] I’m not actually worried about the question of the underscore, but I’m curious, if I did want to, how would I “see the discussion on discord”? Is there a way to link to a particular discussion, or is it just a matter (as I’d always assumed) that I’d just have to scroll through everything hoping to spot the conversation?

Also to point out, the Discord @brettcannon is referring to is only available to core developers, whereas this Discourse instance has wider membership rules. So non-core devs would not have access to the discussions on Discord.

It’s possible to link to Discord messages directly. I won’t post the link here because the Discord is private, but I can send it to you if you like. The discussion really didn’t have much more than what Brett wrote above though.

Everything Jelle said is accurate. There’s always always using the search feature in Discord to find the discussion.