refactor(builder): simplify builder package#69
Merged
Conversation
- Collapse `is_collection` two-step logic to `not remainder`
- Drop unused `is_collection_path` param from `_attach`; drop unused `schema_op`/`resource_name` params from `_classify`
- Fold `synthesized` intermediate var into single `operation_id =` expression
- Extract `is_object_like` to eliminate duplicate `top_level in (...)` test
- Replace double `model_extra or {}` double-access with a single `extras` var in `_classify_top_level`, `_object_branch`, and `_collect_sensitive_paths`
- Simplify `_collect_sensitive_paths` ref-cycle guard: track `schema.ref` only (the ref we entered with)
- Replace `getattr(schema, "format", None)` with direct `schema.format` (typed field)
No behaviour changes. All tests pass.
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.
Closes #49
Simplify pass on
nsc/builder/build.py. No behaviour changes. All tests pass.Changes:
_resource_from_path: collapseis_collectiontwo-step logic tonot remainder_attach: drop unusedis_collection_pathparameter_classify: drop unusedschema_op/resource_nameparameters; renameextra_path_segments→last_segment_to_model_operation: foldsynthesizedintermediate var into single assignment_to_request_body_shape: extractis_object_liketo eliminate duplicatetop_level in (...)test_classify_top_level/_object_branch/_collect_sensitive_paths: replace repeated(model_extra or {}).get(...)double-access with a singleextraslocal_collect_sensitive_paths: simplify ref-cycle guard — trackschema.refonly (the ref we entered with, nottarget.ref)_is_sensitive_field: replacegetattr(schema, "format", None)with directschema.format(typed Pydantic field)