Pass Tongues pycheck, remove in-tree transpiler and dist#410
Merged
Conversation
Workaround for Tongues not resolving type aliases used before their definition (ldayton/Tongues#243). Converts the Union type aliases into actual base classes that the leaf node types inherit from, eliminating the forward-reference cycle.
- Delete transpiler/ directory (now lives in ldayton/Tongues) - Remove src-subset, transpiler-subset, transpiler-test justfile targets - Remove transpiler path args from backend-transpile/backend-test/backend-coverage - Remove transpiler-related Claude skills (c-fix, idiomatize, perl-fix) - Remove transpiler from README project structure
Backends now live in their own repositories.
…ance - Add to_sexp() to ArithNode and CondNode base classes so Tongues can resolve method calls on the base type - Change peek()/advance() return type from str | None to str, returning "" instead of None at end-of-input (all callers already guard with at_end())
- Add assert for self._parser is not None before Parser method calls - Use isinstance() checks instead of .kind string comparisons for type narrowing in _format_cond_body, _starts_with_subshell, _format_cmdsub_node, and other dispatch sites - Type cmdsub_parts/procsub_parts as specific list types
- Extract tuple elements to local vars for is-not-None narrowing - Add assert for _parser before method calls - Use explicit is not None / != "" instead of truthiness for optionals - Add missing list type annotations
- Fix covariant return types: parse_* methods return Node | None - Use isinstance() for type narrowing in _format_cmdsub_node - Fix redirect list types and _format_redirect narrowing - Fix result_parts type from tuple to str - Widen Subshell/BraceGroup redirect types to list[Node] Remaining 4 errors are Tongues not understanding bytearray operations.
Allows at most 4 known bytearray errors (ldayton/Tongues#244).
- Delete unused _string_to_bytes function (last pycheck error) - Add check-tongues justfile target requiring >= 0.2.1 - pycheck depends on check-tongues
- Remove default from _scan_double_quote(handle_line_continuation=True) (sole caller already passes explicitly) - Remove default from parse_list(newline_as_separator=True), add True at all 12 bare call sites Reduces lowering errors from 3 to 1 (remaining: bytearray.decode, Tongues#250).
Tongues subset does not allow inheriting from concrete classes. MatchedPairError is now a standalone Exception with its own fields. Catch sites updated to catch both (ParseError, MatchedPairError).
…able reuse - Wrap int f-string args with str() for Tongues subset compliance - Add assert self._parser is not None at 14 additional call sites - Rename result -> segments in _format_cmdsub_node list branch to avoid variable type reuse (list[str] vs str in same function scope)
- List.to_sexp, _to_sexp_with_precedence, _to_sexp_amp_and_higher - Pipeline.to_sexp, _cmd_sexp - Word._collect_cmdsubs (split or-chained isinstance into separate branches) - Word._format_command_substitutions (rename node -> cmdsub/procsub) - Use nested ifs for Operator.op checks (workaround for pycheck bug with isinstance + field compare on same line) Eliminates all 92 "cannot access field on interface Node" errors.
- ParseError/MatchedPairError: pos=X → positional - Parser(): extglob= and in_process_sub= → positional
CondNode narrowing, find() workaround, named arg leftovers, SavedParserState heredoc type
…arrowing) - _parse_cond_or, _parse_cond_and, _parse_cond_term now return CondNode - Arith parser methods stay as Node: expansions (ParamExpansion, CommandSubstitution, etc.) can appear inside arithmetic contexts, so the return type can't be narrowed to ArithNode
…irect types - Guard CommandSubstitution(cmd) against None from parse_list() - Restructure parse_pipeline() to narrow Node | None before prefix wrapping - Guard Negation(inner) against None from recursive parse_pipeline() - Annotate words: list[Word] = [] in for/select parsers Dev pycheck: 44 → 30 (remaining 29 are ArithNode narrowing, 1 covariance)
- All Arith* node fields widened from ArithNode to Node (expansions like ParamExpansion appear inside arithmetic expressions) - ArithTernary.if_true/if_false widened to Node | None (empty branches) - ArithmeticCommand/ConditionalExpr redirects widened to list[Node] - Guard nullable fields in to_sexp and _collect_cmdsubs Dev pycheck: 30 → 0
…nullability - Eliminate variable reuse in _parse_compound_command (separate var per branch) - Fix last named arg (pos=start in MatchedPairError) - Add assert for Token nullable return in peek_token - Widen parse_conditional_expr return to Node | None (covariance)
The nested for-loop variable `cmd` inside an `elif isinstance` branch was incorrectly flagged as "used before assignment" by the Tongues Taytsh checker when transpiling the full file. Extracting the loop into a helper function avoids the issue.
- Split param None/empty check so param is always str after guard - Annotate words with explicit type to avoid redefinition ambiguity - Use separate variable for peek_word result to avoid hoisted optional
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
transpiler/anddist/directories — Tongues is now installed via HomebrewArithNode/CondNodeUnion aliases with base classespeek()/advance()fromstr | Nonetostrisinstance()narrowing for subclass attribute accessis not NonechecksNode | None_string_to_bytesfunctionjust pycheckandjust check-tongues(requires >= 0.2.1)fuzzer-agentand fuzzer docs/prompts