Arguments to decorators as dependencies of the decorated function
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 20.6k
- Fork
- 3.3k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Forgive me (and please let me know) if I'm asking a question that is out of scope for this issue tracker. I'm trying to use mypy to do things it was not necessarily designed to do.
Specifically, I'm trying to use the fine-grained dependency mapping (see, e.g., mypy/server/deps.py) to find the source code that is needed for a given function. Concretely I'm running mypy --logical-deps example.py and then inspecting the dependency graphs generated in .mypy_cache/3.6/example.deps.json.
It seems to work pretty well for my purposes except that arguments to decorators are not listed as dependencies of the decorated function, e.g., in the following example
some_var = 1
@my_decorator(some_var)
def my_func(x):
return x
Here, for my purpose, some_var is a dependency of my_func in the sense that it is needed to run my_decorator which returns the decorator for my_func. However, mypy does not list some_var as a dependency of my_func. If I understand the type checking correctly, this makes sense because it is not a dependency in terms of type checking; the type of some_var is relevant to type check the call to my_decorator, and the return type of my_decorator is relevant to type check the decoration, but there is no direct connection between some_var and my_func, right?
My question is if I have understood this correctly. This issue can be closed if someone knows this well enough to say "forget it kid, mypy is never going to solve your problem". My hope of course is that someone will say "yeah, that actually is a dependency, and here is the patch we need to write".
Thank you for your time.
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
Bắt đầu bằng cách đọc mypy/server/deps.py và logic dependency chi tiết, sau đó tái hiện ví dụ bằng mypy --logical-deps example.py. So sánh .mypy_cache/3.6/example.deps.json được tạo ra với biểu thức decorator và xác định xem các đối số của decorator có nên được ghi nhận là dependency của hàm được decorator hay không.
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
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100