Browse Source

chore: Upgrade parsimonious to 0.10.0 (#65150)

This PR upgrades to parsimonious `0.10.0` with the necessary fixes to
adapt to the new version. This will be needed for the PR where we bump
the `snuba-sdk` since it's using this newer version of the
`parsimonious` library.

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Riccardo Busetti 1 year ago
parent
commit
9d3ca66d9e

+ 1 - 1
requirements-base.txt

@@ -36,7 +36,7 @@ maxminddb>=2.3
 mistune>=2.0.3
 mistune>=2.0.3
 mmh3>=4.0.0
 mmh3>=4.0.0
 packaging>=21.3
 packaging>=21.3
-parsimonious>=0.9.0
+parsimonious>=0.10.0
 petname>=2.6
 petname>=2.6
 phonenumberslite>=8.12.32
 phonenumberslite>=8.12.32
 Pillow>=10.2.0
 Pillow>=10.2.0

+ 1 - 1
requirements-dev-frozen.txt

@@ -111,7 +111,7 @@ openapi-spec-validator==0.7.1
 outcome==1.2.0
 outcome==1.2.0
 packaging==21.3
 packaging==21.3
 parse==1.19.0
 parse==1.19.0
-parsimonious==0.9.0
+parsimonious==0.10.0
 pathable==0.4.3
 pathable==0.4.3
 pathspec==0.9.0
 pathspec==0.9.0
 pep517==0.12.0
 pep517==0.12.0

+ 1 - 1
requirements-frozen.txt

@@ -77,7 +77,7 @@ msgpack==1.0.7
 oauthlib==3.1.0
 oauthlib==3.1.0
 openai==1.3.5
 openai==1.3.5
 packaging==21.3
 packaging==21.3
-parsimonious==0.9.0
+parsimonious==0.10.0
 petname==2.6
 petname==2.6
 phabricator==0.7.0
 phabricator==0.7.0
 phonenumberslite==8.12.55
 phonenumberslite==8.12.55

+ 2 - 3
src/sentry/api/event_search.py

@@ -10,7 +10,6 @@ from typing import Any, Literal, NamedTuple, Union
 
 
 from django.utils.functional import cached_property
 from django.utils.functional import cached_property
 from parsimonious.exceptions import IncompleteParseError
 from parsimonious.exceptions import IncompleteParseError
-from parsimonious.expressions import Optional
 from parsimonious.grammar import Grammar
 from parsimonious.grammar import Grammar
 from parsimonious.nodes import Node, NodeVisitor
 from parsimonious.nodes import Node, NodeVisitor
 
 
@@ -262,7 +261,7 @@ def flatten(children):
 
 
 def remove_optional_nodes(children):
 def remove_optional_nodes(children):
     def is_not_optional(child):
     def is_not_optional(child):
-        return not (isinstance(child, Node) and isinstance(child.expr, Optional))
+        return not (isinstance(child, Node) and not child.text)
 
 
     return list(filter(is_not_optional, children))
     return list(filter(is_not_optional, children))
 
 
@@ -303,7 +302,7 @@ def handle_negation(negation, operator):
 
 
 def get_operator_value(operator):
 def get_operator_value(operator):
     if isinstance(operator, Node):
     if isinstance(operator, Node):
-        operator = "=" if isinstance(operator.expr, Optional) else operator.text
+        operator = operator.text or "="
     elif isinstance(operator, list):
     elif isinstance(operator, list):
         operator = operator[0]
         operator = operator[0]
     return operator
     return operator

+ 1 - 1
src/sentry/grouping/enhancer/__init__.py

@@ -49,7 +49,7 @@ RUST_CACHE = RustCache(1_000)
 enhancements_grammar = Grammar(
 enhancements_grammar = Grammar(
     r"""
     r"""
 
 
-enhancements = line+
+enhancements = line*
 
 
 line = _ (comment / rule / empty) newline?
 line = _ (comment / rule / empty) newline?
 
 

+ 1 - 1
src/sentry/grouping/fingerprinting/__init__.py

@@ -29,7 +29,7 @@ CONFIGS_DIR: Path = Path(__file__).with_name("configs")
 fingerprinting_grammar = Grammar(
 fingerprinting_grammar = Grammar(
     r"""
     r"""
 
 
-fingerprinting_rules = line+
+fingerprinting_rules = line*
 
 
 line = _ (comment / rule / empty) newline?
 line = _ (comment / rule / empty) newline?
 
 

+ 1 - 1
src/sentry/ownership/grammar.py

@@ -33,7 +33,7 @@ CODEOWNERS = "codeowners"
 ownership_grammar = Grammar(
 ownership_grammar = Grammar(
     rf"""
     rf"""
 
 
-ownership = line+
+ownership = line*
 
 
 line = _ (comment / rule / empty) newline?
 line = _ (comment / rule / empty) newline?