diff --git a/pyproject.toml b/pyproject.toml index b3a3ffee0568e4..edf19192378972 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,7 +98,6 @@ module = [ "codeowners.*", "confluent_kafka.*", "csp.middleware.*", - "cssselect.*", "datadog.*", "django_zero_downtime_migrations.backends.postgres.schema.*", "docker.*", diff --git a/requirements-base.txt b/requirements-base.txt index 3a8fa56b1bfa0b..84f064e96c201d 100644 --- a/requirements-base.txt +++ b/requirements-base.txt @@ -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 diff --git a/requirements-dev-frozen.txt b/requirements-dev-frozen.txt index b87c786a5ccf54..dce414e0ae3494 100644 --- a/requirements-dev-frozen.txt +++ b/requirements-dev-frozen.txt @@ -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 diff --git a/requirements-frozen.txt b/requirements-frozen.txt index 8031b438a4ab77..00d225dc15ffb5 100644 --- a/requirements-frozen.txt +++ b/requirements-frozen.txt @@ -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 diff --git a/src/sentry/replays/lib/selector/parse.py b/src/sentry/replays/lib/selector/parse.py index d3a3df8b05fb81..601aea640554be 100644 --- a/src/sentry/replays/lib/selector/parse.py +++ b/src/sentry/replays/lib/selector/parse.py @@ -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): @@ -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 [] @@ -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.