mypy error "Incompatible return value type" on webdriver.find_element
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- mobile-dev
Hướng nghiên cứu
Bắt đầu tại appium.webdriver.WebDriver và kiểm tra các chữ ký find_element và find_elements được kế thừa. Chạy đoạn mã có thể tái hiện bằng mypy, sau đó xác minh rằng các chú thích của WebDriver tạo ra các kiểu trả về Appium WebElement và các lỗi return-value được báo cáo biến mất.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Mypy errors on the fact that appium.webdriver.WebDriver.find_element isn't overridden but indeed returns a different WebElement.
Reproducible Code
# no need to actually run this code, just send it through MyPy to see the error.
from appium.webdriver.common.appiumby import AppiumBy
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from appium.webdriver import Remote
from appium.webdriver.webelement import WebElement
def find_element(driver: Remote) -> WebElement:
# should get a mypy error on next line
return driver.find_element(AppiumBy.ACCESSIBILITY_ID, "demo button")
def find_elements(driver: Remote) -> WebElement:
# should get a mypy error on next line
return driver.find_elements(AppiumBy.ACCESSIBILITY_ID, "demo confetti")
mypy output:
mypy .
screenpy_appium/target.py:89: error: Incompatible return value type (got "selenium.webdriver.remote.webelement.WebElement", expected "appium.webdriver.webelement.WebElement") [return-value]
screenpy_appium/target.py:98: error: Incompatible return value type (got "list[selenium.webdriver.remote.webelement.WebElement]", expected "list[appium.webdriver.webelement.WebElement]") [return-value]
Found 2 errors in 1 file (checked 35 source files)
Solution
Annotations need to be added to appium.webdriver.WebDriver
class WebDriver(
webdriver.Remote,
...
):
if TYPE_CHECKING:
def find_element(self, by=By.ID, value: Optional[str] = None) -> MobileWebElement:
...
def find_elements(self, by=By.ID, value: Optional[str] = None) -> list[MobileWebElement]:
...
- Ngôn ngữ chính
- Python
- Star
- 1.8k
- Fork
- 570
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 25
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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.
Issue khác của appium/python-client
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
appium/python-client#1230 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
question
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
appium/python-client#1168 · 9 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 38/100
appium/python-client#1091 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
appium/python-client#1076 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
appium/python-client#980 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của appium/python-client
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
qgis/QGIS-Plugins-Website#459 ·
-
bug severity:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
bot-found bug priority: P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
madenvel/KalinkaPlayer#179 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ls1intum/edutelligence#1098 ·
Maintainer thường phản hồi trong vòng 1 ngày