Type constraints in generic bluesky protocols are not respected

Đang mở
#1,788 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

The report gives a reproducible snippet but names no files, so start by reading how the controller validates a plan's parameter types against the device types before execution (the path behind blueapi controller run). Reproduce locally with the demo_plan/MovStr pair from the issue, then find where the Movable[T] type argument is dropped or ignored — likely in the plan-to-device parameter checking rather than in bluesky itself. Done means running the plan against a Movable[str] device fails validation instead of printing Setting name=3.14, with a test covering the constrained TypeVar case.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

With a plan defined as

T = TypeVar("T", int, float)

def demo_plan(mov: Movable[T]) -> MsgGenerator:
    yield from abs_set(mov, 3.14)

and a device that implements Movable[str]

class MovStr(Device, Movable[str]):
    def set(self, name: str):
        print(f"Setting {name=}")

@devices.factory
def demo() -> MovStr:
    return MovStr()

Running the demo_plan with demo runs without raising errors

$ uv run blueapi controller run -i cm12345-1 demo_plan -a '["demo"]'
Plan succeeded

and the server console shows

Setting name=3.14

The type checking should prevent this plan being run

Ngôn ngữ chính
Python
Star
14
Fork
14
Merge trung bình
2 ngày 23 giờ
Pull request đã merge (30 ngày)
27

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DiamondLightSource/blueapi

Tất cả issue của DiamondLightSource/blueapi

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.