Skip to content

Commit

Permalink
Reformatting with black, isort, pre-commit (#74)
Browse files Browse the repository at this point in the history
* Initial configuration files

* Reformat code with black and isort

* Apply pre-commit hooks

* Enable lint tasks

* Prepare for release
  • Loading branch information
MrNaif2018 committed Feb 2, 2023
1 parent 7e765a5 commit a007126
Show file tree
Hide file tree
Showing 29 changed files with 554 additions and 469 deletions.
37 changes: 35 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,43 @@ jobs:
- run:
name: run fast tests
command: |
make lint
make test
make ci
- upload-results

deploy:
executor: bitcartcc/docker-python
docker:
- image: cimg/python:3.8
steps:
- checkout

- run:
name: setup credentials
command: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = $PYPI_USER" >> ~/.pypirc
echo -e "password = $PYPI_PASS" >> ~/.pypirc
- run:
name: create env, build dist and upload
command: |
virtualenv ~/venv
. ~/venv/bin/activate
pip install -U wheel twine
python setup.py sdist
python setup.py bdist_wheel
twine upload dist/*
workflows:
version: 2
test_and_deploy:
jobs:
- bitcartcc/lint:
name: lint
- test:
name: test-<< matrix.v >>
requires:
- lint
matrix:
parameters:
v:
Expand All @@ -90,3 +116,10 @@ workflows:
- "3.9"
- "3.10"
- "3.11"
- deploy:
context: global
filters:
tags:
only: /[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
indent_style = tab

[*.{yml,yaml}]
indent_size = 2

[*.md]
indent_size = 2
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
max-complexity=11
max-line-length=127
ignore=E266, E203, W503
ignore=E266, E203, W503
48 changes: 48 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-merge-conflict
- repo: https://github.com/asottile/yesqa
rev: v1.4.0
hooks:
- id: yesqa
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: check-case-conflict
- id: check-shebang-scripts-are-executable
- id: check-json
- id: check-toml
- id: check-yaml
- id: check-symlinks
- id: debug-statements
- id: fix-byte-order-marker
- id: fix-encoding-pragma
args: ["--remove"]
- id: detect-private-key
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
hooks:
- id: prettier
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ format:
test:
pytest tests/ ${TEST_ARGS}

ci: checkformat lint test
ci: checkformat lint test
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# tronpy

[![PyPI version](https://badge.fury.io/py/tronpy.svg)](https://pypi.org/project/tronpy/)
[![CircleCI](https://dl.circleci.com/status-badge/img/gh/andelf/tronpy/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/andelf/tronpy/tree/master)

TRON Python Client Library. [Documentation](https://tronpy.readthedocs.io/en/latest/index.html)

> Note: in case you want to use cryptocurrency functions in an universal way or e.g. reliably calculate transaction fees for BTC, ETH, Tron and many others, check out the [BitcartCC project](https://bitcartcc.com)
## How to use

```python
Expand Down
18 changes: 9 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,37 @@

# -- Project information -----------------------------------------------------

project = 'TronPy'
copyright = '2020, Andelf'
author = 'Andelf'
project = "TronPy"
copyright = "2020, Andelf"
author = "Andelf"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc']
extensions = ["sphinx.ext.autodoc"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'classic' # 'alabaster'
html_theme = "classic" # 'alabaster'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

master_doc = 'index'
master_doc = "index"
2 changes: 1 addition & 1 deletion docs/keys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ Key API reference
.. automethod:: hex()

.. autoclass:: tronpy.keys.Signature
:members:
:members:
7 changes: 4 additions & 3 deletions examples/check_balance.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pprint import pprint

from tronpy import Tron
from tronpy.exceptions import AddressNotFound
from pprint import pprint

client = Tron()

Expand All @@ -10,7 +11,7 @@ def check_balance(address):
balance = client.get_account_balance(address)
return balance
except AddressNotFound:
return 'Adress not found..!'
return "Adress not found..!"


pprint(check_balance('<address>'))
pprint(check_balance("<address>"))
2 changes: 1 addition & 1 deletion examples/generate_address.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from tronpy import Tron
from pprint import pprint

from tronpy import Tron

client = Tron()
pprint(client.generate_address())
11 changes: 4 additions & 7 deletions examples/justswap.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@


import json
import os
import time

from tronpy import Tron
from tronpy import keys
from tronpy import Tron, keys

__dir__ = os.path.dirname(__file__)

dzi_trade = 'TSMssi9ojNkzj5fT5bAjzuGjrLmsKau8Xj'
from_addr = 'TVrSWkL6a9xvtxRKq5RHg2HjUpGdPN3wBa'
dzi_trade = "TSMssi9ojNkzj5fT5bAjzuGjrLmsKau8Xj"
from_addr = "TVrSWkL6a9xvtxRKq5RHg2HjUpGdPN3wBa"
priv_key = keys.PrivateKey.fromhex("975a98.....(omitted)..........86b98d97b")


Expand All @@ -23,7 +20,7 @@ def timestamp():
swap_abi = json.load(fp)


client = Tron(network='nile')
client = Tron(network="nile")

cntr = client.get_contract(dzi_trade)
cntr.abi = swap_abi
Expand Down
51 changes: 28 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tronpy"
version = "0.2.6"
version = "0.3.0"
description = "TRON Python client library"
authors = ["andelf <andelf@gmail.com>"]
license = "MIT"
Expand Down Expand Up @@ -49,28 +49,33 @@ filterwarnings = [
]

[tool.black]
line-length = 100
target-version = ['py36']
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
| foo.py # also separately exclude a file named foo.py in
# the root of the project
)
'''
line-length = 127

[tool.isort]
profile = "black"
line_length = 127

[tool.mypy]
warn_redundant_casts = true
warn_unused_ignores = true
disallow_untyped_calls = true
disallow_untyped_defs = true
check_untyped_defs = true
warn_return_any = true
no_implicit_optional = true
strict_optional = true
ignore_missing_imports = true


[tool.coverage.run]
omit = [
"*__init__.py",
"tests/*",
"venv/*",
"env/*",
"setup.py",
]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"
45 changes: 22 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
# -*- coding: utf-8 -*-
from setuptools import setup

packages = ['tronpy', 'tronpy.keys', 'tronpy.providers']
packages = ["tronpy", "tronpy.keys", "tronpy.providers"]

package_data = {'': ['*']}
package_data = {"": ["*"]}

install_requires = [
'base58',
'coincurve',
'eth_abi>=4.0.0a,<5.0.0',
'httpx',
'pycryptodome<4',
'requests',
"base58",
"coincurve",
"eth_abi>=4.0.0a,<5.0.0",
"httpx",
"pycryptodome<4",
"requests",
]

setup_kwargs = {
'name': 'tronpy',
'version': '0.2.6',
'description': 'TRON Python client library',
'long_description': open("README.md").read(),
'long_description_content_type': "text/markdown",
'author': 'andelf',
'author_email': 'andelf@gmail.com',
'maintainer': None,
'maintainer_email': None,
'url': 'https://github.com/andelf/tronpy',
'packages': packages,
'package_data': package_data,
'install_requires': install_requires,
'python_requires': '>=3.6,<4.0',
"name": "tronpy",
"version": "0.3.0",
"description": "TRON Python client library",
"long_description": open("README.md").read(),
"long_description_content_type": "text/markdown",
"author": "andelf",
"author_email": "andelf@gmail.com",
"maintainer": None,
"maintainer_email": None,
"url": "https://github.com/andelf/tronpy",
"packages": packages,
"package_data": package_data,
"install_requires": install_requires,
"python_requires": ">=3.7",
}


Expand Down
Loading

0 comments on commit a007126

Please sign in to comment.