Skip to content

Conversation

@Apricot-S
Copy link
Collaborator

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/or conditional expression with an explicit if not suits: return "".
This makes the control flow clearer and easier to understand.

3. Introduced intermediate variables

Added man_words, pin_words, sou_words, and honors_words to 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.

@Apricot-S Apricot-S requested a review from Nihisil January 24, 2026 16:48
@Apricot-S Apricot-S self-assigned this Jan 24, 2026
@Nihisil Nihisil merged commit 5fb1faa into MahjongRepository:master Jan 25, 2026
10 checks passed
@Apricot-S Apricot-S deleted the refactor/to_string branch January 25, 2026 08:53
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