diff options
Diffstat (limited to 'pyparsing/core.py')
-rw-r--r-- | pyparsing/core.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pyparsing/core.py b/pyparsing/core.py index 786256b..6fb8f92 100644 --- a/pyparsing/core.py +++ b/pyparsing/core.py @@ -3660,7 +3660,11 @@ class ParseExpression(ParserElement): def _setResultsName(self, name, listAllMatches=False): if __diag__.warn_ungrouped_named_tokens_in_collection: for e in self.exprs: - if isinstance(e, ParserElement) and e.resultsName and not e.resultsName.startswith("_NOWARN"): + if ( + isinstance(e, ParserElement) + and e.resultsName + and not e.resultsName.startswith("_NOWARN") + ): warnings.warn( "{}: setting results name {!r} on {} expression " "collides with {!r} on contained expression".format( @@ -4701,7 +4705,11 @@ class _MultipleMatch(ParseElementEnhance): def _setResultsName(self, name, listAllMatches=False): if __diag__.warn_ungrouped_named_tokens_in_collection: for e in [self.expr] + self.expr.recurse(): - if isinstance(e, ParserElement) and e.resultsName and not e.resultsName.startswith("_NOWARN"): + if ( + isinstance(e, ParserElement) + and e.resultsName + and not e.resultsName.startswith("_NOWARN") + ): warnings.warn( "{}: setting results name {!r} on {} expression " "collides with {!r} on contained expression".format( |