Skip to content

Introduce ContextDimension#293

Merged
therazix merged 19 commits into
teemtee:mainfrom
LecrisUT:fix/289
Jun 2, 2026
Merged

Introduce ContextDimension#293
therazix merged 19 commits into
teemtee:mainfrom
LecrisUT:fix/289

Conversation

@LecrisUT
Copy link
Copy Markdown
Member

@LecrisUT LecrisUT commented Apr 28, 2026

This is quite a big one, but I will keep the commits relatively logically contained for easier review commit by commit. The idea here is:

  • Add a container for defining the context dimension comparison operators: ContextDimension
  • Users can extend ContextDimension by sub-classing it and defining the _dimension_name it is linked to
  • If a dimension is not found in the sub-classes, the create_default is used, which by default wraps around ContextValue for backwards-compatibility
  • All of the comparator logic was moved to ContextDimension instead. Operators and decorators were added to manage these more dynamically
  • Some cleanups
    • staticmethod -> classmethod to allow expanding the Context class
    • re_expression_triple was made a function for the reason above
    • Dropped some dead-code parts

Closes #289
Depends-on #297


Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • mention the version
  • include a release note

@github-project-automation github-project-automation Bot moved this to backlog in planning Apr 28, 2026
@LecrisUT LecrisUT moved this from backlog to implement in planning Apr 28, 2026
@LecrisUT LecrisUT moved this from implement to review in planning Apr 28, 2026
@tcornell-bus
Copy link
Copy Markdown

blocked by #294

@thrix
Copy link
Copy Markdown
Contributor

thrix commented Apr 30, 2026

This does not look good:

❯ python3 -c 'import fmf; fmf.Context("module = perl:5.28").matches("module == perl")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import fmf; fmf.Context("module = perl:5.28").matches("module == perl")
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/var/home/thrix/git/github.com/teemtee/fmf/fmf/context.py", line 752, in matches
    result = self.evaluate(expression)
  File "/var/home/thrix/git/github.com/teemtee/fmf/fmf/context.py", line 805, in evaluate
    return self._op_core(dimension_name, values, operator)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/home/thrix/git/github.com/teemtee/fmf/fmf/context.py", line 541, in _op_core
    assert isinstance(dimension_value, ContextDimension)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

Comment thread fmf/context.py
Comment thread fmf/context.py Outdated
@happz
Copy link
Copy Markdown
Contributor

happz commented May 13, 2026

LGTM, in general the operator-based approach fits my view how these things should be implemented. I guess I will have a comment or two, mostly minor ones, when I get back in the evening.

Comment thread fmf/context.py
@psss psss moved this from review to implement in planning May 18, 2026
@LecrisUT LecrisUT force-pushed the fix/289 branch 2 times, most recently from 4dba56d to 3204c6c Compare May 18, 2026 15:44
@LecrisUT LecrisUT moved this from implement to review in planning May 18, 2026
Signed-off-by: Cristian Le <git@lecris.dev>
@psss psss added this to the 1.8 milestone May 19, 2026
Comment thread tests/unit/test_context.py Outdated
Comment thread fmf/context.py
Comment thread fmf/base.py
Copy link
Copy Markdown
Contributor

@thrix thrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing else found. LGTM

@thrix thrix requested a review from happz May 26, 2026 00:52
Copy link
Copy Markdown
Member

@psss psss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just the missing release note.

Comment thread fmf/context.py
@happz happz removed their assignment Jun 2, 2026
@therazix therazix moved this from review to merge in planning Jun 2, 2026
@therazix therazix merged commit e90b1af into teemtee:main Jun 2, 2026
13 checks passed
@github-project-automation github-project-automation Bot moved this from merge to done in planning Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: done

Development

Successfully merging this pull request may close these issues.

Allow context values to be special strings

6 participants