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

Workaround to fix Pyright/Pydantic missing parameters issue #4725

Closed
wants to merge 3 commits into from

Conversation

jtv8
Copy link

@jtv8 jtv8 commented Mar 25, 2022

Users of Pyright, or the Pylance extension in Visual Studio Code, may have noticed that when type checking is activated certain models in fastapi.openapi.models complain about missing parameters that are actually optional.

Most notably, the Schema object cannot be created programmatically without a type checking error as Pyright/Pylance believes that it is missing an required keyword argument, $ref, that cannot be legally provided in Python.

Arguments missing for parameters "$ref", ...

This is due to a known compatibility issue with a workaround that is documented here:
pydantic/pydantic#3753

This PR implements that workaround for the models in fastapi.openapi.models.

@codecov
Copy link

codecov bot commented Apr 25, 2022

Codecov Report

Merging #4725 (23888ca) into master (9090c77) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #4725   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          531       531           
  Lines        13630     13630           
=========================================
  Hits         13630     13630           
Impacted Files Coverage Δ
fastapi/openapi/models.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9090c77...23888ca. Read the comment docs.

@github-actions
Copy link
Contributor

📝 Docs preview for commit f009542 at: https://6266e4e6547fcf1234c09be4--fastapi.netlify.app

@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2022

📝 Docs preview for commit 23888ca at: https://62752357792e881799766842--fastapi.netlify.app

@jtv8
Copy link
Author

jtv8 commented May 23, 2022

Resolved by #4906

@jtv8 jtv8 closed this May 23, 2022
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 this pull request may close these issues.

None yet

2 participants