Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
style: Bumps ruff to 0.1.7 (#37)
Browse files Browse the repository at this point in the history
* chore: Bumps ruff version to 0.1.7

* style: Adds ruff config

* style: Fixes lint

* style: Adds ruff configs

* style: Adds refurb to ruff

* chore: Bumps ruff

* docs: Updates makefile

* refactor: Removes comments

* refactor: Reverts DTZ
  • Loading branch information
frgfm authored Dec 6, 2023
1 parent fd9945e commit fab7766
Show file tree
Hide file tree
Showing 17 changed files with 145 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
architecture: x64
- name: Run ruff
run: |
pip install "ruff==0.1.3"
pip install "ruff==0.1.7"
ruff --version
ruff check --diff .
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
- id: debug-statements
language_version: python3
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.1.3'
rev: 'v0.1.7'
hooks:
- id: ruff
args:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ style:

# Pin the dependencies
lock:
poetry lock
poetry lock --no-update

# Build the docker
build:
Expand Down
40 changes: 20 additions & 20 deletions poetry.lock

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

27 changes: 23 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ alembic = "^1.8.1"
posthog = "^3.0.0"

[tool.poetry.group.quality.dependencies]
ruff = { version = "==0.1.3", optional = true }
ruff = { version = "==0.1.7", optional = true }
mypy = { version = "==1.6.1", optional = true }
types-requests = { version = ">=2.0.0", optional = true }
types-python-jose = { version = ">=3.3.0", optional = true }
Expand All @@ -57,7 +57,7 @@ select = [
"I", # isort
"C4", # flake8-comprehensions
"B", # flake8-bugbear
"CPY001", # flake8-copyright
"CPY", # flake8-copyright
"ISC", # flake8-implicit-str-concat
"PYI", # flake8-pyi
"NPY", # numpy
Expand All @@ -70,6 +70,16 @@ select = [
"T20", # flake8-print
"PT", # flake8-pytest-style
"LOG", # flake8-logging
"SIM", # flake8-simplify
"YTT", # flake8-2020
"ANN", # flake8-annotations
"ASYNC", # flake8-async
"BLE", # flake8-blind-except
"A", # flake8-builtins
"ICN", # flake8-import-conventions
"PIE", # flake8-pie
"ARG", # flake8-unused-arguments
"FURB", # refurb
]
ignore = [
"E501", # line too long, handled by black
Expand All @@ -79,6 +89,11 @@ ignore = [
"F403", # star imports
"E731", # lambda assignment
"C416", # list comprehension to list()
"ANN101", # missing type annotations on self
"ANN102", # missing type annotations on cls
"ANN002", # missing type annotations on *args
"ANN003", # missing type annotations on **kwargs
"COM812", # trailing comma missing
]
exclude = [".git"]
line-length = 120
Expand All @@ -91,12 +106,16 @@ indent-style = "space"

[tool.ruff.per-file-ignores]
"**/__init__.py" = ["I001", "F401", "CPY001"]
"scripts/**.py" = ["D", "T201", "S101"]
"scripts/**.py" = ["D", "T201", "S101", "ANN"]
".github/**.py" = ["D", "T201"]
"client/docs/**.py" = ["E402"]
"src/tests/**.py" = ["D103", "CPY001", "S101", "T201"]
"src/tests/**.py" = ["D103", "CPY001", "S101", "T201", "ANN001", "ANN201", "ARG001"]
"src/alembic/versions/**.py" = ["CPY001"]
"src/alembic/**.py" = ["ANN"]
"client/tests/**.py" = ["D103", "CPY001", "S101"]
"src/app/main.py" = ["ANN"]
"src/app/schemas/**.py" = ["A"]
"src/app/models.py" = ["A"]

[tool.ruff.flake8-quotes]
docstring-quotes = "double"
Expand Down
1 change: 1 addition & 0 deletions src/alembic/versions/2023-11-07-15-35_eb1a6567456c.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-11-07 15:35:08.955263
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
Expand Down
6 changes: 3 additions & 3 deletions src/app/api/api_v1/endpoints/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from app.api.dependencies import get_current_user, get_guideline_crud, get_repo_crud
from app.crud import GuidelineCRUD, RepositoryCRUD
from app.models import Guideline, UserScope
from app.models import Guideline, User, UserScope
from app.schemas.compute import ComplianceResult, Snippet
from app.services.openai import ExecutionMode, openai_client
from app.services.telemetry import telemetry_client
Expand All @@ -23,7 +23,7 @@ async def check_code_against_repo_guidelines(
repo_id: int = Path(..., gt=0),
repos: RepositoryCRUD = Depends(get_repo_crud),
guidelines: GuidelineCRUD = Depends(get_guideline_crud),
user=Security(get_current_user, scopes=[UserScope.ADMIN, UserScope.USER]),
user: User = Security(get_current_user, scopes=[UserScope.ADMIN, UserScope.USER]),
) -> List[ComplianceResult]:
telemetry_client.capture(user.id, event="compute-analyze", properties={"repo_id": repo_id})
# Check repo
Expand All @@ -41,7 +41,7 @@ async def check_code_against_guideline(
payload: Snippet,
guideline_id: int = Path(..., gt=0),
guidelines: GuidelineCRUD = Depends(get_guideline_crud),
user=Security(get_current_user, scopes=[UserScope.ADMIN, UserScope.USER]),
user: User = Security(get_current_user, scopes=[UserScope.ADMIN, UserScope.USER]),
) -> ComplianceResult:
# Check repo
guideline = cast(Guideline, await guidelines.get(guideline_id, strict=True))
Expand Down
18 changes: 9 additions & 9 deletions src/app/api/api_v1/endpoints/guidelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from app.api.dependencies import get_current_user, get_guideline_crud, get_repo_crud
from app.crud import GuidelineCRUD, RepositoryCRUD
from app.models import Guideline, Repository, UserScope
from app.models import Guideline, Repository, User, UserScope
from app.schemas.base import OptionalGHToken
from app.schemas.guidelines import (
ContentUpdate,
Expand All @@ -35,7 +35,7 @@ async def create_guideline(
payload: GuidelineCreate,
guidelines: GuidelineCRUD = Depends(get_guideline_crud),
repos: RepositoryCRUD = Depends(get_repo_crud),
user=Security(get_current_user, scopes=[UserScope.USER, UserScope.ADMIN]),
user: User = Security(get_current_user, scopes=[UserScope.USER, UserScope.ADMIN]),
) -> Guideline:
telemetry_client.capture(user.id, event="guideline-creation", properties={"repo_id": payload.repo_id})
# Check if user is allowed
Expand All @@ -48,7 +48,7 @@ async def create_guideline(
async def get_guideline(
guideline_id: int = Path(..., gt=0),
guidelines: GuidelineCRUD = Depends(get_guideline_crud),
user=Security(get_current_user, scopes=[UserScope.USER, UserScope.ADMIN]),
user: User = Security(get_current_user, scopes=[UserScope.USER, UserScope.ADMIN]),
) -> Guideline:
guideline = cast(Guideline, await guidelines.get(guideline_id, strict=True))
telemetry_client.capture(user.id, event="guideline-get", properties={"repo_id": guideline.repo_id})
Expand All @@ -58,7 +58,7 @@ async def get_guideline(
@router.get("/", status_code=status.HTTP_200_OK)
async def fetch_guidelines(
guidelines: GuidelineCRUD = Depends(get_guideline_crud),
user=Security(get_current_user, scopes=[UserScope.ADMIN]),
user: User = Security(get_current_user, scopes=[UserScope.ADMIN]),
) -> List[Guideline]:
telemetry_client.capture(user.id, event="guideline-fetch")
return [elt for elt in await guidelines.fetch_all()]
Expand All @@ -70,7 +70,7 @@ async def update_guideline_content(
guideline_id: int = Path(..., gt=0),
guidelines: GuidelineCRUD = Depends(get_guideline_crud),
repos: RepositoryCRUD = Depends(get_repo_crud),
user=Security(get_current_user, scopes=[UserScope.USER, UserScope.ADMIN]),
user: User = Security(get_current_user, scopes=[UserScope.USER, UserScope.ADMIN]),
) -> Guideline:
guideline = await guidelines.update(guideline_id, ContentUpdate(**payload.dict(), updated_at=datetime.utcnow()))
telemetry_client.capture(user.id, event="guideline-content", properties={"repo_id": guideline.repo_id})
Expand All @@ -87,7 +87,7 @@ async def update_guideline_order(
order_idx: int = Path(..., gte=0),
guidelines: GuidelineCRUD = Depends(get_guideline_crud),
repos: RepositoryCRUD = Depends(get_repo_crud),
user=Security(get_current_user, scopes=[UserScope.USER, UserScope.ADMIN]),
user: User = Security(get_current_user, scopes=[UserScope.USER, UserScope.ADMIN]),
) -> Guideline:
guideline = await guidelines.update(guideline_id, OrderUpdate(order=order_idx, updated_at=datetime.utcnow()))
telemetry_client.capture(user.id, event="guideline-order", properties={"repo_id": guideline.repo_id})
Expand All @@ -103,7 +103,7 @@ async def delete_guideline(
guideline_id: int = Path(..., gt=0),
guidelines: GuidelineCRUD = Depends(get_guideline_crud),
repos: RepositoryCRUD = Depends(get_repo_crud),
user=Security(get_current_user, scopes=[UserScope.USER, UserScope.ADMIN]),
user: User = Security(get_current_user, scopes=[UserScope.USER, UserScope.ADMIN]),
) -> None:
guideline = cast(Guideline, await guidelines.get(guideline_id, strict=True))
telemetry_client.capture(user.id, event="guideline-deletion", properties={"repo_id": guideline.repo_id})
Expand All @@ -116,7 +116,7 @@ async def delete_guideline(
@router.post("/parse", status_code=status.HTTP_200_OK)
async def parse_guidelines_from_text(
payload: TextContent,
user=Security(get_current_user, scopes=[UserScope.ADMIN, UserScope.USER]),
user: User = Security(get_current_user, scopes=[UserScope.ADMIN, UserScope.USER]),
) -> List[GuidelineContent]:
telemetry_client.capture(user.id, event="guideline-parse")
# Analyze with LLM
Expand All @@ -126,7 +126,7 @@ async def parse_guidelines_from_text(
@router.post("/examples", status_code=status.HTTP_200_OK)
async def generate_examples_for_text(
payload: ExampleRequest,
user=Security(get_current_user, scopes=[UserScope.ADMIN, UserScope.USER]),
user: User = Security(get_current_user, scopes=[UserScope.ADMIN, UserScope.USER]),
) -> GuidelineExample:
telemetry_client.capture(user.id, event="guideline-examples")
# Analyze with LLM
Expand Down
Loading

0 comments on commit fab7766

Please sign in to comment.