fix compatibility with 0.730 (#189)

This commit is contained in:
Maxim Kurnikov
2019-09-28 05:23:55 +03:00
committed by GitHub
parent 7725b416b6
commit be3fc259d5
8 changed files with 15 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
black
pytest-mypy-plugins==1.0.3
pytest-mypy-plugins==1.1.0
psycopg2
flake8==3.7.8
flake8-pyi==19.3.0

View File

@@ -8,8 +8,7 @@ from django.forms.utils import ErrorDict, ErrorList
from django.forms.widgets import Media, MediaDefiningClass
from django.utils.safestring import SafeText
class DeclarativeFieldsMetaclass(MediaDefiningClass):
def __new__(mcs, name: str, bases: Sequence[Type[BaseForm]], attrs: Dict[str, Any]) -> Type[BaseForm]: ...
class DeclarativeFieldsMetaclass(MediaDefiningClass): ...
class BaseForm:
class Meta:

View File

@@ -54,8 +54,7 @@ class ModelFormOptions:
field_classes: Optional[Dict[str, Type[Field]]] = ...
def __init__(self, options: Optional[type] = ...) -> None: ...
class ModelFormMetaclass(DeclarativeFieldsMetaclass):
def __new__(mcs, name: str, bases: Sequence[Type[Any]], attrs: Dict[str, Any]) -> Type[ModelForm]: ...
class ModelFormMetaclass(DeclarativeFieldsMetaclass): ...
class BaseModelForm(BaseForm):
instance: Any = ...
@@ -73,7 +72,6 @@ class BaseModelForm(BaseForm):
use_required_attribute: Optional[bool] = ...,
renderer: Any = ...,
) -> None: ...
def clean(self) -> Dict[str, Any]: ...
def validate_unique(self) -> None: ...
save_m2m: Any = ...
def save(self, commit: bool = ...) -> Any: ...

View File

@@ -27,8 +27,7 @@ class Media:
def merge(list_1: Iterable[Any], list_2: Iterable[Any]) -> Iterable[Any]: ...
def __add__(self, other: Media) -> Media: ...
class MediaDefiningClass(type):
def __new__(mcs, name: str, bases: Sequence[Any], attrs: Dict[str, Any]) -> type: ...
class MediaDefiningClass(type): ...
class Widget:
needs_multipart_form: bool = ...
@@ -70,9 +69,7 @@ class HiddenInput(Input):
choices: Iterable[Tuple[str, str]]
class MultipleHiddenInput(HiddenInput): ...
class FileInput(Input):
needs_multipart_form: bool = ...
class FileInput(Input): ...
class ClearableFileInput(FileInput):
clear_checkbox_label: Any = ...
@@ -102,7 +99,7 @@ class ChoiceWidget(Widget):
allow_multiple_selected: bool = ...
input_type: Optional[str] = ...
template_name: Optional[str] = ...
option_template_name: Any = ...
option_template_name: str = ...
add_id_index: bool = ...
checked_attribute: Any = ...
option_inherits_attrs: bool = ...
@@ -130,10 +127,8 @@ class SelectMultiple(Select):
class RadioSelect(ChoiceWidget):
can_add_related: bool
option_template_name: str = ...
class CheckboxSelectMultiple(ChoiceWidget):
def id_for_label(self, id_: str, index: Optional[str] = ...) -> str: ...
class CheckboxSelectMultiple(ChoiceWidget): ...
class MultiWidget(Widget):
template_name: str = ...

View File

@@ -69,7 +69,8 @@ IGNORED_ERRORS = {
'SimpleLazyObject'
],
'aggregation': [
re.compile(r'got "Optional\[(Author|Publisher)\]", expected "Union\[(Author|Publisher), Combinable\]"')
re.compile(r'got "Optional\[(Author|Publisher)\]", expected "Union\[(Author|Publisher), Combinable\]"'),
'Argument 2 for "super" not an instance of argument 1',
],
'annotations': [
'Incompatible type for "store" of "Employee" (got "Optional[Store]", expected "Union[Store, Combinable]")'
@@ -151,7 +152,8 @@ IGNORED_ERRORS = {
],
'file_uploads': [
'"Iterable[Any]" has no attribute',
'"IO[Any]" has no attribute'
'"IO[Any]" has no attribute',
'has no attribute "content_type"',
],
'file_storage': [
'Incompatible types in assignment (expression has type "Callable"'

View File

@@ -76,8 +76,7 @@ if __name__ == '__main__':
mypy_options = ['--cache-dir', str(mypy_config_file.parent / '.mypy_cache'),
'--config-file', str(mypy_config_file),
'--show-traceback',
# '--no-error-summary',
# '--no-pretty',
'--no-error-summary',
'--hide-error-context'
]
mypy_options += [str(tests_root)]

View File

@@ -21,7 +21,7 @@ with open('README.md', 'r') as f:
readme = f.read()
dependencies = [
'mypy>=0.720,<0.730',
'mypy>=0.730,<0.740',
'typing-extensions',
'django',
]

View File

@@ -5,7 +5,7 @@
# standard settings
reveal_type(settings.AUTH_USER_MODEL) # N: Revealed type is 'builtins.str'
reveal_type(settings.ROOT_DIR) # N: Revealed type is 'builtins.str'
reveal_type(settings.APPS_DIR) # N: Revealed type is 'pathlib.Path'
reveal_type(settings.APPS_DIR) # N: Revealed type is 'pathlib.Path*'
reveal_type(settings.NUMBERS) # N: Revealed type is 'builtins.list[builtins.str*]'
reveal_type(settings.DICT) # N: Revealed type is 'builtins.dict[Any, Any]'
custom_settings: |
@@ -40,7 +40,7 @@
from settings.basic_settings import *
main: |
from django.conf import settings
reveal_type(settings.MEDIA_ROOT) # N: Revealed type is 'pathlib.Path'
reveal_type(settings.MEDIA_ROOT) # N: Revealed type is 'pathlib.Path*'
reveal_type(settings.MEDIA_ROOT / 'part') # N: Revealed type is 'pathlib.Path*'
files:
- path: settings/__init__.py