diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 8d218eaa..00000000 --- a/.flake8 +++ /dev/null @@ -1,19 +0,0 @@ -[flake8] -max-line-length=127 -extend-ignore=E203 -ban-relative-imports=true -exclude=.venv,.git,.cache,.tox -ignore= - # *args annotation - ANN002, - # **kwargs annotation - ANN003, - # self param annotation - ANN101, - # cls param annotation - ANN102, - # return type annotation for special methods - ANN204, - # ABC class without any abstractmethods - B024, -per-file-ignores=test_*.py:ANN diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index a6b82b92..896e960a 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -39,7 +39,7 @@ jobs: restore-keys: "precommit-${{ runner.os }}-${{ steps.poetry_setup.outputs-python-version}}-" - name: Run pre-commit hooks - run: SKIP=black,isort,flake8,pyright pre-commit run --all-files + run: SKIP=black,isort,ruff,pyright pre-commit run --all-files - name: Run black formatter check run: black --check --diff . @@ -50,8 +50,8 @@ jobs: - name: Run pyright type checker run: pyright . - - name: Run flake8 linter - run: flake8 . + - name: Run ruff linter + run: ruff check --show-source . # Steps below are here to generate and upload an artifact from # this workflow so that we can have the data about author and some diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c1db2fcf..e49d0eb3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,12 +26,14 @@ repos: - repo: local hooks: - - id: flake8 - name: Flake8 - description: Run flake8 checks on the code - entry: poetry run flake8 + - id: ruff + name: Ruff + description: Run ruff checks on the code + entry: poetry run ruff check --force-exclude language: system types: [python] + require_serial: true + args: [--fix, --exit-non-zero-on-fix] - repo: local hooks: diff --git a/mcstatus/__init__.py b/mcstatus/__init__.py index 0b698784..368cc844 100644 --- a/mcstatus/__init__.py +++ b/mcstatus/__init__.py @@ -1,4 +1,4 @@ -from mcstatus.server import BedrockServer, JavaServer, MCServer # noqa: F401 +from mcstatus.server import BedrockServer, JavaServer, MCServer __all__ = [ "MCServer", diff --git a/mcstatus/utils.py b/mcstatus/utils.py index 5ea24940..cbd42992 100644 --- a/mcstatus/utils.py +++ b/mcstatus/utils.py @@ -124,7 +124,7 @@ def deprecated( def deprecated( - obj: Any = None, # noqa: ANN401 + obj: Any = None, *, replacement: str | None = None, version: str | None = None, diff --git a/poetry.lock b/poetry.lock index cc433504..99985a6a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -693,110 +693,6 @@ files = [ docs = ["furo (>=2023.3.27)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] testing = ["covdefaults (>=2.3)", "coverage (>=7.2.3)", "diff-cover (>=7.5)", "pytest (>=7.3.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)", "pytest-timeout (>=2.1)"] -[[package]] -name = "flake8" -version = "6.0.0" -description = "the modular source code checker: pep8 pyflakes and co" -optional = false -python-versions = ">=3.8.1" -files = [ - {file = "flake8-6.0.0-py2.py3-none-any.whl", hash = "sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7"}, - {file = "flake8-6.0.0.tar.gz", hash = "sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181"}, -] - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.10.0,<2.11.0" -pyflakes = ">=3.0.0,<3.1.0" - -[[package]] -name = "flake8-annotations" -version = "3.0.1" -description = "Flake8 Type Annotation Checks" -optional = false -python-versions = ">=3.8.1" -files = [ - {file = "flake8_annotations-3.0.1-py3-none-any.whl", hash = "sha256:af78e3216ad800d7e144745ece6df706c81b3255290cbf870e54879d495e8ade"}, - {file = "flake8_annotations-3.0.1.tar.gz", hash = "sha256:ff37375e71e3b83f2a5a04d443c41e2c407de557a884f3300a7fa32f3c41cb0a"}, -] - -[package.dependencies] -attrs = ">=21.4" -flake8 = ">=5.0" - -[[package]] -name = "flake8-bugbear" -version = "23.7.10" -description = "A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle." -optional = false -python-versions = ">=3.8.1" -files = [ - {file = "flake8-bugbear-23.7.10.tar.gz", hash = "sha256:0ebdc7d8ec1ca8bd49347694562381f099f4de2f8ec6bda7a7dca65555d9e0d4"}, - {file = "flake8_bugbear-23.7.10-py3-none-any.whl", hash = "sha256:d99d005114020fbef47ed5e4aebafd22f167f9a0fbd0d8bf3c9e90612cb25c34"}, -] - -[package.dependencies] -attrs = ">=19.2.0" -flake8 = ">=6.0.0" - -[package.extras] -dev = ["coverage", "hypothesis", "hypothesmith (>=0.2)", "pre-commit", "pytest", "tox"] - -[[package]] -name = "flake8-future-annotations" -version = "1.1.0" -description = "Verifies python 3.7+ files use from __future__ import annotations" -optional = false -python-versions = ">=3.7" -files = [ - {file = "flake8-future-annotations-1.1.0.tar.gz", hash = "sha256:df416bd2b9e1eda7ea639a5fd2a083dabb942ffe49d197f836df380d0dcf6608"}, - {file = "flake8_future_annotations-1.1.0-py3-none-any.whl", hash = "sha256:555f16f51ae24ab4d0683b1ce8d0f59d36259c3a7e776bd5642f58c78ce7d3ab"}, -] - -[package.dependencies] -flake8 = "*" -setuptools = "*" - -[[package]] -name = "flake8-new-union-types" -version = "0.4.1" -description = "Flake8 plugin to enforce the new Union and Optional annotation syntax defined in PEP 604" -optional = false -python-versions = ">=3.8,<4.0" -files = [ - {file = "flake8-new-union-types-0.4.1.tar.gz", hash = "sha256:0a9dd421099f2525f8be525977ff6632b13b68719a7b0807cf49028d4287b0aa"}, - {file = "flake8_new_union_types-0.4.1-py3-none-any.whl", hash = "sha256:92737a2f598772d5aedd05b5450c5dd200e0f1acd42b3c1f95dbbe3211af2009"}, -] - -[package.dependencies] -attrs = ">=21.4.0" -flake8 = ">=3.0.0" - -[[package]] -name = "flake8-pep585" -version = "0.1.7" -description = "flake8 plugin to enforce new-style type hints (PEP 585)" -optional = false -python-versions = ">=3.7,<4.0" -files = [ - {file = "flake8-pep585-0.1.7.tar.gz", hash = "sha256:363f9413aa12849ee9bfdc437c4e79cc4e0fb3af4abbb61cfed79860e349e0e0"}, - {file = "flake8_pep585-0.1.7-py3-none-any.whl", hash = "sha256:d5c7a5858382d6ca8c56554bd8bed090e12c378b98f6d7c6502abed9a40a658e"}, -] - -[[package]] -name = "flake8-tidy-imports" -version = "4.10.0" -description = "A flake8 plugin that helps you write tidier imports." -optional = false -python-versions = ">=3.8" -files = [ - {file = "flake8_tidy_imports-4.10.0-py3-none-any.whl", hash = "sha256:b0387fb2ea200441bd142309e716fb7b8f4b0937bdf5f8b7c0c118a5f5e2b8ed"}, - {file = "flake8_tidy_imports-4.10.0.tar.gz", hash = "sha256:bd6cf86465402d2b86903009b748d85a628e599e17b76e810c9857e3a2815173"}, -] - -[package.dependencies] -flake8 = ">=3.8.0" - [[package]] name = "furo" version = "2023.5.20" @@ -1151,17 +1047,6 @@ files = [ {file = "MarkupSafe-2.1.2.tar.gz", hash = "sha256:abcabc8c2b26036d62d4c746381a6f7cf60aafcc653198ad678306986b09450d"}, ] -[[package]] -name = "mccabe" -version = "0.7.0" -description = "McCabe checker, plugin for flake8" -optional = false -python-versions = ">=3.6" -files = [ - {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, - {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, -] - [[package]] name = "mdurl" version = "0.1.2" @@ -1314,20 +1199,6 @@ files = [ {file = "pathspec-0.11.1.tar.gz", hash = "sha256:2798de800fa92780e33acca925945e9a19a133b715067cf165b8866c15a31687"}, ] -[[package]] -name = "pep8-naming" -version = "0.13.3" -description = "Check PEP-8 naming conventions, plugin for flake8" -optional = false -python-versions = ">=3.7" -files = [ - {file = "pep8-naming-0.13.3.tar.gz", hash = "sha256:1705f046dfcd851378aac3be1cd1551c7c1e5ff363bacad707d43007877fa971"}, - {file = "pep8_naming-0.13.3-py3-none-any.whl", hash = "sha256:1a86b8c71a03337c97181917e2b472f0f5e4ccb06844a0d6f0a33522549e7a80"}, -] - -[package.dependencies] -flake8 = ">=5.0.0" - [[package]] name = "pexpect" version = "4.8.0" @@ -1523,17 +1394,6 @@ files = [ {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] -[[package]] -name = "pycodestyle" -version = "2.10.0" -description = "Python style guide checker" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pycodestyle-2.10.0-py2.py3-none-any.whl", hash = "sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610"}, - {file = "pycodestyle-2.10.0.tar.gz", hash = "sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053"}, -] - [[package]] name = "pycparser" version = "2.21" @@ -1545,17 +1405,6 @@ files = [ {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, ] -[[package]] -name = "pyflakes" -version = "3.0.1" -description = "passive checker of Python programs" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pyflakes-3.0.1-py2.py3-none-any.whl", hash = "sha256:ec55bf7fe21fff7f1ad2f7da62363d749e2a470500eab1b555334b67aa1ef8cf"}, - {file = "pyflakes-3.0.1.tar.gz", hash = "sha256:ec8b276a6b60bd80defed25add7e439881c19e64850afd9b346283d4165fd0fd"}, -] - [[package]] name = "pygments" version = "2.15.1" @@ -1973,6 +1822,32 @@ typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.9 [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] +[[package]] +name = "ruff" +version = "0.0.278" +description = "An extremely fast Python linter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.0.278-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:1a90ebd8f2a554db1ee8d12b2f3aa575acbd310a02cd1a9295b3511a4874cf98"}, + {file = "ruff-0.0.278-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:38ca1c0c8c1221fe64c0a66784c91501d09a8ed02a4dbfdc117c0ce32a81eefc"}, + {file = "ruff-0.0.278-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2c62a0bde4d20d087cabce2fa8b012d74c2e985da86d00fb3359880469b90e31"}, + {file = "ruff-0.0.278-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:7545bb037823cd63dca19280f75a523a68bd3e78e003de74609320d6822b5a52"}, + {file = "ruff-0.0.278-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8cb380d2d6fdb60656a0b5fa78305535db513fc72ce11f4532cc1641204ef380"}, + {file = "ruff-0.0.278-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d11149c7b186f224f2055e437a030cd83b164a43cc0211314c33ad1553ed9c4c"}, + {file = "ruff-0.0.278-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:666e739fb2685277b879d493848afe6933e3be30d40f41fe0e571ad479d57d77"}, + {file = "ruff-0.0.278-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ec8b0469b54315803aaf1fbf9a37162a3849424cab6182496f972ad56e0ea702"}, + {file = "ruff-0.0.278-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c25b96602695a147d62a572865b753ef56aff1524abab13b9436724df30f9bd7"}, + {file = "ruff-0.0.278-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:a48621f5f372d5019662db5b3dbfc5f1450f927683d75f1153fe0ebf20eb9698"}, + {file = "ruff-0.0.278-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:1078125123a3c68e92463afacedb7e41b15ccafc09e510c6c755a23087afc8de"}, + {file = "ruff-0.0.278-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3ce0d620e257b4cad16e2f0c103b2f43a07981668a3763380542e8a131d11537"}, + {file = "ruff-0.0.278-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1cae4c07d334eb588f171f1363fa89a8911047eb93184276be11a24dbbc996c7"}, + {file = "ruff-0.0.278-py3-none-win32.whl", hash = "sha256:70d39f5599d8449082ab8ce542fa98e16413145eb411dd1dc16575b44565d52d"}, + {file = "ruff-0.0.278-py3-none-win_amd64.whl", hash = "sha256:e131595ab7f4ce61a1650463bd2fe304b49e7d0deb0dfa664b92817c97cdba5f"}, + {file = "ruff-0.0.278-py3-none-win_arm64.whl", hash = "sha256:737a0cfb6c36aaa92d97a46957dfd5e55329299074ad06ed12663b98e0c6fc82"}, + {file = "ruff-0.0.278.tar.gz", hash = "sha256:1a9f1d925204cfba81b18368b7ac943befcfccc3a41e170c91353b674c6b7a66"}, +] + [[package]] name = "secretstorage" version = "3.3.3" @@ -2497,4 +2372,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4" -content-hash = "39042bc4fa5ed70773010cd7ae41813bdc2d5ec050dc0d7075ac05f15a9345d6" +content-hash = "b59bd3a399d90cf063456a3d0f261c45cf8ca27094529b6cea9b1a019ad9b0d0" diff --git a/pyproject.toml b/pyproject.toml index 72d8d2ff..e6d8159b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,17 +46,10 @@ pytest-rerunfailures = "^11.1.2" coverage = "^7.2.6" [tool.poetry.group.lint.dependencies] +ruff = "^0.0.278" black = "^23.3.0" coverage = "^7.2.6" -flake8 = "^6.0.0" -flake8-annotations = "^3.0.1" -flake8-bugbear = "^23.5.9" -flake8-tidy-imports = "^4.8.0" -flake8-pep585 = {version = "^0.1.7", python = ">=3.9"} -flake8-new-union-types = "^0.4.1" -flake8-future-annotations = "^1.1.0" isort = "^5.12.0" -pep8-naming = "^0.13.3" pyright = "^1.1.309" typing-extensions = "^4.6.1" @@ -99,6 +92,44 @@ bump = true enable = true style = "pep440" +[tool.ruff] +target-version = "py38" +line-length = 127 + +select = [ + "F", # Pyflakes + "W", # Pycodestyle (warnigns) + "E", # Pycodestyle (errors) + "N", # pep8-naming + "ANN", # flake8-annotations + "B", # flake8-bugbear + "FA", # flake8-future-annotations + "TID", # flake8-tidy-imports + "UP007", # flake8-new-union-types equivalent rule + "RUF", # ruff's custom rules +] + +ignore = [ + "ANN002", # Missing type annotation for *args + "ANN003", # Missing type annotation for **kwargs + "ANN101", # Missing type annotation for self in method + "ANN102", # Missing type annotation for cls in classmethod + "ANN204", # Missing return type annotation for special method + "B904", # Exception raised within try-except should use raise ... from exc + "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` +] + +[tool.ruff.extend-per-file-ignores] +"test_*.py" = [ + "ANN", # flake8-annotations +] +"docs/examples/code/**" = [ + "FA", # flake8-future-annotations +] + +[tool.ruff.flake8-tidy-imports] +ban-relative-imports = "all" + [tool.black] line-length = 127 diff --git a/tests/motd/test_transformers.py b/tests/motd/test_transformers.py index 8e8dba0f..5d9fce0a 100644 --- a/tests/motd/test_transformers.py +++ b/tests/motd/test_transformers.py @@ -71,8 +71,8 @@ def test_correct_output(self, result: Callable[["str | dict", bool], str], sourc "8" "9" "10" # noqa: W503 + + str((64, 42, 0) if bedrock else (42, 42, 0)) + + "'>10" "11" "12" "13" diff --git a/tests/status_response/__init__.py b/tests/status_response/__init__.py index 15c4605e..ca9a8d63 100644 --- a/tests/status_response/__init__.py +++ b/tests/status_response/__init__.py @@ -16,7 +16,7 @@ class BaseStatusResponseTest(abc.ABC): # if we don't specify item in raw answer, target field will be None # first element is a list with fields to remove, and attribute that # must be None. a dict is a raw answer to pass into `build` method - OPTIONAL_FIELDS: tuple[list[tuple[str, str]], dict[str, Any]] | None = None # noqa: ANN401 + OPTIONAL_FIELDS: tuple[list[tuple[str, str]], dict[str, Any]] | None = None def _validate(self) -> None: """Perform checks to validate the class."""