Skip to content

Commit 139de9a

Browse files
committed
chore: undo ruff.toml delete
1 parent aea60f6 commit 139de9a

4 files changed

Lines changed: 33 additions & 17 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# FastAPI Clerk Auth Middleware
22

33
[![PyPI version](https://img.shields.io/pypi/v/fastapi-clerk-auth.svg)](https://pypi.org/project/fastapi-clerk-auth/)
4-
[![Python Versions](https://img.shields.io/pypi/pyversions/fastapi-clerk-auth)](https://pypi.org/project/fastapi-clerk-auth/)
4+
[![Python Versions](https://img.shields.io/pypi/pyversions/fastapi-clerk-auth.svg)](https://pypi.org/project/fastapi-clerk-auth/)
55
[![License](https://img.shields.io/github/license/OSSMafia/fastapi-clerk-middleware)](https://github.com/OSSMafia/fastapi-clerk-middleware/blob/main/LICENSE)
66

77
A lightweight, easy-to-use authentication middleware for [FastAPI](https://fastapi.tiangolo.com/) that integrates with [Clerk](https://clerk.com) authentication services.

dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ COPY .bumpversion.cfg .bumpversion.cfg
66

77

88
FROM base AS format
9+
COPY ./ruff.toml ./ruff.toml
910
RUN pip install -e .[dev]
1011
WORKDIR /app/fastapi_clerk_auth
11-
CMD ruff check ./ --fix --config ../pyproject.toml && ruff format ./ --config ../pyproject.toml
12+
CMD ruff check ./ --fix --config ../ruff.toml && ruff format ./ --config ../ruff.toml
1213

1314

1415
FROM base AS bumpversion

fastapi_clerk_auth/__init__.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
from fastapi import Request
66
from fastapi.encoders import jsonable_encoder
77
from fastapi.openapi.models import HTTPBearer as HTTPBearerModel
8-
from fastapi.security import (
9-
HTTPAuthorizationCredentials as FastAPIHTTPAuthorizationCredentials,
10-
)
8+
from fastapi.security import HTTPAuthorizationCredentials as FastAPIHTTPAuthorizationCredentials
119
from fastapi.security import HTTPBearer
1210
from fastapi.security.utils import get_authorization_scheme_param
1311
import jwt
@@ -125,9 +123,7 @@ def __init__(
125123

126124
def _check_config(self) -> None:
127125
if not self.config.audience and self.config.verify_aud:
128-
raise ValueError(
129-
"Audience must be set in config because verify_aud is True"
130-
)
126+
raise ValueError("Audience must be set in config because verify_aud is True")
131127
if not self.config.issuer and self.config.verify_iss:
132128
raise ValueError("Issuer must be set in config because verify_iss is True")
133129

@@ -152,16 +148,12 @@ def _decode_token(self, token: str) -> dict | None:
152148
raise e
153149
return None
154150

155-
async def __call__(
156-
self, request: Request
157-
) -> Optional[HTTPAuthorizationCredentials]:
151+
async def __call__(self, request: Request) -> Optional[HTTPAuthorizationCredentials]:
158152
authorization = request.headers.get("Authorization")
159153
scheme, credentials = get_authorization_scheme_param(authorization)
160154
if not (authorization and scheme and credentials):
161155
if self.auto_error:
162-
raise HTTPException(
163-
status_code=HTTP_403_FORBIDDEN, detail="Not Authenticated"
164-
)
156+
raise HTTPException(status_code=HTTP_403_FORBIDDEN, detail="Not Authenticated")
165157
return None
166158
if scheme.lower() != "bearer":
167159
if self.auto_error:
@@ -177,9 +169,7 @@ async def __call__(
177169
status_code=HTTP_403_FORBIDDEN,
178170
detail="Invalid Authentication Credentials",
179171
)
180-
response = HTTPAuthorizationCredentials(
181-
scheme=scheme, credentials=credentials, decoded=decoded_token
182-
)
172+
response = HTTPAuthorizationCredentials(scheme=scheme, credentials=credentials, decoded=decoded_token)
183173
if self.add_state:
184174
request.state.clerk_auth = response
185175
return response

ruff.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
line-length = 180
2+
3+
[lint]
4+
select = [
5+
"E", # pycodestyle errors
6+
"W", # pycodestyle warnings
7+
"F", # pyflakes
8+
"I", # isort
9+
"B", # flake8-bugbear
10+
"C4", # flake8-comprehensions
11+
"UP", # pyupgrade
12+
]
13+
ignore = [
14+
"E501", # line too long, handled by black
15+
"B008", # do not perform function calls in argument defaults
16+
"C901", # too complex
17+
"W191", # indentation contains tabs
18+
"B026", # keyword argument unpacking
19+
]
20+
21+
[lint.isort]
22+
known-first-party = ["fastapi_clerk_auth"]
23+
combine-as-imports = true
24+
force-single-line = true
25+
force-sort-within-sections = true

0 commit comments

Comments
 (0)