Skip to content

Commit

Permalink
Use Optional[str] instead of Union[str, None]
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Nov 6, 2022
1 parent 46b9f9f commit f835d21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions huawei_lte_api/Tools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, Tuple
from typing import Optional, Tuple

from binascii import hexlify
import math
Expand All @@ -10,7 +10,7 @@
class Tools:

@staticmethod
def enforce_list_response(data: dict, singular_key_name: str, plural_key_name: Union[str, None] = None) -> dict:
def enforce_list_response(data: dict, singular_key_name: str, plural_key_name: Optional[str] = None) -> dict:
"""
Make sure Hosts->Host is a list
It may be returned as a single dict if only one is associated,
Expand Down
8 changes: 4 additions & 4 deletions huawei_lte_api/api/User.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import hashlib
import time
from types import TracebackType
from typing import Union, Type, Optional
from typing import Type, Optional
import requests

from huawei_lte_api.ApiGroup import ApiGroup
Expand All @@ -22,7 +22,7 @@


class UserSession:
def __init__(self, session: Session, username: str = DEFAULT_USERNAME, password: Union[str, None] = None):
def __init__(self, session: Session, username: str = DEFAULT_USERNAME, password: Optional[str] = None):
self.user = User(session)
self.user.login(username, password, True)

Expand All @@ -43,7 +43,7 @@ class User(ApiGroup):
def state_login(self) -> GetResponseType:
return self._session.get('user/state-login')

def _login(self, username: str, password: Union[str, None], password_type: PasswordTypeEnum = PasswordTypeEnum.BASE_64) -> bool:
def _login(self, username: str, password: Optional[str], password_type: PasswordTypeEnum = PasswordTypeEnum.BASE_64) -> bool:
if not password:
password_encoded = b''
else:
Expand Down Expand Up @@ -88,7 +88,7 @@ def _login(self, username: str, password: Union[str, None], password_type: Passw

return result == ResponseEnum.OK.value

def login(self, username: str = DEFAULT_USERNAME, password: Union[str, None] = None, force_new_login: bool = False) -> bool:
def login(self, username: str = DEFAULT_USERNAME, password: Optional[str] = None, force_new_login: bool = False) -> bool:
if username == '': # <= 1.6.4 backwards compatibility
username = DEFAULT_USERNAME
tries = 5
Expand Down

0 comments on commit f835d21

Please sign in to comment.