cobrateam / cobrateam/splinter

More type annotations?

Open
#1,222 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.7k
Forks
511
PR merge metrics
No merged PRs in 30d

Description

# Request

I would be nice to have expanded type coverage.

## History

- Selenium added typings in 4.1.2 in 2022-02-24
- typeshed: removed selenium types around this time:
- https://github.com/python/typeshed/issues/7381
- https://github.com/python/typeshed/pull/8753
- https://github.com/python/typeshed/commit/9b306c33679cdaa8cdc96c9463bceca88634e54b
- As of 0.20.1, splinter is partially typed.

# Example scenario

_Loosely, even if this isn't idiomatic splinter usage, I think the general benefits of annotations and typings still hold. I am fine to elaborate._

Specifically, I am running into any `Any` with [`BaseWebDriver`](https://github.com/cobrateam/splinter/blob/0.20.1/splinter/driver/webdriver/__init__.py#L279)'s attribute [`.driver`](https://github.com/cobrateam/splinter/blob/0.20.1/splinter/driver/webdriver/__init__.py#L280).

Where I have a function like:

```python
def fill_helper(browser: BaseWebDriver, selectors_path: list[str], value: str) -> None:
# ...
pass
```

And `mypy` will raise:

```
.../test_website.py:31: error: Argument 1 to "fill_helper" becomes "Any" due to an unfollowed import [no-any-unimported]
```

- Selenium: 4.16.1
- Splinter: 0.20.1

Not relevant, but happen to be using:
- pytest: 7.4.3
- pytest-splinter: 3.3.2

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.