From d447aed203bd1c51fddc784caf66b4da05d95613 Mon Sep 17 00:00:00 2001 From: Jack Cherng Date: Fri, 17 Nov 2023 03:03:02 +0800 Subject: [PATCH] chore: replace autoflake/flake8/isort with ruff Signed-off-by: Jack Cherng --- .editorconfig | 23 +++++------- .github/workflows/python.yml | 2 +- LICENSE | 2 +- Makefile | 25 ++++++------- plugin/commands/rfc_copy_rich_codes.py | 6 +-- pyproject.toml | 52 +++++++++++++------------- requirements.txt | 4 +- tox.ini | 16 -------- 8 files changed, 52 insertions(+), 78 deletions(-) delete mode 100644 tox.ini diff --git a/.editorconfig b/.editorconfig index 7b96eac..5240538 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,30 +8,27 @@ indent_style = space insert_final_newline = true trim_trailing_whitespace = true -[*.sublime-{settings,commands,keymap,mousemap}] +[Makefile] indent_style = tab -indent_size = 4 -[*.sublime-syntax] -indent_style = space +[*.md] indent_size = 2 +trim_trailing_whitespace = false [*.json] indent_size = 4 -[*.md] -indent_size = 2 -trim_trailing_whitespace = false - [*.py] indent_size = 4 -[*.{sh,csh,tcsh,zsh,bash,fish}] +[sublime-package.json] +indent_size = 2 + +[*.{sublime-commands,sublime-keymap,sublime-menu,sublime-mousemap,sublime-settings}] indent_size = 4 -[*.{yml,yaml,toml,neon}] -indent_style = space +[*.sublime-syntax] indent_size = 2 -[sublime-package.json] -indent_size = 2 +[*.tmPreferences] +indent_size = 4 diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 57b3cad..40454a9 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -46,4 +46,4 @@ jobs: - name: Do linting run: | - make check + make ci-check diff --git a/LICENSE b/LICENSE index d1fa486..cc2ef3a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Jack Cherng +Copyright (c) 2022-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 index b5b4532..2449cbd 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,18 @@ .PHONY: all -all: fix +all: .PHONY: install install: - pip install -U -r requirements.txt + python -m pip install -U pip -r requirements.txt -.PHONY: check -check: - mypy -p plugin - flake8 . - black --check --diff --preview . - isort --check --diff . +.PHONY: ci-check +ci-check: + mypy -p plugin + ruff check --diff --preview . + black --diff --preview --check . -.PHONY: fix -fix: - autoflake --in-place . - black --preview . - isort . +.PHONY: ci-fix +ci-fix: + ruff check --preview --fix . + # ruff format --preview . + black --preview . diff --git a/plugin/commands/rfc_copy_rich_codes.py b/plugin/commands/rfc_copy_rich_codes.py index bd76943..8bec7e2 100644 --- a/plugin/commands/rfc_copy_rich_codes.py +++ b/plugin/commands/rfc_copy_rich_codes.py @@ -70,8 +70,7 @@ def _fix_html(self, html: str) -> str: return f'{style}{html}' def _css(self) -> str: - css = reformat( - """ + css = reformat(""" body { background-color: ${bgcolor}; padding: 1rem; @@ -80,7 +79,6 @@ def _css(self) -> str: table { background-color: ${bgcolor}; } - """ - ) + """) bgcolor = self.view.style().get("background", "inherit") return string.Template(css).substitute(bgcolor=bgcolor) diff --git a/pyproject.toml b/pyproject.toml index 21146fe..75ec449 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,28 +11,6 @@ module = [ ignore_errors = true ignore_missing_imports = true -[tool.isort] -line_length = 120 -profile = 'black' -py_version=38 -skip_glob = [ - ".venv/**", - "br-*/**", - "branch-*/**", - "libs/**", - "plugin/libs/**", - "stubs/**", - "typings/**", - "vendor/**", - "venv/**", -] - -[tool.autoflake] -quiet = true -recursive = true -remove-all-unused-imports = true -exclude = '\.git,\.?venv,\.mypy_cache,br-.*,branch-.*,libs,stubs,tests/files,typings' - [tool.black] line-length = 120 target-version = ['py38'] @@ -50,11 +28,6 @@ exclude = ''' )/ ''' -[tool.ruff] -select = ["E", "F", "W"] -line-length = 120 -target-version = 'py38' - [tool.pyright] include = ['./'] exclude = [ @@ -71,3 +44,28 @@ ignore = [ ] stubPath = 'typings' pythonVersion = '3.8' + +[tool.ruff] +preview = true +select = ["E", "F", "W", "I"] +ignore = ["E203"] +line-length = 120 +target-version = 'py312' +exclude = [ + ".git", + ".mypy_cache", + ".venv", + ".venv-*", + "branch-*", + "libs", + "plugin/libs", + "stubs", + "tests/files", + "typings", + "vendor", + "venv", + "venv-*", +] + +[tool.ruff.per-file-ignores] +"boot.py" = ["E402"] diff --git a/requirements.txt b/requirements.txt index 56e8f8b..350988b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,6 @@ # This is an implicit value, here for clarity --index https://pypi.python.org/simple/ -autoflake black -flake8 -isort 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