From 9ec60355ef608ade799470095427d8f85fd158cc Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Fri, 3 Jul 2020 13:57:26 +0300 Subject: [PATCH 1/4] Closes #74 --- rest_framework-stubs/views.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rest_framework-stubs/views.pyi b/rest_framework-stubs/views.pyi index c8594c9fe..c48ba26be 100644 --- a/rest_framework-stubs/views.pyi +++ b/rest_framework-stubs/views.pyi @@ -20,6 +20,9 @@ def set_rollback() -> None: ... def exception_handler(exc: Exception, context) -> Optional[Response]: ... class APIView(View): + settings: APISettings + request: Request + renderer_classes: Sequence[Type[BaseRenderer]] = ... parser_classes: Sequence[Type[BaseParser]] = ... authentication_classes: Sequence[Type[BaseAuthentication]] = ... @@ -28,14 +31,15 @@ class APIView(View): content_negotiation_class: Optional[str] = ... metadata_class: Optional[str] = ... versioning_class: Optional[str] = ... - settings: APISettings schema: ViewInspector = ... + @classmethod def as_view(cls, **initkwargs: Any) -> Any: ... @property def allowed_methods(self) -> List[str]: ... @property def default_response_headers(self) -> Dict[str, str]: ... + def permission_denied(self, request: Request, message: Optional[str] = ...) -> NoReturn: ... def throttled(self, request: Request, wait: float) -> NoReturn: ... def get_authenticate_header(self, request: Request) -> str: ... From d2aae854558db468320cdd8cf6ab4599ac8a1878 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 3 Jul 2020 14:47:05 +0300 Subject: [PATCH 2/4] Fixes CI --- .travis.yml | 2 +- rest_framework-stubs/__init__.pyi | 4 ---- rest_framework-stubs/views.pyi | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 rest_framework-stubs/__init__.pyi diff --git a/.travis.yml b/.travis.yml index a599afda5..668d8e798 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ jobs: python: 3.7 script: - mypy ./mypy_drf_plugin - - mypy -p rest_framework-stubs + - mypy rest_framework-stubs - name: Lint plugin code with flake8 python: 3.7 diff --git a/rest_framework-stubs/__init__.pyi b/rest_framework-stubs/__init__.pyi deleted file mode 100644 index 89ec4480a..000000000 --- a/rest_framework-stubs/__init__.pyi +++ /dev/null @@ -1,4 +0,0 @@ -HTTP_HEADER_ENCODING: str = ... -ISO_8601: str = ... - -default_app_config: str = ... diff --git a/rest_framework-stubs/views.pyi b/rest_framework-stubs/views.pyi index c48ba26be..dbfad7984 100644 --- a/rest_framework-stubs/views.pyi +++ b/rest_framework-stubs/views.pyi @@ -32,14 +32,12 @@ class APIView(View): metadata_class: Optional[str] = ... versioning_class: Optional[str] = ... schema: ViewInspector = ... - @classmethod def as_view(cls, **initkwargs: Any) -> Any: ... @property def allowed_methods(self) -> List[str]: ... @property def default_response_headers(self) -> Dict[str, str]: ... - def permission_denied(self, request: Request, message: Optional[str] = ...) -> NoReturn: ... def throttled(self, request: Request, wait: float) -> NoReturn: ... def get_authenticate_header(self, request: Request) -> str: ... From e4116f6da28af445b21db869335ae7f1ca3ca440 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 3 Jul 2020 15:12:49 +0300 Subject: [PATCH 3/4] Fixes CI --- .travis.yml | 2 +- rest_framework-stubs/__init__.pyi | 0 setup.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 rest_framework-stubs/__init__.pyi diff --git a/.travis.yml b/.travis.yml index 668d8e798..a599afda5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ jobs: python: 3.7 script: - mypy ./mypy_drf_plugin - - mypy rest_framework-stubs + - mypy -p rest_framework-stubs - name: Lint plugin code with flake8 python: 3.7 diff --git a/rest_framework-stubs/__init__.pyi b/rest_framework-stubs/__init__.pyi new file mode 100644 index 000000000..e69de29bb diff --git a/setup.py b/setup.py index 87ebf2940..6a748119f 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ def find_stub_files(name): readme = f.read() dependencies = [ - 'mypy>=0.750', + 'mypy>=0.750,<0.780', 'django-stubs>=1.3.0', 'typing-extensions' ] From 50f4c635a21ec9ceb61514a9297117d120312372 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 3 Jul 2020 15:13:58 +0300 Subject: [PATCH 4/4] Adds setup.py to black --- .travis.yml | 2 +- setup.py | 30 +++++++++++++----------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index a599afda5..b13401185 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ jobs: - name: Lint with black python: 3.7 - script: black --check --line-length=120 scripts/ rest_framework-stubs/ + script: black --check --line-length=120 setup.py scripts/ rest_framework-stubs/ - name: Lint plugin code with isort python: 3.7 diff --git a/setup.py b/setup.py index 6a748119f..1225cfa51 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def find_stub_files(name): result = [] for root, dirs, files in os.walk(name): for file in files: - if file.endswith('.pyi'): + if file.endswith(".pyi"): if os.path.sep in root: sub_root = root.split(os.path.sep, 1)[-1] file = os.path.join(sub_root, file) @@ -16,32 +16,28 @@ def find_stub_files(name): return result -with open('README.md', 'r') as f: +with open("README.md", "r") as f: readme = f.read() -dependencies = [ - 'mypy>=0.750,<0.780', - 'django-stubs>=1.3.0', - 'typing-extensions' -] +dependencies = ["mypy>=0.750,<0.780", "django-stubs>=1.3.0", "typing-extensions"] setup( name="djangorestframework-stubs", version="1.2.0", - description='PEP-484 stubs for django-rest-framework', + description="PEP-484 stubs for django-rest-framework", long_description=readme, - long_description_content_type='text/markdown', + long_description_content_type="text/markdown", url="https://github.com/typeddjango/djangorestframework-stubs", author="Maksim Kurnikov", author_email="maxim.kurnikov@gmail.com", - license='MIT', + license="MIT", install_requires=dependencies, - packages=['rest_framework-stubs', *find_packages(exclude=['scripts'])], - package_data={'rest_framework-stubs': find_stub_files('rest_framework-stubs')}, + packages=["rest_framework-stubs", *find_packages(exclude=["scripts"])], + package_data={"rest_framework-stubs": find_stub_files("rest_framework-stubs")}, classifiers=[ - 'Development Status :: 3 - Alpha', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7' - ] + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + ], )