[PATCH web] Check for `None` with `is`, not `==`
Export this patch
See PEP 8 (https://www.python.org/dev/peps/pep-0008).
---
Do test this; I tested it and it seems to work but I feel like I might
have broken something somehow. :/
main.py | 6 +++---
templates/index.html | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/main.py b/main.py
index 4ffd85c..a960f5e 100644
--- a/main.py
+++ b/main.py
@@ -105,7 +105,7 @@ async def api_tts():
USER_AGENT = "Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0"
- if url != None:
+ if url is not None:
b = BytesIO(
requests.get(
url, headers={"Referrer": None, "User-Agent": USER_AGENT}
@@ -255,11 +255,11 @@ async def index():
tts_from = None
tts_to = None
# check if the engine even supports TTS
- if engine.get_tts("auto", "test") != None:
+ if engine.get_tts("auto", "test") is not None:
if len(inp) > 0:
params = {"engine": engine_name, "lang": from_l_code, "text": inp}
tts_from = f"/api/tts/?{urlencode(params)}"
- if translation != None:
+ if translation is not None:
if len(translation) > 0:
params = {"engine": engine_name, "lang": to_l_code, "text": translation}
tts_to = f"/api/tts/?{urlencode(params)}"
diff --git a/templates/index.html b/templates/index.html
index 4879b4b..d2ba476 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -188,7 +188,7 @@
<div class="item-wrapper">
<textarea autofocus class="item" id="input" name="input" dir="auto" placeholder="Enter Text Here">{{ inp }}</textarea>
<!-- TTS for the input text -->
- {%- if tts_from != None -%}
+ {%- if tts_from is not none -%}
<br>
<center>
<audio controls>
@@ -202,10 +202,10 @@
<div class="item-wrapper">
<textarea class="translation item" dir="auto" placeholder="Translation" readonly>
- {%- if translation != None -%}{{ translation }}{%- endif -%}
+ {%- if translation is not none -%}{{ translation }}{%- endif -%}
</textarea>
<!-- TTS for the output text -->
- {%- if tts_to != None -%}
+ {%- if tts_to is not none -%}
<br>
<center>
<audio controls>
--
2.33.1