Skip to content

Python: "take item" selects part of comment before item #2803

Open

Description

@afallou

I have this pytest file:

import pytest
from freezegun import freeze_time

from quaero_api.models.published_item_query import QueryField


@pytest.mark.parametrize(
    "field, keywords, expected_output",
    [
        # The extra space before the ~ should still work, making sure it doesn't create another issue
        (
            QueryField.TITLE_OR_ABSTRACT,
            ['"the two" ~5'],
            'Title:("the two" ~5) OR ArticleTitle:("the two" ~5) OR AbstractText.Abstract:("the two" ~5)',
        ),
    ],
)
@freeze_time("2022-09-17")
def test_build_query_segment_string(field: QueryField, keywords: list[str], expected_output: str) -> None:
    assert field.build_query_segment_string(keywords) == expected_output

I have a yellow hat on the "Q" of "QueryField" in those lines:

Image

I wanted to add another parametrized case by cloning that tuple-valued list item. clone item round yellow quench was giving me weird results, which got me to notice that take item round yellow quench was resulting in the selection of a piece of the comment above the tuple.

More precisely, this whole thing ends up selected:
Image

Activity

  1. changed the title [-]Python: "take item" includes part of comment[/-] [+]Python: "take item" selects part of comment before item[/+] on Jan 31, 2025
  2. AndreasArvidsson commented on Jan 31, 2025

    @AndreasArvidsson
    Member

    The items scope has no understanding of comments today. The only thing it does is split on commas. This is of course something we want to improve in the future, but today it's not a bug in the current implementation; it's not just a feature we have implemented yet.

  3. added
    enhancement
    on Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions