TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

Hey guys!

I’m having an issue with my deployment, I’m building a FastApi endpoint and when I run my code locally it works perfectly, but when I push to render I get a deployment error:

May 9 08:43:32 AM File “/opt/render/project/src/server.py”, line 2, in
May 9 08:43:32 AM from routes.property_routes import property
May 9 08:43:32 AM File “/opt/render/project/src/routes/property_routes.py”, line 24, in
May 9 08:43:32 AM bathrooms: float | None = None,
May 9 08:43:32 AM TypeError: unsupported operand type(s) for |: ‘type’ and ‘NoneType’

This is where it’s failing

@property.get("/")
async def get_properties(
    city: str,
    transaction_type: str = "venta",
    price_min: int | None = 0,
    price_max: int | None = 999999999,
    rooms: int | None = None,
    **bathrooms: float | None = None,**
):

not sure why it’s failing for my render deployment but it works locally, it’s my first time using python too.

Thanks!

Hi,

I suspect you may have a different version of Python locally. May be try specifying a Python version to match your local/tested version.

Alan

that was it! sorry, it’s my first time trying python, thanks a lot!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.