Skip to content

Commit

Permalink
fix: loosen dependancies for click and requests, removes six de…
Browse files Browse the repository at this point in the history
…pendancy (#394)

* Loosen click version requirement

* Add pyproject.toml to test triggers

* Loosen requests version requirements
Also add changelog links

* Remove six depandancy and reorganize imports
  • Loading branch information
pndurette committed Jan 16, 2023
1 parent 3667f06 commit a4ce0c9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
paths:
- 'gtts/**'
- 'pyproject.toml'

jobs:
test:
Expand Down
1 change: 0 additions & 1 deletion gtts/tests/test_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import pytest
from unittest.mock import Mock
from six.moves import urllib

from gtts.tts import gTTS, gTTSError
from gtts.langs import _main_langs
Expand Down
30 changes: 13 additions & 17 deletions gtts/tts.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
# -*- coding: utf-8 -*-
from gtts.tokenizer import pre_processors, Tokenizer, tokenizer_cases
from gtts.utils import _minimize, _len, _clean_tokens, _translate_url
from gtts.lang import tts_langs, _fallback_deprecated_lang

from six.moves import urllib

try:
from urllib.parse import quote
import urllib3
except ImportError:
from urllib import quote
import urllib2
import requests
import logging
import base64
import json
import logging
import re
import base64
import urllib

import requests

from gtts.lang import _fallback_deprecated_lang, tts_langs
from gtts.tokenizer import Tokenizer, pre_processors, tokenizer_cases
from gtts.utils import _clean_tokens, _len, _minimize, _translate_url

__all__ = ["gTTS", "gTTSError"]

Expand Down Expand Up @@ -233,7 +227,7 @@ def _package_rpc(self, text):

rpc = [[[self.GOOGLE_TTS_RPC, escaped_parameter, None, "generic"]]]
espaced_rpc = json.dumps(rpc, separators=(",", ":"))
return "f.req={}&".format(quote(espaced_rpc))
return "f.req={}&".format(urllib.parse.quote(espaced_rpc))

def get_bodies(self):
"""Get TTS API request bodies(s) that would be sent to the TTS API.
Expand All @@ -253,7 +247,9 @@ def stream(self):
# When disabling ssl verify in requests (for proxies and firewalls),
# urllib3 prints an insecure warning on stdout. We disable that.
try:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
requests.packages.urllib3.disable_warnings(
requests.packages.urllib3.exceptions.InsecureRequestWarning
)
except:
pass

Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ classifiers = [
"Topic :: Multimedia :: Sound/Audio :: Speech",
]
dependencies = [
"requests ~= 2.28.0",
"click ~= 8.1.3",
"six ~= 1.16.0"
"requests >=2.27, <3", # https://docs.python-requests.org/en/latest/community/updates/
"click >=7.1, <8.2", # https://click.palletsprojects.com/en/latest/changes/
]

# TODO: release-please [yet] doesn't support dynamic version for pyproject.toml
Expand Down

0 comments on commit a4ce0c9

Please sign in to comment.