MCPcopy
hub / github.com/psf/black / match

Method match

src/blib2to3/pytree.py:537–561  ·  src/blib2to3/pytree.py::BasePattern.match

Does this pattern exactly match a node? Returns True if it matches, False if not. If results is not None, it must be a dict which will be updated with the nodes matching named subpatterns. Default implementation for non-wildcard patterns.

(self, node: NL, results: _Results | None = None)

Source from the content-addressed store, hash-verified

535 return self
536
537 def match(self, node: NL, results: _Results | None = None) -> bool:
538 class="st">"""
539 Does this pattern exactly match a node?
540
541 Returns True if it matches, False if not.
542
543 If results is not None, it must be a dict which will be
544 updated with the nodes matching named subpatterns.
545
546 Default implementation for non-wildcard patterns.
547 class="st">"""
548 if self.type is not None and node.type != self.type:
549 return False
550 if self.content is not None:
551 r: _Results | None = None
552 if results is not None:
553 r = {}
554 if not self._submatch(node, r):
555 return False
556 if r:
557 assert results is not None
558 results.update(r)
559 if results is not None and self.name:
560 results[self.name] = node
561 return True
562
563 def match_seq(self, nodes: list[NL], results: _Results | None = None) -> bool:
564 class="st">"""

Callers 15

match_seqMethod · 0.95
generate_matchesMethod · 0.95
main.pyFile · 0.45
list_commentsFunction · 0.45
normalize_string_prefixFunction · 0.45
matchMethod · 0.45
_submatchMethod · 0.45
_bare_name_matchesMethod · 0.45
parse_graminit_hMethod · 0.45
parse_graminit_cMethod · 0.45
pytest_configureFunction · 0.45

Calls 1

_submatchMethod · 0.95