Home > Software design >  Is there an advantage to Lambda Powertools’s Parser over straight Pydantic?
Is there an advantage to Lambda Powertools’s Parser over straight Pydantic?

Time:01-09

I’ve got models which inherit Pydantic’s BaseModel and I use this to define my model attributes and do some validation.

But I see that Lambda Powertools comes with a Parser module which uses Pydantic.

Now that I want to use these models within an AWS lambda execution, is there a benefit to using:

from aws_lambda_powertools.utilities.parser import BaseModel

Instead of sticking with my existing

from pydantic import BaseModel

I can see that the Powertools Parser comes with a useful BaseEnvelope - but is BaseModel in Powertools any different?

And as a followup, if there is a benefit, could I monkey patch within the lambda runtime so I can:

  1. Keep my models independent of anything Lambda like.
  2. Spare myself from changing all the imports.

CodePudding user response:

You don't have to update your imports. AWS Lambda Powertools's BaseModel is just a re-export of Pydantic's BaseModel.

  • Related