"See help(type(self)) for accurate signature" in `__init__`'s docstring is misleading
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Feature or enhancement
Let's say I have a simple class:
class A:
def __init__(self, a):
self.a = a
help(A) will produce:
Help on class A in module __main__:
class A(builtins.object)
| A(a)
|
| Methods defined here:
|
| __init__(self, a)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
Note that the signature is already accurate. But, now I see this message: See help(type(self)) for accurate signature.. Let's try to do something about it.
Let's follow the instruction:
class A:
def __init__(self, a):
help(type(self))
self.a = a
It will produce:
Help on class A in module __main__:
class A(builtins.object)
| A(a)
|
| Methods defined here:
|
| __init__(self, a)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
Exactly the same signature. With exactly the same message.
Now, let's try a different example, an empty class:
class B: ...
help(B.__init__) will say:
Help on wrapper_descriptor:
__init__(self, /, *args, **kwargs) unbound builtins.object method
Initialize self. See help(type(self)) for accurate signature.
And help(B) will say (notice that there would be no __init__ at all):
Help on class B in module __main__:
class B(builtins.object)
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
Is this message See help(type(self)) for accurate signature really useful? When do users benefit from seeing it?
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện đầu ra đã được báo cáo bằng help(A), help(A.init) và một lớp B rỗng. Truy vết nơi docstring init tích hợp sẵn và đầu ra lớp của pydoc được tạo ra, sau đó xác định khu vực kiểm thử hồi quy liên quan. Hoàn thành khi hướng dẫn gây hiểu lầm được sửa hoặc loại bỏ một cách nhất quán và đầu ra của help được bao phủ bởi các bài kiểm thử.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- documentation
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100