Skip to content

Replace lambda repr filters with bool #58

Description

@pomponchik

Blocked by mutating/sigmatch#17.

CI failure with the original bool filters:
https://github.com/mutating/cantok/actions/runs/28411635113/job/84185622935?pr=57#logs

AbstractToken.__repr__ uses lambdas only because bool currently raises
sigmatch.errors.SignatureNotFoundError through printo.describe_call on
Python 3.11.

After sigmatch supports matching built-in callables, replace the workaround:

diff --git a/cantok/tokens/abstract/abstract_token.py b/cantok/tokens/abstract/abstract_token.py
@@
             filters={
-                0: lambda argument: bool(argument),
-                'cancelled': lambda argument: bool(argument),
+                0: bool,
+                'cancelled': bool,
                 'doc': not_none,
             },

Verify on Python 3.11 that repr(SimpleToken()) == 'SimpleToken()' and the test
suite still passes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions