Skip to content
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

Add documentation examples for overridden-final-method checker #6080

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions doc/data/messages/o/overridden-final-method/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from typing import final


class Base:
@final
def my_method(self):
pass


class Subclass(Base):
def my_method(self): # [overridden-final-method]
pass
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class Base:
@final
def my_method(self):
pass
class Subclass(Base):
def my_method(self): # [overridden-final-method]
pass
class Animal:
@final
def breath(self):
return True
class Cat(Animal):
def breath(self): # [overridden-final-method]
pass

Copy link
Member Author

Choose a reason for hiding this comment

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

Quite an intuitive example @Pierre-Sassoulas.
I've changed the naming slightly.

1 change: 1 addition & 0 deletions doc/data/messages/o/overridden-final-method/details.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The message can't be emitted when using Python < 3.8.
12 changes: 12 additions & 0 deletions doc/data/messages/o/overridden-final-method/good.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from typing import final


class Base:
@final
def my_method(self):
pass


class Subclass(Base):
def my_other_method(self):
pass
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class Base:
@final
def my_method(self):
pass
class Subclass(Base):
def my_other_method(self):
pass
class Animal:
@final
def breath(self):
return True
class Cat(Animal):
def purr(self):
return True

1 change: 1 addition & 0 deletions doc/data/messages/o/overridden-final-method/related.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `PEP 591 <https://peps.python.org/pep-0591/>`_