Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
docs: Document Black and isort.
Anders Kaseorga0d0b89adbef
diff --git a/README.md b/README.mdindex 1f3703a4031..0e8b43401ea 100644--- a/README.md+++ b/README.md@@ -11,6 +11,7 @@ largest and fastest growing open source group chat project.[](https://circleci.com/gh/zulip/zulip/tree/master)[](https://codecov.io/gh/zulip/zulip/branch/master)[][mypy-coverage]+[](https://github.com/psf/black)[](https://github.com/prettier/prettier)[](https://github.com/zulip/zulip/releases/latest)[](https://zulip.readthedocs.io/en/latest/)diff --git a/docs/contributing/code-style.md b/docs/contributing/code-style.mdindex e8de6fe3a95..fb2a655f7b8 100644--- a/docs/contributing/code-style.md+++ b/docs/contributing/code-style.md@@ -44,8 +44,12 @@ The Vagrant setup process runs this for you.`lint` runs many lint checks in parallel, including-- JavaScript ([ESLint](https://eslint.org/))-- Python ([Pyflakes](https://pypi.python.org/pypi/pyflakes))+- JavaScript ([ESLint](https://eslint.org/),+ [Prettier](https://prettier.io/))+- Python ([mypy](http://mypy-lang.org/),+ [Pyflakes](https://pypi.python.org/pypi/pyflakes),+ [Black](https://github.com/psf/black),+ [isort](https://pycqa.github.io/isort/))- templates- Puppet configuration- custom checks (e.g. trailing whitespace and spaces-not-tabs)@@ -304,6 +308,16 @@ type changes in the future.### Python+- Our Python code is formatted with+ [Black](https://github.com/psf/black) and+ [isort](https://pycqa.github.io/isort/). The [linter+ tool](../testing/linters.md) enforces this by running Black and+ isort in check mode, or in write mode with `tools/lint+ --only=black,isort --fix`. You may find it helpful to [integrate+ Black](https://black.readthedocs.io/en/stable/editor_integration.html)+ and+ [isort](https://pycqa.github.io/isort/#installing-isorts-for-your-preferred-text-editor)+ with your editor.- Don't put a shebang line on a Python file unless it's meaningful torun it as a script. (Some libraries can also be run as scripts, e.g.to run a test suite.)diff --git a/docs/testing/linters.md b/docs/testing/linters.mdindex 84646bf8713..b596a73e34a 100644--- a/docs/testing/linters.md+++ b/docs/testing/linters.md@@ -17,7 +17,9 @@ prevent common coding errors.We borrow some open source tools for much of our linting, and the linksbelow will direct you to the official documentation for these projects.+- [Black](https://github.com/psf/black)- [ESLint](https://eslint.org)+- [isort](https://pycqa.github.io/isort/)- [mypy](http://mypy-lang.org/)- [Prettier](https://prettier.io/)- [Puppet](https://puppet.com/) (puppet provides its own mechanism for@@ -100,6 +102,7 @@ Most of our lint checks get performed by `./tools/lint`. These include thefollowing checks:- Check Python code with pyflakes.+- Check Python formatting with Black and isort.- Check JavaScript and TypeScript code with ESLint.- Check CSS, JavaScript, TypeScript, and YAML formatting with Prettier.- Check Python code for custom Zulip rules.@@ -166,6 +169,11 @@ sense (e.g. a link in a comment to an extremely long URL).#### Python code+Our Python code is formatted using Black (using the options in the+`[tool.black]` section of `pyproject.toml`) and isort (using the+options in `.isort.cfg`). The `lint` script enforces this by running+Black and isort in check mode, or in write mode with `--fix`.+The bulk of our Python linting gets outsourced to the "pyflakes" tool. Wecall "pyflakes" in a fairly vanilla fashion, and then we post-process itsoutput to exclude certain specific errors that Zulip is comfortable