Move `ContextManager` and `AsyncContextManager` type hinting docs from `typing` to `contextlib`
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Documentation
PEP585 deprecated typing.ContextManager and typing.AsyncContextManager in favour of their contextlib counterparts. However, contextlib documentation lacks any type hinting information and does not even list generic parameters.
Several relevant changes were discussed along #123523.
Currently there's no backlink from contextlib to typing docs, hence users don't have any trivial way to discover type parameters of ContextManager (that's worse than collections.abc.Generator where such a link exists).
Similarly to #123583, I propose to add a "Type hinting" section to both of them in contextlib documentation:
.. class:: AbstractContextManager
An :term:`abstract base class` for classes that implement
:meth:`object.__enter__` and :meth:`object.__exit__`. A default
implementation for :meth:`object.__enter__` is provided which returns
``self`` while :meth:`object.__exit__` is an abstract method which by default
returns ``None``. See also the definition of :ref:`typecontextmanager`.
:class:`!AbstractContextManager` can be used in type annotations and accepts
two type parameters: ``AbstractContextManager[T_co, ExitT_co]``.
The first type parameter, ``T_co``, represents the type returned by
the :meth:`~object.__enter__` method. The optional second type parameter,
``ExitT_co``, which defaults to ``bool | None``, represents the type
returned by the :meth:`~object.__exit__` method.
.. versionadded:: 3.6
.. versionchanged:: 3.13
Added the optional second type parameter, ``ExitT_co``.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、contextlib ドキュメントにある既存の ContextManager と AsyncContextManager の項目を確認し、次に #123523 の関連する議論とリンク先の typing ドキュメントを確認します。要求されている Type hinting セクションとジェネリックパラメーターへのバックリンクを追加し、両方のコンテキストマネージャー型と、それらに記載されている型引数を対象にします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 52/100