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

frozenset not working as expected #2932

Closed
9 tasks done
as24-asingla opened this issue Mar 11, 2021 · 8 comments
Closed
9 tasks done

frozenset not working as expected #2932

as24-asingla opened this issue Mar 11, 2021 · 8 comments
Labels
answered feature New feature or request reviewed

Comments

@as24-asingla
Copy link

as24-asingla commented Mar 11, 2021

First check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.
  • After submitting this, I commit to one of:
    • Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
    • I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
    • Implement a Pull Request for a confirmed bug.

Example

Here's a self-contained, minimal, reproducible, example with my use case:

from fastapi import FastAPI

app = FastAPI()


@app.get("/prices", name='Prices for stocks')
def get_prices(stocks: Optional[frozenset]):

    return 23

Description

I get an error 422 when run the query on /docs page itself.

{
  "detail": [
    {
      "loc": [
        "query",
        "stocks"
      ],
      "msg": "value is not a valid frozenset",
      "type": "type_error.frozenset"
    }
  ]
}
```
### Environment

* OS: macOS
* FastAPI Version: 0.63.0

To know the FastAPI version use:

```bash
python -c "import fastapi; print(fastapi.__version__)"
```

* Python version: 3.8.5

To know the Python version use:

```bash
python --version
```
@as24-asingla as24-asingla added the question Question or problem label Mar 11, 2021
@ycd
Copy link
Contributor

ycd commented Mar 11, 2021

Python version: 2.7.18 a typo or?

@as24-asingla
Copy link
Author

Sorry, its 3.8.5. 2.7.18 was the version of my EC2 instance and not docker.

@juntatalor
Copy link
Contributor

@as24-asingla Hi! frozenset was not processed as a sequence (but set did). I suggest a solution in #2938

@theo-brown
Copy link

Hi, I've got this issue as well. Looks like #2938 hasn't been merged.

@tiangolo tiangolo added feature New feature or request question Question or problem and removed question Question or problem labels Aug 26, 2022
@tiangolo
Copy link
Owner

Hey there! Thanks for the discussion. This was solved by @juntatalor in #2938 🎉

It will be available in the next version, released in a couple of hours, FastAPI 0.81.0. 🚀

@tiangolo tiangolo added answered and removed question Question or problem labels Aug 26, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2022

Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs.

@github-actions github-actions bot closed this as completed Sep 6, 2022
@kannanwisen
Copy link

kannanwisen commented Oct 14, 2022

@app.post("/FrozenSet")
def frozen_set(param1: FrozenSet[str] = Body(default=None)):
    print(param1, type(param1))
    return param1

image

If I pass like this, i get the below error.

image

If i pass like below, it works.

image

@kannanwisen
Copy link

Even same for bytes data type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered feature New feature or request reviewed
Projects
None yet
Development

No branches or pull requests

6 participants