refactor: Simplify TilesConverter.to_one_line_string() implementation
#101
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR refactors the internal implementation of
TilesConverter.to_one_line_string()to improve readability, maintainability, and type safety. There are no functional changes.Changes
1. Simplified suit extraction logic (minor performance improvement)
Extraction and offset adjustment are now combined into a single list comprehension.
This reduces redundant loops and results in a small performance gain.
2. Early return in
words()Replaced the previous
and/orconditional expression with an explicitif not suits: return "".This makes the control flow clearer and easier to understand.
3. Introduced intermediate variables
Added
man_words,pin_words,sou_words, andhonors_wordsto clarify the flow of data and stabilize type inference.4. Removed
# type: ignore(made unnecessary by change 3)The introduction of intermediate variables resolved the mypy type errors that previously required
# type: ignore, allowing all ignores to be safely removed.