Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

各種Listenerについて基底クラスを定義する #98

Open
n-ando opened this issue Jul 3, 2019 · 0 comments
Open

各種Listenerについて基底クラスを定義する #98

n-ando opened this issue Jul 3, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@n-ando
Copy link

n-ando commented Jul 3, 2019

Is your feature request related to a problem? Please describe.

現状 Listener クラスの基底クラスが定義されていないので、Listener を自分で定義して使う人Aわかりやすいように、基底クラスを定義する、

Describe the solution you'd like

C++同様に中小基底クラスとして定義してもよいが、Pythonの場合引数、戻り値の方が不明確なので、何らかの方法でユーザに引数、戻り値の型の情報を提供するように基底クラスを定義する。
例えばTemplate Methodパターンのように、ユーザにはユーザ実装のための特定のメソッド#aを実装させ、コールバック時には基底クラスの別のメソッド+Aを呼び出すように実装。+Aでは内部的に#aをコールするがその際に、入力引数と戻り値の型チェックを挟み、引数が不適切な場合、ユーザがおかしな戻り値を返した場合にわかりやすいエラーを出す。

Describe alternatives you've considered

3.5以降では型ヒント機構も使えるようだが、現状2.7では難しいので、少なくともユーザが参考にする来てクラスでは、PEP484のコメントによる型ヒントをユーザに提示するようにする。

https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code
https://blog.ymyzk.com/2016/02/python-2-type-hints/

Additional context

この変更はRELENG_1_2およびmasterに適用する。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants