Skip to content

Commit 9d5d538

Browse files
committed
Filter deprecated
1 parent 2b38971 commit 9d5d538

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

mypy/checker.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4865,7 +4865,9 @@ def infer_context_dependent(
48654865
self, expr: Expression, type_ctx: Type, allow_none_func_call: bool
48664866
) -> ProperType:
48674867
"""Infer type of an expression with fallback to empty type context."""
4868-
with self.msg.filter_errors(filter_errors=True, save_filtered_errors=True) as msg:
4868+
with self.msg.filter_errors(
4869+
filter_errors=True, filter_deprecated=True, save_filtered_errors=True
4870+
) as msg:
48694871
with self.local_type_map as type_map:
48704872
typ = get_proper_type(
48714873
self.expr_checker.accept(
@@ -4879,7 +4881,9 @@ def infer_context_dependent(
48794881
# If there are errors with the original type context, try re-inferring in empty context.
48804882
original_messages = msg.filtered_errors()
48814883
original_type_map = type_map
4882-
with self.msg.filter_errors(filter_errors=True, save_filtered_errors=True) as msg:
4884+
with self.msg.filter_errors(
4885+
filter_errors=True, filter_deprecated=True, save_filtered_errors=True
4886+
) as msg:
48834887
with self.local_type_map as type_map:
48844888
alt_typ = get_proper_type(
48854889
self.expr_checker.accept(expr, None, allow_none_return=allow_none_func_call)

mypy/errors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ def on_error(self, file: str, info: ErrorInfo) -> bool:
206206
"""
207207
if info.code == codes.DEPRECATED:
208208
# Deprecated is not a type error, so it is handled on opt-in basis here.
209-
return self._filter_deprecated
209+
if not self._filter_deprecated:
210+
return False
210211

211212
self._has_new_errors = True
212213
if isinstance(self._filter, bool):

0 commit comments

Comments
 (0)