Type checking for *args and **kwargs when passing them to another function
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ả
Problem:
I am writing a python application, and I made a function that creates an object and passes its additional *args and **kwargs to object's constructor and takes few its own arguments. I want to make *args and **kwargs typed exactly as inner function's arguments.
Description and examples:
A simple example with two functions:
def inner(a: int, b: int) -> None:
...
def wrapper(arg1: str, *args, **kwargs) -> None:
inner(*args, **kwargs) # It will automatically detect passing arguments to another function
In my case, inner is object constructor, I gave an example with functions to make it more simple.
Type checkers should see wrapper's signature like this:
def wrapper(arg1: str, a: int, b: int):
...
It may be enabled by default when passing *args and **kwargs to another function is detected or it may be enabled by adding a decorator to the function.
Detailed description:
Already suggested this to mypy, detailed description of this feature can be found here: python/mypy#19302.
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
Bắt đầu với các ví dụ về wrapper và hàm bên trong trong issue, sau đó đọc thảo luận mypy#19302 được liên kết về đề xuất hiện có và các ràng buộc. Công việc được hoàn tất khi có một phương án được lập tài liệu và thống nhất để suy ra hoặc khai báo kiểu đối số của wrapper từ hàm hoặc constructor nhận *args và **kwargs.
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
- tooling
- 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
- 32/100