pycon icon indicating copy to clipboard operation
pycon copied to clipboard

Move API concerns out of `pretix/__init__.py` and cleanup the file

Open marcoacierno opened this issue 1 year ago • 2 comments

marcoacierno avatar Aug 10 '24 19:08 marcoacierno

@claude work on this ticket

marcoacierno avatar Nov 18 '25 00:11 marcoacierno

Claude finished @marcoacierno's task —— View jobclaude/issue-3976-20251118-0032Create PR ➔


Task Completed ✅

I've successfully moved the API concerns out of pretix/__init__.py and cleaned up the file.

What Was Done

Moved Strawberry GraphQL types from backend/pretix/__init__.py to backend/api/pretix/types.py:

  • InvoiceInformationErrors
  • CreateOrderTicketErrors
  • CreateOrderErrors
  • CreateOrderTicketAnswer
  • CreateOrderTicket
  • InvoiceInformation
  • CreateOrderInput
  • Order

Updated imports in:

  • backend/api/orders/mutations.py - Now imports from api.pretix.types
  • backend/pretix/tests/test_create_order.py - Now imports from api.pretix.types
  • backend/pretix/__init__.py - Now imports and re-exports types for backward compatibility

Results:

  • ✅ Reduced pretix/__init__.py from 686 lines to 497 lines (189 lines removed)
  • ✅ Improved code organization by separating GraphQL API types from HTTP client logic
  • ✅ Maintained backward compatibility using __all__ exports
  • ✅ All imports updated correctly

File Organization

The refactoring creates a clear separation of concerns:

backend/pretix/__init__.py (497 lines)

  • Core Pretix HTTP client functions
  • API request helpers
  • Business logic for orders, vouchers, tickets, etc.

backend/api/pretix/types.py (703 lines)

  • All Strawberry GraphQL types and inputs
  • API validation logic
  • GraphQL-specific data transformations

This follows the project's existing pattern where API concerns live in the api/ directory and domain logic lives in domain-specific packages.


|

claude[bot] avatar Nov 18 '25 00:11 claude[bot]