From dd5cc37aa465df8e33fd872de2528dc53740b2a6 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Fri, 8 Apr 2022 14:36:09 +0100 Subject: [PATCH] Stop maintaining a list of lint targets in `lint.sh` (#12420) --- changelog.d/12420.misc | 1 + docs/code_style.md | 8 +++----- pyproject.toml | 22 ++++------------------ scripts-dev/lint.sh | 8 +------- tox.ini | 2 +- 5 files changed, 10 insertions(+), 31 deletions(-) create mode 100644 changelog.d/12420.misc diff --git a/changelog.d/12420.misc b/changelog.d/12420.misc new file mode 100644 index 000000000000..e1965b071375 --- /dev/null +++ b/changelog.d/12420.misc @@ -0,0 +1 @@ +Stop maintaining a list of lint targets. diff --git a/docs/code_style.md b/docs/code_style.md index e7c9cd1a5e4f..ebda6dcc85f4 100644 --- a/docs/code_style.md +++ b/docs/code_style.md @@ -24,7 +24,7 @@ pip install -e ".[lint,mypy]" functionality) with: ```sh - black . --exclude="\.tox|build|env" + black . ``` - **flake8** @@ -35,7 +35,7 @@ pip install -e ".[lint,mypy]" Check all application and test code with: ```sh - flake8 synapse tests + flake8 . ``` - **isort** @@ -46,11 +46,9 @@ pip install -e ".[lint,mypy]" Auto-fix imports with: ```sh - isort -rc synapse tests + isort . ``` - `-rc` means to recursively search the given directories. - It's worth noting that modern IDEs and text editors can run these tools automatically on save. It may be worth looking into whether this functionality is supported in your editor for a more convenient diff --git a/pyproject.toml b/pyproject.toml index 92ea302b75d4..d44fcf41926d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,24 +36,9 @@ [tool.black] target-version = ['py37', 'py38', 'py39', 'py310'] -exclude = ''' - -( - /( - \.eggs # exclude a few common directories in the - | \.git # root of the project - | \.tox - | \.venv - | \.env - | env - | _build - | _trial_temp.* - | build - | dist - | debian - )/ -) -''' +# black ignores everything in .gitignore by default, see +# https://black.readthedocs.io/en/stable/usage_and_configuration/file_collection_and_discovery.html#gitignore +# Use `extend-exclude` if you want to exclude something in addition to this. [tool.isort] line_length = 88 @@ -65,6 +50,7 @@ known_twisted = ["twisted", "OpenSSL"] multi_line_output = 3 include_trailing_comma = true combine_as_imports = true +skip_gitignore = true [tool.poetry] name = "matrix-synapse" diff --git a/scripts-dev/lint.sh b/scripts-dev/lint.sh index c063fafa973b..4698d2d5be32 100755 --- a/scripts-dev/lint.sh +++ b/scripts-dev/lint.sh @@ -80,13 +80,7 @@ else # then lint everything! if [[ -z ${files+x} ]]; then # Lint all source code files and directories - # Note: this list aims to mirror the one in tox.ini - files=( - "synapse" "docker" "tests" - # annoyingly, black doesn't find these so we have to list them - "scripts-dev" - "contrib" "setup.py" "synmark" "stubs" ".ci" - ) + files=( "." ) fi fi diff --git a/tox.ini b/tox.ini index 69476b5869aa..f1c1bcd82256 100644 --- a/tox.ini +++ b/tox.ini @@ -33,7 +33,7 @@ deps = pip>=10 # directories/files we run the linters on. -# if you update this list, make sure to do the same in scripts-dev/lint.sh +# TODO: this is now out of date; we will remove as part of poetry migration. lint_targets = setup.py synapse