Skip to content

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

Merged
thierry-martinez merged 8 commits intoTeamGraphix:masterfrom
thierry-martinez:remove_deprecated_print_and_relax_limit_type
Mar 10, 2026
Merged

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

Conversation

@thierry-martinez
Copy link
Copy Markdown
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
Copy Markdown

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.89%. Comparing base (256a359) to head (c4ee3de).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #460      +/-   ##
==========================================
+ Coverage   88.85%   88.89%   +0.04%     
==========================================
  Files          44       44              
  Lines        6533     6530       -3     
==========================================
  Hits         5805     5805              
+ Misses        728      725       -3     

☔ 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

and an ellipsis is added at the end to indicate that some commands have been elided.
If ``limit=None``, there is no limit on the number of printed commands.
target: Container[command.CommandKind], optional
If set, only commands of kinds specified in ``target`` are printed.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To make it searchable when the docs are updated, I think it would be good to explicitly mention here something like For example, you can print only measurements with ``command.M`` or X corrections with ``command.X`` .

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I added runnable (and pytest-checked) examples.

@thierry-martinez thierry-martinez merged commit d5343cf into TeamGraphix:master Mar 10, 2026
24 checks passed
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.

3 participants