Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

🚀 Contribution Docs Revision & Refactoring Pre-Commit #197

Merged
merged 6 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
ignore = E203, W503, E402
max-line-length = 109
max-complexity = 18
select = B,C,E,F,W,T4,B9
select = B,C,E,F,W,T4,B9
14 changes: 14 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on:
pull_request:
push:
branches: [main, master]

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.7
- uses: pre-commit/action@v3.0.0
2 changes: 1 addition & 1 deletion .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: View poetry version
run: poetry --version

- name: Update version
run: poetry version patch

Expand Down
26 changes: 25 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default_language_version:
python: python3.7
jiaulislam marked this conversation as resolved.
Show resolved Hide resolved
python: python3

default_stages: [commit, push]

Expand All @@ -16,6 +16,17 @@ ci:
submodules: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- id: detect-private-key
- id: name-tests-test
args: [--pytest-test-first]
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
Expand All @@ -35,3 +46,16 @@ repos:
- id: isort
files: "\\.(py)$"
args: ["--profile", "black"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 0.9.0
hooks:
- id: pyproject-fmt
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- id: rst-backticks
- id: rst-directive-colons
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
2 changes: 1 addition & 1 deletion deep_translator/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"QCRI": "https://mt.qcri.org/api/v1/{endpoint}?",
"DEEPL": "https://api.deepl.com/{version}/",
"DEEPL_FREE": "https://api-free.deepl.com/{version}/",
"MICROSOFT_TRANSLATE": "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0", # noqa
"MICROSOFT_TRANSLATE": "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0",
"PAPAGO": "https://papago.naver.com/",
"PAPAGO_API": "https://openapi.naver.com/v1/papago/n2mt",
"LIBRE": "https://libretranslate.com/",
Expand Down
8 changes: 6 additions & 2 deletions deep_translator/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class NotValidPayload(BaseError):
def __init__(
self,
val,
message="text must be a valid text with maximum 5000 character, otherwise it cannot be translated", # noqa
message="text must be a valid text with maximum 5000 character,"
"otherwise it cannot be translated",
):
super(NotValidPayload, self).__init__(val, message)

Expand Down Expand Up @@ -123,7 +124,10 @@ class TooManyRequests(Exception):

def __init__(
self,
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
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",
):
self.message = message

Expand Down
1 change: 0 additions & 1 deletion docs/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

3 changes: 3 additions & 0 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ deep-translator
.. image:: https://img.shields.io/pypi/wheel/deep-translator
:target: https://pypi.python.org/pypi/deep-translator

.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit
:target: https://github.com/pre-commit/pre-commit

.. image:: https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2FNidhalBaccouri
:alt: Twitter URL
:target: https://twitter.com/NidhalBaccouri
Expand Down
2 changes: 1 addition & 1 deletion docs/authors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Contributors

@prataffel
@senk8
@nothead31
@nothead31
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"deep_translator Documentation",
author,
"deep_translator",
"A flexible free and unlimited python tool to translate between different languages in a simple way using multiple translators.", # noqa
"A flexible free and unlimited python tool to translate between different languages in a simple way using multiple translators.", # noqa: E501
"Miscellaneous",
),
]
7 changes: 4 additions & 3 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ If you are proposing a feature:
Get Started!
------------

Ready to contribute? Here's how to set up `deep_translator` for local development.
Ready to contribute? Here's how to set up ``deep_translator`` for local development.

1. Fork the `deep_translator` repo on GitHub.
1. Fork the `deep-translator <https://github.com/nidhaloff/deep-translator>`_ repo on GitHub.
2. Clone your fork locally::

$ git clone git@github.com:your_name_here/deep_translator.git
Expand All @@ -70,6 +70,7 @@ Ready to contribute? Here's how to set up `deep_translator` for local developmen
$ cd path/to/project
$ poetry shell
$ poetry install
$ pre-commit install

.. note::

Expand Down Expand Up @@ -128,4 +129,4 @@ Then run::
$ git push
$ git push --tags

After pushing a new version to the master branch, github will build a package and upload it to PyPI.
After pushing a new version to the master branch, github will build a package and upload it to PyPI.
Loading