Skip to content

Conversation

@pydanny
Copy link
Member

@pydanny pydanny commented Dec 8, 2025

Having inherited its Application and Routing classes from FastAPI, Air has a lot of extraneous method arguments for route handlers related to response types. This PR removes those arguments, to simplify the API design.

Unfortunately in doing so we violate the Liskov substitution principle, which causes understandable type failures. This PR addresses that by telling type checkers to ignore that error.

I'm not sure breaking LSP is the right approach. Other options include:

  1. Construct our own Application/Routing object rather than inherit from FastAPI. But then we lose the ability to turn on making each route path show up in the API docs, which can be useful for more complex projects.
  2. Do the above, but mix in typing.Protocol
  3. Keep the extraneous arguments as-is so as not to break a core principal of OO design

Note: This doesn't yet touching routing.py, but if we decide to go this path I'll implement it.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • New feature
    • Core Air (Air Tags, Request/Response cycle, etc)
    • Optional (Authentication, CSRF, etc)
    • Third-Party Integrated (Cookbook documentation on using Air databases or a task manager, etc)
    • Out-of-Scope (Formal integration with databases, external task managers, or commercial services etc - won't be accepted, please create a separate project)
  • Refactoring (no functional changes, no api changes)
  • Chore: Dependency updates, Python version changes, etc.
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Pull request tasks

The following have been completed for this task:

  • Code changes
  • Documentation changes for new or changed features
  • Alterations of behavior come with a working implementation in the examples folder
  • Tests on new or altered behaviors

Checklist

  • I have run just test and just qa, ensuring my code changes passes all existing tests
  • I have performed a self-review of my own code
  • I have ensured that there are tests to cover my changes

@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR simplifies the Air framework's API by removing FastAPI's response model-related parameters from the route operator methods (get, post, patch, put, delete). The parameters are removed from the public API signatures but hardcoded to their default values when calling the parent FastAPI methods.

Key Changes:

  • Removed 7 response model parameters from method signatures: response_model, response_model_include, response_model_exclude, response_model_by_alias, response_model_exclude_unset, response_model_exclude_defaults, and response_model_exclude_none
  • Added # type: ignore[override] comments to suppress Liskov Substitution Principle violations
  • Removed unused IncEx import from fastapi.types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pydanny
Copy link
Member Author

pydanny commented Dec 21, 2025

Superseded by #906

@pydanny pydanny closed this Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants