diff --git a/.mailmap b/.mailmap index 8e04d63ab6c..5cbdc13bc97 100644 --- a/.mailmap +++ b/.mailmap @@ -47,6 +47,8 @@ Dhruv Sondhi Dhruv Dhruv Sondhi Dhruv Sondhi <66117751+DhruvSondhi@users.noreply.github.com> Dhruv Sondhi DhruvSondhi +Dmitry Volodin + Epson Heringer Epson Heringer Heringer-Epson diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000000..53d7ed495bb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +repos: +- repo: https://github.com/psf/black + rev: 21.5b2 + hooks: + - id: black + exclude: | + (?x)^( + (tardis/model + | tardis/montecarlo).* + | setup.py + | docs/conf.py + | tardis/_astropy_init.py + )$ diff --git a/README.rst b/README.rst index 9dcf0888ba6..5a7ff1fc190 100644 --- a/README.rst +++ b/README.rst @@ -27,6 +27,10 @@ stars (*supernovae*). .. image:: https://badges.gitter.im/Join%20Chat.svg :target: https://gitter.im/tardis-sn/tardis +.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white + :target: https://github.com/pre-commit/pre-commit + :alt: pre-commit + .. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/psf/black diff --git a/docs/development/code_quality.rst b/docs/development/code_quality.rst index da100225719..3a18a6096ec 100644 --- a/docs/development/code_quality.rst +++ b/docs/development/code_quality.rst @@ -24,6 +24,8 @@ Black A better method is to run Black automatically - first `integrate it within the code editor `_ you use and then enable the "format on save" or "format on type" option in your editor settings. +Alternatively, Black will run automatically before each commit if you've installed pre-commit hooks (as mentioned in :ref:`Git worklfow `). + .. warning :: If your code doesn't follow the Black code style, then the Black-check action on your PR will fail. Naming Conventions diff --git a/docs/development/git_workflow.rst b/docs/development/git_workflow.rst index 7ff68e0c33b..8bb6237ca4a 100644 --- a/docs/development/git_workflow.rst +++ b/docs/development/git_workflow.rst @@ -151,6 +151,16 @@ TARDIS repository clone. repository will always be immediately available next time you start a Python interpreter and ``import tardis``. +.. _pre-commit-install: + +#. Install pre-commit hooks:: + + $ pre-commit install --install-hooks + + This will install all pre-commit hooks used in TARDIS, which will then run + before each commit. You can check the full list of hooks in the + `.pre-commit-config.yaml`. + Workflow summary ---------------- @@ -328,6 +338,9 @@ In more detail signals that you're going to type a message on the command line. The `git commit`_ manual page might also be useful. + All pre-commit hooks will run automatically if you've correctly installed + them before. + #. Push the changes up to your forked repo on GitHub with ``git push`` (see `git push`_). diff --git a/pyproject.toml b/pyproject.toml index 64ef7f2190f..bfe3a3bbcfc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,26 +7,14 @@ build-backend = 'setuptools.build_meta' [tool.black] line-length = 80 target-version = ['py36'] -exclude = ''' +extend-exclude = ''' ( /( - \.eggs # all directories in the root of the project - | \.git - | \.hg - | \.mypy_cache - | \.nox - | \.tox - | \.venv - | \.svn - | _build - | buck-out - | build - | dist - | model # temporary - to remove later + model # temporary - to remove later | montecarlo # temporary )/ | setup.py | docs/conf.py | _astropy_init.py ) -''' \ No newline at end of file +''' diff --git a/tardis_env3.yml b/tardis_env3.yml index 5a3dc6bf328..8b32f6d0e7f 100644 --- a/tardis_env3.yml +++ b/tardis_env3.yml @@ -67,6 +67,7 @@ dependencies: - coverage # Code quality + - pre-commit - black # Other