79207377

Date: 2024-11-20 13:23:56
Score: 1.5
Natty:
Report link

I'm still not convinced that it's a necessary approach, but here's a really simple option how to achieve this:

from pydantic import BaseModel


class MyModel(BaseModel):
    x: int

    def __init__(self, x: int | str):
        super().__init__(x=len(x) if isinstance(x, str) else x)

MyModel(x='test')
Reasons:
  • Blacklisted phrase (1): how to achieve
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Sergius