Skip to content

Allow printing limit to be None, remove deprecated print_pattern#460

Open
thierry-martinez wants to merge 6 commits intoTeamGraphix:masterfrom
thierry-martinez:remove_deprecated_print_and_relax_limit_type
Open

Allow printing limit to be None, remove deprecated print_pattern#460
thierry-martinez wants to merge 6 commits intoTeamGraphix:masterfrom
thierry-martinez:remove_deprecated_print_and_relax_limit_type

Conversation

@thierry-martinez
Copy link
Collaborator

This commit:

  • updates Pattern methods (to_ascii, to_unicode, to_latex) and pattern_to_str to allow limit to be None.
  • removes the deprecated print_pattern function.

This commit:
- updates `Pattern` methods (`to_ascii`, `to_unicode`, `to_latex`) and
  `pattern_to_str` to allow `limit` to be `None`.
- removes the deprecated `print_pattern` function.
@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.88%. Comparing base (927aa4b) to head (6f37359).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #460      +/-   ##
==========================================
+ Coverage   88.85%   88.88%   +0.02%     
==========================================
  Files          44       44              
  Lines        6533     6530       -3     
==========================================
- Hits         5805     5804       -1     
+ Misses        728      726       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

truncated = len(command_list) > limit
short_command_list = command_list[: limit - 1] if truncated else command_list
truncated = limit is not None and len(command_list) > limit
short_command_list = command_list[: limit - 1] if limit is not None and truncated else command_list
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
short_command_list = command_list[: limit - 1] if limit is not None and truncated else command_list
short_command_list = command_list[: limit - 1] if truncated else command_list

Here truncated is enough,

$$A \land (A \land B) = A \land B,$$

right?

Copy link
Collaborator Author

@thierry-martinez thierry-martinez Mar 9, 2026

Choose a reason for hiding this comment

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

You're right: logically the test is redundant because truncated already implies limit is not None. However, mypy does not track implications across boolean variables, so it won't narrow the type of limit without the explicit check. I added the following comment in commit 9249f0e:

    # Note: The redundant test `limit is not None` is required for mypy
    # to narrow the type of `limit` in the then-branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see thanks, for the clarification and adding the comment

if output == OutputFormat.LaTeX:
result = f"\\({result}\\)"
if truncated:
if limit is not None and truncated:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if limit is not None and truncated:
if truncated:

Copy link
Contributor

@matulni matulni left a comment

Choose a reason for hiding this comment

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

LGTM!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants