Skip to content

docs: improve Python custom code page with model extension guidance and bug fixes#4853

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1775755096-python-custom-code-improvements
Open

docs: improve Python custom code page with model extension guidance and bug fixes#4853
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1775755096-python-custom-code-improvements

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

Summary

Updates the Python "Adding custom code" page based on user feedback that the page only covered extending the base client class, but didn't explain how to add custom methods to returned objects (models/types).

New content:

  • Added a new "Adding custom methods to models" section showing how to extend Fern-generated Pydantic models with custom methods, computed properties, or domain logic. Covers the full workflow: creating a custom model file, .fernignore, exporting via additional_init_exports, and consuming.

Bug fixes in existing code examples:

  • Fixed Python comments using // (JavaScript syntax) instead of #
  • Removed an accidentally duplicated/nested my_helper method definition

Cleanup:

  • Normalized indentation throughout the page (several sections had inconsistent indentation levels)
  • Renamed "Adding custom SDK methods" → "Adding custom client methods" to distinguish it from the new model section

Review & Testing Checklist for Human

  • Verify the model extension pattern is accurate: Confirm that extending a Fern-generated Pydantic model (e.g., from .types.plant import Plant as BasePlant) and using additional_init_exports to re-export it is the recommended approach. Check that this doesn't conflict with the existing generated Plant export in __init__.py.
  • Check rendered page in preview: Verify all <Steps>, <Note>, and code blocks render correctly — the indentation cleanup was extensive and could affect MDX parsing.
  • Validate the additional_init_exports config snippet: Ensure the YAML example matches the actual generator config schema (the from and imports fields).

Notes

  • Triggered by on-page feedback: "how do we add custom methods to returned objects, not just the base client class?" on the /learn/sdks/generators/python/custom-code page.
  • The new model extension example uses plant-themed content consistent with docs conventions.

Link to Devin session: https://app.devin.ai/sessions/9f4bdfc7973a4002a03df64bc59facc9

…on custom code page

Co-Authored-By: bot_apk <apk@cognition.ai>
@devin-ai-integration devin-ai-integration bot requested a review from devalog as a code owner April 9, 2026 17:20
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@fern-api
Copy link
Copy Markdown
Contributor

fern-api bot commented Apr 9, 2026

Requested by: devin
Slack thread: View conversation

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

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.

0 participants