Skip to content

refactor(builder): simplify builder package#69

Merged
thomaschristory merged 3 commits into
mainfrom
refactor/builder-simplify
May 12, 2026
Merged

refactor(builder): simplify builder package#69
thomaschristory merged 3 commits into
mainfrom
refactor/builder-simplify

Conversation

@thomaschristory
Copy link
Copy Markdown
Owner

Closes #49

Simplify pass on nsc/builder/build.py. No behaviour changes. All tests pass.

Changes:

  • _resource_from_path: collapse is_collection two-step logic to not remainder
  • _attach: drop unused is_collection_path parameter
  • _classify: drop unused schema_op/resource_name parameters; rename extra_path_segmentslast_segment
  • _to_model_operation: fold synthesized intermediate var into single assignment
  • _to_request_body_shape: extract is_object_like to eliminate duplicate top_level in (...) test
  • _classify_top_level / _object_branch / _collect_sensitive_paths: replace repeated (model_extra or {}).get(...) double-access with a single extras local
  • _collect_sensitive_paths: simplify ref-cycle guard — track schema.ref only (the ref we entered with, not target.ref)
  • _is_sensitive_field: replace getattr(schema, "format", None) with direct schema.format (typed Pydantic field)

- 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>
@thomaschristory thomaschristory merged commit 33ee3f4 into main May 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: review & simplify nsc/builder/build.py

1 participant