Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: __init__() got an unexpected keyword argument 'prefix' #29

Closed
dineshkumarkb opened this issue Feb 19, 2021 · 2 comments · Fixed by #30
Closed

TypeError: __init__() got an unexpected keyword argument 'prefix' #29

dineshkumarkb opened this issue Feb 19, 2021 · 2 comments · Fixed by #30

Comments

@dineshkumarkb
Copy link

dineshkumarkb commented Feb 19, 2021

Hi there,

I tried to create a sample code from the documentation. However it throws a type error.

Please find my code and other details below.

Code:

from pydantic import BaseModel
from fastapi import FastAPI
from fastapi_crudrouter import MemoryCRUDRouter as CRUDRouter

class Car(BaseModel):

    name: str
    year: int
    make: str


app = FastAPI()
app.include_router(CRUDRouter(schema=Car))

When I try to execute this, I get the following error.

Traceback (most recent call last):
  File "/home/dineshkumarkb/MyGitHub/MyPractice/Python/fastapi/autogenerate.py", line 13, in <module>
    app.include_router(CRUDRouter(Car))
  File "/home/dineshkumarkb/.local/lib/python3.8/site-packages/fastapi_crudrouter/core/mem.py", line 11, in __init__
    super(MemoryCRUDRouter, self).__init__(schema, *args, **kwargs)
  File "/home/dineshkumarkb/.local/lib/python3.8/site-packages/fastapi_crudrouter/core/_base.py", line 35, in __init__
    super().__init__(prefix=prefix, tags=[prefix.strip('/').capitalize()], *args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'prefix'

Am I missing something?

Python version : 3.8.5
OS : Ubuntu 20.04

@awtkns
Copy link
Owner

awtkns commented Feb 20, 2021

Hi there thanks for the feedback! I tested this with fastapi version 0.62.0+ and it worked. It seems prefix was a new feature in v.0.62 so that likely your issue. What version were you using?

Release notes: https://fastapi.tiangolo.com/release-notes/#0620

I am looking a workarounds for older versions of fastapi.

awtkns added a commit that referenced this issue Feb 20, 2021
🐛 No prefixing below fastapi v0.62 #29
@awtkns
Copy link
Owner

awtkns commented Feb 20, 2021

Thanks @dineshkumarkb!

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 a pull request may close this issue.

2 participants