From e6eb41b8d38503cf4f1447ac33a34c21d71e9d63 Mon Sep 17 00:00:00 2001 From: Bhosale Date: Wed, 20 Jul 2022 15:49:02 -0500 Subject: [PATCH 1/7] feat: add pre-commit --- .pre-commit-config.yaml | 35 ++++++++++++++ poetry.lock | 105 ++++++++++++++++++++++++++++++++++++++-- pyproject.toml | 1 + 3 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..4d15a85ee --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +default_language_version: + python: python3.8 + +default_stages: [commit, push] + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.5.0 + hooks: + - id: trailing-whitespace + - id: check-json + - id: check-yaml + - id: end-of-file-fixer + exclude: LICENSE + + - repo: local + hooks: + - id: black + name: black + entry: make black + types: [python] + language: system + + - repo: local + hooks: + - id: flake8 + name: flake8 + entry: make flake8 + types: [python] + language: system +# +# - repo: https://github.com/pycqa/flake8 +# rev: 4.0.0 +# hooks: +# - id: flake8 diff --git a/poetry.lock b/poetry.lock index d9372b496..0a2bafeba 100644 --- a/poetry.lock +++ b/poetry.lock @@ -89,6 +89,14 @@ category = "main" optional = false python-versions = ">=3.6" +[[package]] +name = "cfgv" +version = "3.3.1" +description = "Validate configuration and produce human readable error messages." +category = "dev" +optional = false +python-versions = ">=3.6.1" + [[package]] name = "charset-normalizer" version = "2.1.0" @@ -176,6 +184,14 @@ category = "main" optional = true python-versions = ">=2.6, !=3.0.*, !=3.1.*" +[[package]] +name = "distlib" +version = "0.3.5" +description = "Distribution utilities" +category = "dev" +optional = false +python-versions = "*" + [[package]] name = "docutils" version = "0.17.1" @@ -192,6 +208,18 @@ category = "main" optional = true python-versions = "*" +[[package]] +name = "filelock" +version = "3.7.1" +description = "A platform independent file lock." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +docs = ["furo (>=2021.8.17b43)", "sphinx (>=4.1)", "sphinx-autodoc-typehints (>=1.12)"] +testing = ["covdefaults (>=1.2.0)", "coverage (>=4)", "pytest (>=4)", "pytest-cov", "pytest-timeout (>=1.4.2)"] + [[package]] name = "flake8" version = "3.8.3" @@ -228,6 +256,17 @@ ufo = ["fs (>=2.2.0,<3)"] unicode = ["unicodedata2 (>=14.0.0)"] woff = ["zopfli (>=0.1.4)", "brotlicffi (>=0.8.0)", "brotli (>=1.0.1)"] +[[package]] +name = "identify" +version = "2.5.2" +description = "File identification library for Python" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +license = ["ukkonen"] + [[package]] name = "idna" version = "3.3" @@ -238,7 +277,7 @@ python-versions = ">=3.5" [[package]] name = "imageio" -version = "2.19.3" +version = "2.19.5" description = "Library for reading and writing a wide range of image, video, scientific, and volumetric data formats." category = "main" optional = true @@ -476,6 +515,14 @@ linkify = ["linkify-it-py (>=1.0,<2.0)"] rtd = ["ipython", "sphinx-book-theme", "sphinx-panels", "sphinxcontrib-bibtex (>=2.4,<3.0)", "sphinxext-rediraffe (>=0.2.7,<0.3.0)", "sphinxcontrib.mermaid (>=0.7.1,<0.8.0)", "sphinxext-opengraph (>=0.6.3,<0.7.0)"] testing = ["beautifulsoup4", "coverage", "docutils (>=0.17.0,<0.18.0)", "pytest (>=6,<7)", "pytest-cov", "pytest-regressions", "pytest-param-files (>=0.3.4,<0.4.0)"] +[[package]] +name = "nodeenv" +version = "1.7.0" +description = "Node.js virtual environment builder" +category = "dev" +optional = false +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" + [[package]] name = "numba" version = "0.55.2" @@ -569,6 +616,23 @@ importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "pre-commit" +version = "2.20.0" +description = "A framework for managing and maintaining multi-language pre-commit hooks." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +cfgv = ">=2.0.0" +identify = ">=1.0.0" +importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} +nodeenv = ">=0.11.1" +pyyaml = ">=5.1" +toml = "*" +virtualenv = ">=20.0.8" + [[package]] name = "proglog" version = "0.1.10" @@ -727,7 +791,7 @@ name = "pyyaml" version = "6.0" description = "YAML parser and emitter for Python" category = "main" -optional = true +optional = false python-versions = ">=3.6" [[package]] @@ -961,6 +1025,14 @@ sphinxcontrib-serializinghtml = "*" lint = ["flake8"] test = ["pytest", "sqlalchemy", "whoosh", "sphinx"] +[[package]] +name = "toml" +version = "0.10.2" +description = "Python Library for Tom's Obvious, Minimal Language" +category = "dev" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" + [[package]] name = "tomli" version = "1.2.3" @@ -1015,6 +1087,25 @@ brotli = ["brotlicffi (>=0.8.0)", "brotli (>=1.0.9)", "brotlipy (>=0.6.0)"] secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] +[[package]] +name = "virtualenv" +version = "20.15.1" +description = "Virtual Python Environment builder" +category = "dev" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" + +[package.dependencies] +distlib = ">=0.3.1,<1" +filelock = ">=3.2,<4" +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} +platformdirs = ">=2,<3" +six = ">=1.9.0,<2" + +[package.extras] +docs = ["proselint (>=0.10.2)", "sphinx (>=3)", "sphinx-argparse (>=0.2.5)", "sphinx-rtd-theme (>=0.4.3)", "towncrier (>=21.3)"] +testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)", "pytest (>=4)", "pytest-env (>=0.6.2)", "pytest-freezegun (>=0.4.1)", "pytest-mock (>=2)", "pytest-randomly (>=1)", "pytest-timeout (>=1)", "packaging (>=20.0)"] + [[package]] name = "zipp" version = "3.8.1" @@ -1034,7 +1125,7 @@ examples = ["cma", "ffmpeg", "moviepy"] [metadata] lock-version = "1.1" python-versions = ">=3.7,<3.11" -content-hash = "b78119b43c77c71ffd772388e060e3a8973b92da4619f75acdb52f0876af9ab8" +content-hash = "31633e99dda7371ff2385b3b76fdd2de124f09d6d7b7fb41243eb5de5e27a20d" [metadata.files] alabaster = [ @@ -1053,6 +1144,7 @@ beautifulsoup4 = [ ] black = [] certifi = [] +cfgv = [] charset-normalizer = [] click = [] cma = [] @@ -1061,10 +1153,13 @@ colorama = [] coverage = [] cycler = [] decorator = [] +distlib = [] docutils = [] ffmpeg = [] +filelock = [] flake8 = [] fonttools = [] +identify = [] idna = [ {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, {file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, @@ -1168,6 +1263,7 @@ mypy-extensions = [ {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, ] myst-parser = [] +nodeenv = [] numba = [ {file = "numba-0.55.2-cp310-cp310-macosx_10_14_x86_64.whl", hash = "sha256:dd05f7c0ce64b6977596aa4e5a44747c6ef414d7989da1c7672337c54381a5ef"}, {file = "numba-0.55.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e36232eccd172c583b1f021c5c48744c087ae6fc9dc5c5f0dd2cb2286e517bf8"}, @@ -1249,6 +1345,7 @@ pluggy = [ {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, ] +pre-commit = [] proglog = [] py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, @@ -1359,9 +1456,11 @@ sphinxcontrib-serializinghtml = [ {file = "sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl", hash = "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd"}, ] sphinxcontrib-websupport = [] +toml = [] tomli = [] tqdm = [] typed-ast = [] typing-extensions = [] urllib3 = [] +virtualenv = [] zipp = [] diff --git a/pyproject.toml b/pyproject.toml index b72572e05..6f72f8046 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,6 +60,7 @@ moviepy = {version = "^1.0.3", optional = true, extras = ["examples"]} black = "21.12b0" pytest = "^7.1.1" coverage = "^6.3.3" +pre-commit = "^2.19.0" pytest-html = "^3.1.1" pytest-cov = "^3.0.0" flake8 = "3.8.3" From edc7ce3f54162764c9cd31eefe18466b500186cb Mon Sep 17 00:00:00 2001 From: Bhosale Date: Wed, 20 Jul 2022 15:50:02 -0500 Subject: [PATCH 2/7] remove commented flake8 pre-commit --- .pre-commit-config.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4d15a85ee..01a777bb0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,9 +27,4 @@ repos: name: flake8 entry: make flake8 types: [python] - language: system -# -# - repo: https://github.com/pycqa/flake8 -# rev: 4.0.0 -# hooks: -# - id: flake8 + language: system \ No newline at end of file From b9bea630afcc7de7d2fe1a2ab4d1426e94392c9c Mon Sep 17 00:00:00 2001 From: Bhosale Date: Wed, 20 Jul 2022 15:56:27 -0500 Subject: [PATCH 3/7] feat: add pre-commit install command to makefile --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 90453f9d3..6d7249880 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,10 @@ install: poetry lock -n && poetry export --without-hashes > requirements.txt poetry install -n +.PHONY: pre-commit-install +pre-commit-install: + poetry run pre-commit install + #* Formatters .PHONY: black black: @@ -79,4 +83,4 @@ cleanup: pycache-remove dsstore-remove ipynbcheckpoints-remove pytestcache-remov all: format-codestyle cleanup test -ci: check-codestyle \ No newline at end of file +ci: check-codestyle From 34463d2cd825dbf0e9d00f4ae8ba745715a201f6 Mon Sep 17 00:00:00 2001 From: Bhosale Date: Wed, 20 Jul 2022 16:01:11 -0500 Subject: [PATCH 4/7] refac: merge black and flake8 in pre-commit --- .pre-commit-config.yaml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 01a777bb0..adb771dd8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,16 +15,8 @@ repos: - repo: local hooks: - - id: black - name: black - entry: make black + - id: formatting + name: formatting + entry: make formatting types: [python] language: system - - - repo: local - hooks: - - id: flake8 - name: flake8 - entry: make flake8 - types: [python] - language: system \ No newline at end of file From cc692110077c72626bcf1cd5ddb3151c29117346 Mon Sep 17 00:00:00 2001 From: Bhosale Date: Wed, 20 Jul 2022 16:04:59 -0500 Subject: [PATCH 5/7] add pre-commit install to make install --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 6d7249880..fb030e449 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ poetry-remove: install: poetry lock -n && poetry export --without-hashes > requirements.txt poetry install -n + make pre-commit-install .PHONY: pre-commit-install pre-commit-install: From dce42e931dc3948e00735552a76aea9a847cf916 Mon Sep 17 00:00:00 2001 From: Yashraj Bhosale Date: Wed, 20 Jul 2022 23:22:58 +0000 Subject: [PATCH 6/7] Update .pre-commit-config.yaml Co-authored-by: Arman Tekinalp <53585636+armantekinalp@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index adb771dd8..43ebcfe21 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.8 + python: python3 default_stages: [commit, push] From e5cc9bdf6f483eff766da5991c9470dd1118c99f Mon Sep 17 00:00:00 2001 From: Bhosale Date: Wed, 20 Jul 2022 21:18:20 -0500 Subject: [PATCH 7/7] refac: separate pre-commit install from poetry install --- CONTRIBUTING.md | 15 ++++++++------- Makefile | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1954ee77d..5b62dfe14 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,7 +35,7 @@ The following is a set of guidelines for contributing to PyElastica. These are m ### Setup development environment -Below are steps of how to setup development environment. We mainly use `poetry` to manage +Below are steps of how to setup development environment. We mainly use `poetry` to manage the project, although most of the important commands will be provided in `Makefile`. 1. Clone! @@ -57,10 +57,11 @@ conda install python==3.8 ```bash make poetry-download make install +make pre-commit-install ``` -If you are planning to contribute on documentation, extra dependencies can be installed -using `poetry install -E docs`. The detail instruction is included +If you are planning to contribute on documentation, extra dependencies can be installed +using `poetry install -E docs`. The detail instruction is included [here](https://github.com/GazzolaLab/PyElastica/blob/master/docs/README.md). 4. Now your working environment is set! @@ -107,7 +108,7 @@ This section guides you through submitting an enhancement suggestion, including * If relevant, what **version and OS** was used. * Include a description of the **current behavior** and **explain expected behavior**. * Explain **why this enhancement would be useful**. - + ### Your first code contribution If you are unsure regarding how to start contributing to PyElastica, you can look through `good first issue` and `help wanted` labels. @@ -119,7 +120,7 @@ Also, you might find `TODO` or `FIXME` marks in various places in the code with Once you find the issue that you are interested in, please leave a comment that you would like to resolve the issue. If you leave some questions in the comment, we will provide more detailed descriptions. -You are also welcomed to help us pushing this project further. +You are also welcomed to help us pushing this project further. Please don't hesitate improving [documentation](https://github.com/GazzolaLab/PyElastica/tree/master/docs) or code-coverage. ### Side projects @@ -133,7 +134,7 @@ If you are interested in hearing more, please contact one of our the maintainer. Please follow these steps to have your contribution considered by the maintainers: 1. Follow the [styleguides](#styleguides) -2. Before you submit your pull request run [pytests](https://pypi.org/project/pytest/) and make sure that all tests pass. +2. Before you submit your pull request run [pytests](https://pypi.org/project/pytest/) and make sure that all tests pass. In order to run pytest, run the following line from the top directory: @@ -165,7 +166,7 @@ In order to format the code: `make formatting` -> **Note:** Format/refactoring patches that are not anything substantial to the context or functionality will likely be rejected. +> **Note:** Format/refactoring patches that are not anything substantial to the context or functionality will likely be rejected. ### Documentation styleguide diff --git a/Makefile b/Makefile index fb030e449..6d7249880 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,6 @@ poetry-remove: install: poetry lock -n && poetry export --without-hashes > requirements.txt poetry install -n - make pre-commit-install .PHONY: pre-commit-install pre-commit-install: