Skip to content

Commit 3136b9c

Browse files
authored
Merge pull request #235 from Davi0kProgramsThings/fix/refactoring
Merge branch `Davi0kProgramsThings:fix/refactoring` into branch `bitfinexcom:master`.
2 parents 59c3090 + f94096b commit 3136b9c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2223
-1685
lines changed

.flake8

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[flake8]
2+
max-line-length = 80
3+
extend-select = B950
4+
extend-ignore = E203,E501,E701
5+
6+
exclude =
7+
__pycache__
8+
build
9+
dist
10+
venv
11+
12+
per-file-ignores =
13+
*/__init__.py:F401

.github/ISSUE_TEMPLATE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ A possible solution could be...
2020
## Steps to reproduce (for bugs)
2121
<!-- You can delete this section if you are not submitting a bug report -->
2222

23-
1. &nbsp;
24-
2. &nbsp;
25-
3. &nbsp;
23+
1.
24+
2.
25+
3.
2626

2727
### Python version
2828
<!-- Indicate your python version here -->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ PR fixes the following issue:
2020

2121
# Checklist:
2222

23-
- [ ] My code follows the style guidelines of this project;
24-
- [ ] I have performed a self-review of my code;
25-
- [ ] I have commented my code, particularly in hard-to-understand areas;
26-
- [ ] I have made corresponding changes to the documentation;
27-
- [ ] My changes generate no new warnings;
28-
- [ ] Mypy returns no errors or warnings when run on the root package;
29-
- [ ] Pylint returns a score of 10.00/10.00 when run on the root package;
23+
- [ ] I've done a self-review of my code;
24+
- [ ] I've made corresponding changes to the documentation;
25+
- [ ] I've made sure my changes generate no warnings;
26+
- [ ] mypy returns no errors when run on the root package;
27+
<!-- If you use pre-commit hooks you can always check off the following tasks -->
28+
- [ ] I've run black to format my code;
29+
- [ ] I've run isort to format my code's import statements;
30+
- [ ] flake8 reports no errors when run on the entire code base;

.github/workflows/bitfinex-api-py-ci.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ on:
88
branches:
99
- master
1010

11-
permissions:
12-
contents: read
13-
1411
jobs:
1512
build:
1613
runs-on: ubuntu-latest
@@ -23,7 +20,7 @@ jobs:
2320
python-version: '3.8'
2421
- name: Install bitfinex-api-py's dependencies
2522
run: python -m pip install -r dev-requirements.txt
26-
- name: Lint the project with pylint (and fail if score is lower than 10.00/10.00)
27-
run: python -m pylint bfxapi
28-
- name: Run mypy to check the correctness of type hinting (and fail if any error or warning is found)
23+
- name: Run pre-commit hooks (see .pre-commit-config.yaml)
24+
uses: pre-commit/[email protected]
25+
- name: Run mypy to ensure correct type hinting
2926
run: python -m mypy bfxapi

.gitignore

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
.venv
2+
.DS_Store
13
.vscode
2-
*.pyc
3-
*.log
4+
.python-version
5+
__pycache__
46

57
bitfinex_api_py.egg-info
8+
bitfinex_api_py.dist-info
9+
build/
10+
dist/
11+
pip-wheel-metadata/
12+
.eggs
613

7-
__pycache__
14+
.idea
815

9-
dist
10-
venv
11-
!.gitkeep
12-
MANIFEST
16+
venv/

.isort.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[settings]
2+
profile = black

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
repos:
2+
- repo: https://github.com/PyCQA/isort
3+
rev: 5.13.2
4+
hooks:
5+
- id: isort
6+
- repo: https://github.com/psf/black-pre-commit-mirror
7+
rev: 24.2.0
8+
hooks:
9+
- id: black
10+
- repo: https://github.com/PyCQA/flake8
11+
rev: 7.0.0
12+
hooks:
13+
- id: flake8
14+
15+
additional_dependencies: [
16+
flake8-bugbear
17+
]

.pylintrc

Lines changed: 0 additions & 25 deletions
This file was deleted.

