From e17c6a752e280259278536ea34b5c3e48c7e85be Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Wed, 5 Aug 2020 19:42:48 -0700 Subject: [PATCH] Fixed base classes to avoid "Cannot create consistent method ordering" error. Like the Python interpreter, the pyright type checker reports an error when a class is defined in a way that a deterministic MRO cannot be established. This set of changes eliminates these errors. (#4392) Co-authored-by: Eric Traut --- third_party/2and3/click/_termui_impl.pyi | 2 +- third_party/2and3/pynamodb/attributes.pyi | 4 ++-- third_party/2and3/pynamodb/models.pyi | 2 +- third_party/2and3/werkzeug/datastructures.pyi | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/third_party/2and3/click/_termui_impl.pyi b/third_party/2and3/click/_termui_impl.pyi index 749acc75d..43e98ac34 100644 --- a/third_party/2and3/click/_termui_impl.pyi +++ b/third_party/2and3/click/_termui_impl.pyi @@ -2,7 +2,7 @@ from typing import Generic, Optional, TypeVar _T = TypeVar("_T") -class ProgressBar(object, Generic[_T]): +class ProgressBar(Generic[_T]): def update(self, n_steps: int) -> None: ... def finish(self) -> None: ... def __enter__(self) -> ProgressBar[_T]: ... diff --git a/third_party/2and3/pynamodb/attributes.pyi b/third_party/2and3/pynamodb/attributes.pyi index 493e69509..2dea16016 100644 --- a/third_party/2and3/pynamodb/attributes.pyi +++ b/third_party/2and3/pynamodb/attributes.pyi @@ -81,7 +81,7 @@ class NullAttribute(Attribute[None]): class MapAttributeMeta(type): def __init__(self, name, bases, attrs) -> None: ... -class MapAttribute(Generic[_KT, _VT], Attribute[Mapping[_KT, _VT]], metaclass=MapAttributeMeta): +class MapAttribute(Attribute[Mapping[_KT, _VT]], metaclass=MapAttributeMeta): attribute_values: Any def __init__( self, @@ -100,7 +100,7 @@ class MapAttribute(Generic[_KT, _VT], Attribute[Mapping[_KT, _VT]], metaclass=Ma def is_type_safe(self, key: Any, value: Any) -> bool: ... def validate(self) -> bool: ... -class ListAttribute(Generic[_T], Attribute[List[_T]]): +class ListAttribute(Attribute[List[_T]]): element_type: Any def __init__( self, diff --git a/third_party/2and3/pynamodb/models.pyi b/third_party/2and3/pynamodb/models.pyi index 00eb4dc03..023a2eef5 100644 --- a/third_party/2and3/pynamodb/models.pyi +++ b/third_party/2and3/pynamodb/models.pyi @@ -150,7 +150,7 @@ class ModelContextManager(Generic[_T]): def __init__(self, model: Type[_T], auto_commit: bool = ...) -> None: ... def __enter__(self) -> ModelContextManager[_T]: ... -class BatchWrite(Generic[_T], ModelContextManager[_T]): +class BatchWrite(ModelContextManager[_T]): def save(self, put_item: _T) -> None: ... def delete(self, del_item: _T) -> None: ... def __enter__(self) -> BatchWrite[_T]: ... diff --git a/third_party/2and3/werkzeug/datastructures.pyi b/third_party/2and3/werkzeug/datastructures.pyi index c49c60d71..d04de7ce6 100644 --- a/third_party/2and3/werkzeug/datastructures.pyi +++ b/third_party/2and3/werkzeug/datastructures.pyi @@ -30,7 +30,7 @@ def is_immutable(self) -> NoReturn: ... def iter_multi_items(mapping): ... def native_itermethods(names): ... -class ImmutableListMixin(object, Generic[_V]): +class ImmutableListMixin(Generic[_V]): def __hash__(self) -> int: ... def __reduce_ex__(self: _D, protocol) -> Tuple[Type[_D], List[_V]]: ... def __delitem__(self, key: _V) -> NoReturn: ...