Skip to content

Commit

Permalink
Merge pull request #53 from newgene/add-pre-commit-hooks
Browse files Browse the repository at this point in the history
Setup pre-commit hooks
  • Loading branch information
newgene authored Aug 2, 2022
2 parents 4d45c3f + 0bfc9a2 commit 2e2a7c6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 27 deletions.
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 11cdc8d8201091a19ff1c28f7b7c75c3691954ad
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: debug-statements
- id: no-commit-to-branch
- id: check-merge-conflict

- repo: https://github.com/4Catalyzer/fourmat
rev: master # or specify a version
hooks:
- id: fourmat
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ Some Python code formatters can be useful, but use them with caution. Double che
* [black](https://github.com/python/black)
* [yapf](https://github.com/google/yapf/)

### Setup pre-commit

After all above recommendations, we already setup [pre-commit](https://github.com/pre-commit/pre-commit) framework.
You just need to install it on your local git repo:

pre-commit install

### Some useful references

* [**requests** code style](http://python-requests.org//en/latest/dev/contributing/#kenneth-reitz-s-code-style)
Expand Down
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tool.black]
line-length = 99
target-version = ['py36', 'py37', 'py38', 'py39', 'py310']
skip-string-normalization = 1

[tool.isort]
profile = "black"
combine_as_imports = true
line_length = 159
src_paths = ["."]
50 changes: 23 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import glob
import os
from subprocess import CalledProcessError, check_output

import glob
from subprocess import check_output
from subprocess import CalledProcessError
from setuptools import setup, find_packages
from setuptools import find_packages, setup

setup_path = os.path.dirname(__file__)

Expand Down Expand Up @@ -47,53 +46,50 @@ def read(fname):
'singledispatchmethod; python_version < "3.8.0"',
'dataclasses; python_version < "3.7.0"',
'PyYAML>=5.1',
'orjson>=3.6.1', # this is a faster json lib support inf/nan and datetime
# v3.6.1 is the last version supports Python 3.6
'orjson>=3.6.1', # this is a faster json lib support inf/nan and datetime
# v3.6.1 is the last version supports Python 3.6
]

# extra requirements for biothings.web
web_extra_requires = [
'msgpack>=0.6.1', # support format=msgpack
'msgpack>=0.6.1', # support format=msgpack
'sentry-sdk>=1.5.3', # new sentry package
]

# extra requirements to run biothings.hub
hub_requires = [
'beautifulsoup4', # used in dumper.GoogleDriveDumper
'aiocron==1.8', # setup scheduled jobs
'aiohttp==3.8.1', # elasticsearch requires aiohttp>=3,<4
'beautifulsoup4', # used in dumper.GoogleDriveDumper
'aiocron==1.8', # setup scheduled jobs
'aiohttp==3.8.1', # elasticsearch requires aiohttp>=3,<4
'asyncssh==2.11.0', # needs libffi-dev installed (apt-get)
'pymongo>=4.1.0,<5.0', # support MongoDB 5.0 since v3.12.0
'psutil',
'jsonpointer', # for utils.jsonpatch
'IPython', # for interactive hub console
'jsonpointer', # for utils.jsonpatch
'IPython', # for interactive hub console
'multiprocessing_on_dill', # can replace pickler in concurrent.futures
'dill', # a pickle alternative with extra object type support
'pyinotify; sys_platform == "linux"', # Linux-only; used in utils.hub.PyInotifyHubReloader
'prettytable', # diff report renderer
'sockjs-tornado==1.0.7', # websocket server for HubServer
'dill', # a pickle alternative with extra object type support
'pyinotify; sys_platform == "linux"', # Linux-only; used in utils.hub.PyInotifyHubReloader
'prettytable', # diff report renderer
'sockjs-tornado==1.0.7', # websocket server for HubServer
'jsonschema>=2.6.0',
'pip', # auto-install requirements from plugins
'pip', # auto-install requirements from plugins
# 'pandas==1.0.1', # json with inf/nan and more to come (replaced by orjson below now)
# 'orjson>=3.5.2', # this is a faster json lib support inf/nan and datetime
'yapf', # code reformatter, better results than autopep8
'requests-aws4auth', # aws s3 auth requests for autohub
'networkx>=2.1,<2.6', # datatransform
'biothings_client>=0.2.6' # datatransform (api client)
'yapf', # code reformatter, better results than autopep8
'requests-aws4auth', # aws s3 auth requests for autohub
'networkx>=2.1,<2.6', # datatransform
'biothings_client>=0.2.6', # datatransform (api client)
]

# extra requirements to develop biothings
dev_requires = [
'pytest',
'pytest-mock',
'pre-commit==2.17.0',
]

# extra requirements for building docs
docs_requires = [
'sphinx>=2.4.3',
'sphinx_rtd_theme>=1.0.0',
'sphinx_reredirects>=0.0.1'
]
docs_requires = ['sphinx>=2.4.3', 'sphinx_rtd_theme>=1.0.0', 'sphinx_reredirects>=0.0.1']

setup(
name="biothings",
Expand Down Expand Up @@ -133,6 +129,6 @@ def read(fname):
extras_require={
'web_extra': web_extra_requires,
'hub': hub_requires,
'dev': web_extra_requires + hub_requires + dev_requires + docs_requires
'dev': web_extra_requires + hub_requires + dev_requires + docs_requires,
},
)

0 comments on commit 2e2a7c6

Please sign in to comment.