From 14d7431ff1f554ae1d103b996995bfe3ecec67bd Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 27 Jun 2021 13:17:28 -0700 Subject: [PATCH] Recommend `Self` in CONTRIBUTING.md (#5699) Part of #5676. Co-authored-by: Akuli --- CONTRIBUTING.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3e02a6693..7a0a31c7c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -373,6 +373,10 @@ are not sure whether exceptions are suppressed or not or if the context manager is meant to be subclassed, pick `Optional[bool]`. See https://github.com/python/mypy/issues/7214 for more details. +`__enter__` methods and other methods that return instances of the +current class should be annotated with the `_typeshed.Self` type +variable ([example](https://github.com/python/typeshed/pull/5698)). + A few guidelines for protocol names below. In cases that don't fall into any of those categories, use your best judgement.