From 6fecdffa32771a596eaed8e761e74afb898c8a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 23 Jan 2024 22:22:19 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Adopt=20Ruff=20for=20formatting?= =?UTF-8?q?=20and=20linting=20(#111)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 38 +++++--------------------------------- asyncer/_main.py | 2 +- pyproject.toml | 12 ++++-------- scripts/format.sh | 5 ++--- scripts/lint.sh | 5 ++--- tests/conftest.py | 2 +- 6 files changed, 15 insertions(+), 49 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 820b7bf..b21e5ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,41 +13,13 @@ repos: - --unsafe - id: end-of-file-fixer - id: trailing-whitespace -- repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.6 hooks: - - id: pyupgrade + - id: ruff args: - - --py3-plus - - --keep-runtime-typing -- repo: https://github.com/PyCQA/autoflake - rev: v2.2.1 - hooks: - - id: autoflake - args: - - --recursive - - --in-place - - --remove-all-unused-imports - - --remove-unused-variables - - --expand-star-imports - - --exclude - - __init__.py - - --remove-duplicate-keys -- repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - name: isort (python) - - id: isort - name: isort (cython) - types: [cython] - - id: isort - name: isort (pyi) - types: [pyi] -- repo: https://github.com/psf/black - rev: 23.12.1 - hooks: - - id: black + - --fix + - id: ruff-format ci: autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate diff --git a/asyncer/_main.py b/asyncer/_main.py index 5deada2..a5ee497 100644 --- a/asyncer/_main.py +++ b/asyncer/_main.py @@ -309,7 +309,7 @@ def asyncify( function: Callable[T_ParamSpec, T_Retval], *, cancellable: bool = False, - limiter: Optional[anyio.CapacityLimiter] = None + limiter: Optional[anyio.CapacityLimiter] = None, ) -> Callable[T_ParamSpec, Awaitable[T_Retval]]: """ Take a blocking function and create an async one that receives the same diff --git a/pyproject.toml b/pyproject.toml index 9c6333e..1bfb855 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,17 +35,13 @@ typing_extensions = { version = "^4.8.0", python = "<3.10" } [tool.poetry.dev-dependencies] pytest = "^7.0.1" -mypy = "^0.971" -flake8 = "^5.0.4" -black = "^22.10.0" +mypy = "1.4.1" +mkdocs-material = "9.2.7" pillow = "^9.3.0" cairosvg = "^2.5.2" -mkdocs = "^1.2.1" -mkdocs-material = "^8.1.4" mdx-include = "^1.4.1" -coverage = {extras = ["toml"], version = "^6.2"} -autoflake = "^1.4" -isort = "^5.9.3" +coverage = {extras = ["toml"], version = ">=6.2,<8.0"} +ruff = "^0.1.2" [build-system] requires = ["poetry-core"] diff --git a/scripts/format.sh b/scripts/format.sh index 01a141f..5209baf 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -1,6 +1,5 @@ #!/bin/sh -e set -x -autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place asyncer docs_src tests --exclude=__init__.py -black asyncer tests docs_src -isort asyncer tests docs_src +ruff asyncer tests docs_src --fix +ruff format asyncer tests docs_src diff --git a/scripts/lint.sh b/scripts/lint.sh index 4f422c4..8e0d78f 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -4,6 +4,5 @@ set -e set -x mypy asyncer -flake8 asyncer tests docs_src -black asyncer tests docs_src --check -isort asyncer tests docs_src scripts --check-only +ruff asyncer tests docs_src +ruff format asyncer tests docs_src --check diff --git a/tests/conftest.py b/tests/conftest.py index 349af52..ee11a3b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,7 +2,7 @@ def get_testing_print_function( - calls: List[List[Union[str, Dict[str, Any]]]] + calls: List[List[Union[str, Dict[str, Any]]]], ) -> Callable[..., Any]: def new_print(*args): data = []