From 83f5f774479c282112f6e2166319573424045ad1 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Fri, 5 Jul 2019 15:50:19 +0100 Subject: [PATCH] New analyzer: improve documentation of defer() This concludes documentation that started in #7130 and #7135. Closes #7071. --- mypy/newsemanal/semanal.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mypy/newsemanal/semanal.py b/mypy/newsemanal/semanal.py index 576099c5d281..68a815dda66c 100644 --- a/mypy/newsemanal/semanal.py +++ b/mypy/newsemanal/semanal.py @@ -4262,10 +4262,14 @@ def defer(self, debug_context: Optional[Context] = None) -> None: """Defer current analysis target to be analyzed again. This must be called if something in the current target is - incomplete or has a placeholder node. - - This must not be called during the final analysis iteration! - Instead, an error should be generated. + incomplete or has a placeholder node. However, this must *not* + be called during the final analysis iteration! Instead, an error + should be generated. Often 'process_placeholder' is a good + way to either defer or generate an error. + + NOTE: Some methods, such as 'anal_type', 'mark_incomplete' and + 'record_incomplete_ref', call this implicitly, or when needed. + They are usually preferable to a direct defer() call. """ assert not self.final_iteration, 'Must not defer during final iteration' self.deferred = True