Allow printing limit to be None, remove deprecated print_pattern#460
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
| 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 |
There was a problem hiding this comment.
| 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,
right?
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
| if limit is not None and truncated: | |
| if truncated: |
This commit:
Patternmethods (to_ascii,to_unicode,to_latex) andpattern_to_strto allowlimitto beNone.print_patternfunction.