Giter Club home page Giter Club logo

drf-yasg-stubs's Introduction

mypy logo

Typing stubs for drf-yasg library

PyPI version Tests status

PEP 484 type stubs for Mypy and PyCharm.

This package contains type stubs to provide more precise static types and type inference for drf-yasg, the OpenAPI/Swagger generator for Django REST Framework.

Installation

pip install drf-yasg-stubs

That's all, run Mypy and it should be able to pick up these stubs.

Changelog

0.1.4 (2021-06-29)

  • Allow passing request_body=no_body to swagger_auto_schema (#14)

    Contributed by Étienne Noss @etene

0.1.3 (2021-01-15)

  • Add re-exports to inspectors/__init__.py (#13)
  • get_schema_view() now expects list arguments instead of tuple, as in drf-yasg 1.20 (#11)
  • Type hints for OpenAPISchemaGenerator (#10)

0.1.2 (2020-08-19)

  • Fixed get_schema_view() arguments authentication_classes, permission_classes (#6)

0.1.1 (2020-08-18)

  • Fixed SchemaView method annotations (#2)
  • Fixed @swagger_serializer_method decorator hints
  • Improved hints for EndpointEnumerator, OpenAPISchemaGenerator

0.1.0 (2020-01-13)

  • Initial release

Development

Release process: https://twine.readthedocs.io/en/stable/#using-twine

drf-yasg-stubs's People

Contributors

etene avatar intgr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

skrausler etene

drf-yasg-stubs's Issues

Usage with mypy.ini

For some reason the mypy.ini of this package is ignored for me every second run and get the problem that ruamel is missing. Just added the content of this file to my mypy.ini and it worked.

SchemaView without_ui/with_ui return a function, not ApiView

In both cases they've called as_cached_view which calls as_view

With the current stubs I get

error: No overload variant of "url" matches argument types "str", "APIView", "str"
note: Possible overload variants:
note:     def url(regex: str, view: Callable[..., HttpResponseBase], kwargs: Dict[str, Any] = ..., name: str = ...) -> URLPattern
note:     def url(regex: str, view: Tuple[List[URLResolver], Optional[str], Optional[str]], kwargs: Dict[str, Any] = ..., name: str = ...) -> URLResolver
note:     def url(regex: str, view: List[Union[URLResolver, str]], kwargs: Dict[str, Any] = ..., name: str = ...) -> URLResolver

They should be marked as returning some sort of Callable variant I think

Type annotation for `permission_classes` in `get_schema_view` expects List but should be Tuple

There seems to be back and forth for this parameter on the type. I see it was once changed from a Tuple to a List but has since changed back to a Tuple in the drf-yasg repo. The documentation also reflects this change. The stubs need to be updated.

-    permission_classes: Optional[List[Type[BasePermission]]] = ...,
+    permission_classes: Optional[Tuple[Type[BasePermission]]] = ...,

permission_classes type on get_schema_view

I've got some code that sets the permission_classes arg for get_schema_view to (permissions.AllowAny,), and I get the error
error: Argument "permission_classes" to "get_schema_view" has incompatible type "Tuple[Type[AllowAny]]"; expected "Optional[Tuple[str]]"

Admittedly, in my particular use case it turns out I can delete the arg as it's the defaults, but if I wanted a non-default I'd get issues with mypy.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.