Skip to content

Commit

Permalink
Remove flake8 and black references
Browse files Browse the repository at this point in the history
List all ignored rules in ruff to make it easier to fix them later.
  • Loading branch information
iurisilvio committed Jul 8, 2024
1 parent 889ee39 commit 5752f8c
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"extensions": [
"ms-python.python",
"ms-python.debugpy",
"ms-python.black-formatter"
"charliermarsh.ruff"
],
"settings": {
"extensions.verifySignature": false
}
}
}
}
}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install ".[dev]"
- name: 🧹 Lint with flake8
- name: 🧹 Lint
run: |
make check_code_quality
- name: Check types with mypy
Expand Down
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ repos:
args: ["--autofix", "--no-sort-keys", "--indent=4"]
- id: trailing-whitespace

- repo: https://github.com/PyCQA/flake8
rev: 7.1.0
hooks:
- id: flake8
name: Flake8 Checks
entry: flake8
additional_dependencies: [Flake8-pyproject]

- repo: https://github.com/PyCQA/bandit
rev: 1.7.9
hooks:
Expand Down
5 changes: 2 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
],
"editor.formatOnSave": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.defaultFormatter": "charliermarsh.ruff"
},
"python.formatting.provider": "none",
"python.testing.pytestEnabled": false,
"editor.inlineSuggest.showToolbar": "onHover"
}
}
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pip install -e ".[dev]"

### Devcontainer

This project comes with a [convenient devcontainer](https://www.loom.com/share/a183c4a351ed4700a79476fedf08ab9b) that makes it easier to run tests and has black configured to run on save.
This project comes with a [convenient devcontainer](https://www.loom.com/share/a183c4a351ed4700a79476fedf08ab9b) that makes it easier to run tests and has lint configured to run on save.

On rare occasions a full rebuild is needed, you can do it in VSCode by pressing `Ctrl+Shift+P` and running `Dev Containers: Rebuild Container`.

Expand Down Expand Up @@ -57,10 +57,10 @@ def example_function(param1: int, param2: str) -> bool:
We provide a `Makefile` to format and ensure code quality. **Be sure to run them before creating a PR**.

```bash
# format code with `black` and `isort`
# format code with `ruff`
make style

# check code with flake8
# check code with `ruff`
make check_code_quality
```

Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ style:
check_code_quality:
ruff format $(check_dirs) --check
ruff check $(check_dirs)
# stop the build if there are Python syntax errors or undefined names
flake8 $(check_dirs) --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. E203 for black, E501 for docstring, W503 for line breaks before logical operators
flake8 $(check_dirs) --count --max-line-length=120 --exit-zero --ignore=D --extend-ignore=E203,E501,W503 --statistics

publish:
python setup.py sdist bdist_wheel
Expand Down
51 changes: 31 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,49 @@
requires = ["setuptools>=57", "wheel"]
build-backend = "setuptools.build_meta"

[tool.flake8]
exclude = ".venv"
max-complexity = 10
max-line-length = 120
extend-ignore = """
W503,
E203,
E701,
C901,
"""
per-file-ignores = """
__init__.py: F401
"""

[tool.bandit]
target = ["test", "roboflow"]
tests = ["B201", "B301"]

[tool.ruff]
target-version = "py38"
# Same as Black.
line-length = 120

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
"ALL",
]
ignore = [
"E501", # line too long, handled by black
"A",
"ANN",
"ARG",
"B",
"BLE",
"C",
"COM",
"D",
"DTZ",
"EM",
"ERA",
"FBT",
"FIX",
"FLY",
"ISC",
"N",
"PERF",
"PIE",
"PLR",
"PLW",
"PT",
"PTH",
"RET",
"RUF",
"S",
"SIM",
"SLF",
"T",
"TD",
"TRY",
]

# Exclude a variety of commonly ignored directories.
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
extras_require={
"desktop": ["opencv-python==4.8.0.74"],
"dev": [
"flake8",
"mypy",
"responses",
"ruff",
Expand Down

0 comments on commit 5752f8c

Please sign in to comment.