Skip to content

Commit

Permalink
Add documentation examples for too-many-ancestors (#7067)
Browse files Browse the repository at this point in the history
Co-authored-by: Vladyslav Krylasov <[email protected]>
Co-authored-by: Pierre Sassoulas <[email protected]>
  • Loading branch information
3 people authored Jun 27, 2022
1 parent 24aa4d2 commit 3c5eca2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
24 changes: 24 additions & 0 deletions doc/data/messages/t/too-many-ancestors/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class Animal: ...
class BeakyAnimal(Animal): ...
class FurryAnimal(Animal): ...
class Swimmer(Animal): ...
class EggLayer(Animal): ...
class VenomousAnimal(Animal): ...
class ProtectedSpecie(Animal): ...
class BeaverTailedAnimal(Animal): ...
class Vertebrate(Animal): ...


# max of 7 by default, can be configured
# each edge of a diamond inheritance counts
class Playtypus( # [too-many-ancestors]
BeakyAnimal,
FurryAnimal,
Swimmer,
EggLayer,
VenomousAnimal,
ProtectedSpecie,
BeaverTailedAnimal,
Vertebrate,
):
pass
1 change: 0 additions & 1 deletion doc/data/messages/t/too-many-ancestors/details.rst

This file was deleted.

34 changes: 33 additions & 1 deletion doc/data/messages/t/too-many-ancestors/good.py
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
# This is a placeholder for correct code for this message.
class Animal:
beaver_tailed: bool
can_swim: bool
has_beak: bool
has_fur: bool
has_vertebrae: bool
lays_egg: bool
protected_specie: bool
venomous: bool


class Invertebrate(Animal):
has_vertebrae = False


class Vertebrate(Animal):
has_vertebrae = True


class Mammal(Vertebrate):
has_beak = False
has_fur = True
lays_egg = False
venomous = False


class Playtypus(Mammal):
beaver_tailed = True
can_swim = True
has_beak = True
lays_egg = False
protected_specie = True
venomous = True

0 comments on commit 3c5eca2

Please sign in to comment.