Skip to content

Commit 3e42e82

Browse files
committed
Move to ruff format
1 parent ed4fcc6 commit 3e42e82

16 files changed

+21
-49
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"ms-python.python",
3030
"ms-python.vscode-pylance",
3131
"charliermarsh.ruff",
32-
"ms-python.black-formatter",
3332
"mtxr.sqltools",
3433
"mtxr.sqltools-driver-pg",
3534
"ms-vscode.vscode-node-azure-pack",
@@ -45,7 +44,7 @@
4544
"editor.codeActionsOnSave": {
4645
"source.fixAll": "explicit"
4746
},
48-
"editor.defaultFormatter": "ms-python.black-formatter"
47+
"editor.defaultFormatter": "charliermarsh.ruff"
4948
},
5049
"files.exclude": {
5150
".ruff_cache": true,

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ See [CONTRIBUTING.md](https://github.com/Azure-Samples/rag-postgres-openai-pytho
3232
- [ ] I added tests that prove my fix is effective or that my feature works
3333
- [ ] I ran `python -m pytest --cov` to verify 100% coverage of added lines
3434
- [ ] I ran `python -m mypy` to check for type errors
35-
- [ ] I either used the pre-commit hooks or ran `ruff` and `black` manually on my code.
36-
35+
- [ ] I either used the pre-commit hooks or ran `ruff` manually on my code.

.github/workflows/python-code-quality.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ jobs:
2121
pip install -r requirements-dev.txt
2222
- name: Lint with ruff
2323
run: ruff check .
24-
- name: Check formatting with black
25-
run: black . --check --verbose
24+
- name: Check formatting with ruff
25+
run: ruff format --check .

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ repos:
88
- repo: https://github.com/astral-sh/ruff-pre-commit
99
rev: v0.1.0
1010
hooks:
11-
- id: ruff
12-
- repo: https://github.com/psf/black
13-
rev: 23.9.1
14-
hooks:
15-
- id: black
11+
# Run the linter.
12+
- id: ruff
13+
args: [ --fix ]
14+
# Run the formatter.
15+
- id: ruff-format

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Compile the JavaScript:
9393
This codebase includes several languages: TypeScript, Python, Bicep, Powershell, and Bash.
9494
Code should follow the standard conventions of each language.
9595

96-
For Python, you can enforce the conventions using `ruff` and `black`.
96+
For Python, you can enforce the conventions using `ruff`.
9797

9898
Install the development dependencies:
9999

@@ -104,13 +104,13 @@ python3 -m pip install -r requirements-dev.txt
104104
Run `ruff` to lint a file:
105105

106106
```
107-
python3 -m ruff <path-to-file>
107+
python3 -m ruff check <path-to-file>
108108
```
109109

110-
Run `black` to format a file:
110+
Run `ruff` to format a file:
111111

112112
```
113-
python3 -m black <path-to-file>
113+
python3 -m ruff format <path-to-file>
114114
```
115115

116-
If you followed the steps above to install the pre-commit hooks, then you can just wait for those hooks to run `ruff` and `black` for you.
116+
If you followed the steps above to install the pre-commit hooks, then you can just wait for those hooks to run `ruff` for you.

pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,3 @@ ignore = ["D203"]
88

99
[tool.ruff.lint.isort]
1010
known-first-party = ["fastapi_app"]
11-
12-
[tool.black]
13-
line-length = 120
14-
target-version = ["py311"]

requirements-dev.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
-r src/requirements.txt
22
ruff
3-
black
43
pre-commit
5-
pip-tools
4+
pip-tools

src/fastapi_app/api_routes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
@router.post("/chat")
1313
async def chat_handler(chat_request: ChatRequest):
14-
1514
messages = [message.model_dump() for message in chat_request.messages]
1615
overrides = chat_request.context.get("overrides", {})
1716

src/fastapi_app/openai_clients.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ async def create_openai_chat_client(azure_credential):
3838

3939

4040
async def create_openai_embed_client(azure_credential):
41-
4241
OPENAI_EMBED_HOST = os.getenv("OPENAI_EMBED_HOST")
4342
if OPENAI_EMBED_HOST == "azure":
4443
token_provider = azure.identity.aio.get_bearer_token_provider(

src/fastapi_app/postgres_engine.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99

1010
async def create_postgres_engine(*, host, username, database, password, sslmode, azure_credential) -> AsyncEngine:
11-
1211
if host.endswith(".database.azure.com"):
1312
logger.info("Authenticating to Azure Database for PostgreSQL using Azure Identity...")
1413
if azure_credential is None:

0 commit comments

Comments
 (0)