+| <a id="Y034" href="#Y034">Y034</a> | Y034 detects common errors where certain methods are annotated as having a fixed return type, despite returning `self` at runtime. Such methods should be annotated with `typing_extensions.Self`. This check looks for:<br><br> **1.** Any in-place BinOp dunder methods (`__iadd__`, `__ior__`, etc.) that do not return `Self`.<br> **2.** `__new__`, `__enter__` and `__aenter__` methods that return the class's name unparameterised.<br> **3.** `__iter__` methods that return `Iterator`, even if the class inherits directly from `Iterator`.<br> **4.** `__aiter__` methods that return `AsyncIterator`, even if the class inherits directly from `AsyncIterator`.<br><br>Note that this check excludes methods decorated with `@overload` or `@abstractmethod`, and those in the bodies of protocol classes. | Correctness
0 commit comments