README.md

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ Contributors must uphold the [Contributor Covenant code of conduct](https://gith
312312
1. [Installation and setup](#installation-and-setup)
313313
* [Cloning the repository](#cloning-the-repository)
314314
* [Installing the dependencies](#installing-the-dependencies)
315+
* [Set up the pre-commit hooks (optional)](#set-up-the-pre-commit-hooks-optional)
315316
2. [Before opening a PR](#before-opening-a-pr)
317+
* [Tip](#tip)
316318
3. [License](#license)
317319

318320
## Installation and setup
@@ -333,23 +335,48 @@ git clone --branch v3-beta --single-branch https://github.com/bitfinexcom/bitfin
333335
python3 -m pip install -r dev-requirements.txt
334336
```
335337

336-
Make sure to install `dev-requirements.txt` instead of `requirements.txt`. \
337-
`dev-requirements.txt` will install all dependencies in `requirements.txt` plus any development dependencies. \
338-
This will also install the versions in use of [`pylint`](https://github.com/pylint-dev/pylint) and [`mypy`](https://github.com/python/mypy), which you should both use before opening your PRs.
338+
Make sure to install `dev-requirements.txt` (and not `requirements.txt`!). \
339+
`dev-requirements.txt` will install all dependencies in `requirements.txt` plus any development dependency. \
340+
dev-requirements includes [mypy](https://github.com/python/mypy), [black](https://github.com/psf/black), [isort](https://github.com/PyCQA/isort), [flake8](https://github.com/PyCQA/flake8), and [pre-commit](https://github.com/pre-commit/pre-commit) (more on these tools in later chapters).
339341

340342
All done, your Python 3.8+ environment should now be able to run `bitfinex-api-py`'s source code.
341343

344+
### Set up the pre-commit hooks (optional)
345+
346+
**Do not skip this paragraph if you intend to contribute to the project.**
347+
348+
This repository includes a pre-commit configuration file that defines the following hooks:
349+
1. [isort](https://github.com/PyCQA/isort)
350+
2. [black](https://github.com/psf/black)
351+
3. [flake8](https://github.com/PyCQA/flake8)
352+
353+
To set up pre-commit use:
354+
```console
355+
python3 -m pre-commit install
356+
```
357+
358+
These will ensure that isort, black and flake8 are run on each git commit.
359+
360+
[Visit this page to learn more about git hooks and pre-commit.](https://pre-commit.com/#introduction)
361+
362+
#### Manually triggering the pre-commit hooks
363+
364+
You can also manually trigger the execution of all hooks with:
365+
```console
366+
python3 -m pre-commit run --all-files
367+
```
368+
342369
## Before opening a PR
343370

344-
**We won't accept your PR or we will request changes if the following requirements aren't met.**
371+
**We won't accept your PR or we'll request changes if the following requirements aren't met.**
345372

346373
Wheter you're submitting a bug fix, a new feature or a documentation change, you should first discuss it in an issue.
347374

348-
All PRs must follow this [PULL_REQUEST_TEMPLATE](https://github.com/bitfinexcom/bitfinex-api-py/blob/v3-beta/.github/PULL_REQUEST_TEMPLATE.md) and include an exhaustive description.
375+
You must be able to check off all tasks listed in [PULL_REQUEST_TEMPLATE](https://raw.githubusercontent.com/bitfinexcom/bitfinex-api-py/master/.github/PULL_REQUEST_TEMPLATE.md) before opening a pull request.
376+
377+
### Tip
349378

350-
Before opening a pull request, you should also make sure that:
351-
- [ ] [`pylint`](https://github.com/pylint-dev/pylint) returns a score of 10.00/10.00 when run against your code.
352-
- [ ] [`mypy`](https://github.com/python/mypy) doesn't throw any error code when run on the project (excluding notes).
379+
Setting up the project's pre-commit hooks will help automate this process ([more](#set-up-the-pre-commit-hooks-optional)).
353380

354381
## License
355382

bfxapi/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
from ._client import \
2-
Client, \
3-
REST_HOST, \
4-
WSS_HOST, \
5-
PUB_REST_HOST, \
6-
PUB_WSS_HOST
1+
from ._client import PUB_REST_HOST, PUB_WSS_HOST, REST_HOST, WSS_HOST, Client

0 commit comments

Comments
 (0)