Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes mypyc/mypyc#1243.
The runtime
@deprecateddecorator (PEP 702, fromwarningsortyping_extensions) stores the message in the__deprecated__attribute of the function that it wraps. Compiled functions don't support setting attributes, so a module that uses the decorator on a function or a method fails at import:With this PR mypyc no longer calls the decorator. The compiled function issues the warning itself when it's called. A method isn't a decorated method for mypyc any more, so it's still called natively, and these work as for any other method: property getters and setters, class and static methods, and overriding a native method (or being overridden by one). The implementation of an overloaded function works too. A generator or a coroutine warns when it's created, like with the runtime decorator.
Differences from interpreted Python:
__deprecated__attribute. This now also applies to nested and async functions,where the runtime decorator happened to work. I did this to keep the behavior uniform, but I can leave
those on the runtime path if that's preferred. It would seem adding support for attributes on compiled methods like
__deprecated__might be a bigger change than even this large PR.