Skip to content

Create a challenge for PEP 698 @override #56

@laike9m

Description

@laike9m
Owner

Activity

changed the title [-]Create a challenge for [PEP 698](https://www.python.org/dev/peps/pep-0698/) `@override`[/-] [+]Create a challenge for PEP 698 `@override`[/+] on Nov 28, 2023
laike9m

laike9m commented on Dec 10, 2023

@laike9m
OwnerAuthor

I find it hard to come up with a challenge for @override. We can have something like the following, but # expect-type-error always needs to resides with @override, and it's impossible to have @override in user code and # expect-type-error in test code.

"""
TODO:
Annotate the methods of class `Tiger`.
"""

class Animal:
    def eat(self, food):
        ...

from typing import override

class Tiger(Animal):
    @override
    def eat(self):  # expect-type-error
        ...

    @override
    def eat(self, food):
        ...

    @override
    def fly(self):  # expect-type-error
        ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @laike9m

        Issue actions

          Create a challenge for PEP 698 `@override` · Issue #56 · laike9m/Python-Type-Challenges