Skip to content

Commit 2244015

Browse files
authored
Merge pull request #86 from bretterer/ruff
Add ruff formatting and update devcontainer
2 parents 7eeb3b6 + 73067e5 commit 2244015

File tree

14 files changed

+70
-47
lines changed

14 files changed

+70
-47
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
1+
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon)
22
ARG VARIANT=3-bullseye
33
FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}
44

5-
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
6-
ARG NODE_VERSION="none"
7-
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
8-
95
# Poetry
106
ARG POETRY_VERSION="none"
117
RUN if [ "${POETRY_VERSION}" != "none" ]; then su vscode -c "umask 0002 && pip3 install poetry==${POETRY_VERSION}"; fi

.devcontainer/devcontainer.json

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,40 @@
33
{
44
"name": "Python 3",
55
"build": {
6-
"dockerfile": "Dockerfile",
7-
"context": "..",
8-
"args": {
9-
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
10-
// Append -bullseye or -buster to pin to an OS version.
11-
// Use -bullseye variants on local on arm64/Apple Silicon.
12-
"VARIANT": "3.10-bullseye",
13-
// Options
14-
"NODE_VERSION": "lts/*",
15-
"POETRY_VERSION": "1.5.1",
16-
}
6+
"dockerfile": "Dockerfile",
7+
"context": "..",
8+
"args": {
9+
// Update 'VARIANT' to pick a Python version
10+
// Append -bullseye or -buster to pin to an OS version.
11+
// Use -bullseye variants on local on arm64/Apple Silicon.
12+
"VARIANT": "3.12-bullseye",
13+
// Options
14+
"POETRY_VERSION": "1.8.2"
15+
}
1716
},
18-
1917
// Configure tool-specific properties.
2018
"customizations": {
2119
// Configure properties specific to VS Code.
2220
"vscode": {
23-
// Set *default* container specific settings.json values on container create.
24-
"settings": {
25-
"python.defaultInterpreterPath": "/usr/local/bin/python",
26-
"python.linting.enabled": true,
27-
"python.linting.pylintEnabled": true,
28-
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
29-
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
30-
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
31-
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
32-
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
33-
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
34-
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
35-
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
36-
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
37-
},
38-
39-
// Add the IDs of extensions you want installed when the container is created.
40-
"extensions": [
41-
"ms-python.python",
42-
"ms-python.vscode-pylance"
21+
// Set *default* container specific settings.json values on container create.
22+
"settings": {
23+
"python.defaultInterpreterPath": "./.venv/bin/python",
24+
"[python]": {
25+
"editor.defaultFormatter": "charliermarsh.ruff"
26+
}
27+
},
28+
// Add the IDs of extensions you want installed when the container is created.
29+
"extensions": [
30+
"ms-python.python",
31+
"ms-python.vscode-pylance",
32+
"charliermarsh.ruff"
4333
]
4434
}
4535
},
46-
4736
// Use 'forwardPorts' to make a list of ports inside the container available locally.
4837
// "forwardPorts": [],
49-
5038
// Use 'postCreateCommand' to run commands after the container is created.
5139
"postCreateCommand": "bash ./.devcontainer/post-install.sh",
52-
5340
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
5441
"remoteUser": "vscode"
55-
}
42+
}

.devcontainer/post-install.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22

3-
poetry install
3+
poetry config virtualenvs.in-project true
4+
poetry install --all-extras

.github/workflows/ci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
- name: Install dependencies
2626
run: |
2727
poetry install
28+
- name: Run linting
29+
run: |
30+
poetry run ruff check .
31+
poetry run ruff format . --check
2832
- name: Run mypy
2933
run: poetry run mypy src/rivian
3034
- name: Run tests with poetry and pytest

poetry.lock

Lines changed: 27 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pytest-asyncio = ">=0.18.3,<0.24.0"
2323
python-dotenv = ">=0.20,<1.1"
2424
aresponses = ">=2.1.5,<4.0.0"
2525
mypy = ">=1.7.0,<2.0.0"
26+
ruff = "^0.4"
2627

2728
[tool.poetry.extras]
2829
ble = ["bleak", "dbus-fast"]
@@ -33,6 +34,10 @@ vcs = "git"
3334
style = "semver"
3435
pattern = "default-unprefixed"
3536

37+
[tool.ruff.lint.isort]
38+
combine-as-imports = true
39+
split-on-trailing-comma = false
40+
3641
[build-system]
3742
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
3843
build-backend = "poetry_dynamic_versioning.backend"

src/rivian/ble.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Rivian BLE handler."""
2+
23
from __future__ import annotations
34

45
import asyncio

src/rivian/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Rivian constants."""
2+
23
from __future__ import annotations
34

45
import sys

src/rivian/rivian.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Asynchronous Python client for the Rivian API."""
2+
23
from __future__ import annotations
34

45
import asyncio
@@ -33,7 +34,7 @@
3334
import asyncio as async_timeout
3435
else:
3536
import async_timeout
36-
37+
3738
_LOGGER = logging.getLogger(__name__)
3839

3940
GRAPHQL_BASEPATH = "https://rivian.com/api/gql"

src/rivian/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Utilities."""
2+
23
from __future__ import annotations
34

45
import hashlib

0 commit comments

Comments
 (0)