Skip to content

Commit e12972e

Browse files
committed
[py]: fix alot of mypy complaints
1 parent e142d5d commit e12972e

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

py/selenium/webdriver/common/options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class BaseOptions(metaclass=ABCMeta):
2525
Base class for individual browser options
2626
"""
2727

28-
def __init__(self):
28+
def __init__(self) -> None:
2929
super().__init__()
3030
self._caps = self.default_capabilities
3131
self.set_capability("pageLoadStrategy", "normal")
@@ -225,7 +225,7 @@ def default_capabilities(self):
225225

226226
class ArgOptions(BaseOptions):
227227

228-
def __init__(self):
228+
def __init__(self) -> None:
229229
super().__init__()
230230
self._arguments = []
231231
self._ignore_local_proxy = False
@@ -249,7 +249,7 @@ def add_argument(self, argument):
249249
else:
250250
raise ValueError('argument can not be null')
251251

252-
def ignore_local_proxy_environment_variables(self):
252+
def ignore_local_proxy_environment_variables(self) -> None:
253253
"""
254254
By calling this you will ignore HTTP_PROXY and HTTPS_PROXY from being picked up and used.
255255
"""

py/selenium/webdriver/common/virtual_authenticator.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def __init__(self) -> None:
6464
- isUserVerified: False
6565
"""
6666

67-
self._protocol: Literal = Protocol.CTAP2
68-
self._transport: Literal = Transport.USB
67+
self._protocol: Protocol = Protocol.CTAP2
68+
self._transport: Transport = Transport.USB
6969
self._has_resident_key: bool = False
7070
self._has_user_verification: bool = False
7171
self._is_user_consenting: bool = True
@@ -88,38 +88,38 @@ def transport(self, transport: Transport) -> None:
8888
self._transport = transport
8989

9090
@property
91-
def has_resident_key(self) -> None:
91+
def has_resident_key(self) -> bool:
9292
return self._has_resident_key
9393

9494
@has_resident_key.setter
9595
def has_resident_key(self, value: bool) -> None:
9696
self._has_resident_key = value
9797

9898
@property
99-
def has_user_verification(self) -> None:
99+
def has_user_verification(self) -> bool:
100100
return self._has_user_verification
101101

102102
@has_user_verification.setter
103103
def has_user_verification(self, value: bool) -> None:
104104
self._has_user_verification = value
105105

106106
@property
107-
def is_user_consenting(self) -> None:
107+
def is_user_consenting(self) -> bool:
108108
return self._is_user_consenting
109109

110110
@is_user_consenting.setter
111111
def is_user_consenting(self, value: bool) -> None:
112112
self._is_user_consenting = value
113113

114114
@property
115-
def is_user_verified(self) -> None:
115+
def is_user_verified(self) -> bool:
116116
return self._is_user_verified
117117

118118
@is_user_verified.setter
119119
def is_user_verified(self, value: bool) -> None:
120120
self._is_user_verified = value
121121

122-
def to_dict(self) -> dict:
122+
def to_dict(self) -> typing.Dict[str, typing.Any]:
123123
return {
124124
"protocol": self.protocol,
125125
"transport": self.transport,
@@ -131,7 +131,7 @@ def to_dict(self) -> dict:
131131

132132

133133
class Credential:
134-
def __init__(self, credential_id: bytes, is_resident_credential: bool, rp_id: str, user_handle: bytes, private_key: bytes, sign_count: int):
134+
def __init__(self, credential_id: bytes, is_resident_credential: bool, rp_id: str, user_handle: typing.Optional[bytes], private_key: bytes, sign_count: int):
135135
"""Constructor. A credential stored in a virtual authenticator.
136136
https://w3c.github.io/webauthn/#credential-parameters
137137
@@ -151,29 +151,29 @@ def __init__(self, credential_id: bytes, is_resident_credential: bool, rp_id: st
151151
self._sign_count = sign_count
152152

153153
@property
154-
def id(self):
154+
def id(self) -> str:
155155
return urlsafe_b64encode(self._id).decode()
156156

157157
@property
158158
def is_resident_credential(self) -> bool:
159159
return self._is_resident_credential
160160

161161
@property
162-
def rp_id(self):
162+
def rp_id(self) -> str:
163163
return self._rp_id
164164

165165
@property
166-
def user_handle(self):
166+
def user_handle(self) -> typing.Optional[str]:
167167
if self._user_handle:
168168
return urlsafe_b64encode(self._user_handle).decode()
169169
return None
170170

171171
@property
172-
def private_key(self):
172+
def private_key(self) -> str:
173173
return urlsafe_b64encode(self._private_key).decode()
174174

175175
@property
176-
def sign_count(self):
176+
def sign_count(self) -> int:
177177
return self._sign_count
178178

179179
@classmethod
@@ -192,7 +192,7 @@ def create_non_resident_credential(cls, id: bytes, rp_id: str, private_key: byte
192192
return cls(id, False, rp_id, None, private_key, sign_count)
193193

194194
@classmethod
195-
def create_resident_credential(cls, id: bytes, rp_id: str, user_handle: bytes, private_key: bytes, sign_count: int) -> 'Credential':
195+
def create_resident_credential(cls, id: bytes, rp_id: str, user_handle: typing.Optional[bytes], private_key: bytes, sign_count: int) -> 'Credential':
196196
"""Creates a resident (i.e. stateful) credential.
197197
198198
:Args:
@@ -207,7 +207,7 @@ def create_resident_credential(cls, id: bytes, rp_id: str, user_handle: bytes, p
207207
"""
208208
return cls(id, True, rp_id, user_handle, private_key, sign_count)
209209

210-
def to_dict(self):
210+
def to_dict(self) -> typing.Dict[str, typing.Any]:
211211
credential_data = {
212212
'credentialId': self.id,
213213
'isResidentCredential': self._is_resident_credential,
@@ -222,7 +222,7 @@ def to_dict(self):
222222
return credential_data
223223

224224
@classmethod
225-
def from_dict(cls, data):
225+
def from_dict(cls, data: typing.Dict[str, typing.Any]) -> 'Credential':
226226
_id = urlsafe_b64decode(f"{data['credentialId']}==")
227227
is_resident_credential = bool(data['isResidentCredential'])
228228
rp_id = data.get('rpId', None)

0 commit comments

Comments
 (0)