From 96d1a6520078a6c7fba067f854ca0b91b30679ca Mon Sep 17 00:00:00 2001 From: Jack Cherng Date: Sun, 19 Nov 2023 04:47:58 +0800 Subject: [PATCH] chore: replace autoflake/flake8/isort with ruff Signed-off-by: Jack Cherng --- .gitignore | 6 +++- LICENSE | 2 +- Makefile | 18 ++++++++++++ boot.py | 2 +- mypy.ini | 10 ------- pyproject.toml | 71 ++++++++++++++++++++++++++++++++++++------------ requirements.txt | 2 +- tox.ini | 16 ----------- 8 files changed, 80 insertions(+), 47 deletions(-) create mode 100644 Makefile delete mode 100644 mypy.ini delete mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 0c92ed6..09d38a7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,9 @@ Thumbs.db # Python *.py[cod] -.mypy_cache/ +*_cache/ +.venv-*/ +.venv/ __pycache__/ +venv-*/ +venv/ diff --git a/LICENSE b/LICENSE index 0bc614d..8a44a9c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021-2022 Jack Cherng +Copyright (c) 2021-2023 Jack Cherng Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2449cbd --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +.PHONY: all +all: + +.PHONY: install +install: + python -m pip install -U pip -r requirements.txt + +.PHONY: ci-check +ci-check: + mypy -p plugin + ruff check --diff --preview . + black --diff --preview --check . + +.PHONY: ci-fix +ci-fix: + ruff check --preview --fix . + # ruff format --preview . + black --preview . diff --git a/boot.py b/boot.py index 1b1d110..c5ad39d 100644 --- a/boot.py +++ b/boot.py @@ -1,7 +1,7 @@ def reload_plugin() -> None: import sys - # Remove all previously loaded plugin modules. + # remove all previously loaded plugin modules prefix = f"{__package__}." for module_name in tuple(filter(lambda m: m.startswith(prefix) and m != __name__, sys.modules)): del sys.modules[module_name] diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index fd862ff..0000000 --- a/mypy.ini +++ /dev/null @@ -1,10 +0,0 @@ -[mypy] -;ignore_missing_imports = False -check_untyped_defs = True -strict_optional = True -mypy_path = typings:stubs:stubs/st-stubs - -; for 3rd-party libs -[mypy-plugin.libs.*] -ignore_errors = True -ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index c13dddf..1179fd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,30 +1,67 @@ +[tool.mypy] +# ignore_missing_imports = False +check_untyped_defs = true +strict_optional = true +mypy_path = 'typings:stubs' + +[[tool.mypy.overrides]] +module = ["plugin.libs.*"] +ignore_errors = true +ignore_missing_imports = true + [tool.black] +preview = true line-length = 120 target-version = ['py38'] - -# regex exclude = ''' /( - \.git | - plugin/libs | - stubs | - typings + \.git + | \.?venv + | \.mypy_cache + | br-.* + | branch-.* + | libs + | stubs + | tests/files + | typings )/ ''' [tool.pyright] -include = ["./"] +include = ['./'] exclude = [ - "**/__pycache__/", - "**/node_modules/", + '**/__pycache__/', + '**/node_modules/', # git-related - "**/.git/", - "**/br-*/", - "**/branch-*/", + '**/.git/', + '**/br-*/', + '**/branch-*/', ] -ignore = [ - "**/.venv", - "plugin/libs/", +ignore = ['**/.venv', '**/libs'] +stubPath = 'typings' +pythonVersion = '3.8' + +[tool.ruff] +preview = true +select = ["E", "F", "W", "I", "UP"] +ignore = ["E203"] +line-length = 120 +target-version = 'py38' +exclude = [ + ".git", + ".mypy_cache", + ".venv", + ".venv-*", + "branch-*", + "libs", + "plugin/libs", + "stubs", + "tests/files", + "typings", + "vendor", + "venv", + "venv-*", ] -stubPath = "typings" -pythonVersion = "3.8" + +[tool.ruff.per-file-ignores] +"boot.py" = ["E402"] diff --git a/requirements.txt b/requirements.txt index d735f36..350988b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,5 @@ --index https://pypi.python.org/simple/ black -flake8 mypy +ruff diff --git a/tox.ini b/tox.ini deleted file mode 100644 index a172055..0000000 --- a/tox.ini +++ /dev/null @@ -1,16 +0,0 @@ -[flake8] -max-line-length = 120 -extend-ignore = E203 -exclude = - .git, - .mypy_cache, - .venv, - branch-*, - libs, - plugin/libs, - stubs, - tests/files, - typings, - venv, -per-file-ignores = - boot.py: E402