MCPcopy Index your code
hub / github.com/python/mypy / AsPattern

Class AsPattern

mypy/patterns.py:25–42  ·  view source on GitHub ↗

The pattern as

Source from the content-addressed store, hash-verified

23
24
25class AsPattern(Pattern):
26 """The pattern <pattern> as <name>"""
27
28 # The python ast, and therefore also our ast merges capture, wildcard and as patterns into one
29 # for easier handling.
30 # If pattern is None this is a capture pattern. If name and pattern are both none this is a
31 # wildcard pattern.
32 # Only name being None should not happen but also won't break anything.
33 pattern: Pattern | None
34 name: NameExpr | None
35
36 def __init__(self, pattern: Pattern | None, name: NameExpr | None) -> None:
37 super().__init__()
38 self.pattern = pattern
39 self.name = name
40
41 def accept(self, visitor: PatternVisitor[T]) -> T:
42 return visitor.visit_as_pattern(self)
43
44
45class OrPattern(Pattern):

Callers 3

visit_MatchAsMethod · 0.90
visit_as_patternMethod · 0.90
read_patternFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…