|
2 | 2 |
|
3 | 3 | from __future__ import annotations
|
4 | 4 |
|
5 |
| -import fnmatch |
6 | 5 | import itertools
|
7 | 6 | from collections import defaultdict
|
8 | 7 | from contextlib import contextmanager, nullcontext
|
@@ -327,8 +326,6 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
327 | 326 | current_node_deferred = False
|
328 | 327 | # Is this file a typeshed stub?
|
329 | 328 | is_typeshed_stub = False
|
330 |
| - # Should strict Optional-related errors be suppressed in this file? |
331 |
| - suppress_none_errors = False # TODO: Get it from options instead |
332 | 329 | options: Options
|
333 | 330 | # Used for collecting inferred attribute types so that they can be checked
|
334 | 331 | # for consistency.
|
@@ -391,12 +388,7 @@ def __init__(
|
391 | 388 | self.is_stub = tree.is_stub
|
392 | 389 | self.is_typeshed_stub = is_typeshed_file(path)
|
393 | 390 | self.inferred_attribute_types = None
|
394 |
| - if options.strict_optional_whitelist is None: |
395 |
| - self.suppress_none_errors = not options.show_none_errors |
396 |
| - else: |
397 |
| - self.suppress_none_errors = not any( |
398 |
| - fnmatch.fnmatch(path, pattern) for pattern in options.strict_optional_whitelist |
399 |
| - ) |
| 391 | + |
400 | 392 | # If True, process function definitions. If False, don't. This is used
|
401 | 393 | # for processing module top levels in fine-grained incremental mode.
|
402 | 394 | self.recurse_into_functions = True
|
@@ -5604,8 +5596,6 @@ def check_subtype(
|
5604 | 5596 | subtype, supertype, context, msg_text, subtype_label, supertype_label, code=code
|
5605 | 5597 | ):
|
5606 | 5598 | return False
|
5607 |
| - if self.should_suppress_optional_error([subtype]): |
5608 |
| - return False |
5609 | 5599 | extra_info: list[str] = []
|
5610 | 5600 | note_msg = ""
|
5611 | 5601 | notes: list[str] = []
|
@@ -5705,9 +5695,6 @@ def contains_none(self, t: Type) -> bool:
|
5705 | 5695 | )
|
5706 | 5696 | )
|
5707 | 5697 |
|
5708 |
| - def should_suppress_optional_error(self, related_types: list[Type]) -> bool: |
5709 |
| - return self.suppress_none_errors and any(self.contains_none(t) for t in related_types) |
5710 |
| - |
5711 | 5698 | def named_type(self, name: str) -> Instance:
|
5712 | 5699 | """Return an instance type with given name and implicit Any type args.
|
5713 | 5700 |
|
|
0 commit comments