Import order causes warnings when working with epicscorelibs and softioc

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

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
32/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện ví dụ về thứ tự import trong test_imports.py, sau đó đọc epicscorelibs/path/cothread.py và softioc/init.py tại các vị trí được liên kết. So sánh cách cothread.catools và softioc khởi tạo các dependency của chúng, và xác định hoàn thành là tránh cảnh báo và yêu cầu thứ tự import không an toàn mà không làm hỏng bất kỳ đường dẫn import nào trong hai đường dẫn.

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

Mô tả

As epicscorelibs maintains its own libca, it provides the option to set the 'CATOOLS_LIBCA_PATH' before using cothread. This can be found here. This mechanism does not appear to be ideal.

For example, softioc uses this mechanism here. The problem comes when another program attempts to use both softioc and cothread itself. A simple program such as the following:

#! /usr/bin/env python3

import cothread.catools
import softioc

will result in the following error (and potentially problematic behaviour):

$ ./test_imports.py 
/path/to/pipenv/environment/lib/python3.7/site-packages/epicscorelibs/path/cothread.py:18: UserWarning: epicscorelibs.path.cothread must be imported before cothread.catools to have effect
  warnings.warn("epicscorelibs.path.cothread must be imported before cothread.catools to have effect")

There are two problems:

  1. It is not immediately clear what is causing the error
  2. If using standard tools such as isort, you need to manually force a particular order of imports to avoid this error. You need to isort:skip multiple lines of code

I am not sure why cothread does not use epicscorelibs by default. Would it be possible to implement this?

Alternatively, some kind of conditional import of epicscorelibs could be useful.

Ngôn ngữ chính
C
Star
13
Fork
12
Merge trung bình
6 giờ 21 phút
Pull request đã merge (30 ngày)
1

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/cothread

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

Issue tương tự

Thêm issue về C

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.