Repository navigation
Code style: _bedrock.py without comments, its markdown parser in steps - #93
Merged
Merged
Conversation
Every # comment in _bedrock.py is gone: the price tables' sources and keys are in the module docstring, each dataclass's fields in its docstring (KBDocument, Passage, Citation, ModelInfo, SavedFileList, _Json, _Answer), and the rest in the docstrings of the functions they explained. The functions over ruff's limits are split into steps: - _md_blocks is a loop over _md_block, which hands each kind of block to its reader: _md_code, _md_quote, _md_table (with _md_align), _md_list and _md_paragraph. - _Markdown.parse hands each kind of inline markup to _inline_at: _code_span, _emphasis_node, _link_node, _autolink and _bare_url; link() finds its brackets with _md_closing_bracket and _md_link_target_after. - parse_models reads as _is_text_model, _served_models, _model_info (with _profile_preference) and _application_profile_model; _conditions hands (operator, *values) to _operator_conditions. Old and new give byte-identical output on 4,000 generated markdown answers with random citations (HTML, text lines and [n] markers), every where= form and its errors, and parse_models across regions and profile lists. _bedrock.py is off ruff.toml's per-file-ignores and tests/test_style.py's comment allowances. Co-Authored-By: Claude Opus 5.5 <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.
Step 3 of the code style work, for
_bedrock.py, the modulebedrock_kb.pyandbedrock_chat.pyshare (after #90–#92).What changed
Comments. All 90
#comments are gone:KBDocument,Passage,Citation,ModelInfo,SavedFileList,_Json,_Answer).Long functions split into steps:
_md_blocks: complexity 17, 75 lines_md_block, which hands each kind of block to its reader:_md_code,_md_quote,_md_table(with_md_align),_md_listand_md_paragraph_Markdown.parse: complexity 19_inline_at, which hands each kind of inline markup to_code_span,_emphasis_node,_link_node,_autolinkor_bare_url_Markdown.link: complexity 12_md_closing_bracketand_md_link_target_afterparse_models: complexity 11_is_text_model,_served_models,_model_info(with_profile_preference) and_application_profile_model_conditions: complexity 11_operator_conditionsfor(operator, *values)_bedrock.pycomes off both allowance lists.Nothing a user sees changed
main's_bedrock.pyand this branch's gave byte-identical output on all of these:javascript:links) with random citations: the HTML, the text lines and the[n]markers, 2.2 MB in all;where=form and its error messages;parse_modelsacross three regions, with profiles listed, unlisted and empty.snapshot.py compareshows 319 of 321 outputs identical. The other two are the known traceback line numbers, the only "lost" names are the two from Code style: agent/ without comments, its tools as methods #92, and the AWS operations are unchanged.No CHANGELOG entry: nothing a user sees changes.
🤖 Generated with Claude Code