Skip to content

Commit

Permalink
Use ruff only (#579)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
arthurio and renovate[bot] authored May 7, 2024
1 parent 33bd74b commit 4f6c1e4
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 106 deletions.
19 changes: 7 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
repos:
- repo: local
hooks:
- id: isort
name: "isort"
entry: isort
types: [python]
language: system
- id: flynt
name: "flynt"
entry: flynt
args: [--fail-on-change]
types: [python]
language: system
- id: black
name: "black"
entry: black
language: system
- id: ruff-format
name: "ruff format"
entry: ruff format
types: [python]
- id: ruff
name: "ruff"
entry: ruff
language: system
- id: ruff-lint
name: "ruff lint"
entry: ruff check
args:
- --fix
types: [python]
Expand Down
3 changes: 2 additions & 1 deletion examples/fastapi_filter_sqlalchemy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from typing import Any, AsyncIterator, Optional
from collections.abc import AsyncIterator
from typing import Any, Optional

import click
import uvicorn
Expand Down
5 changes: 3 additions & 2 deletions fastapi_filter/base/filter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys
from collections import defaultdict
from collections.abc import Iterable
from copy import deepcopy
from typing import Any, Iterable, Optional, Type, Union, get_args, get_origin
from typing import Any, Optional, Union, get_args, get_origin

from fastapi import Depends
from fastapi.exceptions import RequestValidationError
Expand Down Expand Up @@ -44,7 +45,7 @@ class BaseFilterModel(BaseModel, extra="forbid"):
"""

class Constants: # pragma: no cover
model: Type
model: Any
ordering_field_name: str = "order_by"
search_model_fields: list[str]
search_field_name: str = "search"
Expand Down
1 change: 0 additions & 1 deletion fastapi_filter/contrib/sqlalchemy/filter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from enum import Enum
from typing import Union
from warnings import warn
Expand Down
117 changes: 46 additions & 71 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 28 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,29 @@ module = [
ignore_missing_imports = true

[tool.ruff]
line-length = 120
# Assume Python 3.9 to be compatible with typing.
target-version = "py39"
# Exclude a variety of commonly ignored directories.
exclude = [
".git",
".mypy_cache",
".nox",
".ruff_cache",
]


[tool.ruff.lint]
select = [
"A",
"B",
"C",
"D",
"E",
"F"
"F",
"I",
"SIM",
"UP",
]
ignore = [
"A003", # Argument name should be lowercase.
Expand All @@ -48,25 +64,22 @@ ignore = [
fixable = ["A", "B", "C", "D", "E", "F"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
".git",
".mypy_cache",
".nox",
".ruff_cache",
]

line-length = 120

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.12.
target-version = "py312"

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"
# Like Black, indent with spaces, rather than tabs.
indent-style = "space"
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

[tool.poetry]
name = "fastapi-filter"
version = "2.0.0"
Expand Down Expand Up @@ -100,12 +113,10 @@ Faker = "^22.7.0"
SQLAlchemy-Utils = "^0.41.0"
aiosqlite = "^0.19.0"
bandit = "^1.7.8"
black = "^23.12.1"
flynt = "^1.0.1"
greenlet = "^3.0.3"
httpx = "^0.26.0"
ipython = "^8.11.0,<8.24.0"
isort = "^5.13.2"
mkdocs-material = "^9.5.21"
mypy = "^1.10.0"
mypy-extensions = "^1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mongoengine/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ async def get_users(user_filter: UserFilter = FilterDepends(UserFilter)): # typ

@app.get("/users-by-alias", response_model=list[UserOut]) # type: ignore[valid-type]
async def get_users_by_alias(
user_filter: UserFilter = FilterDepends(UserFilterByAlias, by_alias=True) # type: ignore[valid-type]
user_filter: UserFilter = FilterDepends(UserFilterByAlias, by_alias=True), # type: ignore[valid-type]
):
query = user_filter.filter(User.objects()) # type: ignore[attr-defined]
query = query.select_related()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_sqlalchemy/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import AsyncIterator
from datetime import datetime
from typing import AsyncIterator, Optional
from typing import Optional

import pytest
import pytest_asyncio
Expand Down

0 comments on commit 4f6c1e4

Please sign in to comment.