jiaulislam
commited on
Commit
Β·
fe23c24
1
Parent(s):
6cab457
π adding more pre-commit hooks
Browse files- adding default_language_version(general python3) in .pre-commit-config.yaml
- adding out-of-box official pre-commit-hooks
- adding check for toml file
- adding check for yaml file
- adding check for end of file fixer
- adding check for trailing whitespace
- adding check for mixed line ending
- adding check for any private key
- adding check for test file name starts with test
- adding some regex based hooks
- check for blanket noqa [must specify the ignore error code now]
- check for mock methods
- check for no eval
- check for no-log-warn
- check for .rst file not using single backtick
- check for .rst file directive not ending with double colon or space before the double colon
- .flake8 +1 -1
- .github/workflows/pre-commit.yml +1 -1
- .github/workflows/test-release.yml +1 -1
- .pre-commit-config.yaml +27 -0
- LICENSE +1 -1
- deep_translator/constants.py +1 -1
- deep_translator/exceptions.py +2 -2
- docs/LICENSE +0 -1
- docs/authors.rst +1 -1
- docs/conf.py +1 -1
- docs/contributing.rst +3 -3
- pyproject.toml +28 -27
.flake8
CHANGED
@@ -2,4 +2,4 @@
|
|
2 |
ignore = E203, W503, E402
|
3 |
max-line-length = 109
|
4 |
max-complexity = 18
|
5 |
-
select = B,C,E,F,W,T4,B9
|
|
|
2 |
ignore = E203, W503, E402
|
3 |
max-line-length = 109
|
4 |
max-complexity = 18
|
5 |
+
select = B,C,E,F,W,T4,B9
|
.github/workflows/pre-commit.yml
CHANGED
@@ -11,4 +11,4 @@ jobs:
|
|
11 |
- uses: actions/setup-python@v4
|
12 |
with:
|
13 |
python-version: 3.7
|
14 |
-
- uses: pre-commit/[email protected]
|
|
|
11 |
- uses: actions/setup-python@v4
|
12 |
with:
|
13 |
python-version: 3.7
|
14 |
+
- uses: pre-commit/[email protected]
|
.github/workflows/test-release.yml
CHANGED
@@ -23,7 +23,7 @@ jobs:
|
|
23 |
|
24 |
- name: View poetry version
|
25 |
run: poetry --version
|
26 |
-
|
27 |
- name: Update version
|
28 |
run: poetry version patch
|
29 |
|
|
|
23 |
|
24 |
- name: View poetry version
|
25 |
run: poetry --version
|
26 |
+
|
27 |
- name: Update version
|
28 |
run: poetry version patch
|
29 |
|
.pre-commit-config.yaml
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
default_stages: [commit, push]
|
2 |
|
3 |
ci:
|
@@ -13,6 +16,17 @@ ci:
|
|
13 |
submodules: false
|
14 |
|
15 |
repos:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
- repo: https://github.com/psf/black
|
17 |
rev: 23.1.0
|
18 |
hooks:
|
@@ -32,3 +46,16 @@ repos:
|
|
32 |
- id: isort
|
33 |
files: "\\.(py)$"
|
34 |
args: ["--profile", "black"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
default_language_version:
|
2 |
+
python: python3
|
3 |
+
|
4 |
default_stages: [commit, push]
|
5 |
|
6 |
ci:
|
|
|
16 |
submodules: false
|
17 |
|
18 |
repos:
|
19 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
20 |
+
rev: v4.4.0
|
21 |
+
hooks:
|
22 |
+
- id: check-toml
|
23 |
+
- id: check-yaml
|
24 |
+
- id: end-of-file-fixer
|
25 |
+
- id: trailing-whitespace
|
26 |
+
- id: mixed-line-ending
|
27 |
+
- id: detect-private-key
|
28 |
+
- id: name-tests-test
|
29 |
+
args: [--pytest-test-first]
|
30 |
- repo: https://github.com/psf/black
|
31 |
rev: 23.1.0
|
32 |
hooks:
|
|
|
46 |
- id: isort
|
47 |
files: "\\.(py)$"
|
48 |
args: ["--profile", "black"]
|
49 |
+
- repo: https://github.com/tox-dev/pyproject-fmt
|
50 |
+
rev: 0.9.0
|
51 |
+
hooks:
|
52 |
+
- id: pyproject-fmt
|
53 |
+
- repo: https://github.com/pre-commit/pygrep-hooks
|
54 |
+
rev: v1.10.0
|
55 |
+
hooks:
|
56 |
+
- id: python-check-blanket-noqa
|
57 |
+
- id: python-check-mock-methods
|
58 |
+
- id: python-no-eval
|
59 |
+
- id: python-no-log-warn
|
60 |
+
- id: rst-backticks
|
61 |
+
- id: rst-directive-colons
|
LICENSE
CHANGED
@@ -198,4 +198,4 @@
|
|
198 |
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
See the License for the specific language governing permissions and
|
201 |
-
limitations under the License.
|
|
|
198 |
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
See the License for the specific language governing permissions and
|
201 |
+
limitations under the License.
|
deep_translator/constants.py
CHANGED
@@ -10,7 +10,7 @@ BASE_URLS = {
|
|
10 |
"QCRI": "https://mt.qcri.org/api/v1/{endpoint}?",
|
11 |
"DEEPL": "https://api.deepl.com/{version}/",
|
12 |
"DEEPL_FREE": "https://api-free.deepl.com/{version}/",
|
13 |
-
"MICROSOFT_TRANSLATE": "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0",
|
14 |
"PAPAGO": "https://papago.naver.com/",
|
15 |
"PAPAGO_API": "https://openapi.naver.com/v1/papago/n2mt",
|
16 |
"LIBRE": "https://libretranslate.com/",
|
|
|
10 |
"QCRI": "https://mt.qcri.org/api/v1/{endpoint}?",
|
11 |
"DEEPL": "https://api.deepl.com/{version}/",
|
12 |
"DEEPL_FREE": "https://api-free.deepl.com/{version}/",
|
13 |
+
"MICROSOFT_TRANSLATE": "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0",
|
14 |
"PAPAGO": "https://papago.naver.com/",
|
15 |
"PAPAGO_API": "https://openapi.naver.com/v1/papago/n2mt",
|
16 |
"LIBRE": "https://libretranslate.com/",
|
deep_translator/exceptions.py
CHANGED
@@ -39,7 +39,7 @@ class NotValidPayload(BaseError):
|
|
39 |
def __init__(
|
40 |
self,
|
41 |
val,
|
42 |
-
message="text must be a valid text with maximum 5000 character, otherwise it cannot be translated", # noqa
|
43 |
):
|
44 |
super(NotValidPayload, self).__init__(val, message)
|
45 |
|
@@ -123,7 +123,7 @@ class TooManyRequests(Exception):
|
|
123 |
|
124 |
def __init__(
|
125 |
self,
|
126 |
-
message="Server Error: You made too many requests to the server. According to google, you are allowed to make 5 requests per second and up to 200k requests per day. You can wait and try again later or you can try the translate_batch function", # noqa
|
127 |
):
|
128 |
self.message = message
|
129 |
|
|
|
39 |
def __init__(
|
40 |
self,
|
41 |
val,
|
42 |
+
message="text must be a valid text with maximum 5000 character, otherwise it cannot be translated", # noqa: E501
|
43 |
):
|
44 |
super(NotValidPayload, self).__init__(val, message)
|
45 |
|
|
|
123 |
|
124 |
def __init__(
|
125 |
self,
|
126 |
+
message="Server Error: You made too many requests to the server. According to google, you are allowed to make 5 requests per second and up to 200k requests per day. You can wait and try again later or you can try the translate_batch function", # noqa: E501
|
127 |
):
|
128 |
self.message = message
|
129 |
|
docs/LICENSE
CHANGED
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
SOFTWARE.
|
22 |
-
|
|
|
19 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
SOFTWARE.
|
|
docs/authors.rst
CHANGED
@@ -12,4 +12,4 @@ Contributors
|
|
12 |
|
13 |
@prataffel
|
14 |
@senk8
|
15 |
-
@nothead31
|
|
|
12 |
|
13 |
@prataffel
|
14 |
@senk8
|
15 |
+
@nothead31
|
docs/conf.py
CHANGED
@@ -168,7 +168,7 @@ texinfo_documents = [
|
|
168 |
"deep_translator Documentation",
|
169 |
author,
|
170 |
"deep_translator",
|
171 |
-
"A flexible free and unlimited python tool to translate between different languages in a simple way using multiple translators.", # noqa
|
172 |
"Miscellaneous",
|
173 |
),
|
174 |
]
|
|
|
168 |
"deep_translator Documentation",
|
169 |
author,
|
170 |
"deep_translator",
|
171 |
+
"A flexible free and unlimited python tool to translate between different languages in a simple way using multiple translators.", # noqa: E501
|
172 |
"Miscellaneous",
|
173 |
),
|
174 |
]
|
docs/contributing.rst
CHANGED
@@ -58,9 +58,9 @@ If you are proposing a feature:
|
|
58 |
Get Started!
|
59 |
------------
|
60 |
|
61 |
-
Ready to contribute? Here's how to set up
|
62 |
|
63 |
-
1. Fork the `
|
64 |
2. Clone your fork locally::
|
65 |
|
66 |
$ git clone [email protected]:your_name_here/deep_translator.git
|
@@ -129,4 +129,4 @@ Then run::
|
|
129 |
$ git push
|
130 |
$ git push --tags
|
131 |
|
132 |
-
After pushing a new version to the master branch, github will build a package and upload it to PyPI.
|
|
|
58 |
Get Started!
|
59 |
------------
|
60 |
|
61 |
+
Ready to contribute? Here's how to set up ``deep_translator`` for local development.
|
62 |
|
63 |
+
1. Fork the `deep-translator <https://github.com/nidhaloff/deep-translator>`_ repo on GitHub.
|
64 |
2. Clone your fork locally::
|
65 |
|
66 |
$ git clone [email protected]:your_name_here/deep_translator.git
|
|
|
129 |
$ git push
|
130 |
$ git push --tags
|
131 |
|
132 |
+
After pushing a new version to the master branch, github will build a package and upload it to PyPI.
|
pyproject.toml
CHANGED
@@ -1,3 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
[tool.poetry]
|
2 |
name = "deep-translator"
|
3 |
version = "1.10.1"
|
@@ -51,35 +76,11 @@ isort = "^5.10.1"
|
|
51 |
python-semantic-release = "^7.26.0"
|
52 |
pre-commit = "^2.21.0"
|
53 |
|
54 |
-
|
55 |
-
[tool.black]
|
56 |
-
line-length = 79
|
57 |
-
include = '\.pyi?$'
|
58 |
-
exclude = '''
|
59 |
-
/(
|
60 |
-
\.git
|
61 |
-
| \.hg
|
62 |
-
| \.mypy_cache
|
63 |
-
| \.tox
|
64 |
-
| \.venv
|
65 |
-
| _build
|
66 |
-
| buck-out
|
67 |
-
| build
|
68 |
-
| dist
|
69 |
-
)/
|
70 |
-
'''
|
71 |
-
|
72 |
-
[tool.isort]
|
73 |
-
line_length = 79
|
74 |
-
multi_line_output = 3
|
75 |
-
include_trailing_comma = true
|
76 |
-
force_grid_wrap = 0
|
77 |
-
use_parentheses = true
|
78 |
-
ensure_newline_before_comments = true
|
79 |
-
|
80 |
[tool.pycln]
|
81 |
all = true
|
82 |
|
83 |
[build-system]
|
84 |
-
requires = ["poetry-core>=1.0.0"]
|
85 |
build-backend = "poetry.core.masonry.api"
|
|
|
|
|
|
|
|
1 |
+
[tool.black]
|
2 |
+
line-length = 79
|
3 |
+
include = '\.pyi?$'
|
4 |
+
exclude = '''
|
5 |
+
/(
|
6 |
+
\.git
|
7 |
+
| \.hg
|
8 |
+
| \.mypy_cache
|
9 |
+
| \.tox
|
10 |
+
| \.venv
|
11 |
+
| _build
|
12 |
+
| buck-out
|
13 |
+
| build
|
14 |
+
| dist
|
15 |
+
)/
|
16 |
+
'''
|
17 |
+
|
18 |
+
[tool.isort]
|
19 |
+
line_length = 79
|
20 |
+
multi_line_output = 3
|
21 |
+
include_trailing_comma = true
|
22 |
+
force_grid_wrap = 0
|
23 |
+
use_parentheses = true
|
24 |
+
ensure_newline_before_comments = true
|
25 |
+
|
26 |
[tool.poetry]
|
27 |
name = "deep-translator"
|
28 |
version = "1.10.1"
|
|
|
76 |
python-semantic-release = "^7.26.0"
|
77 |
pre-commit = "^2.21.0"
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
[tool.pycln]
|
80 |
all = true
|
81 |
|
82 |
[build-system]
|
|
|
83 |
build-backend = "poetry.core.masonry.api"
|
84 |
+
requires = [
|
85 |
+
"poetry-core>=1",
|
86 |
+
]
|