From 0d1a79f941404e1916dfb2579a52ed45c7ed4f8a Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Tue, 15 May 2018 07:54:59 -0400 Subject: [PATCH 1/4] Remove old bad stubs, fix importlib for mypy --- stdlib/3.7/importlib/__init__.pyi | 0 .../2/selenium/webdriver/remote/webdriver.pyi | 107 ------------------ .../selenium/webdriver/remote/webelement.pyi | 61 ---------- 3 files changed, 168 deletions(-) create mode 100644 stdlib/3.7/importlib/__init__.pyi delete mode 100644 third_party/2/selenium/webdriver/remote/webdriver.pyi delete mode 100644 third_party/2/selenium/webdriver/remote/webelement.pyi diff --git a/stdlib/3.7/importlib/__init__.pyi b/stdlib/3.7/importlib/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/third_party/2/selenium/webdriver/remote/webdriver.pyi b/third_party/2/selenium/webdriver/remote/webdriver.pyi deleted file mode 100644 index 6136c99356d9..000000000000 --- a/third_party/2/selenium/webdriver/remote/webdriver.pyi +++ /dev/null @@ -1,107 +0,0 @@ -from typing import Any, Dict, List, Optional, Text -from .mobile import Mobile as Mobile -from selenium.webdriver.remote.webelement import WebElement -from selenium.webdriver.remote.errorhandler import ErrorHandler -from selenium.webdriver.remote.file_detector import FileDetector - -Capabilities = Dict[basestring, Any] -ExecuteResult = Dict[basestring, Any] # containing 'success', 'value', 'sessionId' - -class WebDriver: - command_executor = ... # type: basestring - session_id = ... # type: Any - capabilities = ... # type: Capabilities - error_handler = ... # type: ErrorHandler - file_detector = ... # type: FileDetector - def __init__(self, - command_executor: basestring = ..., - desired_capabilities: Capabilities = ..., - browser_profile: Optional[Any] = ..., # should be selenium.webdriver.firefox.firefox_profile.FirefoxProfile, but we don't have a stub for that - proxy: Optional[Any] = ..., # should be selenium.webdriver.common.proxy.Proxy, but there's no stub for that - keep_alive: bool = ... - ) -> None: ... - @property - def mobile(self) -> Mobile: ... - @property - def name(self) -> basestring: ... - def start_client(self): ... - def stop_client(self): ... - w3c = ... # type: Any - def start_session(self, desired_capabilities, browser_profile=None): ... - def create_web_element(self, element_id: basestring) -> WebElement: ... - def execute(self, driver_command: basestring, params: Optional[Dict[basestring, Any]] = ...) -> ExecuteResult: ... - def get(self, url: basestring) -> None: ... - @property - def title(self) -> basestring: ... - def find_element_by_id(self, id_: basestring) -> WebElement: ... - def find_elements_by_id(self, id_: basestring) -> List[WebElement]: ... - def find_element_by_xpath(self, xpath: basestring) -> WebElement: ... - def find_elements_by_xpath(self, xpath: basestring) -> List[WebElement]: ... - def find_element_by_link_text(self, link_text: basestring) -> WebElement: ... - def find_elements_by_link_text(self, text: basestring) -> List[WebElement]: ... - def find_element_by_partial_link_text(self, link_text: basestring) -> WebElement: ... - def find_elements_by_partial_link_text(self, link_text: basestring) -> List[WebElement]: ... - def find_element_by_name(self, name: basestring) -> WebElement: ... - def find_elements_by_name(self, name: basestring) -> List[WebElement]: ... - def find_element_by_tag_name(self, name: basestring) -> WebElement: ... - def find_elements_by_tag_name(self, name: basestring) -> List[WebElement]: ... - def find_element_by_class_name(self, name: basestring) -> WebElement: ... - def find_elements_by_class_name(self, name: basestring) -> List[WebElement]: ... - def find_element_by_css_selector(self, css_selector: basestring) -> WebElement: ... - def find_elements_by_css_selector(self, css_selector: basestring) -> List[WebElement]: ... - def execute_script(self, script, *args): ... - def execute_async_script(self, script, *args): ... - @property - def current_url(self) -> basestring: ... - @property - def page_source(self): ... - def close(self): ... - def quit(self): ... - @property - def current_window_handle(self): ... - @property - def window_handles(self): ... - def maximize_window(self): ... - @property - def switch_to(self): ... - def switch_to_active_element(self): ... - def switch_to_window(self, window_name): ... - def switch_to_frame(self, frame_reference): ... - def switch_to_default_content(self): ... - def switch_to_alert(self): ... - def back(self): ... - def forward(self): ... - def refresh(self): ... - def get_cookies(self): ... - def get_cookie(self, name): ... - def delete_cookie(self, name): ... - def delete_all_cookies(self): ... - def add_cookie(self, cookie_dict): ... - def implicitly_wait(self, time_to_wait): ... - def set_script_timeout(self, time_to_wait): ... - def set_page_load_timeout(self, time_to_wait): ... - def find_element(self, by=..., value=None): ... - def find_elements(self, by=..., value=None): ... - @property - def desired_capabilities(self) -> Capabilities: ... - def get_screenshot_as_file(self, filename: Text) -> bool: ... - def save_screenshot(self, filename: Text) -> bool: ... - def get_screenshot_as_png(self) -> bytes: ... - def get_screenshot_as_base64(self) -> str: ... - def set_window_size(self, width: int, height: int, windowHandle: str = ...) -> None: ... - def get_window_size(self, windowHandle: str = ...) -> Dict[str, int]: ... - def set_window_position(self, x: int, y: int, windowHandle: str = ...) -> None: ... - def get_window_position(self, windowHandle: str = ...) -> Dict[str, int]: ... - @property - def file_detector(self): ... - @file_detector.setter - def file_detector(self, detector): ... - @property - def orientation(self): ... - @orientation.setter - def orientation(self, value): ... - @property - def application_cache(self): ... - @property - def log_types(self): ... - def get_log(self, log_type): ... diff --git a/third_party/2/selenium/webdriver/remote/webelement.pyi b/third_party/2/selenium/webdriver/remote/webelement.pyi deleted file mode 100644 index 0aa8b6214e8e..000000000000 --- a/third_party/2/selenium/webdriver/remote/webelement.pyi +++ /dev/null @@ -1,61 +0,0 @@ -from selenium.webdriver.remote.webdriver import WebDriver -from typing import Optional, Dict, List, Text - -SizeDict = Dict[str, int] # containing "height", "width" -PointDict = Dict[str, int] # containing "x", "y" - -class WebElement: - def __init__(self, parent: WebDriver, id_: Optional[basestring], w3c: bool = ...) -> None: ... - @property - def tag_name(self) -> basestring: ... - @property - def text(self) -> Optional[basestring]: ... - def click(self) -> None: ... - def submit(self) -> None: ... - def clear(self) -> None: ... - def get_attribute(self, name: basestring) -> Optional[basestring]: ... - def is_selected(self) -> bool: ... - def is_enabled(self) -> bool: ... - - def find_element_by_id(self, id_: basestring) -> WebElement: ... - def find_elements_by_id(self, id_: basestring) -> List[WebElement]: ... - def find_element_by_name(self, name: basestring) -> WebElement: ... - def find_elements_by_name(self, name: basestring) -> List[WebElement]: ... - def find_element_by_link_text(self, link_text: basestring) -> WebElement: ... - def find_elements_by_link_text(self, link_text: basestring) -> List[WebElement]: ... - def find_element_by_partial_link_text(self, link_text: basestring) -> WebElement: ... - def find_elements_by_partial_link_text(self, link_text: basestring) -> List[WebElement]: ... - def find_element_by_tag_name(self, name: basestring) -> WebElement: ... - def find_elements_by_tag_name(self, name: basestring) -> List[WebElement]: ... - def find_element_by_xpath(self, xpath: basestring) -> WebElement: ... - def find_elements_by_xpath(self, xpath: basestring) -> List[WebElement]: ... - def find_element_by_class_name(self, name: basestring) -> WebElement: ... - def find_elements_by_class_name(self, name: basestring) -> List[WebElement]: ... - def find_element_by_css_selector(self, css_selector: basestring) -> WebElement: ... - def find_elements_by_css_selector(self, css_selector: basestring) -> List[WebElement]: ... - - def send_keys(self, *value: basestring) -> None: ... - def is_displayed(self) -> bool: ... - @property - def location_once_scrolled_into_view(self): ... - @property - def size(self) -> SizeDict: ... - def value_of_css_property(self, property_name): ... - @property - def location(self) -> PointDict: ... - @property - def rect(self): ... - @property - def screenshot_as_base64(self): ... - @property - def screenshot_as_png(self): ... - def screenshot(self, filename: basestring): ... - @property - def parent(self) -> WebDriver: ... - @property - def id(self) -> Optional[basestring]: ... - def __eq__(self, element: object) -> bool: ... - def __ne__(self, element: object) -> bool: ... - def find_element(self, by: Text = ..., value: Optional[Text] = ...) -> WebElement: ... - def find_elements(self, by: Text = ..., value: Optional[Text] = ...) -> List[WebElement]: ... - def __hash__(self) -> int: ... From 839f2791f209a92e97f780d5c6c2a416ecd547aa Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Tue, 15 May 2018 08:27:12 -0400 Subject: [PATCH 2/4] Move importlib.resources to be in 3, but only usable on 3.7 --- stdlib/3.7/importlib/__init__.pyi | 0 stdlib/3.7/importlib/resources.pyi | 22 ---------------------- stdlib/3/importlib/resources.pyi | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 22 deletions(-) delete mode 100644 stdlib/3.7/importlib/__init__.pyi delete mode 100644 stdlib/3.7/importlib/resources.pyi create mode 100644 stdlib/3/importlib/resources.pyi diff --git a/stdlib/3.7/importlib/__init__.pyi b/stdlib/3.7/importlib/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/stdlib/3.7/importlib/resources.pyi b/stdlib/3.7/importlib/resources.pyi deleted file mode 100644 index 57dc7b9f24c6..000000000000 --- a/stdlib/3.7/importlib/resources.pyi +++ /dev/null @@ -1,22 +0,0 @@ -import os - -from pathlib import Path -from types import ModuleType -from typing import ContextManager, Iterator, Union, BinaryIO, TextIO - -Package = Union[str, ModuleType] -Resource = Union[str, os.PathLike] - -def open_binary(package: Package, resource: Resource) -> BinaryIO: ... -def open_text(package: Package, - resource: Resource, - encoding: str = ..., - errors: str = ...) -> TextIO: ... -def read_binary(package: Package, resource: Resource) -> bytes: ... -def read_text(package: Package, - resource: Resource, - encoding: str = ..., - errors: str = ...) -> str: ... -def path(package: Package, resource: Resource) -> ContextManager[Path]: ... -def is_resource(package: Package, name: str) -> bool: ... -def contents(package: Package) -> Iterator[str]: ... diff --git a/stdlib/3/importlib/resources.pyi b/stdlib/3/importlib/resources.pyi new file mode 100644 index 000000000000..f2c4160c9d22 --- /dev/null +++ b/stdlib/3/importlib/resources.pyi @@ -0,0 +1,24 @@ +import sys +if sys.version_info >= (3, 7, 0): + import os + + from pathlib import Path + from types import ModuleType + from typing import ContextManager, Iterator, Union, BinaryIO, TextIO + + Package = Union[str, ModuleType] + Resource = Union[str, os.PathLike] + + def open_binary(package: Package, resource: Resource) -> BinaryIO: ... + def open_text(package: Package, + resource: Resource, + encoding: str = ..., + errors: str = ...) -> TextIO: ... + def read_binary(package: Package, resource: Resource) -> bytes: ... + def read_text(package: Package, + resource: Resource, + encoding: str = ..., + errors: str = ...) -> str: ... + def path(package: Package, resource: Resource) -> ContextManager[Path]: ... + def is_resource(package: Package, name: str) -> bool: ... + def contents(package: Package) -> Iterator[str]: ... From 41f7b831310b54b1a2073c6c897c23488bd99394 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Tue, 15 May 2018 08:34:04 -0400 Subject: [PATCH 3/4] Fix version comparison --- stdlib/3/importlib/resources.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/importlib/resources.pyi b/stdlib/3/importlib/resources.pyi index f2c4160c9d22..cdfb3e0b4a13 100644 --- a/stdlib/3/importlib/resources.pyi +++ b/stdlib/3/importlib/resources.pyi @@ -1,5 +1,5 @@ import sys -if sys.version_info >= (3, 7, 0): +if sys.version_info >= (3, 7): import os from pathlib import Path From 9ee7567ea6fdc8f6d103f9e712e6f6ec69158b56 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Tue, 15 May 2018 10:13:10 -0400 Subject: [PATCH 4/4] Restore selenium stubs and add comment about importlib.resources --- stdlib/3/importlib/resources.pyi | 1 + .../2/selenium/webdriver/remote/webdriver.pyi | 107 ++++++++++++++++++ .../selenium/webdriver/remote/webelement.pyi | 61 ++++++++++ 3 files changed, 169 insertions(+) create mode 100644 third_party/2/selenium/webdriver/remote/webdriver.pyi create mode 100644 third_party/2/selenium/webdriver/remote/webelement.pyi diff --git a/stdlib/3/importlib/resources.pyi b/stdlib/3/importlib/resources.pyi index cdfb3e0b4a13..2db82b32641f 100644 --- a/stdlib/3/importlib/resources.pyi +++ b/stdlib/3/importlib/resources.pyi @@ -1,4 +1,5 @@ import sys +# This is a >=3.7 module, so we conditionally include its source. if sys.version_info >= (3, 7): import os diff --git a/third_party/2/selenium/webdriver/remote/webdriver.pyi b/third_party/2/selenium/webdriver/remote/webdriver.pyi new file mode 100644 index 000000000000..6136c99356d9 --- /dev/null +++ b/third_party/2/selenium/webdriver/remote/webdriver.pyi @@ -0,0 +1,107 @@ +from typing import Any, Dict, List, Optional, Text +from .mobile import Mobile as Mobile +from selenium.webdriver.remote.webelement import WebElement +from selenium.webdriver.remote.errorhandler import ErrorHandler +from selenium.webdriver.remote.file_detector import FileDetector + +Capabilities = Dict[basestring, Any] +ExecuteResult = Dict[basestring, Any] # containing 'success', 'value', 'sessionId' + +class WebDriver: + command_executor = ... # type: basestring + session_id = ... # type: Any + capabilities = ... # type: Capabilities + error_handler = ... # type: ErrorHandler + file_detector = ... # type: FileDetector + def __init__(self, + command_executor: basestring = ..., + desired_capabilities: Capabilities = ..., + browser_profile: Optional[Any] = ..., # should be selenium.webdriver.firefox.firefox_profile.FirefoxProfile, but we don't have a stub for that + proxy: Optional[Any] = ..., # should be selenium.webdriver.common.proxy.Proxy, but there's no stub for that + keep_alive: bool = ... + ) -> None: ... + @property + def mobile(self) -> Mobile: ... + @property + def name(self) -> basestring: ... + def start_client(self): ... + def stop_client(self): ... + w3c = ... # type: Any + def start_session(self, desired_capabilities, browser_profile=None): ... + def create_web_element(self, element_id: basestring) -> WebElement: ... + def execute(self, driver_command: basestring, params: Optional[Dict[basestring, Any]] = ...) -> ExecuteResult: ... + def get(self, url: basestring) -> None: ... + @property + def title(self) -> basestring: ... + def find_element_by_id(self, id_: basestring) -> WebElement: ... + def find_elements_by_id(self, id_: basestring) -> List[WebElement]: ... + def find_element_by_xpath(self, xpath: basestring) -> WebElement: ... + def find_elements_by_xpath(self, xpath: basestring) -> List[WebElement]: ... + def find_element_by_link_text(self, link_text: basestring) -> WebElement: ... + def find_elements_by_link_text(self, text: basestring) -> List[WebElement]: ... + def find_element_by_partial_link_text(self, link_text: basestring) -> WebElement: ... + def find_elements_by_partial_link_text(self, link_text: basestring) -> List[WebElement]: ... + def find_element_by_name(self, name: basestring) -> WebElement: ... + def find_elements_by_name(self, name: basestring) -> List[WebElement]: ... + def find_element_by_tag_name(self, name: basestring) -> WebElement: ... + def find_elements_by_tag_name(self, name: basestring) -> List[WebElement]: ... + def find_element_by_class_name(self, name: basestring) -> WebElement: ... + def find_elements_by_class_name(self, name: basestring) -> List[WebElement]: ... + def find_element_by_css_selector(self, css_selector: basestring) -> WebElement: ... + def find_elements_by_css_selector(self, css_selector: basestring) -> List[WebElement]: ... + def execute_script(self, script, *args): ... + def execute_async_script(self, script, *args): ... + @property + def current_url(self) -> basestring: ... + @property + def page_source(self): ... + def close(self): ... + def quit(self): ... + @property + def current_window_handle(self): ... + @property + def window_handles(self): ... + def maximize_window(self): ... + @property + def switch_to(self): ... + def switch_to_active_element(self): ... + def switch_to_window(self, window_name): ... + def switch_to_frame(self, frame_reference): ... + def switch_to_default_content(self): ... + def switch_to_alert(self): ... + def back(self): ... + def forward(self): ... + def refresh(self): ... + def get_cookies(self): ... + def get_cookie(self, name): ... + def delete_cookie(self, name): ... + def delete_all_cookies(self): ... + def add_cookie(self, cookie_dict): ... + def implicitly_wait(self, time_to_wait): ... + def set_script_timeout(self, time_to_wait): ... + def set_page_load_timeout(self, time_to_wait): ... + def find_element(self, by=..., value=None): ... + def find_elements(self, by=..., value=None): ... + @property + def desired_capabilities(self) -> Capabilities: ... + def get_screenshot_as_file(self, filename: Text) -> bool: ... + def save_screenshot(self, filename: Text) -> bool: ... + def get_screenshot_as_png(self) -> bytes: ... + def get_screenshot_as_base64(self) -> str: ... + def set_window_size(self, width: int, height: int, windowHandle: str = ...) -> None: ... + def get_window_size(self, windowHandle: str = ...) -> Dict[str, int]: ... + def set_window_position(self, x: int, y: int, windowHandle: str = ...) -> None: ... + def get_window_position(self, windowHandle: str = ...) -> Dict[str, int]: ... + @property + def file_detector(self): ... + @file_detector.setter + def file_detector(self, detector): ... + @property + def orientation(self): ... + @orientation.setter + def orientation(self, value): ... + @property + def application_cache(self): ... + @property + def log_types(self): ... + def get_log(self, log_type): ... diff --git a/third_party/2/selenium/webdriver/remote/webelement.pyi b/third_party/2/selenium/webdriver/remote/webelement.pyi new file mode 100644 index 000000000000..0aa8b6214e8e --- /dev/null +++ b/third_party/2/selenium/webdriver/remote/webelement.pyi @@ -0,0 +1,61 @@ +from selenium.webdriver.remote.webdriver import WebDriver +from typing import Optional, Dict, List, Text + +SizeDict = Dict[str, int] # containing "height", "width" +PointDict = Dict[str, int] # containing "x", "y" + +class WebElement: + def __init__(self, parent: WebDriver, id_: Optional[basestring], w3c: bool = ...) -> None: ... + @property + def tag_name(self) -> basestring: ... + @property + def text(self) -> Optional[basestring]: ... + def click(self) -> None: ... + def submit(self) -> None: ... + def clear(self) -> None: ... + def get_attribute(self, name: basestring) -> Optional[basestring]: ... + def is_selected(self) -> bool: ... + def is_enabled(self) -> bool: ... + + def find_element_by_id(self, id_: basestring) -> WebElement: ... + def find_elements_by_id(self, id_: basestring) -> List[WebElement]: ... + def find_element_by_name(self, name: basestring) -> WebElement: ... + def find_elements_by_name(self, name: basestring) -> List[WebElement]: ... + def find_element_by_link_text(self, link_text: basestring) -> WebElement: ... + def find_elements_by_link_text(self, link_text: basestring) -> List[WebElement]: ... + def find_element_by_partial_link_text(self, link_text: basestring) -> WebElement: ... + def find_elements_by_partial_link_text(self, link_text: basestring) -> List[WebElement]: ... + def find_element_by_tag_name(self, name: basestring) -> WebElement: ... + def find_elements_by_tag_name(self, name: basestring) -> List[WebElement]: ... + def find_element_by_xpath(self, xpath: basestring) -> WebElement: ... + def find_elements_by_xpath(self, xpath: basestring) -> List[WebElement]: ... + def find_element_by_class_name(self, name: basestring) -> WebElement: ... + def find_elements_by_class_name(self, name: basestring) -> List[WebElement]: ... + def find_element_by_css_selector(self, css_selector: basestring) -> WebElement: ... + def find_elements_by_css_selector(self, css_selector: basestring) -> List[WebElement]: ... + + def send_keys(self, *value: basestring) -> None: ... + def is_displayed(self) -> bool: ... + @property + def location_once_scrolled_into_view(self): ... + @property + def size(self) -> SizeDict: ... + def value_of_css_property(self, property_name): ... + @property + def location(self) -> PointDict: ... + @property + def rect(self): ... + @property + def screenshot_as_base64(self): ... + @property + def screenshot_as_png(self): ... + def screenshot(self, filename: basestring): ... + @property + def parent(self) -> WebDriver: ... + @property + def id(self) -> Optional[basestring]: ... + def __eq__(self, element: object) -> bool: ... + def __ne__(self, element: object) -> bool: ... + def find_element(self, by: Text = ..., value: Optional[Text] = ...) -> WebElement: ... + def find_elements(self, by: Text = ..., value: Optional[Text] = ...) -> List[WebElement]: ... + def __hash__(self) -> int: ...