Remove dead code and unused helper functions#7
Merged
Conversation
Systematic dead code cleanup identified via vulture analysis and manual call-graph tracing from the entry points (pull/diff/push/test in __main__.py). Removed across 14 files: - diff_engine.py: Legacy DiffOperation class and entire unused insert chain (_generate_paragraph_insert, _generate_special_insert, _generate_table_insert, _emit_cell_content, _table_cell_starts, _table_length, _element_length, _operation_to_request, _full_run_text_style, _styles_to_text_style, _adjust_for_segment_end, _calculate_content_length, _get_element_text) - block_diff.py: Unused methods (_calculate_table_cell_end_index, _diff_table_cells, _lcs_align) - request_generators/content.py: Entire file gutted (generate_content_requests and all supporting code never called from production) - request_generators/structural.py: Unused functions (separate_structural_requests, extract_created_ids, substitute_placeholder_ids, CREATION_REQUEST_TYPES) - request_generators/table.py: Unused functions (generate_table_cell_style_requests, calculate_cell_positions, calculate_table_length, generate_insert_table_request) - style_converter.py: NAMED_STYLE_MAP, build_text_style_request, build_paragraph_style_request - style_factorizer.py: extract_paragraph_style - style_hash.py: style_id_short, __main__ demo block - desugar.py: flatten_section, Paragraph.text_content - xml_converter.py: _indent, _convert_footnote, current_tab_id field - transport.py: Unused instance attributes (_access_token, _timeout) - __main__.py: cmd_test (handled inline) All 45 passing tests remain passing. The one pre-existing test failure (test_table_cell_modified) is unrelated. https://claude.ai/code/session_01N8TnRLa3jk8RQWYhT3wb7H
sripathikrishnan
added a commit
that referenced
this pull request
Feb 27, 2026
Security: - Move session_token from POST body to Authorization: Bearer header to prevent proxy/access log exposure (#1) - Atomic ownership check in revoke_session_token via expected_email param, eliminating TOCTOU race (#2) - Redact full session_hash from list_sessions when admin views another user's sessions; self-service callers retain it (#3) - Fix X-Forwarded-For to use rightmost (infra-injected) IP instead of first (spoofable) entry (#7) Correctness: - Ensure service account is provisioned at session establishment time (exchange_auth_code_for_session), enforcing the invariant that SA always exists for any v2 session; remove downstream or-"" fallbacks and 500 guard (#6) - Validate _server_base_url before opening browser to avoid post-auth failure when server URL is not configured (#4) - Raise ValueError instead of silently dropping extra scopes in v2 get_oauth_token (#5) - Apply SA_TOKEN_CACHE_SECONDS cap client-side for SA tokens (#8) UX: - Prompt for confirmation before revoking an existing valid session in auth login; skip prompt when stdin is not a tty (#9) - Use timezone.utc in all datetime.fromtimestamp calls in CLI output (#10) Fakes / tests: - Fix FakeDatabase.retrieve_auth_code to check flow_type and expiry before popping, preventing silent code destruction on type mismatch (#11) - Update FakeDatabase.revoke_session_token to accept expected_email (#2) Docs: - Fix stale pseudo_scope field name in database.py docstring (#12) - Document _explicit_auth_urls v2 activation edge case (#13) - Add type safety / None discipline principle to CLAUDE.md files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
This PR removes a significant amount of dead code and unused helper functions that were identified during code cleanup. These functions were either superseded by newer implementations, no longer called, or part of incomplete refactoring efforts.
Key Changes
Removed Functions
cmd_test()in__main__.py- Unused command wrapper_calculate_table_cell_end_index()inblock_diff.py- Unused table cell calculation_diff_table_cells()inblock_diff.py- Legacy table diffing method (replaced by_diff_table_structure)_lcs_align()inblock_diff.py- Unused LCS alignment utilityParagraph.text_content()indesugar.py- Unused text extraction methodflatten_section()indesugar.py- Unused section flattening utilitydiff_engine.py:_styles_to_text_style()_full_run_text_style()DiffOperationdataclass_operation_to_request()_generate_paragraph_insert()_generate_special_insert()_generate_table_insert()_emit_cell_content()_table_cell_starts()_table_length()_element_length()diff_engine.py:_adjust_for_segment_end()_calculate_content_length()_get_element_text()Updated Imports
diff_engine.py(json,Paragraph,SpecialElement,Table,TableCell)desugar.py(Any)request_generators/__init__.pyto remove exports of deleted functionsConfiguration
[dependency-groups]section topyproject.tomlfor PEP 735 compatibilityImpact
https://claude.ai/code/session_01N8TnRLa3jk8RQWYhT3wb7H