Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stubs are completely broken #1919

Open
DetachHead opened this issue Sep 10, 2024 · 5 comments
Open

stubs are completely broken #1919

DetachHead opened this issue Sep 10, 2024 · 5 comments
Assignees

Comments

@DetachHead
Copy link
Contributor

it looks like whatever is being used to generate the stubs is completely broken. for example the type annotations in SeleniumLibrary/__init__.pyi are mostly invalid:

class SeleniumLibrary:
    def __init__(self, timeout = timedelta(seconds=5.0), implicit_wait = timedelta(seconds=0.0), run_on_failure = 'Capture Page Screenshot', screenshot_root_directory: Optional[Optional] = None, plugins: Optional[Optional] = None, event_firing_webdriver: Optional[Optional] = None, page_load_timeout = timedelta(seconds=300.0), action_chain_delay = timedelta(seconds=0.25)): ...
    def add_cookie(self, name: str, value: str, path: Optional[Optional] = None, domain: Optional[Optional] = None, secure: Optional[Optional] = None, expiry: Optional[Optional] = None): ...
    
    ...
    
    def click_button(self, locator: Union, modifier: Union = False): ...
    def click_element(self, locator: Union, modifier: Union = False, action_chain: bool = False): ...
    def click_element_at_coordinates(self, locator: Union, xoffset: int, yoffset: int): ...
    def click_image(self, locator: Union, modifier: Union = False): ...
    def click_link(self, locator: Union, modifier: Union = False): ...
  • Optional[Optional] isn't valid. the correct usage would be something like Optional[int] (though Optional is deprecated in favor of the new union syntax eg. int | None)
  • Union is not valid as a type on its own. it should be something like Union[int, str] (which is deprecated in favor of int | str)
  • i see that __init__.py contains type annotations, so the generated stubs should not be needed and can probably just be deleted
  • a py.typed file is also required for type checkers to treat the package as typed
@emanlove emanlove self-assigned this Sep 10, 2024
@emanlove
Copy link
Member

The v6.6.1 stub file was just regenerated as part of the release. I might have messed them up some how. I do recall I was switching between Python 3.12 and an earlier version as to implement and test 3.12 support. Will take a look today. One can regenerate it using the invoke gen-stub task from the root project directory. (See the BUILD / developer docs for more info.)

@DetachHead
Copy link
Contributor Author

i don't think the stub file is even needed anymore since the source code now contains type annotations

@aaltat
Copy link
Contributor

aaltat commented Sep 10, 2024

It is needed, when using SL from Python side, IDE doesn’t know what public API is.

@aaltat
Copy link
Contributor

aaltat commented Sep 10, 2024

The v6.6.1 stub file was just regenerated as part of the release. I might have messed them up some how. I do recall I was switching between Python 3.12 and an earlier version as to implement and test 3.12 support. Will take a look today. One can regenerate it using the invoke gen-stub task from the root project directory. (See the BUILD / developer docs for more info.)

I think I built some custom parsing, which is not good idea. It might be better to scrap that logic and use MyPy to generate base for the pyi file. It will need some code for finding correct methods and compile it into single file

@jorenham
Copy link

jorenham commented Sep 10, 2024

It is needed, when using SL from Python side, IDE doesn’t know what public API is.

That's probably because a py.typed is missing. With it, the stubs can (and should) be deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants