summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDudeNr33 <3929834+DudeNr33@users.noreply.github.com>2022-05-27 19:56:08 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2022-05-27 20:39:02 +0200
commit0295cb1a5a86ad75332ad87196160ca1bc7388e5 (patch)
tree651a496a9c45a5ca1d45a0b486fbc563e1957930 /tests
parent854170d866c60e2852f38be54d1d8d32eb53e808 (diff)
downloadpylint-git-0295cb1a5a86ad75332ad87196160ca1bc7388e5.tar.gz
Fix tests and add example for explicit `Union` type hint.
Diffstat (limited to 'tests')
-rw-r--r--tests/pyreverse/functional/class_diagrams/annotations/method_annotation.mmd1
-rw-r--r--tests/pyreverse/functional/class_diagrams/annotations/method_annotation.py11
2 files changed, 9 insertions, 3 deletions
diff --git a/tests/pyreverse/functional/class_diagrams/annotations/method_annotation.mmd b/tests/pyreverse/functional/class_diagrams/annotations/method_annotation.mmd
index 705228c3a..a0fd4d764 100644
--- a/tests/pyreverse/functional/class_diagrams/annotations/method_annotation.mmd
+++ b/tests/pyreverse/functional/class_diagrams/annotations/method_annotation.mmd
@@ -2,5 +2,6 @@ classDiagram
class Monkey {
eat(food: Banana | Coconut) None
jump(height: Optional[int]) None
+ munch(food: Union[Leaf, Insect]) None
scream(volume: int | None) Sound
}
diff --git a/tests/pyreverse/functional/class_diagrams/annotations/method_annotation.py b/tests/pyreverse/functional/class_diagrams/annotations/method_annotation.py
index 08405ed0a..26ea3f4a5 100644
--- a/tests/pyreverse/functional/class_diagrams/annotations/method_annotation.py
+++ b/tests/pyreverse/functional/class_diagrams/annotations/method_annotation.py
@@ -1,14 +1,19 @@
+# pylint: disable=import-error,consider-alternative-union-syntax
from __future__ import annotations
-# pylint: disable-next=import-error
-from lib import Banana, Coconut, Sound # type: ignore[import]
+from typing import Optional, Union
+
+from lib import Banana, Coconut, Insect, Leaf, Sound # type: ignore[import]
class Monkey:
def eat(self, food: Banana | Coconut) -> None:
print(f"Monkey eats {food}")
- def jump(self, height: int | None = 10) -> None:
+ def munch(self, food: Union[Leaf, Insect]) -> None:
+ print(f"Monkey munches {food}")
+
+ def jump(self, height: Optional[int] = 10) -> None:
print(f"Monkey jumps {height}")
def scream(self, volume: int | None) -> Sound: