TypeDict "dict style" positional arguments
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 1.8k
- Fork
- 302
- Merge trung bình
- 23 giờ
- Pull request đã merge (30 ngày)
- 8
Mô tả
Hi.
I'm just curious why passing arguments to TypeDict is strictly constrained. I tried some variants including positional arguments style and failed. It's not reflected in docs or function signature (ctrl + p in Pycharm)
https://docs.python.org/3/library/typing.html#typing.TypedDict
In [1]: from typing import TypedDict
In [2]:
...: ProfileText = TypedDict(name='ProfileText', fields={'name': str, 'non variable key': str}, total=False) # Error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-7d3b7c9254f3> in <module>
----> 1 ProfileText = TypedDict(name='ProfileText', fields={'name': str, 'non variable key': str}, total=False) # Error
TypeError: _typeddict_new() missing 1 required positional argument: 'typename'
In [3]:
...: ProfileText = TypedDict('ProfileText', {'name': str, 'non variable key': str}, total=False) # Error
In [4]:
...: ProfileText = TypedDict('ProfileText', {'name': str, 'non variable key': str}, False) # Error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-b3b55e028c98> in <module>
----> 1 ProfileText = TypedDict('ProfileText', {'name': str, 'non variable key': str}, False) # Error
TypeError: _typeddict_new() takes from 2 to 3 positional arguments but 4 were given
In [5]:
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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
Issue đề cập đến entry point TypedDict và tài liệu Python typing; trước tiên hãy so sánh các dạng gọi bằng từ khóa và dạng gọi theo vị trí được minh họa với tài liệu đó. Xác định quy ước gọi nào cần được hỗ trợ, sau đó định nghĩa việc hoàn tất là hành vi, thông tin chữ ký, tài liệu và các bài kiểm thử nhất quán với dạng được chấp nhận.
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
- devtools
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- 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