summaryrefslogtreecommitdiff
path: root/tests/mypy-ignore-cases/forward_methods.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mypy-ignore-cases/forward_methods.py')
-rw-r--r--tests/mypy-ignore-cases/forward_methods.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/mypy-ignore-cases/forward_methods.py b/tests/mypy-ignore-cases/forward_methods.py
new file mode 100644
index 0000000..ff50f5b
--- /dev/null
+++ b/tests/mypy-ignore-cases/forward_methods.py
@@ -0,0 +1,14 @@
+import pyparsing as pp
+
+# first, some basic validation: forward is a ParserElement, so is Literal
+# MatchFirst([Forward(), Literal(...)]) should also be okay
+e: pp.ParserElement = pp.Forward()
+e = pp.Literal()
+e = pp.MatchFirst([pp.Forward(), pp.Literal("hi there")])
+# confirm that it isn't returning Any because it cannot be assigned to a str
+x: str = pp.Forward() | pp.Literal("oops") # type: ignore[assignment]
+
+# confirm that `Forward.__or__` has the right behavior
+e = pp.Forward() | pp.Literal("nice to meet you")
+# and that it isn't returning Any because it cannot be assigned to an int
+y: int = pp.Forward() | pp.Literal("oops") # type: ignore[assignment]