refactor(grammar): modernize string formatting with f-strings and improve type hinting - #1635
refactor(grammar): modernize string formatting with f-strings and improve type hinting#1635ardozcnn wants to merge 4 commits into
Conversation
|
Overall looks okay. You can use tox to run the type checker with the official configuration. |
|
I ran the code can you check? |
|
Opus says (and I agree):
We support Python 3.8 and have no runtime dependencies, so import it the way common.py already does: if TYPE_CHECKING: |
|
Thanks for the detailed review! I've updated renamed() to return Self (handled via TYPE_CHECKING for Python 3.8 compatibility) and changed memo in NonTerminal.serialize to Any as suggested. |
|
You accidentally deleted the |
added ###}
|
Sorry about that! I've restored the ###} comment for the standalone parser. Thanks for the review |
Replaced legacy % string formatting across Symbol, Terminal, RuleOptions, and Rule classes with modern Python f-strings.
Added missing type hints for method parameters (other: Any, memo: Optional[Dict], f: Callable) and return types (-> None, -> str, -> int).
Included empty_indices in RuleOptions.repr to accurately reflect all initialization parameters.
Formatted tuple entries in serialize_fields consistently.