Fern Python SDK oddities

When building FastAPI client I use provided types for typehints and OpenAPI schema, this however has some amount of weirdness:

  1. Many model docstrings has _ symbol escaped, this results in numerous warnings happening when importing a related module:
/usr/local/lib/python3.12/site-packages/square/requests/invoice.py:143: SyntaxWarning: invalid escape sequence '\_'
  For example, a payment `due_date` of 2021-03-09 with a `timezone` of America/Los\_Angeles
/usr/local/lib/python3.12/site-packages/square/requests/invoice_payment_request.py:54: SyntaxWarning: invalid escape sequence '\_'
  of America/Los\_Angeles becomes overdue at midnight on March 9 in America/Los\_Angeles (which equals a UTC
/usr/local/lib/python3.12/site-packages/square/types/invoice.py:144: SyntaxWarning: invalid escape sequence '\_'
  For example, a payment `due_date` of 2021-03-09 with a `timezone` of America/Los\_Angeles
/usr/local/lib/python3.12/site-packages/square/types/invoice_payment_request.py:55: SyntaxWarning: invalid escape sequence '\_'
  of America/Los\_Angeles becomes overdue at midnight on March 9 in America/Los\_Angeles (which equals a UTC
/usr/local/lib/python3.12/site-packages/square/requests/external_payment_details.py:21: SyntaxWarning: invalid escape sequence '\_'
  - OTHER\_GIFT\_CARD - Paid using a non-Square gift card.
/usr/local/lib/python3.12/site-packages/square/types/external_payment_details.py:22: SyntaxWarning: invalid escape sequence '\_'
  - OTHER\_GIFT\_CARD - Paid using a non-Square gift card.
/usr/local/lib/python3.12/site-packages/square/requests/destination_details_external_refund_details.py:19: SyntaxWarning: invalid escape sequence '
  1. Confusingly, all models have typing.Optional[some type here] = pydantic.Field(default=None) set on all fields. And the model itself subclasses custom UncheckedBaseModel.
    Not sure what exactly is patched, but this completely breaks OpenAPI schema generator, which in turn resolves all type definition to Any:
Money			{}
Payment			{}
PaymentRefund	{}

Is it possible to update Fern configuration so that information is generated with proper typehints?

:waving_hand: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Square GraphQL
Build your First GraphQL Query
Frontend and Backend Development

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Hello,

Thanks for share great guide but i have one question .
Is the use of UncheckedBaseModel deliberate, and does it impact schema generation? Should I be subclassing from a different base to get proper OpenAPI types? hctra org

Best Regard,
Lisa

The team is looking into this. :slight_smile:

1 Like