Skip to content

Commit

Permalink
ref: upgrade cssselect
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile-sentry committed Jun 9, 2023
1 parent 9f7c706 commit 6ed6dbf
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ module = [
"codeowners.*",
"confluent_kafka.*",
"csp.middleware.*",
"cssselect.*",
"datadog.*",
"django_zero_downtime_migrations.backends.postgres.schema.*",
"docker.*",
Expand Down
2 changes: 1 addition & 1 deletion requirements-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ celery>=4.4.7
click>=8.0.4
confluent-kafka>=1.9.2
croniter>=1.3.10
cssselect>=1.0.3
cssselect>=1.2
datadog>=0.29.3
django-crispy-forms>=1.14.0
django-csp>=3.7
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev-frozen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ confluent-kafka==1.9.2
coverage==6.3.3
croniter==1.3.10
cryptography==39.0.1
cssselect==1.0.3
cssselect==1.2.0
cssutils==2.4.0
datadog==0.29.3
decorator==5.1.1
Expand Down
2 changes: 1 addition & 1 deletion requirements-frozen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ click==8.0.4
confluent-kafka==1.9.2
croniter==1.3.10
cryptography==39.0.1
cssselect==1.0.3
cssselect==1.2.0
cssutils==2.4.0
datadog==0.29.3
decorator==5.1.1
Expand Down
12 changes: 5 additions & 7 deletions src/sentry/replays/lib/selector/parse.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from typing import List, Optional, Union
from typing import List, Optional

from cssselect import Selector, SelectorSyntaxError
from cssselect import SelectorSyntaxError
from cssselect import parse as cssselect_parse
from cssselect.parser import Attrib, Class, CombinedSelector, Element, Hash
from cssselect.parser import Attrib, Class, CombinedSelector, Element, Hash, Tree
from rest_framework.exceptions import ParseError

SelectorType = Union[Attrib, Class, Element, Hash]


class QueryType:
def __init__(self):
Expand All @@ -22,7 +20,7 @@ def __init__(self):

def parse_selector(css_selector: str) -> List[QueryType]:
try:
selectors: List[Selector] = cssselect_parse(css_selector)
selectors = cssselect_parse(css_selector)
except SelectorSyntaxError:
# Invalid selector syntax. No query data can be extracted.
return []
Expand All @@ -38,7 +36,7 @@ def parse_selector(css_selector: str) -> List[QueryType]:
return queries


def visit_selector_tree(query: QueryType, selector: SelectorType) -> None:
def visit_selector_tree(query: QueryType, selector: Tree) -> None:
"""Visit selector tree ignoring unhandled items.
We intentionally ignore specificity and psuedo-elements.
Expand Down

0 comments on commit 6ed6dbf

Please sign in to comment.