Skip to content

Conflict with openpyxl? #2612

@ufoym

Description

@ufoym

Describe the bug

Importing openpyxl makes fastapi confuse types of query parameters.

To Reproduce

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

import fastapi
import openpyxl   # if comment out, the result would be OK
from typing import List, Union, Optional

app = fastapi.FastAPI()

@app.get('/')
def read_items(p: Optional[Union[int, str]] = None):
    return isinstance(p, int)   # if p = 1, return false!

Description

  • Open the browser and call the endpoint /.
  • Input p = 1.
  • It returns false.
  • But I expected it to return true.
  • If comment out import openpyxl, the result would be true as expected.

Environment

  • OS: macOS
  • FastAPI Version: 0.62.0
  • Python version: 3.7.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions