Switch from flake8 to ruff (#1696)

pull/1700/head
Gulshan Singh 3 years ago committed by GitHub
parent 2f03a901e7
commit 487afacc7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -60,7 +60,7 @@ Note that in the test, we can access `pwndbg` library code like `pwndbg.gdblib.r
## Linting
The `lint.sh` script runs `isort`, `black`, `flake8`, `shfmt`, and `vermin`. `isort` and `black` are able to automatically fix any issues they detect, and you can enable this by running `./lint.sh -f`. You can find the configuration files for these tools in `setup.cfg` and `pyproject.toml`.
The `lint.sh` script runs `isort`, `black`, `ruff`, `shfmt`, and `vermin`. `isort` and `black` are able to automatically fix any issues they detect, and you can enable this by running `./lint.sh -f`. You can find the configuration files for these tools in `setup.cfg` and `pyproject.toml`.
When submitting a PR, the CI job defined in `.github/workflows/lint.yml` will verify that running `./lint.sh` succeeds, otherwise the job will fail and we won't be able to merge your PR.

@ -2,21 +2,18 @@ black==22.8.0; python_version < '3.7'
black==22.12.0; python_version >= '3.7'
coverage==6.2; python_version < '3.7'
coverage==7.0.1; python_version >= '3.7'
flake8==5.0.4; python_version < '3.9'
flake8==6.0.0; python_version >= '3.9'
flake8-builtins==2.0.0; python_version < '3.7'
flake8-builtins==2.1.0; python_version >= '3.7'
mypy==0.991; python_version >= '3.7'
testresources==2.0.1
isort==5.10.1; python_version < '3.7'
isort==5.11.4; python_version >= '3.7'
pytest==7.0.1; python_version < '3.7'
pytest==7.2.0; python_version >= '3.7'
rich==12.6.0; python_version < '3.7'
rich==13.3.1; python_version >= '3.7'
ruff==0.0.264; python_version >= '3.7'
testresources==2.0.1
types-gdb==12.1.4.1
types-psutil==5.9.5
types-Pygments==2.12.1
types-tabulate==0.9.0.0
types-requests==2.28.11.17
vermin==1.5.1
rich==12.6.0; python_version < '3.7'
rich==13.3.1; python_version >= '3.7'

@ -29,7 +29,7 @@ done
set -o xtrace
LINT_FILES="pwndbg tests *.py"
LINT_TOOLS="isort black flake8 vermin"
LINT_TOOLS="isort black ruff vermin"
if ! type ${LINT_TOOLS} &> /dev/null; then
PIP_CMD="pip install -Ur dev-requirements.txt"
@ -58,7 +58,7 @@ fi
# Checking minimum python version
vermin -vvv --no-tips -q -t=3.6 --violations ./pwndbg/
flake8 --show-source ${LINT_FILES}
ruff check --show-source ${LINT_FILES}
if [ -x "$(command -v mypy)" ]; then
mypy pwndbg

@ -2,6 +2,47 @@
line-length = 100
extend-exclude = "gdb-pt-dump"
[tool.ruff]
exclude = ["gdb-pt-dump"]
ignore = [
"A003",
"E402",
"E501",
"E731",
"F405",
"F811",
"F821",
"F841",
"W505",
]
line-length = 100
select = [
"A",
"E",
"F",
"W",
]
[tool.ruff.flake8-builtins]
builtins-ignorelist = [
"all",
"bin",
"breakpoint",
"copyright",
"dir",
"exit",
"format",
"hex",
"map",
"max",
"min",
"next",
"type",
]
[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]
[tool.mypy]
strict_optional = false
check_untyped_defs = true

@ -1,50 +0,0 @@
[flake8]
ignore =
# whitespace before :
E203,
# too many leading '#' for block comment
E266,
# block comment should start with #
E265,
# module level import not at top of file
E402,
# line too long (82 > 79 characters)
E501,
# do not assign a lambda expression, use a def
E731
# line break before binary operator (default)
W503,
# doc line too long (82 > 79 characters) (default)
W505,
# name may be undefined, or defined from star imports: module
F405,
# redefinition of unused name from line n
F811,
# undefined name name
F821,
# local variable name is assigned to but never used
F841,
# class attribute is shadowing a python builtin
A003
per-file-ignores =
# Unused imports in __init__.py are fine
__init__.py:F401
max-line-length = 100
exclude = gdb-pt-dump
# flake8-builtins should allow these builtins to be shadowed
builtins-ignorelist =
all,
breakpoint,
copyright,
dir,
exit,
format,
hex,
map,
max,
min,
next,
type
Loading…
Cancel
Save