From 230c24a4e0e7cc6a84809ad71d2f46aa9b2432e5 Mon Sep 17 00:00:00 2001 From: Martijn Pieters Date: Tue, 16 May 2023 13:42:12 +0100 Subject: [PATCH] Give tests and examples separate ruff configs (#158) This allows more fine-grained lint rule adjustments, and allows the examples to treat fastapi_cache as a 'third party' module, just like users of the library would use it. --- examples/in_memory/main.py | 7 +++---- examples/pyproject.toml | 3 +++ examples/redis/main.py | 10 +++++----- pyproject.toml | 3 --- tests/pyproject.toml | 7 +++++++ 5 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 examples/pyproject.toml create mode 100644 tests/pyproject.toml diff --git a/examples/in_memory/main.py b/examples/in_memory/main.py index 8174c8a..ac2c5dc 100644 --- a/examples/in_memory/main.py +++ b/examples/in_memory/main.py @@ -4,13 +4,12 @@ from typing import Dict, Optional import pendulum import uvicorn from fastapi import FastAPI -from pydantic import BaseModel -from starlette.requests import Request -from starlette.responses import JSONResponse, Response - from fastapi_cache import FastAPICache from fastapi_cache.backends.inmemory import InMemoryBackend from fastapi_cache.decorator import cache +from pydantic import BaseModel +from starlette.requests import Request +from starlette.responses import JSONResponse, Response app = FastAPI() diff --git a/examples/pyproject.toml b/examples/pyproject.toml new file mode 100644 index 0000000..4f6a4dc --- /dev/null +++ b/examples/pyproject.toml @@ -0,0 +1,3 @@ +[tool.ruff] +extend = "../pyproject.toml" + diff --git a/examples/redis/main.py b/examples/redis/main.py index 4867b4b..c9a4f7c 100644 --- a/examples/redis/main.py +++ b/examples/redis/main.py @@ -2,20 +2,20 @@ import time import pendulum -import redis.asyncio as redis import uvicorn from fastapi import FastAPI from fastapi.responses import HTMLResponse from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates -from redis.asyncio.connection import ConnectionPool -from starlette.requests import Request -from starlette.responses import JSONResponse, Response - from fastapi_cache import FastAPICache from fastapi_cache.backends.redis import RedisBackend from fastapi_cache.coder import PickleCoder from fastapi_cache.decorator import cache +from starlette.requests import Request +from starlette.responses import JSONResponse, Response + +import redis.asyncio as redis +from redis.asyncio.connection import ConnectionPool app = FastAPI() diff --git a/pyproject.toml b/pyproject.toml index 230b6da..d9e29c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,9 +92,6 @@ select = [ ] target-version = "py37" -[tool.ruff.per-file-ignores] -"tests/**/*.py" = ["S101"] - [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" diff --git a/tests/pyproject.toml b/tests/pyproject.toml new file mode 100644 index 0000000..273ca7f --- /dev/null +++ b/tests/pyproject.toml @@ -0,0 +1,7 @@ +[tool.ruff] +extend = "../pyproject.toml" +ignore = ["S101"] + +[tool.ruff.isort] +known-first-party = ["examples", "fastapi_cache"] +