Skip to content

Refactor: Move dataclasses from routes/models.py to resources/ - #591

Merged
razor-x merged 1 commit into
mainfrom
claude/models-resources-refactor-y7k01s
Jul 27, 2026
Merged

Refactor: Move dataclasses from routes/models.py to resources/#591
razor-x merged 1 commit into
mainfrom
claude/models-resources-refactor-y7k01s

Conversation

@razor-x

@razor-x razor-x commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

This PR refactors the codebase to reorganize dataclass definitions by moving them from a monolithic seam/routes/models.py file into individual modules under a new seam/resources/ package. Abstract route classes are now defined inline within their respective route modules rather than in a centralized models file.

Key Changes

  • Removed seam/routes/models.py: Deleted the 3640-line monolithic models file that contained all dataclass definitions and abstract route classes
  • Created seam/resources/ package: New package structure with individual dataclass modules:
    • Resource dataclasses: AccessCode, Device, AcsUser, AcsSystem, Workspace, SeamEvent, etc.
    • Action/pagination classes: ActionAttempt, Pagination
    • All dataclasses now use @dataclass decorator and DeepAttrDict utility
  • Inline abstract classes: Abstract route classes (e.g., AbstractAccessCodes, AbstractThermostats) are now defined directly in their corresponding route modules using abc.ABC
  • Updated imports across codebase: All route modules and other files updated to import from seam.resources instead of seam.routes.models
  • Updated codegen:
    • Removed codegen/lib/layouts/models.ts
    • Added codegen/lib/layouts/resources.ts to generate individual resource modules
    • Updated route generation to include abstract classes inline
    • Modified codegen/smith.ts to clean up both routes and resources directories

Implementation Details

  • Each resource is now in its own module (e.g., seam/resources/device.py, seam/resources/access_code.py)
  • Resources are re-exported from seam/resources/__init__.py for convenient importing
  • Abstract route classes use Python's abc module with @abc.abstractmethod decorators
  • Maintains backward compatibility through the centralized __init__.py export
  • Codegen templates updated to generate resources as individual files rather than a single models file

https://claude.ai/code/session_01MNpvDnkB6xgtjBT4bnPZzC

Replace the single seam/routes/models.py with a seam/resources package that
exports one dataclass per module, and move each abstract route class next to
the concrete route class it describes.

- seam/resources/<resource>.py holds one dataclass each, re-exported from
  seam/resources/__init__.py
- seam/routes/<namespace>.py now defines AbstractX alongside X, and
  seam/routes/__init__.py defines AbstractRoutes alongside Routes
- AbstractSeamHttpClient moves from seam/models.py to seam/client.py so that
  seam.client no longer imports seam.models, which would otherwise cycle
  through seam.routes
- Codegen emits the new layout: models.hbs is replaced by resource.hbs and
  resources-index.hbs, and the models layout context becomes resources.ts

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MNpvDnkB6xgtjBT4bnPZzC
@razor-x
razor-x marked this pull request as ready for review July 27, 2026 23:45
@razor-x
razor-x requested a review from a team as a code owner July 27, 2026 23:45
@razor-x
razor-x merged commit 8394b5a into main Jul 27, 2026
18 checks passed
@razor-x
razor-x deleted the claude/models-resources-refactor-y7k01s branch July 27, 2026 23:45
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.

2 participants