Skip to content

Commit

Permalink
Format with black
Browse files Browse the repository at this point in the history
  • Loading branch information
tmke8 committed Jul 29, 2022
1 parent aaaf4c4 commit 614c9cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 0 additions & 1 deletion mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,6 @@ def check___new___signature(self, fdef: FuncDef, typ: CallableType) -> None:
"but must return a subtype of",
)


def check_reverse_op_method(
self, defn: FuncItem, reverse_type: CallableType, reverse_name: str, context: Context
) -> None:
Expand Down
17 changes: 10 additions & 7 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,13 @@ def analyze_func_def(self, defn: FuncDef) -> None:
# Mark protocol methods with empty bodies and None-incompatible return types as abstract.
if self.is_class_scope() and defn.type is not None:
assert self.type is not None and isinstance(defn.type, CallableType)
if (not self.is_stub_file and self.type.is_protocol and
(not isinstance(self.scope.function, OverloadedFuncDef)
or defn.is_property) and
not can_be_none(defn.type.ret_type) and is_trivial_body(defn.body)):
if (
not self.is_stub_file
and self.type.is_protocol
and (not isinstance(self.scope.function, OverloadedFuncDef) or defn.is_property)
and not can_be_none(defn.type.ret_type)
and is_trivial_body(defn.body)
):
defn.is_abstract = True

if (
Expand Down Expand Up @@ -6110,7 +6113,7 @@ def can_be_none(t: Type) -> bool:
"""Can a variable of the given type be None?"""
t = get_proper_type(t)
return (
isinstance(t, NoneType) or
isinstance(t, AnyType) or
(isinstance(t, UnionType) and any(can_be_none(ut) for ut in t.items))
isinstance(t, NoneType)
or isinstance(t, AnyType)
or (isinstance(t, UnionType) and any(can_be_none(ut) for ut in t.items))
)

0 comments on commit 614c9cc

Please sign in to comment.