Skip to content

Commit

Permalink
🔧 Adopt Ruff for formatting and linting (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangolo authored Jan 23, 2024
1 parent 2d0feab commit 6fecdff
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 49 deletions.
38 changes: 5 additions & 33 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion asyncer/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
5 changes: 2 additions & 3 deletions scripts/format.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 2 additions & 3 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit 6fecdff

Please sign in to comment.