Skip to content

Commit 66d8051

Browse files
authored
Merge branch 'trunk' into fix-mypy-type-errors-2
2 parents 4dbf5b0 + 0fe5ed2 commit 66d8051

File tree

9 files changed

+289
-201
lines changed

9 files changed

+289
-201
lines changed

py/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ py_wheel(
312312
"trio~=0.30.0",
313313
"trio-websocket~=0.12.2",
314314
"certifi>=2025.4.26",
315-
"typing_extensions~=4.13.2",
315+
"typing_extensions~=4.14.0",
316316
"websocket-client~=1.8.0",
317317
],
318318
strip_path_prefixes = [

py/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies = [
2929
"trio~=0.30.0",
3030
"trio-websocket~=0.12.2",
3131
"certifi>=2025.4.26",
32-
"typing_extensions~=4.13.2",
32+
"typing_extensions~=4.14.0",
3333
"websocket-client~=1.8.0",
3434
]
3535

py/requirements.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
async-generator==1.10
22
attrs==25.3.0
3-
cachetools==5.5.2
3+
cachetools==6.0.0
44
certifi==2025.4.26
55
cffi==1.17.1
66
chardet==5.2.0
77
charset-normalizer==3.4.2
88
colorama==0.4.6
9-
cryptography==44.0.3
9+
cryptography==45.0.3
1010
debugpy==1.8.14
1111
distlib==0.3.9
1212
docutils==0.21.2
@@ -26,22 +26,22 @@ keyring==25.6.0
2626
markdown-it-py==3.0.0
2727
mdurl==0.1.2
2828
more-itertools==10.7.0
29-
multidict==6.4.3
29+
multidict==6.4.4
3030
nh3==0.2.21
3131
outcome==1.3.0.post0
3232
packaging==25.0
3333
platformdirs==4.3.8
34-
pluggy==1.5.0
34+
pluggy==1.6.0
3535
py==1.11.0
3636
pycparser==2.22
3737
Pygments==2.19.1
38-
pyOpenSSL==25.0.0
38+
pyOpenSSL==25.1.0
3939
pyparsing==3.2.3
40-
pyproject-api==1.9.0
40+
pyproject-api==1.9.1
4141
PySocks==1.7.1
42-
pytest==8.3.5
42+
pytest==8.4.0
4343
pytest-instafail==0.5.0
44-
pytest-mock==3.14.0
44+
pytest-mock==3.14.1
4545
pytest-trio==0.8.0
4646
readme_renderer==44.0
4747
requests==2.32.3
@@ -52,13 +52,13 @@ SecretStorage==3.3.3
5252
sniffio==1.3.1
5353
sortedcontainers==2.4.0
5454
toml==0.10.2
55-
tox==4.25.0
55+
tox==4.26.0
5656
trio==0.30.0
5757
trio-websocket==0.12.2
5858
twine==6.1.0
59-
typing_extensions==4.13.2
59+
typing_extensions==4.14.0
6060
urllib3[socks]==2.4.0
6161
virtualenv==20.31.2
6262
websocket-client==1.8.0
6363
wsproto==1.2.0
64-
zipp==3.21.0
64+
zipp==3.22.0

py/requirements_lock.txt

Lines changed: 171 additions & 170 deletions
Large diffs are not rendered by default.

py/selenium/webdriver/common/bidi/storage.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from typing import Optional, Union
18+
from typing import Any, Optional, Union
1919

2020
from selenium.webdriver.common.bidi.common import command_builder
2121

@@ -85,12 +85,19 @@ def from_dict(cls, data: dict) -> "Cookie":
8585
-------
8686
Cookie: A new instance of Cookie.
8787
"""
88-
value = BytesValue(data.get("value", {}).get("type"), data.get("value", {}).get("value"))
88+
# Validation for empty strings
89+
name = data.get("name")
90+
if not name:
91+
raise ValueError("name is required and cannot be empty")
92+
domain = data.get("domain")
93+
if not domain:
94+
raise ValueError("domain is required and cannot be empty")
8995

96+
value = BytesValue(data.get("value", {}).get("type"), data.get("value", {}).get("value"))
9097
return cls(
91-
name=data.get("name"),
98+
name=str(name),
9299
value=value,
93-
domain=data.get("domain"),
100+
domain=str(domain),
94101
path=data.get("path"),
95102
size=data.get("size"),
96103
http_only=data.get("httpOnly"),
@@ -125,14 +132,14 @@ def __init__(
125132
self.same_site = same_site
126133
self.expiry = expiry
127134

128-
def to_dict(self) -> dict:
135+
def to_dict(self) -> dict[str, Any]:
129136
"""Converts the CookieFilter to a dictionary.
130137
131138
Returns:
132139
-------
133140
Dict: A dictionary representation of the CookieFilter.
134141
"""
135-
result = {}
142+
result: dict[str, Any] = {}
136143
if self.name is not None:
137144
result["name"] = self.name
138145
if self.value is not None:
@@ -242,14 +249,14 @@ def __init__(
242249
self.same_site = same_site
243250
self.expiry = expiry
244251

245-
def to_dict(self) -> dict:
252+
def to_dict(self) -> dict[str, Any]:
246253
"""Converts the PartialCookie to a dictionary.
247254
248255
Returns:
249256
-------
250257
Dict: A dictionary representation of the PartialCookie.
251258
"""
252-
result = {
259+
result: dict[str, Any] = {
253260
"name": self.name,
254261
"value": self.value.to_dict(),
255262
"domain": self.domain,

py/selenium/webdriver/common/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def __init__(self) -> None:
422422
self._caps = self.default_capabilities
423423
self._proxy = None
424424
self.set_capability("pageLoadStrategy", PageLoadStrategy.normal)
425-
self.mobile_options = None
425+
self.mobile_options: Optional[dict[str, str]] = None
426426
self._ignore_local_proxy = False
427427

428428
@property

py/selenium/webdriver/common/virtual_authenticator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
class Protocol(str, Enum):
2525
"""Protocol to communicate with the authenticator."""
2626

27-
CTAP2: str = "ctap2"
28-
U2F: str = "ctap1/u2f"
27+
CTAP2 = "ctap2"
28+
U2F = "ctap1/u2f"
2929

3030

3131
class Transport(str, Enum):
3232
"""Transport method to communicate with the authenticator."""
3333

34-
BLE: str = "ble"
35-
USB: str = "usb"
36-
NFC: str = "nfc"
37-
INTERNAL: str = "internal"
34+
BLE = "ble"
35+
USB = "usb"
36+
NFC = "nfc"
37+
INTERNAL = "internal"
3838

3939

4040
class VirtualAuthenticatorOptions:

py/tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ setenv =
3232
[testenv:mypy]
3333
skip_install = true
3434
deps =
35-
mypy==1.15.0
36-
lxml==5.3.2
37-
types-urllib3==1.26.25
35+
mypy==1.16.0
36+
lxml==5.4.0
37+
types-urllib3==1.26.25.14
3838
types-certifi==2021.10.8.3
3939
trio-typing==0.10.0
4040
commands =

scripts/update_py_dependencies.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This script updates the development dependendencies used for the Python bindings.
4+
#
5+
# When you run it, it will:
6+
# - create and activate a temporary virtual env
7+
# - install the current package dependencies from `py/requirements.txt`
8+
# - upgrade the package dependencies to the latest versions available on PyPI
9+
# - run `pip freeze` to generate a new `py/requirements.txt` file
10+
# - run `bazel run //py:requirements.update` to generate a new `py/requirements_lock.txt` file
11+
# - deactivate and remove the temporary virtual env
12+
#
13+
# After running this script, you should also manually check package dependency versions in
14+
# `py/pyproject.toml`, `py/tox.ini` and `py/BUILD.bazel`, and update those if needed.
15+
#
16+
# Once all dependencies are updated, create a new Pull Request with the changes.
17+
18+
set -e
19+
20+
REQUIREMENTS_FILE="./py/requirements.txt"
21+
VENV="./temp_virtualenv"
22+
23+
cd "$(git rev-parse --show-toplevel)"
24+
25+
if [[ ! -f "${REQUIREMENTS_FILE}" ]]; then
26+
echo "can't find: ${REQUIREMENTS_FILE}"
27+
exit 1
28+
fi
29+
30+
if [[ -d "${VENV}" ]]; then
31+
echo "${VENV} already exists"
32+
exit 1
33+
fi
34+
35+
echo "creating virtual env: ${VENV}"
36+
python3 -m venv "${VENV}"
37+
38+
echo "activating virtual env"
39+
source "${VENV}/bin/activate"
40+
41+
echo "upgrading pip"
42+
python -m pip install --upgrade pip > /dev/null
43+
44+
echo "installing dev dependencies from: ${REQUIREMENTS_FILE}"
45+
pip install -r "${REQUIREMENTS_FILE}" > /dev/null
46+
47+
echo "upgrading outdated dependencies ..."
48+
echo
49+
pip list --outdated | while read -r line; do
50+
if [[ ! "${line}" =~ "Version Latest" && ! "${line}" =~ "----" ]]; then
51+
read -ra fields <<< "${line}"
52+
package="${fields[0]}"
53+
echo "upgrading ${package} from ${fields[1]} to ${fields[2]}"
54+
pip install --upgrade "${package}==${fields[2]}" > /dev/null
55+
fi
56+
done
57+
58+
echo
59+
echo "generating new ${REQUIREMENTS_FILE}"
60+
pip freeze > "${REQUIREMENTS_FILE}"
61+
# `pip freeze` doesn't show package "extras", so we explicitly add it here for urllib3
62+
if [[ "${OSTYPE}" == "linux"* ]]; then
63+
sed -i "s/urllib3/urllib3[socks]/g" "${REQUIREMENTS_FILE}" # GNU sed
64+
else
65+
sed -i "" "s/urllib3/urllib3[socks]/g" "${REQUIREMENTS_FILE}"
66+
fi
67+
68+
echo "generating new lock file"
69+
bazel run //py:requirements.update
70+
71+
echo
72+
echo "deleting virtual env: ${VENV}"
73+
deactivate
74+
rm -rf "${VENV}"
75+
76+
echo
77+
git status
78+
79+
echo
80+
echo "done!"

0 commit comments

Comments
 (0)