Skip to content

Commit

Permalink
Merge pull request #86 from bretterer/ruff
Browse files Browse the repository at this point in the history
Add ruff formatting and update devcontainer
  • Loading branch information
natekspencer authored Jun 9, 2024
2 parents 7eeb3b6 + 73067e5 commit 2244015
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 47 deletions.
6 changes: 1 addition & 5 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# [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
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon)
ARG VARIANT=3-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}

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

# Poetry
ARG POETRY_VERSION="none"
RUN if [ "${POETRY_VERSION}" != "none" ]; then su vscode -c "umask 0002 && pip3 install poetry==${POETRY_VERSION}"; fi
Expand Down
59 changes: 23 additions & 36 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,40 @@
{
"name": "Python 3",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local on arm64/Apple Silicon.
"VARIANT": "3.10-bullseye",
// Options
"NODE_VERSION": "lts/*",
"POETRY_VERSION": "1.5.1",
}
"dockerfile": "Dockerfile",
"context": "..",
"args": {
// Update 'VARIANT' to pick a Python version
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local on arm64/Apple Silicon.
"VARIANT": "3.12-bullseye",
// Options
"POETRY_VERSION": "1.8.2"
}
},

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
// Set *default* container specific settings.json values on container create.
"settings": {
"python.defaultInterpreterPath": "./.venv/bin/python",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff"
]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bash ./.devcontainer/post-install.sh",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
}
3 changes: 2 additions & 1 deletion .devcontainer/post-install.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh

poetry install
poetry config virtualenvs.in-project true
poetry install --all-extras
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ jobs:
- name: Install dependencies
run: |
poetry install
- name: Run linting
run: |
poetry run ruff check .
poetry run ruff format . --check
- name: Run mypy
run: poetry run mypy src/rivian
- name: Run tests with poetry and pytest
Expand Down
28 changes: 27 additions & 1 deletion poetry.lock

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

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pytest-asyncio = ">=0.18.3,<0.24.0"
python-dotenv = ">=0.20,<1.1"
aresponses = ">=2.1.5,<4.0.0"
mypy = ">=1.7.0,<2.0.0"
ruff = "^0.4"

[tool.poetry.extras]
ble = ["bleak", "dbus-fast"]
Expand All @@ -33,6 +34,10 @@ vcs = "git"
style = "semver"
pattern = "default-unprefixed"

[tool.ruff.lint.isort]
combine-as-imports = true
split-on-trailing-comma = false

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
build-backend = "poetry_dynamic_versioning.backend"
1 change: 1 addition & 0 deletions src/rivian/ble.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Rivian BLE handler."""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions src/rivian/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Rivian constants."""

from __future__ import annotations

import sys
Expand Down
3 changes: 2 additions & 1 deletion src/rivian/rivian.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Asynchronous Python client for the Rivian API."""

from __future__ import annotations

import asyncio
Expand Down Expand Up @@ -33,7 +34,7 @@
import asyncio as async_timeout
else:
import async_timeout

_LOGGER = logging.getLogger(__name__)

GRAPHQL_BASEPATH = "https://rivian.com/api/gql"
Expand Down
1 change: 1 addition & 0 deletions src/rivian/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities."""

from __future__ import annotations

import hashlib
Expand Down
1 change: 1 addition & 0 deletions src/rivian/ws_monitor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Websocket monitor."""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions tests/responses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Response tests data."""

from __future__ import annotations

import json
Expand Down
2 changes: 1 addition & 1 deletion tests/rivian_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Tests for `rivian.rivian`."""

# pylint: disable=protected-access
from __future__ import annotations

import aiohttp
import pytest
from aresponses import ResponsesMockServer

from rivian import Rivian
from rivian.exceptions import (
RivianApiException,
Expand Down
2 changes: 0 additions & 2 deletions tests/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from __future__ import annotations

import time

from rivian import VehicleCommand, utils

PHONE_NONCE = bytes.fromhex("e4e9b1f0abba398bdfe5b2d90cba16ad")
Expand Down

0 comments on commit 2244015

Please sign in to comment.