Skip to content

Commit

Permalink
Add django-stubs v1.10.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
henribru committed Mar 26, 2022
1 parent d5fd23d commit 27f32af
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
python-version: ['3.7', '3.8', '3.9']
steps:
- uses: actions/checkout@v2
- name: Setup system dependencies
Expand All @@ -52,7 +52,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
python-version: ['3.7', '3.8', '3.9']
steps:
- uses: actions/checkout@v2
- name: Setup system dependencies
Expand Down
4 changes: 2 additions & 2 deletions mypy_drf_plugin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from mypy.nodes import TypeInfo
from mypy.options import Options
from mypy.plugin import ClassDefContext, Plugin
from mypy_django_plugin import main as mypy_django_main
from mypy_django_plugin.config import DjangoPluginConfig
from mypy_django_plugin.django.context import DjangoContext

from mypy_drf_plugin.lib import fullnames, helpers
Expand All @@ -22,7 +22,7 @@ class NewSemanalDRFPlugin(Plugin):
def __init__(self, options: Options) -> None:
super().__init__(options)

django_settings_module = mypy_django_main.extract_django_settings_module(options.config_file)
django_settings_module = DjangoPluginConfig(options.config_file).django_settings_module
self.django_context = DjangoContext(django_settings_module)

def _get_currently_defined_serializers(self) -> Dict[str, int]:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
wheel
gitpython==3.1.9
pre-commit==2.7.1
pre-commit==2.9.2
pytest==6.1.1
pytest-mypy-plugins==1.9.1
djangorestframework==3.12.1
Expand Down
3 changes: 2 additions & 1 deletion rest_framework-stubs/test.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ from django.test.client import RequestFactory as DjangoRequestFactory
from rest_framework.authtoken.models import Token
from rest_framework.request import Request
from rest_framework.response import Response
import urllib3

def force_authenticate(
request: HttpRequest, user: Optional[Union[AnonymousUser, AbstractBaseUser]] = ..., token: Optional[Token] = ...
) -> None: ...

class HeaderDict(requests.packages.urllib3._collections.HTTPHeaderDict):
class HeaderDict(urllib3._collections.HTTPHeaderDict):
def get_all(self, key: Any, default: Any): ...

class MockOriginalResponse:
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def find_stub_files(name):

dependencies = [
"mypy>=0.790",
"django-stubs>=1.7.0",
"django-stubs>=1.10.0",
"typing-extensions>=3.7.2",
"requests>=2.0.0",
"coreapi>=2.0.0",
Expand All @@ -43,11 +43,10 @@ def find_stub_files(name):
install_requires=dependencies,
packages=["rest_framework-stubs", *find_packages(exclude=["scripts"])],
package_data={"rest_framework-stubs": find_stub_files("rest_framework-stubs")},
python_requires=">=3.6",
python_requires=">=3.7",
classifiers=[
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
2 changes: 1 addition & 1 deletion tests/typecheck/test_serializers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from rest_framework import serializers
reveal_type(serializers.ModelSerializer.Meta.model) # N: Revealed type is "Type[_MT?]"
reveal_type(serializers.ModelSerializer.Meta.fields) # N: Revealed type is "typing.Sequence[builtins.str]"
reveal_type(serializers.ModelSerializer.Meta.fields) # N: Revealed type is "Union[typing.Sequence[builtins.str], Literal['__all__']]"
reveal_type(serializers.ModelSerializer.Meta.read_only_fields) # N: Revealed type is "Union[typing.Sequence[builtins.str], None]"
reveal_type(serializers.ModelSerializer.Meta.exclude) # N: Revealed type is "Union[typing.Sequence[builtins.str], None]"
reveal_type(serializers.ModelSerializer.Meta.depth) # N: Revealed type is "Union[builtins.int, None]"
Expand Down

0 comments on commit 27f32af

Please sign in to comment.